Skip to content

Commit 0c89faa

Browse files
authored
Rename 'mojopkg' to 'mojoc' (#84)
This forms part of the renaming of `.mojopkg` to `.mojoc`. In certain cases some form of "dep" or "mojodep" is used to convey dependencies as a concept rather than being overly specific about the file type.
1 parent 37e8350 commit 0c89faa

7 files changed

Lines changed: 30 additions & 26 deletions

File tree

mojo/extensions.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ _mojo_toolchain_repository = repository_rule(
6868
default = "",
6969
),
7070
"use_prebuilt_packages": attr.bool(
71-
doc = "Whether to automatically add prebuilt mojopkgs to every mojo target.",
71+
doc = "Whether to automatically add prebuilt mojo packages to every mojo target.",
7272
mandatory = True,
7373
),
7474
"_template": attr.label(
@@ -177,7 +177,7 @@ _toolchain_tag = tag_class(
177177
default = "",
178178
),
179179
"use_prebuilt_packages": attr.bool(
180-
doc = "Whether to automatically add prebuilt mojopkgs to every mojo target.",
180+
doc = "Whether to automatically add prebuilt mojo packages to every mojo target.",
181181
default = True,
182182
),
183183
},

mojo/mojo_import.bzl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
1-
"""Import a prebuilt mojopkg for use in other Mojo targets."""
1+
"""Import a precompiled mojo file for use in other Mojo targets."""
22

33
load("//mojo:providers.bzl", "MojoInfo")
44
load("//mojo/private:utils.bzl", "collect_mojoinfo")
55

66
def _mojo_import_impl(ctx):
7-
mojo_packages = ctx.files.mojopkgs
8-
import_paths, transitive_mojopkgs = collect_mojoinfo(ctx.attr.deps)
7+
mojo_deps = ctx.files.mojodeps
8+
import_paths, transitive_mojodeps = collect_mojoinfo(ctx.attr.deps)
99
return [
10-
DefaultInfo(files = depset(mojo_packages, transitive = [transitive_mojopkgs])),
10+
DefaultInfo(files = depset(mojo_deps, transitive = [transitive_mojodeps])),
1111
MojoInfo(
12-
import_paths = depset([pkg.dirname for pkg in mojo_packages], transitive = [import_paths]),
13-
mojopkgs = depset([pkg for pkg in mojo_packages], transitive = [transitive_mojopkgs]),
12+
import_paths = depset([pkg.dirname for pkg in mojo_deps], transitive = [import_paths]),
13+
mojodeps = depset([pkg for pkg in mojo_deps], transitive = [transitive_mojodeps]),
1414
),
1515
]
1616

1717
mojo_import = rule(
1818
implementation = _mojo_import_impl,
1919
attrs = {
20-
"mojopkgs": attr.label_list(
21-
allow_files = [".mojopkg"],
22-
doc = "The mojopkg files to import.",
20+
"mojodeps": attr.label_list(
21+
allow_files = [".mojopkg", ".mojoc"],
22+
doc = "The precompiled mojo files to import.",
2323
),
2424
"deps": attr.label_list(
2525
providers = [MojoInfo],
26-
doc = "Additional Mojo dependencies required by the imported mojopkg.",
26+
doc = "Additional Mojo dependencies required by the imported mojo file.",
2727
),
2828
},
2929
)

mojo/mojo_library.bzl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
"""Compile Mojo files into a mojopkg that can be consumed by other Mojo targets."""
1+
"""Compile Mojo files into a precompiled object (mojoc) that can be consumed by
2+
other Mojo targets."""
23

34
load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo")
45
load("//mojo:providers.bzl", "MojoInfo")
@@ -25,7 +26,7 @@ def _mojo_library_implementation(ctx):
2526
for copt in ctx.attr.copts
2627
])
2728

28-
import_paths, transitive_mojopkgs = collect_mojoinfo(ctx.attr.deps + mojo_toolchain.implicit_deps)
29+
import_paths, transitive_mojodeps = collect_mojoinfo(ctx.attr.deps + mojo_toolchain.implicit_deps)
2930
root_directory = ctx.files.srcs[0].dirname
3031

3132
file_args = ctx.actions.args()
@@ -41,11 +42,11 @@ def _mojo_library_implementation(ctx):
4142
output_group_kwargs["mojo_fixits"] = depset([fixits_file])
4243
args.add("--experimental-export-fixit", fixits_file)
4344

