From a17db9ef46cf059f78dcc1cdb5d0be6af941f71b Mon Sep 17 00:00:00 2001 From: Will Toth Date: Sat, 13 May 2023 17:50:37 -0500 Subject: [PATCH 1/5] Fixes command line length too long for Windows This commit adds support for param files. This is important for Windows since even the most basic STM32Cube project ends up with more lines than Windows supports. --- toolchains/gcc_arm_none_eabi/gcc_arm_none_toolchain.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toolchains/gcc_arm_none_eabi/gcc_arm_none_toolchain.bzl b/toolchains/gcc_arm_none_eabi/gcc_arm_none_toolchain.bzl index e33fa14..198b136 100644 --- a/toolchains/gcc_arm_none_eabi/gcc_arm_none_toolchain.bzl +++ b/toolchains/gcc_arm_none_eabi/gcc_arm_none_toolchain.bzl @@ -307,7 +307,7 @@ def gcc_arm_none_toolchain(name, compiler_components, architecture, float_abi, e strip_files = compiler_components, as_files = compiler_components, ar_files = compiler_components, - supports_param_files = 0, + supports_param_files = 1, toolchain_config = ":" + toolchain_config, toolchain_identifier = "arm-none-eabi", ) From 70e9ce621ea29e6ae02ec1953f0310d855efae35 Mon Sep 17 00:00:00 2001 From: Will Toth Date: Mon, 22 Mar 2021 10:09:32 -0500 Subject: [PATCH 2/5] Adds windows implementation of print_all_features --- toolchains/features/defs.bzl | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/toolchains/features/defs.bzl b/toolchains/features/defs.bzl index 98a863d..ea7514e 100644 --- a/toolchains/features/defs.bzl +++ b/toolchains/features/defs.bzl @@ -2,6 +2,7 @@ load("//toolchains/features/common:types.bzl", "CC_ALL_COMMON_FEATURES_INFO") load("//toolchains/features/embedded:type.bzl", "CC_ALL_EMBEDDED_FEATURES_INFO") def _print_all_features_impl(ctx): + is_windows = ctx.host_configuration.host_path_separator == ";" common_features = CC_ALL_COMMON_FEATURES_INFO.keys() common_features.remove("type_name") common_features_str = "Common Features:\n " + "\n ".join(common_features) @@ -9,10 +10,23 @@ def _print_all_features_impl(ctx): embedded_features.remove("type_name") embedded_features_str = "Embedded Features:\n " + "\n ".join(embedded_features) all_feature_str = common_features_str + "\n" + embedded_features_str - print_script_str = """ -echo "{}" -""".format(all_feature_str) - script = ctx.actions.declare_file("%s.sh" % ctx.label.name) + + file_type = "" + print_script_str = "" + if is_windows: + file_type = "bat" + # Windows must have 'echo' before each line + all_feature_str = all_feature_str.replace("\n", "\necho ") + print_script_str = """ + @echo off + echo {} + """.format(all_feature_str) + else: + file_type = "sh" + print_script_str = """ + echo "{}" + """.format(all_feature_str) + script = ctx.actions.declare_file("{}.{}".format(ctx.label.name, file_type)) ctx.actions.write(script, print_script_str, is_executable = True) return [DefaultInfo(executable = script)] From f3e849fcdfebf099f30ea1a298c2d3b7b2e0b877 Mon Sep 17 00:00:00 2001 From: Will Toth Date: Sat, 13 May 2023 18:11:27 -0500 Subject: [PATCH 3/5] Bump openocd to 0.12 --- tools/openocd/openocd_repository.bzl | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tools/openocd/openocd_repository.bzl b/tools/openocd/openocd_repository.bzl index 80097ef..baa554a 100644 --- a/tools/openocd/openocd_repository.bzl +++ b/tools/openocd/openocd_repository.bzl @@ -1,19 +1,19 @@ def _get_platform_specific_config(os_name): _WINDOWS = { - "sha256": "1fb26bbcfd65dbabe747ce3c8467a1f1cece7253bde4a95de13c2267d422ed8b", - "prefix": "xpack-openocd-0.10.0-14", - "url": "https://github.com/xpack-dev-tools/openocd-xpack/releases/download/v0.10.0-14/xpack-openocd-0.10.0-14-win32-x64.zip", + "sha256": "5cba78c08ad03aa38549e94186cbb4ec34c384565a40a6652715577e4f1a458f", + "prefix": "xpack-openocd-0.12.0-1", + "url": "https://github.com/xpack-dev-tools/openocd-xpack/releases/download/v0.12.0-1/xpack-openocd-0.12.0-1-win32-x64.zip", } _PLATFORM_SPECIFIC_CONFIGS = { "mac os x": { - "sha256": "30917a5c6f60fcd7df82b41dcec8ab7d86f0cea3caeaf98b965b901c10a60b39", - "prefix": "xpack-openocd-0.10.0-14", - "url": "https://github.com/xpack-dev-tools/openocd-xpack/releases/download/v0.10.0-14/xpack-openocd-0.10.0-14-darwin-x64.tar.gz", + "sha256": "ca569b6bfd9b3cd87a5bc88b3a33a5c4fe854be3cf95a3dcda1c194e8da9d7bb", + "prefix": "xpack-openocd-0.12.0-1", + "url": "https://github.com/xpack-dev-tools/openocd-xpack/releases/download/v0.12.0-1/xpack-openocd-0.12.0-1-darwin-x64.tar.gz", }, "linux": { - "sha256": "185c070f9729cf38dca08686c2905561c07a63c563e5bc7a70e045f2a1865c11", - "prefix": "xpack-openocd-0.10.0-14", - "url": "https://github.com/xpack-dev-tools/openocd-xpack/releases/download/v0.10.0-14/xpack-openocd-0.10.0-14-linux-x64.tar.gz", + "sha256": "940f22eccddb0946b69149d227948f77d5917a2c5f1ab68e5d84d614c2ceed20", + "prefix": "xpack-openocd-0.12.0-1", + "url": "https://github.com/xpack-dev-tools/openocd-xpack/releases/download/v0.12.0-1/xpack-openocd-0.12.0-1-linux-x64.tar.gz", }, "windows": _WINDOWS, "windows server 2019": _WINDOWS, From 3c0029f194a8fbf74b4417f8c66cac686d37015b Mon Sep 17 00:00:00 2001 From: Will Toth Date: Wed, 24 Apr 2024 18:42:52 -0500 Subject: [PATCH 4/5] Add windows 11 --- .../compilers/gcc_arm_none_eabi/impl/gcc_arm_none_versions.bzl | 3 +++ toolchains/compilers/llvm/impl/llvm_versions.bzl | 2 ++ tools/openocd/openocd_repository.bzl | 1 + 3 files changed, 6 insertions(+) diff --git a/toolchains/compilers/gcc_arm_none_eabi/impl/gcc_arm_none_versions.bzl b/toolchains/compilers/gcc_arm_none_eabi/impl/gcc_arm_none_versions.bzl index 30e7ab1..13aa1e5 100644 --- a/toolchains/compilers/gcc_arm_none_eabi/impl/gcc_arm_none_versions.bzl +++ b/toolchains/compilers/gcc_arm_none_eabi/impl/gcc_arm_none_versions.bzl @@ -41,6 +41,7 @@ _PLATFORM_SPECIFIC_CONFIGS_9 = { "windows": _WINDOWS_9, "windows server 2019": _WINDOWS_9, "windows 10": _WINDOWS_9, + "windows 11": _WINDOWS_9, "mac os x": { "full_version": "9.2.1", "remote_compiler": { @@ -72,6 +73,7 @@ _PLATFORM_SPECIFIC_CONFIGS_11 = { "windows": _WINDOWS_11, "windows server 2019": _WINDOWS_11, "windows 10": _WINDOWS_11, + "windows 11": _WINDOWS_11, "mac os x": { "full_version": "11.3.rel1", "remote_compiler": { @@ -103,6 +105,7 @@ _PLATFORM_SPECIFIC_CONFIGS_12 = { "windows": _WINDOWS_12, "windows server 2019": _WINDOWS_12, "windows 10": _WINDOWS_12, + "windows 11": _WINDOWS_12, "mac os x": { "full_version": "12.2.rel1", "remote_compiler": { diff --git a/toolchains/compilers/llvm/impl/llvm_versions.bzl b/toolchains/compilers/llvm/impl/llvm_versions.bzl index e2ea369..81f2162 100644 --- a/toolchains/compilers/llvm/impl/llvm_versions.bzl +++ b/toolchains/compilers/llvm/impl/llvm_versions.bzl @@ -41,6 +41,7 @@ _PLATFORM_SPECIFIC_CONFIGS_11 = { "windows": _WINDOWS_11, "windows server 2019": _WINDOWS_11, "windows 10": _WINDOWS_11, + "windows 11": _WINDOWS_11, "mac os x": { "full_version": "11.0", "remote_compiler": { @@ -72,6 +73,7 @@ _PLATFORM_SPECIFIC_CONFIGS_14 = { "windows": _WINDOWS_14, "windows server 2019": _WINDOWS_14, "windows 10": _WINDOWS_14, + "windows 11": _WINDOWS_14, "mac os x": { "full_version": "14.0", "remote_compiler": { diff --git a/tools/openocd/openocd_repository.bzl b/tools/openocd/openocd_repository.bzl index baa554a..62cdb2f 100644 --- a/tools/openocd/openocd_repository.bzl +++ b/tools/openocd/openocd_repository.bzl @@ -18,6 +18,7 @@ def _get_platform_specific_config(os_name): "windows": _WINDOWS, "windows server 2019": _WINDOWS, "windows 10": _WINDOWS, + "windows 11": _WINDOWS, } if os_name not in _PLATFORM_SPECIFIC_CONFIGS.keys(): fail("OS configuration not available for:", os_name) From 704ea8844a5222fb6f8d5773a1995fffd9108926 Mon Sep 17 00:00:00 2001 From: Will Toth Date: Wed, 24 Apr 2024 23:04:58 -0500 Subject: [PATCH 5/5] Fix method to check for windows --- toolchains/clang/clang_toolchain.bzl | 9 ++++++++- toolchains/features/BUILD | 4 ++++ toolchains/features/defs.bzl | 8 ++++++-- toolchains/gcc_arm_none_eabi/gcc_arm_none_toolchain.bzl | 9 ++++++++- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/toolchains/clang/clang_toolchain.bzl b/toolchains/clang/clang_toolchain.bzl index c4ff56d..b6dcfb7 100644 --- a/toolchains/clang/clang_toolchain.bzl +++ b/toolchains/clang/clang_toolchain.bzl @@ -117,7 +117,7 @@ def _clang_toolchain_config_info_impl(ctx): ] os = "nix" postfix = "" - if ctx.host_configuration.host_path_separator == ";": + if ctx.attr.is_windows: os = "windows" postfix = ".bat" tool_paths = [tool_path(name = t.name, path = t.path.format(os = os) + postfix) for t in tool_paths] @@ -181,6 +181,9 @@ clang_toolchain_config = rule( doc = "Passthrough gcc wrappers used for the compiler", default = "//toolchains/clang/clang_wrappers:all", ), + "is_windows": attr.bool( + mandatory = True, + ), }, provides = [CcToolchainConfigInfo], ) @@ -230,6 +233,10 @@ def clang_toolchain(name): supports_param_files = 0, toolchain_config = ":" + toolchain_config, toolchain_identifier = "clang", + is_windows = select({ + "@bazel_tools//src/conditions:host_windows": True, + "//conditions:default": False, + }), ) native.toolchain( diff --git a/toolchains/features/BUILD b/toolchains/features/BUILD index 7775ae9..489d57a 100644 --- a/toolchains/features/BUILD +++ b/toolchains/features/BUILD @@ -2,4 +2,8 @@ load(":defs.bzl", "print_all_features") print_all_features( name = "print_all_features", + is_windows = select({ + "@bazel_tools//src/conditions:host_windows": True, + "//conditions:default": False, + }), ) diff --git a/toolchains/features/defs.bzl b/toolchains/features/defs.bzl index ea7514e..f196d5b 100644 --- a/toolchains/features/defs.bzl +++ b/toolchains/features/defs.bzl @@ -2,7 +2,6 @@ load("//toolchains/features/common:types.bzl", "CC_ALL_COMMON_FEATURES_INFO") load("//toolchains/features/embedded:type.bzl", "CC_ALL_EMBEDDED_FEATURES_INFO") def _print_all_features_impl(ctx): - is_windows = ctx.host_configuration.host_path_separator == ";" common_features = CC_ALL_COMMON_FEATURES_INFO.keys() common_features.remove("type_name") common_features_str = "Common Features:\n " + "\n ".join(common_features) @@ -13,7 +12,7 @@ def _print_all_features_impl(ctx): file_type = "" print_script_str = "" - if is_windows: + if ctx.attr.is_windows: file_type = "bat" # Windows must have 'echo' before each line all_feature_str = all_feature_str.replace("\n", "\necho ") @@ -33,4 +32,9 @@ def _print_all_features_impl(ctx): print_all_features = rule( _print_all_features_impl, executable = True, + attrs = { + "is_windows": attr.bool( + mandatory = True, + ), + } ) diff --git a/toolchains/gcc_arm_none_eabi/gcc_arm_none_toolchain.bzl b/toolchains/gcc_arm_none_eabi/gcc_arm_none_toolchain.bzl index 198b136..203e883 100644 --- a/toolchains/gcc_arm_none_eabi/gcc_arm_none_toolchain.bzl +++ b/toolchains/gcc_arm_none_eabi/gcc_arm_none_toolchain.bzl @@ -118,7 +118,7 @@ def _gcc_arm_none_toolchain_config_info_impl(ctx): ] os = "nix" postfix = "" - if ctx.host_configuration.host_path_separator == ";": + if ctx.attr.is_windows: os = "windows" postfix = ".bat" tool_paths = [tool_path(name = t.name, path = t.path.format(os = os) + postfix) for t in tool_paths] @@ -264,6 +264,9 @@ gcc_arm_none_toolchain_config = rule( doc = "Passthrough gcc wrappers used for the compiler", default = "//toolchains/gcc_arm_none_eabi/gcc_wrappers:all", ), + "is_windows": attr.bool( + mandatory = True, + ), }, provides = [CcToolchainConfigInfo], ) @@ -295,6 +298,10 @@ def gcc_arm_none_toolchain(name, compiler_components, architecture, float_abi, e endian = endian, fpu = fpu, toolchain_identifier = "arm-none-eabi", + is_windows = select({ + "@bazel_tools//src/conditions:host_windows": True, + "//conditions:default": False, + }), ) cc_toolchain(