Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions mojo/extensions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ load("//mojo:mojo_host_platform.bzl", "mojo_host_platform")
load("//mojo/private:mojo_gpu_toolchains_repository.bzl", "mojo_gpu_toolchains_repository")

_PLATFORMS = ["linux_aarch64", "linux_x86_64", "macos_arm64"]
_DEFAULT_VERSION = "1.0.0b3.dev2026061206"
_DEFAULT_VERSION = "1.0.0b3.dev2026072006"
_KNOWN_SHAS = {
"1.0.0b3.dev2026061206": {
"linux_aarch64": "061042c815d945c8e403a13c5317d6dbd9ceef5a0ef84422ae6b6da0a2f0fe59",
"linux_x86_64": "b7f569472b02a35f40c8ea96ea51dac73b6c6c085e23c08ecf3613276df4f7dd",
"macos_arm64": "bc4106c6013994b4eb246702832c7bc6967c4f6eeaa911eccf75d2dff26d7a3a",
"mojo_compiler_mojo_libs": "1c99770a8a14804f810e6a2a12f1fd5b8d5c783301b38b74c785bc421ac334b9",
"1.0.0b3.dev2026072006": {
"linux_aarch64": "63ad1c8fe113abc6a617ecadc76d42a5cbcabe19a6ef01c90b5cbc4281b118e2",
"linux_x86_64": "72c810694ebcc514a363857e3d8f07828be994cf26a9317b50839a3f09c45fa3",
"macos_arm64": "f58003493298e4427bf217c26274649f0973b3fafe379c9d319e59231066fff2",
"mojo_compiler_mojo_libs": "27f7acea73231e93f4e9b4485d33059343d357c552b9828f2a4e2575018742a5",
},
}
_PLATFORM_MAPPINGS = {
Expand Down
11 changes: 10 additions & 1 deletion mojo/mojo_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,15 @@ def _mojo_library_implementation(ctx):
for target in ctx.attr.data:
transitive_runfiles.append(target[DefaultInfo].default_runfiles)

import_path = mojo_precmp_file.dirname + "/" + ctx.attr.import_path

return [
DefaultInfo(
files = depset([mojo_precmp_file]),
runfiles = ctx.runfiles(ctx.files.data).merge_all(transitive_runfiles),
),
MojoInfo(
import_paths = depset([mojo_precmp_file.dirname], transitive = [import_paths]),
import_paths = depset([import_path], transitive = [import_paths]),
mojodeps = depset([mojo_precmp_file], transitive = [transitive_mojodeps]),
),
OutputGroupInfo(**output_group_kwargs),
Expand Down Expand Up @@ -111,6 +113,13 @@ precompile' since it does not accept many flags.
"deps": attr.label_list(
providers = [MojoInfo],
),
"import_path": attr.string(
doc = """
Path relative to this package where it should be imported from.
Generally something like `.`, `..`, or `../..`.
""",
default = ".",
),
"data": attr.label_list(),
"_mojo_precompile_copts": attr.label(
default = Label("//:mojo_precompile_copt"),
Expand Down
8 changes: 4 additions & 4 deletions mojo/private/mojo_binary_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ def _find_main(name, srcs, main):
def _format_include(arg):
return ["-I", arg.dirname]

def _format_path(arg):
return [arg.path]
def _add_include(arg):
return ["-I", arg]

def _mojo_binary_test_implementation(ctx, *, shared_library = False):
cc_toolchain = find_cpp_toolchain(ctx)
Expand All @@ -120,8 +120,8 @@ def _mojo_binary_test_implementation(ctx, *, shared_library = False):
args.add_all([file], map_each = _format_include)

all_deps = ctx.attr.deps + mojo_toolchain.implicit_deps + ([ctx.attr._link_extra_lib] if ctx.attr._link_extra_lib else [])
_, transitive_mojodeps = collect_mojoinfo(all_deps)
args.add_all(transitive_mojodeps, map_each = _format_include)
transitive_includes, transitive_mojodeps = collect_mojoinfo(all_deps)
args.add_all(transitive_includes, map_each = _add_include)

# NOTE: Argument order:
# 1. Basic functional arguments
Expand Down
8 changes: 8 additions & 0 deletions tests/nested/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
load("//mojo:mojo_test.bzl", "mojo_test")

mojo_test(
name = "main",
srcs = ["main.mojo"],
visibility = ["//tests:__subpackages__"],
deps = ["//tests/nested/outer:inner"],
)
4 changes: 4 additions & 0 deletions tests/nested/main.mojo
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from outer.inner import get_five

def main():
print(get_five())
10 changes: 10 additions & 0 deletions tests/nested/outer/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
load("//mojo:mojo_library.bzl", "mojo_library")

mojo_library(
name = "inner",
srcs = [
"__init__.mojo",
],
import_path = "..",
visibility = ["//tests:__subpackages__"],
)
2 changes: 2 additions & 0 deletions tests/nested/outer/__init__.mojo
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def get_five() -> Int:
return 5
2 changes: 1 addition & 1 deletion tests/python/python_shared_library.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ from std.python._cpython import PyObjectPtr


@export
def PyInit_python_shared_library() -> PythonObject:
def PyInit_python_shared_library() abi("C") -> PythonObject:
"""Create a Python module with a function binding for `mojo_count_args`."""

try:
Expand Down
Loading