Skip to content

Commit 2bd3566

Browse files
authored
Rename 'mojo package' to 'mojo precompile' (#85)
Update the toolchain to 1.0.0b2.dev2026051806 and update Mojo tests to account for the change in compiler (`fn` -> `def`).
1 parent 0c89faa commit 2bd3566

13 files changed

Lines changed: 46 additions & 46 deletions

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/extensions.bzl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ load("//mojo:mojo_host_platform.bzl", "mojo_host_platform")
44
load("//mojo/private:mojo_gpu_toolchains_repository.bzl", "mojo_gpu_toolchains_repository")
55

66
_PLATFORMS = ["linux_aarch64", "linux_x86_64", "macos_arm64"]
7-
_DEFAULT_VERSION = "0.26.3.0.dev2026031105"
7+
_DEFAULT_VERSION = "1.0.0b2.dev2026051806"
88
_KNOWN_SHAS = {
9-
"0.26.3.0.dev2026031105": {
10-
"linux_aarch64": "a62136e7d0bd0a44bc0d0b62e6179180d721c99c7308fd4c666885c37f43740e",
11-
"linux_x86_64": "acf1777039b79c9f75e814ca0124ab913c02a68a4f4bb919e6fed183fa2f2602",
12-
"macos_arm64": "50b994a44fa52f2487e81e288dbb2e417da7132fffe0e908a2e3a1ec9418e42e",
13-
"mojo_compiler_mojo_libs": "32fb42e57af02309f35b668c0e4eb78fc87d0459165dca0a10223ab6d37a5cb3",
9+
"1.0.0b2.dev2026051806": {
10+
"linux_aarch64": "224c4c1590debdff509bde74ead2da7b3eef2bc052380627e824072fe18bef05",
11+
"linux_x86_64": "7775e0386cb564cfd09f34c74209b80fc5a5d43b5ac20e36e638032e0f0cd63a",
12+
"macos_arm64": "5effdfe6fa9962802bba236baa15541584d7c27e3224d304d39d00912113fe58",
13+
"mojo_compiler_mojo_libs": "63e7bcbca2f311d6aba0c90cdd3c1152d153ee3f0f65ccc5c4f06f61b84c06e4",
1414
},
1515
}
1616
_PLATFORM_MAPPINGS = {

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 = """\

tests/cc/cc_test.mojo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from std.ffi import external_call
22

3-
fn main() raises:
3+
def main() raises:
44
external_call["foo", NoneType]()

tests/fixits/fixits.mojo

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
fn old_origin_of[T: AnyType](b: T):
1+
def old_origin_of[T: AnyType](b: T):
22
_ = __origin_of(b)
33

4-
fn main():
4+
def main():
55
pass

tests/fixits/package/package.mojo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
fn old_origin_of[T: AnyType](b: T):
1+
def old_origin_of[T: AnyType](b: T):
22
_ = __origin_of(b)

tests/hello_world.mojo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from package.package import foo
22

3-
fn main():
3+
def main():
44
print("Hello, World!", foo())

tests/hello_world_test.mojo

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ from std.testing import assert_equal
22
from package.package import foo
33

44

5-
fn test_basic() raises:
5+
def test_basic() raises:
66
assert_equal(foo(), 42)
77

88

9-
fn main() raises:
9+
def main() raises:
1010
print("Running tests...")
1111
test_basic()

0 commit comments

Comments
 (0)