Skip to content

Commit

Permalink
Support Windows .exe file extensions on tools
Browse files Browse the repository at this point in the history
All tool executables have the filename suffix ".exe".

Fixes bazelbuild#2
  • Loading branch information
Tom Renn committed Jun 3, 2024
1 parent 69f07a5 commit e2084fe
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
3 changes: 2 additions & 1 deletion BUILD.ndk_clang.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ cc_toolchain_suite(
clang_resource_directory = "{clang_resource_directory}",
target_system_name = target_system_name,
toolchain_identifier = "toolchain_identifier_%s" % target_system_name,
executable_extension = "{executable_extension}",
) for target_system_name in TARGET_SYSTEM_NAMES]

filegroup(
Expand Down Expand Up @@ -72,7 +73,7 @@ filegroup(
[filegroup(
name = "compiler_files_%s" % target_system_name,
srcs = [
"bin/clang",
"bin/clang{executable_extension}",
":ar_files",
":as_files",
":objcopy_files",
Expand Down
23 changes: 12 additions & 11 deletions ndk_cc_toolchain_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -1459,17 +1459,17 @@ def ndk_cc_toolchain_config_rule_implementation(ctx):
api_level = ctx.attr.api_level,
target_system_name = ctx.attr.target_system_name,
tools = {
"clang": "bin/clang",
"ar": "bin/llvm-ar",
"cpp": "bin/clang++",
"dwp": "bin/llvm-dwp",
"gcc": "bin/clang",
"gcov": "bin/gcov",
"ld": "bin/ld",
"nm": "bin/llvm-nm",
"objcopy": "bin/llvm-objcopy",
"objdump": "bin/llvm-objdump",
"strip": "bin/llvm-strip",
"clang": "bin/clang" + ctx.attr.executable_extension,
"ar": "bin/llvm-ar" + ctx.attr.executable_extension,
"cpp": "bin/clang++" + ctx.attr.executable_extension,
"dwp": "bin/llvm-dwp" + ctx.attr.executable_extension,
"gcc": "bin/clang" + ctx.attr.executable_extension,
"gcov": "bin/gcov" + ctx.attr.executable_extension,
"ld": "bin/ld" + ctx.attr.executable_extension,
"nm": "bin/llvm-nm" + ctx.attr.executable_extension,
"objcopy": "bin/llvm-objcopy" + ctx.attr.executable_extension,
"objdump": "bin/llvm-objdump" + ctx.attr.executable_extension,
"strip": "bin/llvm-strip" + ctx.attr.executable_extension,
},
cxx_builtin_include_directories = [
"sysroot/usr/include/c++/v1",
Expand Down Expand Up @@ -1510,6 +1510,7 @@ ndk_cc_toolchain_config_rule = rule(
],
),
"toolchain_identifier": attr.string(mandatory = True),
"executable_extension": attr.string(default = ""),
},
)

Expand Down
3 changes: 3 additions & 0 deletions rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def _android_ndk_repository_impl(ctx):
"path attribute of android_ndk_repository must be set.")

is_windows = False
executable_extension = ""
if ctx.os.name == "linux":
clang_directory = "toolchains/llvm/prebuilt/linux-x86_64"
elif ctx.os.name == "mac os x":
Expand All @@ -37,6 +38,7 @@ def _android_ndk_repository_impl(ctx):
elif ctx.os.name.startswith("windows"):
clang_directory = "toolchains/llvm/prebuilt/windows-x86_64"
is_windows = True
executable_extension = ".exe"
else:
fail("Unsupported operating system: " + ctx.os.name)

Expand Down Expand Up @@ -83,6 +85,7 @@ def _android_ndk_repository_impl(ctx):
"{api_level}": str(api_level),
"{clang_resource_directory}": clang_resource_directory,
"{sysroot_directory}": sysroot_directory,
"{executable_extension}": executable_extension,
},
executable = False,
)
Expand Down

0 comments on commit e2084fe

Please sign in to comment.