Skip to content

Commit 09704c4

Browse files
committed
Rename 'mojo package' to 'mojo precompile'
Now that the mojo toolchain is making the switch to 'precompile' over 'package', update our bazel rules to adjust.
1 parent 0c89faa commit 09704c4

4 files changed

Lines changed: 29 additions & 29 deletions

File tree

BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ repeatable_string_flag(
88
)
99

1010
repeatable_string_flag(
11-
name = "mojo_package_copt",
11+
name = "mojo_precompile_copt",
1212
build_setting_default = [],
1313
visibility = ["//visibility:public"],
1414
)

mojo/mojo_library.bzl

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ def _mojo_library_implementation(ctx):
1212
mojo_toolchain = ctx.toolchains["//:toolchain_type"].mojo_toolchain_info
1313
build_env = getattr(ctx.toolchains["//:toolchain_type"], "build_env", {})
1414

15-
mojo_package = ctx.actions.declare_file(ctx.label.name + ".mojopkg")
15+
mojo_precmp_file = ctx.actions.declare_file(ctx.label.name + ".mojoc")
1616
args = ctx.actions.args()
17-
args.add("package")
17+
args.add("precompile")
1818
args.add("-strip-file-prefix=.")
19-
args.add("-o", mojo_package)
19+
args.add("-o", mojo_precmp_file)
2020