44-
file_args.add_all(transitive_mojopkgs, map_each = _format_include)
45+
file_args.add_all(transitive_mojodeps, map_each = _format_include)
4546
file_args.add(root_directory)
4647
ctx.actions.run(
4748
executable = mojo_toolchain.mojo,
48-
inputs = depset(ctx.files.srcs + ctx.files.additional_compiler_inputs, transitive = [transitive_mojopkgs]),
49+
inputs = depset(ctx.files.srcs + ctx.files.additional_compiler_inputs, transitive = [transitive_mojodeps]),
4950
tools = mojo_toolchain.all_tools,
5051
outputs = package_outputs,
5152
arguments = [args, file_args],
@@ -74,7 +75,7 @@ def _mojo_library_implementation(ctx):
7475
),
7576
MojoInfo(
7677
import_paths = depset([mojo_package.dirname], transitive = [import_paths]),
77-
mojopkgs = depset([mojo_package], transitive = [transitive_mojopkgs]),
78+
mojodeps = depset([mojo_package], transitive = [transitive_mojodeps]),
7879
),
7980
OutputGroupInfo(**output_group_kwargs),
8081
]

mojo/private/mojo_binary_test.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def _mojo_binary_test_implementation(ctx, *, shared_library = False):
113113
args.add("-I", file.dirname)
114114

115115
all_deps = ctx.attr.deps + mojo_toolchain.implicit_deps + ([ctx.attr._link_extra_lib] if ctx.attr._link_extra_lib else [])
116-
import_paths, transitive_mojopkgs = collect_mojoinfo(all_deps)
116+
import_paths, transitive_mojodeps = collect_mojoinfo(all_deps)
117117
args.add_all(import_paths, before_each = "-I")
118118

119119
# NOTE: Argument order:
@@ -145,7 +145,7 @@ def _mojo_binary_test_implementation(ctx, *, shared_library = False):
145145
ctx.actions.run(
146146
executable = mojo_toolchain.mojo,
147147
tools = mojo_toolchain.all_tools,
148-
inputs = depset(ctx.files.srcs + ctx.files.additional_compiler_inputs, transitive = [transitive_mojopkgs]),
148+
inputs = depset(ctx.files.srcs + ctx.files.additional_compiler_inputs, transitive = [transitive_mojodeps]),
149149
outputs = compile_outputs,
150150
arguments = [args],
151151
mnemonic = "MojoCompile",

mojo/private/toolchain.BUILD

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,13 @@ _INTERNAL_LIBRARIES = [
3333
]
3434

3535
mojo_import(
36-
name = "all_mojopkgs",
37-
mojopkgs = glob(
36+
name = "all_mojodeps",
37+
mojodeps = glob(
3838
["lib/mojo/**/*.mojopkg"],
3939
allow_empty = False,
40+
) + glob(
41+
["lib/mojo/**/*.mojoc"],
42+
allow_empty = True,
4043
),
4144
)
4245

@@ -46,7 +49,7 @@ mojo_toolchain(
4649
implicit_deps = [
4750
name
4851
for name, _ in _INTERNAL_LIBRARIES
49-
] + ([":all_mojopkgs"] if "{INCLUDE_MOJOPKGS}" else []),
52+
] + ([":all_mojodeps"] if "{INCLUDE_MOJOPKGS}" else []),
5053
lld = "bin/lld",
5154
mojo = "bin/mojo",
5255
visibility = ["//visibility:public"],

mojo/private/utils.bzl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ def collect_mojoinfo(deps):
1515
A single MojoInfo object with the combined data.
1616
"""
1717
import_paths = []
18-
mojopkgs = []
18+
mojodeps = []
1919
for dep in deps:
2020
if MojoInfo in dep:
2121
info = dep[MojoInfo]
22-
mojopkgs.append(info.mojopkgs)
22+
mojodeps.append(info.mojodeps)
2323
import_paths.append(info.import_paths)
2424

25-
return depset(transitive = import_paths), depset(transitive = mojopkgs)
25+
return depset(transitive = import_paths), depset(transitive = mojodeps)
2626

2727
def is_exec_config(ctx):
2828
"""Determines whether the current configuration is an exec configuration.

mojo/providers.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ MojoInfo = provider(
44
doc = "Information about how to build a Mojo target.",
55
fields = {
66
"import_paths": "Directories that should be passed with -I to mojo",
7-
"mojopkgs": "The mojopkg files required by the target",
7+
"mojodeps": "The precompiled mojo files required by the target",
88
},
99
)
1010

0 commit comments

Comments
 (0)