Skip to content
Open
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
1 change: 1 addition & 0 deletions .bazeliskrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
USE_BAZEL_VERSION=4.2.2
6 changes: 5 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ coverage --experimental_generate_llvm_lcov
coverage --incompatible_cc_coverage

# Static analyser support
build:analyser --aspects //tools/clang_tidy:clang_tidy.bzl%clang_tidy_aspect --output_groups=report
build:analyser --aspects //tools/clang_tidy:clang_tidy.bzl%clang_tidy_aspect --output_groups=report

# Enable transitions for toolchains. Required for ARM toolchain to work
# correctly.
build --incompatible_override_toolchain_transition
6 changes: 5 additions & 1 deletion .githooks/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@ bazel test $TARGETS --test_tag_filters=-benchmark

bazel build $TARGETS

bazel build $STATIC_ANALYZER_TARGETS --aspects //tools/clang_tidy:clang_tidy.bzl%clang_tidy_aspect --output_groups=report
bazel build $STATIC_ANALYZER_TARGETS --aspects //tools/clang_tidy:clang_tidy.bzl%clang_tidy_aspect --output_groups=report

echo "Test compiler agains well known ARM embedded repos."

bazel build @com_github_stmicroelectronics_stm32cubel4//:stm32l4xx_hal_driver @com_github_stmicroelectronics_stm32cubel4//:stm32_cmsis_driver --platforms=//tests:stm32l432xx
11 changes: 9 additions & 2 deletions .github/workflows/blank.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,12 @@ jobs:
run: |
bazelisk test @com_google_googletest//... @com_github_google_benchmark//... @com_google_absl//... --test_tag_filters=-benchmark
bazelisk build @com_google_googletest//... @com_github_google_benchmark//... @com_google_absl//...
bazelisk build @com_google_googletest//... @com_github_google_benchmark//... @com_google_absl//... --aspects //tools/clang_tidy:clang_tidy.bzl%clang_tidy_aspect --output_groups=report

bazelisk build @com_google_googletest//... @com_github_google_benchmark//... @com_google_absl//... --aspects //tools/clang_tidy:clang_tidy.bzl%clang_tidy_aspect --output_groups=report
bazelisk build @com_github_stmicroelectronics_stm32cubel4//:stm32l4xx_hal_driver @com_github_stmicroelectronics_stm32cubel4//:stm32_cmsis_driver --platforms=//tests:stm32l432xx

- name: Bazel build/test internal test repos
run: |
bazelisk build //...
bazelisk build //... --platforms=//tests:cortex_m0
bazelisk build //... --platforms=//tests:cortex_m4
bazelisk build //... --platforms=//tests:cortex_m7
13 changes: 13 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
MIT License

Files: default, unless otherwise specified

Copyright (c) 2021 silvergasp

Permission is hereby granted, free of charge, to any person obtaining a copy
Expand All @@ -19,3 +21,14 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Apache license

Files: tests/startup_stm32l432xx.s (Used for testing only, not linked).

Copyright (c) 2017 STMicroelectronics. All rights reserved.

This software component is licensed by ST under Apache License, Version 2.0,
the "License"; You may not use this file except in compliance with the
License. You may obtain a copy of the License at:
opensource.org/licenses/Apache-2.0
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ build --incompatible_require_linker_input_cc_api
# Use new cc toolchain resolution api
build --incompatible_enable_cc_toolchain_resolution

# Enable transitions for toolchains. Required for ARM toolchain to work
# correctly.
build --incompatible_override_toolchain_transition

# Code coverage support
coverage --combined_report=lcov
coverage --experimental_use_llvm_covmap
Expand Down
5 changes: 4 additions & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ bazel_skylib_workspace()

rules_cc_toolchain_deps()

register_toolchains("//cc_toolchain/...")
register_execution_platforms("@rules_cc_toolchain//tests/...")

register_toolchains("@rules_cc_toolchain//cc_toolchain/...")

# Sets up Bazels documentation generator.
# Required by: rules_cc_toolchain.
Expand All @@ -33,6 +35,7 @@ git_repository(
name = "io_bazel_stardoc",
commit = "8f6d22452d088b49b13ba2c224af69ccc8ccbc90",
remote = "https://github.com/bazelbuild/stardoc.git",
shallow_since = "1620849756 -0400",
)

# Sets up Bazels packaging rules, for use the document generator.
Expand Down
90 changes: 87 additions & 3 deletions cc_toolchain/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ load(
)
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@io_bazel_stardoc//stardoc:stardoc.bzl", "stardoc")
load(
"@rules_cc_toolchain//third_party:gcc_arm_none_eabi_10_3_2021_10_x86_64_helpers.bzl",
ARM_NONE_EABI_LIB_INFO = "LIB_INFO",
)