21-
args.add_all(mojo_toolchain.package_copts)
21+
args.add_all(mojo_toolchain.precompile_copts)
2222
if not is_exec_config(ctx):
23-
args.add_all(ctx.attr._mojo_package_copts[BuildSettingInfo].value)
23+
args.add_all(ctx.attr._mojo_precompile_copts[BuildSettingInfo].value)
2424
args.add_all([
2525
ctx.expand_location(copt, targets = ctx.attr.additional_compiler_inputs)
2626
for copt in ctx.attr.copts
@@ -35,10 +35,10 @@ def _mojo_library_implementation(ctx):
3535
args.add_all([file], map_each = _format_include)
3636

3737
output_group_kwargs = {}
38-
package_outputs = [mojo_package]
38+
precompile_outputs = [mojo_precmp_file]
3939
if ctx.attr._export_fixits[BuildSettingInfo].value:
4040
fixits_file = ctx.actions.declare_file(ctx.label.name + ".mojo_fixits.yaml")
41-
package_outputs.append(fixits_file)
41+
precompile_outputs.append(fixits_file)
4242
output_group_kwargs["mojo_fixits"] = depset([fixits_file])
4343
args.add("--experimental-export-fixit", fixits_file)
4444

@@ -48,10 +48,10 @@ def _mojo_library_implementation(ctx):
4848
executable = mojo_toolchain.mojo,
4949
inputs = depset(ctx.files.srcs + ctx.files.additional_compiler_inputs, transitive = [transitive_mojodeps]),
5050
tools = mojo_toolchain.all_tools,
51-
outputs = package_outputs,
51+
outputs = precompile_outputs,
5252
arguments = [args, file_args],
53-
mnemonic = "MojoPackage",
54-
progress_message = "%{label} building mojo package",
53+
mnemonic = "MojoPrecompile",
54+
progress_message = "%{label} precompiling mojo file",
5555
env = {
5656
"MODULAR_CRASH_REPORTING_ENABLED": "false",
5757
"PATH": "/dev/null", # Avoid using the host's PATH
@@ -70,12 +70,12 @@ def _mojo_library_implementation(ctx):
7070

7171
return [
7272
DefaultInfo(
73-
files = depset([mojo_package]),
73+
files = depset([mojo_precmp_file]),
7474
runfiles = ctx.runfiles(ctx.files.data).merge_all(transitive_runfiles),
7575
),
7676
MojoInfo(
77-
import_paths = depset([mojo_package.dirname], transitive = [import_paths]),
78-
mojodeps = depset([mojo_package], transitive = [transitive_mojodeps]),
77+
import_paths = depset([mojo_precmp_file.dirname], transitive = [import_paths]),
78+
mojodeps = depset([mojo_precmp_file], transitive = [transitive_mojodeps]),
7979
),
8080
OutputGroupInfo(**output_group_kwargs),
8181
]
@@ -95,13 +95,13 @@ then be used in copts with the $(location) function.
9595
Additional compiler options to pass to the Mojo compiler.
9696
9797
Order of options:
98-
1. copts from mojo_toolchain.package_copts
99-
2. copts from //:mojo_package_copt (if not building in exec config)
98+
1. copts from mojo_toolchain.precompile_copts
99+
2. copts from //:mojo_precompile_copt (if not building in exec config)
100100
3. copts from this attribute, with $(location) expanded for files in
101101
additional_compiler_inputs.
102102
103103
NOTE: copts from --mojocopt and mojo_toolchain.copts are not passed to 'mojo
104-
package' since it does not accept many flags.
104+
precompile' since it does not accept many flags.
105105
""",
106106
),
107107
"srcs": attr.label_list(
@@ -112,8 +112,8 @@ package' since it does not accept many flags.
112112
providers = [MojoInfo],
113113
),
114114
"data": attr.label_list(),
115-
"_mojo_package_copts": attr.label(
116-
default = Label("//:mojo_package_copt"),
115+
"_mojo_precompile_copts": attr.label(
116+
default = Label("//:mojo_precompile_copt"),
117117
),
118118
"_export_fixits": attr.label(
119119
default = Label("@rules_mojo//:experimental_export_fixits"),

mojo/providers.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ MojoToolchainInfo = provider(
1313
fields = {
1414
"all_tools": "All the files that must be available in actions in order for the toolchain to work.",
1515
"copts": "Additional compiler options to pass to the Mojo compiler.",
16-
"package_copts": "Additional compiler options to pass to the Mojo compiler when running 'mojo package'.",
16+
"precompile_copts": "Additional compiler options to pass to the Mojo compiler when running 'mojo precompile'.",
1717
"lld": "The lld compiler executable to link with",
1818
"mojo": "The mojo compiler executable to build with",
1919
"implicit_deps": "Implicit dependencies that every target should depend on, providing either CcInfo, or MojoInfo",
@@ -24,7 +24,7 @@ MojoCoptsToolchainInfo = provider(
2424
doc = "Provider holding additional compiler options for the Mojo compiler.",
2525
fields = {
2626
"copts": "Additional compiler options to pass to the Mojo compiler.",
27-
"package_copts": "Additional compiler options to pass to the Mojo compiler when running 'mojo package'.",
27+
"precompile_copts": "Additional compiler options to pass to the Mojo compiler when running 'mojo precompile'.",
2828
},
2929
)
3030

mojo/toolchain.bzl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def _mojo_toolchain_impl(ctx):
1010
tool_files.append(dep[DefaultInfo].files)
1111

1212
copts = list(ctx.attr.copts)
13-
package_copts = list(ctx.attr.package_copts)
13+
precompile_copts = list(ctx.attr.precompile_copts)
1414
gpu_toolchain = ctx.toolchains["//:gpu_toolchain_type"]
1515
if gpu_toolchain:
1616
copts.append("--target-accelerator=" + gpu_toolchain.mojo_gpu_toolchain_info.target_accelerator)
@@ -24,14 +24,14 @@ def _mojo_toolchain_impl(ctx):
2424
copts_toolchain = ctx.toolchains["//:copts_toolchain_type"]
2525
if copts_toolchain:
2626
copts.extend(copts_toolchain.copts_toolchain_info.copts)
27-
package_copts = copts_toolchain.copts_toolchain_info.package_copts
27+
precompile_copts = copts_toolchain.copts_toolchain_info.precompile_copts
2828

2929
return [
3030
platform_common.ToolchainInfo(
3131
mojo_toolchain_info = MojoToolchainInfo(
3232
all_tools = tool_files,
3333
copts = copts,
34-
package_copts = package_copts,
34+
precompile_copts = precompile_copts,
3535
lld = ctx.executable.lld,
3636
mojo = ctx.executable.mojo,
3737
implicit_deps = ctx.attr.implicit_deps,
@@ -46,9 +46,9 @@ mojo_toolchain = rule(
4646
mandatory = False,
4747
doc = "Additional compiler options to pass to the Mojo compiler.",
4848
),
49-
"package_copts": attr.string_list(
49+
"precompile_copts": attr.string_list(
5050
mandatory = False,
51-
doc = "Additional compiler options to pass to the Mojo compiler when running 'mojo package'.",
51+
doc = "Additional compiler options to pass to the Mojo compiler when running 'mojo precompile'.",
5252
),
5353
"extra_tools": attr.label_list(
5454
providers = [DefaultInfo],
@@ -96,7 +96,7 @@ def _mojo_copts_toolchain_impl(ctx):
9696
platform_common.ToolchainInfo(
9797
copts_toolchain_info = MojoCoptsToolchainInfo(
9898
copts = ctx.attr.copts,
99-
package_copts = ctx.attr.package_copts,
99+
precompile_copts = ctx.attr.precompile_copts,
100100
),
101101
),
102102
]
@@ -108,9 +108,9 @@ mojo_copts_toolchain = rule(
108108
mandatory = True,
109109
doc = "Additional compiler options to pass to the Mojo compiler.",
110110
),
111-
"package_copts": attr.string_list(
111+
"precompile_copts": attr.string_list(
112112
mandatory = True,
113-
doc = "Additional compiler options to pass to the Mojo compiler when running 'mojo package'.",
113+
doc = "Additional compiler options to pass to the Mojo compiler when running 'mojo precompile'.",
114114
),
115115
},
116116
doc = """\

0 commit comments

Comments
 (0)