cc_toolchain_import(
name = "all_imports",
Expand All @@ -23,7 +27,7 @@ cc_toolchain_import(
)

filegroup(
name = "all",
name = "all_files",
srcs = [
":all_imports",
"//cc_toolchain/features:startup_libs",
Expand Down Expand Up @@ -75,12 +79,90 @@ filegroup(
],
)

################################ arm-none-eabi ################################
cc_toolchain_config(
name = "arm_none_eabi_toolchain_config",
archiver = "@clang_llvm_12_00_x86_64_linux_gnu_ubuntu_16_04//:bin/llvm-ar",
c_compiler = "@clang_llvm_12_00_x86_64_linux_gnu_ubuntu_16_04//:bin/clang",
cc_compiler = "@clang_llvm_12_00_x86_64_linux_gnu_ubuntu_16_04//:bin/clang++",
compiler_features = [
# Hermetic libraries feature required before import.
"//cc_toolchain/features:hermetic_libraries",
"//cc_toolchain/features:toolchain_import",

# Common configuration.
"//cc_toolchain/features:garbage_collect_symbols",
"//cc_toolchain/features:warnings",
"//cc_toolchain/features:errors",
"//cc_toolchain/features:reproducible",
"//cc_toolchain/features:language",
"//cc_toolchain/features:use_lld",
"//cc_toolchain/features:sysroot",
"//cc_toolchain/features:dbg",
"//cc_toolchain/features:opt",
"//cc_toolchain/features:opt_standard",
"//cc_toolchain/features:fastbuild",
"//cc_toolchain/features:startup_libs",
"//cc_toolchain/features:coverage",

# Baremetal configuration.
"//cc_toolchain/features:opt_size",
"//cc_toolchain/features:float_abi",
"//cc_toolchain/features:free_standing_code",
"//cc_toolchain/features:no_rtti",

# ARM specific configuration.
"//cc_toolchain/features:arm_cpu",
"//cc_toolchain/features:arm_fpu",
"//cc_toolchain/features:thumb_target_triplet",
],
linker = "@clang_llvm_12_00_x86_64_linux_gnu_ubuntu_16_04//:bin/ld.lld",
object_dump_tool = "@clang_llvm_12_00_x86_64_linux_gnu_ubuntu_16_04//:bin/llvm-objdump",
symbol_list_tool = "@clang_llvm_12_00_x86_64_linux_gnu_ubuntu_16_04//:bin/llvm-nm",
)

[
cc_toolchain(
name = name + "_none_eabi_toolchain",
all_files = ":all_files",
ar_files = ":ar_files",
as_files = ":compiler_files",
compiler_files = ":compiler_files",
dwp_files = ":all_files",
linker_files = ":linker_files",
objcopy_files = ":objcopy_files",
strip_files = ":strip_files",
supports_param_files = 0,
toolchain_config = ":arm_none_eabi_toolchain_config",
toolchain_identifier = name + "_none_eabi",
)
for name, info in ARM_NONE_EABI_LIB_INFO.items()
]

[
toolchain(
name = name + "_none_eabi_cc_toolchain",
exec_compatible_with = [
"@platforms//os:none",
] + info["constraint_values"],
target_compatible_with = [
"@platforms//os:none",
] + info["constraint_values"],
toolchain = ":" + name + "_none_eabi_toolchain",
toolchain_type = "@rules_cc//cc:toolchain_type",
)
for name, info in ARM_NONE_EABI_LIB_INFO.items()
]

########################### Linux x86_64 ######################################

cc_toolchain(
name = "linux_x86_64_toolchain",
all_files = ":all",
all_files = ":all_files",
ar_files = ":ar_files",
as_files = ":compiler_files",
compiler_files = ":compiler_files",
dwp_files = ":all",
dwp_files = ":all_files",
linker_files = ":linker_files",
objcopy_files = ":objcopy_files",
strip_files = ":strip_files",
Expand Down Expand Up @@ -109,6 +191,8 @@ cc_toolchain_config(
"//cc_toolchain/features:sysroot",
"//cc_toolchain/features:dbg",
"//cc_toolchain/features:opt",
"//cc_toolchain/features:opt_size",
"//cc_toolchain/features:opt_standard",
"//cc_toolchain/features:fastbuild",
"//cc_toolchain/features:position_independent_code",
"//cc_toolchain/features:supports_pic",
Expand Down
Loading