Add extracted tools: CitrineOS, OpenOCPP, ShapeShifter

- CitrineOS core extracted (CSMS OCPP 2.0.1)
- OpenOCPP extracted (firmware OCPP 1.6J/2.0.1)
- ShapeShifter library installed (pip install -e)
- ShapeShifter specification extracted
- EVerest extracted

TODO updated with progress
This commit is contained in:
Eric F
2026-06-08 00:38:27 -04:00
parent 468cfeaa50
commit d398a6ced2
7326 changed files with 1177561 additions and 7 deletions

View File

View File

@@ -0,0 +1,23 @@
load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake")
filegroup(
name = "all_srcs",
srcs = glob(["**"]),
visibility = ["//visibility:public"],
)
cmake(
name = "date",
cache_entries = {
"CMAKE_INSTALL_LIBDIR": "lib",
"BUILD_TZ_LIB": "ON",
"USE_SYSTEM_TZ_DB": "ON",
"HAS_REMOTE_API": "0",
"USE_AUTOLOAD": "0",
},
lib_source = ":all_srcs",
out_static_libs = ["libdate-tz.a"],
visibility = [
"//visibility:public",
],
)

View File

@@ -0,0 +1,15 @@
load("@rules_cc//cc:defs.bzl", "cc_library")
cc_library(
name = "json-schema-validator",
srcs = glob([
"src/*.cpp",
"src/*.hpp",
]),
hdrs = glob(["src/nlohmann/*.hpp"]),
strip_include_prefix = "src",
visibility = ["//visibility:public"],
deps = [
"@com_github_nlohmann_json//:json",
],
)

View File

@@ -0,0 +1,60 @@
load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake")
filegroup(
name = "all_srcs",
srcs = [
"CMakeLists.txt",
"CMakeLists-implied-options.txt",
] + glob([
"cmake/**",
"include/**",
"lib/**",
"lwsws/**",
"plugins/**",
]),
visibility = ["//visibility:public"],
)
cmake(
name = "libwebsockets",
cache_entries = {
"CMAKE_POLICY_DEFAULT_CMP0077": "NEW",
"CMAKE_POSITION_INDEPENDENT_CODE": "ON",
"LWS_ROLE_RAW_FILE": "OFF",
"LWS_UNIX_SOCK": "OFF",
"LWS_WITH_SYS_STATE": "OFF",
"LWS_WITH_SYS_SMD": "OFF",
"LWS_WITH_BORINGSSL": "OFF",
"LWS_WITH_UPNG": "OFF",
"LWS_WITH_JPEG": "OFF",
"LWS_WITH_DLO": "OFF",
"LWS_WITH_SECURE_STREAMS": "OFF",
"LWS_WITH_STATIC": "ON",
"LWS_WITH_LHP": "OFF",
"LWS_WITH_LEJP_CONF": "OFF",
"LWS_WITH_MINIMAL_EXAMPLES": "OFF",
"LWS_WITH_CACHE_NSCOOKIEJAR": "OFF",
"LWS_WITHOUT_TESTAPPS": "ON",
"LWS_WITHOUT_TEST_SERVER": "ON",
"LWS_WITHOUT_TEST_SERVER_EXTPOLL": "ON",
"LWS_WITHOUT_TEST_PING": "ON",
"LWS_WITHOUT_TEST_CLIENT": "ON",
"CMAKE_VERBOSE_MAKEFILE": "ON",
"LWS_WITH_SSL": "ON",
"LWS_OPENSSL_LIBRARIES": "ssl;crypto",
"DISABLE_WERROR": "ON",
"CMAKE_INSTALL_LIBDIR": "lib"
},
lib_source = ":all_srcs",
out_static_libs = ["libwebsockets.a"],
visibility = [
"//visibility:public",
],
deps = [
"@libcap//:libcap",
"@everest-core//third-party/bazel/openssl:ssl",
"@everest-core//third-party/bazel/openssl:crypto",
],
)

View File

@@ -0,0 +1,137 @@
# SPDX-License-Identifier: Apache-2.0
# stripped down version of the 2.1.2 recipe in the bazel-central-registry
# by UebelAndre, licensed Apache-2.0 https://github.com/bazelbuild/bazel-central-registry/blob/4c39e836b6db6c1f83f27e3c79a8a9f03fb1b292/modules/mosquitto/2.1.2/overlay/BUILD.bazel
# adapted to mosquitto 2.0.22
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
load("@bazel_skylib//rules:write_file.bzl", "write_file")
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
load("@rules_cc//cc:cc_library.bzl", "cc_library")
###############################################################################
# Common build settings
###############################################################################
COMMON_COPTS = select({
"//conditions:default": [
"-std=gnu99",
"-w",
],
})
COMMON_DEFINES = [
"CMAKE",
'VERSION=\\"2.0.22\\"',
"OPENSSL_API_COMPAT=0x10100000L",
] + select({
"//conditions:default": [
"WITH_UNIX_SOCKETS",
],
})
PLUGIN_LINKOPTS = select({
"//conditions:default": [],
})
###############################################################################
# config_header
###############################################################################
copy_file(
name = "config_header_gen",
src = "config.h",
out = "config_inc/config.h",
)
cc_library(
name = "config_header",
hdrs = ["config_inc/config.h"],
includes = ["config_inc"],
visibility = ["//:__subpackages__"],
)
###############################################################################
# Bundled dependencies (uthash, utlist)
###############################################################################
cc_library(
name = "bundled_deps",
hdrs = [
"deps/uthash.h",
"deps/utlist.h",
],
includes = ["deps"],
visibility = ["//:__subpackages__"],
)
###############################################################################
# mosquitto_common -- shared utility library (libcommon/)
###############################################################################
cc_library(
name = "mosquitto_common",
srcs = [],
hdrs = glob([
"include/*.h",
]),
copts = COMMON_COPTS,
includes = [
"include",
"libcommon",
],
local_defines = COMMON_DEFINES + select({
"//conditions:default": [],
}),
visibility = ["//:__subpackages__"],
deps = [
":bundled_deps",
":config_header",
"@everest-core//third-party/bazel/openssl:ssl",
] + select({
"//conditions:default": [],
}),
)
###############################################################################
# libmosquitto -- MQTT client library (lib/)
###############################################################################
cc_library(
name = "mosquitto",
srcs = glob(
[
"lib/*.c",
"lib/*.h",
],
),
hdrs = glob([
"include/*.h",
]),
copts = COMMON_COPTS,
includes = [
"common",
"include",
"lib",
"libcommon",
],
linkopts = select({
"//conditions:default": [
"-lpthread",
],
}),
local_defines = COMMON_DEFINES + [
] + select({
"//conditions:default": ["WITH_THREADING"],
}) + select({
"//conditions:default": [],
}),
visibility = ["//visibility:public"],
deps = [
":bundled_deps",
":config_header",
":mosquitto_common",
"@everest-core//third-party/bazel/openssl:ssl",
] + select({
"//conditions:default": [],
}),
)

View File

@@ -0,0 +1,29 @@
load("@rules_foreign_cc//foreign_cc:defs.bzl", "configure_make")
filegroup(
name = "all_srcs",
srcs = glob(["**"]),
)
configure_make(
name = "openssl",
configure_command = "Configure",
configure_in_place = True,
configure_options = [
"linux-armv4",
"no-shared",
"no-afalgeng",
"no-dynamic-engine",
"no-tests",
] + select({
"@platforms//cpu:armv7": ["no-atexit"],
"//conditions:default": [],
}),
lib_source = ":all_srcs",
out_static_libs = [
"libssl.a",
"libcrypto.a",
],
targets = ["install_sw"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,16 @@
load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake")
filegroup(
name = "all_srcs",
srcs = glob(["**"]),
visibility = ["//visibility:public"],
)
cmake(
name = "sigslot",
cache_entries = {
"SIGSLOT_COMPILE_EXAMPLES": "OFF",
},
lib_source = "@sigslot//:all_srcs",
out_headers_only = True,
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,86 @@
load("@bazel_features//:features.bzl", "bazel_features")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
load("@bazel_tools//tools/build_defs/repo:local.bzl", "new_local_repository")
def _deps_impl(module_ctx):
maybe(
http_archive,
name = "sigslot",
url = "https://github.com/palacaze/sigslot/archive/b588b791b9cf7eb17ff0a74d8aebd4a61166c2e1.tar.gz",
sha256 = "140f0a2a731ed7d9ebff1bad4cb506ea2aa28fd57f42b3ec79031b1505dc6680",
strip_prefix = "sigslot-b588b791b9cf7eb17ff0a74d8aebd4a61166c2e1",
build_file = "@everest-core//third-party/bazel:BUILD.sigslot.bazel",
)
maybe(
http_archive,
name = "com_github_HowardHinnant_date",
url = "https://github.com/HowardHinnant/date/archive/f94b8f36c6180be0021876c4a397a054fe50c6f2.tar.gz",
sha256 = "8be4c3a52d99b22a4478ce3e2a23fa4b38587ea3d3bc3d1a4d68de22c2e65fb2",
strip_prefix = "date-f94b8f36c6180be0021876c4a397a054fe50c6f2",
build_file = "@everest-core//third-party/bazel:BUILD.date.bazel",
)
maybe(
http_archive,
name = "com_github_pboettch_json-schema-validator",
url = "https://github.com/pboettch/json-schema-validator/archive/c780404a84dd9ba978ba26bc58d17cb43fa7bc80.tar.gz",
sha256 = "5b6ef2fd33c7fbc38fefc851f07281699fc45add5a558c2ac3f24be3e36eb0b6",
strip_prefix = "json-schema-validator-c780404a84dd9ba978ba26bc58d17cb43fa7bc80",
build_file = "@everest-core//third-party/bazel:BUILD.json-schema-validator.bazel",
)
maybe(
http_archive,
name = "com_github_warmcatt_libwebsockets",
url = "https://github.com/warmcat/libwebsockets/archive/85c6f7959fd40d8aaf7a50be3c9b75f08389a01c.tar.gz",
sha256 = "eceb5b1efdaf73505ee60c1761ae457f9d663aed06009057f8fed117ed8e91b3",
strip_prefix = "libwebsockets-85c6f7959fd40d8aaf7a50be3c9b75f08389a01c",
build_file = "@everest-core//third-party/bazel:BUILD.libwebsockets.bazel",
)
# mosquitto 2.0.x is needed at the moment because there are some unresolved issues our usage of 2.1
maybe(
http_archive,
name = "mosquitto",
url = "https://mosquitto.org/files/source/mosquitto-2.0.22.tar.gz",
sha256 = "2f752589ef7db40260b633fbdb536e9a04b446a315138d64a7ff3c14e2de6b68",
strip_prefix = "mosquitto-2.0.22",
build_file = "@everest-core//third-party/bazel:BUILD.mosquitto.bazel",
)
maybe(
http_archive,
name = "openssl_source",
url = "https://github.com/openssl/openssl/releases/download/openssl-3.3.1/openssl-3.3.1.tar.gz",
sha256 = "777cd596284c883375a2a7a11bf5d2786fc5413255efab20c50d6ffe6d020b7e",
strip_prefix = "openssl-3.3.1",
build_file = "@everest-core//third-party/bazel:BUILD.openssl-foreign-cc.bazel",
)
version = "0.2.15"
maybe(
http_archive,
name = "pybind11_json",
strip_prefix = "pybind11_json-%s" % version,
urls = ["https://github.com/pybind/pybind11_json/archive/refs/tags/%s.tar.gz" % version],
build_file_content = """
load("@rules_cc//cc:defs.bzl", "cc_library")
cc_library(
name = "pybind11_json",
hdrs = glob(["include/**/*.hpp"]),
visibility = [
"//visibility:public",
],
includes = ["include"]
)
""",
)
deps = module_extension(
doc = "Non-module dependencies for everest-core",
implementation = _deps_impl,
)

View File

@@ -0,0 +1,27 @@
# Currently the openssl version from does not support armv7. For this target we
# compile openssl with rules_foreign_cc and switch here based on the
# architecture.
load("@rules_cc//cc:defs.bzl", "cc_library")
config_setting(
name = "armv7",
constraint_values = ["@platforms//cpu:armv7"],
)
cc_library(
name = "ssl",
visibility = ["//visibility:public"],
deps = select({
":armv7": ["@openssl_source//:openssl"],
"//conditions:default": ["@openssl//:ssl"],
}),
)
cc_library(
name = "crypto",
visibility = ["//visibility:public"],
deps = select({
":armv7": ["@openssl_source//:openssl"],
"//conditions:default": ["@openssl//:crypto"],
}),
)

View File

@@ -0,0 +1,55 @@
package(default_visibility = ["//visibility:public"])
constraint_setting(name = "libc")
constraint_value(
name = "gnu",
constraint_setting = ":libc",
)
constraint_value(
name = "musl",
constraint_setting = ":libc",
)
constraint_value(
name = "none_libc",
constraint_setting = ":libc",
)
platform(
name = "aarch64-linux-gnu",
constraint_values = [
"@platforms//cpu:aarch64",
"@platforms//os:linux",
":gnu",
],
)
platform(
name = "aarch64-linux-musl",
constraint_values = [
"@platforms//cpu:aarch64",
"@platforms//os:linux",
":musl",
],
)
platform(
name = "armv7-linux-gnueabihf",
constraint_values = [
"@platforms//cpu:armv7",
"@platforms//os:linux",
":gnu",
],
)
platform(
name = "armv7-linux-musleabihf",
constraint_values = [
"@platforms//cpu:armv7",
"@platforms//os:linux",
":musl",
],
)

View File

@@ -0,0 +1,16 @@
# Use as target_compatible_with for targets that require a Python toolchain,
# which is not available for cross-compilation platforms.
CROSS_PYTHON_INCOMPATIBLE = select({
"@platforms//cpu:armv7": ["@platforms//:incompatible"],
"@platforms//cpu:aarch64": ["@platforms//:incompatible"],
"//conditions:default": [],
})
# Use as target_compatible_with for test targets that cannot be
# cross-compiled (e.g. tests linking host-only libraries like Catch2/GTest).
CROSS_TEST_INCOMPATIBLE = select({
"@platforms//cpu:armv7": ["@platforms//:incompatible"],
"@platforms//cpu:aarch64": ["@platforms//:incompatible"],
"//conditions:default": [],
})

View File

@@ -0,0 +1,392 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:local.bzl", "new_local_repository")
# =============================================================================
# C++ Cross-Compilation Toolchains Configuration
# =============================================================================
# Resolve canonical labels so constraint references work when everest-core
# is consumed as a dependency module (where @// would point at the root
# module, not everest-core).
_GNU_CONSTRAINT = str(Label("//third-party/bazel/toolchains:gnu"))
_MUSL_CONSTRAINT = str(Label("//third-party/bazel/toolchains:musl"))
# Derive the canonical repo name prefix so that "external/<prefix>+toolchains+<name>"
# resolves correctly whether everest-core is the root module or a dependency.
# Label resolves to e.g. "@@everest-core+//..." (dep) or "@@//..." (root).
_MODULE_REPO_PREFIX = _GNU_CONSTRAINT.split("//")[0][2:] # strip "@@"
_EXTERNAL_PREFIX = "external/" + _MODULE_REPO_PREFIX + "+toolchains+"
def _create_cpp_toolchains():
"""Experiment to create a glibc cross-compilation toolchain."""
repo_names = []
# This toolchain rougly corresponds to kirkstone. Use it as an example
# to cross compile for phyverso.
http_archive(
name = "cc_toolchain_aarch64-linux-gnu-x86_64-linux",
urls = ["https://toolchains.bootlin.com/downloads/releases/toolchains/aarch64/tarballs/aarch64--glibc--stable-2022.08-1.tar.bz2"],
sha256 = "844df3c99508030ee9cb1152cb182500bb9816ff01968f2e18591d51d766c9e7",
strip_prefix = "aarch64--glibc--stable-2022.08-1",
build_file_content = """
load("@@rules_cc+//cc:defs.bzl", "cc_toolchain")
load("@bazel_tools//tools/cpp:unix_cc_toolchain_config.bzl", "cc_toolchain_config")
BIN_PREFIX = "bin/aarch64-buildroot-linux-gnu-"
REPO = "{repo_path}"
SYSROOT = REPO + "/aarch64-buildroot-linux-gnu/sysroot"
cc_toolchain_config(
name = "aarch64-linux-glibc_toolchain_config",
abi_libc_version = "2.35",
abi_version = "unknown",
compile_flags = [
"-nostdinc++",
"-fPIC",
"-mno-outline-atomics",
"-isystem", REPO + "/aarch64-buildroot-linux-gnu/include/c++/11.3.0/",
"-isystem", REPO + "/aarch64-buildroot-linux-gnu/include/c++/11.3.0/aarch64-buildroot-linux-gnu/",
"-isystem", REPO + "/aarch64-buildroot-linux-gnu/sysroot/usr/include/",
"-isystem", REPO + "/lib/gcc/aarch64-buildroot-linux-gnu/11.3.0/include/",
"-isystem", REPO + "/lib/gcc/aarch64-buildroot-linux-gnu/11.3.0/include-fixed/",
],
compiler = "gcc",
cpu = "aarch64",
host_system_name = "local",
target_libc = "unknown",
target_system_name = "aarch64-linux-glibc",
toolchain_identifier = "aarch64-linux-glibc",
tool_paths = {
"ar": BIN_PREFIX + "ar",
"cpp": BIN_PREFIX + "g++.br_real",
"gcc": BIN_PREFIX + "gcc-11.3.0.br_real",
"dwp": BIN_PREFIX + "dwp",
"gcov": BIN_PREFIX + "gcov",
"ld": BIN_PREFIX + "ld",
"nm": BIN_PREFIX + "nm",
"objcopy": BIN_PREFIX + "objcopy",
"objdump": BIN_PREFIX + "objdump",
"strip": BIN_PREFIX + "strip",
"llvm-cov": BIN_PREFIX + "llvm-cov",
},
link_flags = ["-Wl,--start-group"],
link_libs = ["-lstdc++", "-lm", "-ldl"],
)
filegroup(
name = "all",
srcs = glob(["**/**"]),
)
cc_toolchain(
name = "aarch64-linux-glibc_toolchain",
# We tell the toolchain, that for every command, all the files are needed
# This is not ideal, but simple.
all_files = ":all",
ar_files = ":all",
as_files = ":all",
compiler_files = ":all",
dwp_files = ":all",
linker_files = ":all",
objcopy_files = ":all",
strip_files = ":all",
toolchain_config = ":aarch64-linux-glibc_toolchain_config",
)
toolchain(
name = "aarch64-linux-glibc_toolchain_toolchain",
exec_compatible_with = [
"@platforms//os:linux",
"@platforms//cpu:x86_64",
],
target_compatible_with = [
"@platforms//os:linux",
"@platforms//cpu:arm64",
"{gnu_constraint}",
],
toolchain = ":aarch64-linux-glibc_toolchain",
toolchain_type = "@rules_cc//cc:toolchain_type",
)
""".replace("{gnu_constraint}", _GNU_CONSTRAINT).replace("{repo_path}", _EXTERNAL_PREFIX + "cc_toolchain_aarch64-linux-gnu-x86_64-linux"),
)
repo_names.append("cc_toolchain_aarch64-linux-gnu-x86_64-linux")
http_archive(
name = "cc_toolchain_aarch64-linux-musl-x86_64-linux",
urls = ["https://toolchains.bootlin.com/downloads/releases/toolchains/aarch64/tarballs/aarch64--musl--stable-2023.08-1.tar.bz2"],
sha256 = "25767ae9ca70a76e9a71a13c6bc145532066a36d118d8f0ef14bd474784095ce",
strip_prefix = "aarch64--musl--stable-2023.08-1",
build_file_content = """
load("@@rules_cc+//cc:defs.bzl", "cc_toolchain")
load("@bazel_tools//tools/cpp:unix_cc_toolchain_config.bzl", "cc_toolchain_config")
BIN_PREFIX = "bin/aarch64-buildroot-linux-musl-"
REPO = "{repo_path}"
SYSROOT = REPO + "/aarch64-buildroot-linux-musl/sysroot"
cc_toolchain_config(
name = "aarch64-linux-musl_toolchain_config",
abi_libc_version = "1.2.4",
abi_version = "unknown",
compile_flags = [
"-nostdinc++",
"-flto", "-ffat-lto-objects",
"-isystem", REPO + "/aarch64-buildroot-linux-musl/include/c++/12.3.0/",
"-isystem", REPO + "/aarch64-buildroot-linux-musl/include/c++/12.3.0/aarch64-buildroot-linux-musl/",
"-isystem", REPO + "/aarch64-buildroot-linux-musl/sysroot/usr/include/",
"-isystem", REPO + "/lib/gcc/aarch64-buildroot-linux-musl/12.3.0/include/",
"-isystem", REPO + "/lib/gcc/aarch64-buildroot-linux-musl/12.3.0/include-fixed/",
],
compiler = "gcc",
cpu = "aarch64",
host_system_name = "local",
target_libc = "unknown",
target_system_name = "aarch64-linux-musl",
toolchain_identifier = "aarch64-linux-musl",
tool_paths = {
"ar": BIN_PREFIX + "ar",
"cpp": BIN_PREFIX + "g++.br_real",
"gcc": BIN_PREFIX + "gcc-12.3.0.br_real",
"dwp": BIN_PREFIX + "dwp",
"gcov": BIN_PREFIX + "gcov",
"ld": BIN_PREFIX + "ld",
"nm": BIN_PREFIX + "nm",
"objcopy": BIN_PREFIX + "objcopy",
"objdump": BIN_PREFIX + "objdump",
"strip": BIN_PREFIX + "strip",
"llvm-cov": BIN_PREFIX + "llvm-cov",
},
link_flags = ["-Wl,--start-group", "-flto", "-static"],
link_libs = ["-Wl,-Bstatic", "-lstdc++", "-lc", "-lgcc", "-lgcc_eh"],
)
filegroup(
name = "all",
srcs = glob(["**/**"]),
)
cc_toolchain(
name = "aarch64-linux-musl_toolchain",
# We tell the toolchain, that for every command, all the files are needed
# This is not ideal, but simple.
all_files = ":all",
ar_files = ":all",
as_files = ":all",
compiler_files = ":all",
dwp_files = ":all",
linker_files = ":all",
objcopy_files = ":all",
strip_files = ":all",
toolchain_config = ":aarch64-linux-musl_toolchain_config",
)
toolchain(
name = "aarch64-linux-musl_toolchain_toolchain",
exec_compatible_with = [
"@platforms//os:linux",
"@platforms//cpu:x86_64",
],
target_compatible_with = [
"@platforms//os:linux",
"@platforms//cpu:arm64",
"{musl_constraint}",
],
toolchain = ":aarch64-linux-musl_toolchain",
toolchain_type = "@rules_cc//cc:toolchain_type",
)
""".replace("{musl_constraint}", _MUSL_CONSTRAINT).replace("{repo_path}", _EXTERNAL_PREFIX + "cc_toolchain_aarch64-linux-musl-x86_64-linux"),
)
repo_names.append("cc_toolchain_aarch64-linux-musl-x86_64-linux")
http_archive(
name = "cc_toolchain_armv7-linux-gnu-x86_64-linux",
urls = ["https://toolchains.bootlin.com/downloads/releases/toolchains/armv7-eabihf/tarballs/armv7-eabihf--glibc--stable-2022.08-1.tar.bz2"],
sha256 = "64329b3e72350ceda65997368395a945ef83769013d82414dc5f2021c33f2d44",
strip_prefix = "armv7-eabihf--glibc--stable-2022.08-1",
build_file_content = """
load("@@rules_cc+//cc:defs.bzl", "cc_toolchain")
load("@bazel_tools//tools/cpp:unix_cc_toolchain_config.bzl", "cc_toolchain_config")
BIN_PREFIX = "bin/arm-buildroot-linux-gnueabihf-"
REPO = "{repo_path}"
cc_toolchain_config(
name = "armv7-linux-gnu_toolchain_config",
abi_libc_version = "2.35",
abi_version = "unknown",
compile_flags = [
"-nostdinc++",
"-fPIC",
"-mthumb",
"-mfpu=neon",
"-mfloat-abi=hard",
"-mcpu=cortex-a7",
"-isystem", REPO + "/arm-buildroot-linux-gnueabihf/include/c++/11.3.0/",
"-isystem", REPO + "/arm-buildroot-linux-gnueabihf/include/c++/11.3.0/arm-buildroot-linux-gnueabihf/",
"-isystem", REPO + "/arm-buildroot-linux-gnueabihf/sysroot/usr/include/",
"-isystem", REPO + "/lib/gcc/arm-buildroot-linux-gnueabihf/11.3.0/include/",
"-isystem", REPO + "/lib/gcc/arm-buildroot-linux-gnueabihf/11.3.0/include-fixed/",
],
compiler = "gcc",
cpu = "armv7",
host_system_name = "local",
target_libc = "unknown",
target_system_name = "armv7-linux-gnu",
toolchain_identifier = "armv7-linux-gnu",
tool_paths = {
"ar": BIN_PREFIX + "ar",
"cpp": BIN_PREFIX + "g++.br_real",
"gcc": BIN_PREFIX + "gcc-11.3.0.br_real",
"dwp": BIN_PREFIX + "dwp",
"gcov": BIN_PREFIX + "gcov",
"ld": BIN_PREFIX + "ld",
"nm": BIN_PREFIX + "nm",
"objcopy": BIN_PREFIX + "objcopy",
"objdump": BIN_PREFIX + "objdump",
"strip": BIN_PREFIX + "strip",
"llvm-cov": BIN_PREFIX + "llvm-cov",
},
link_flags = ["-Wl,--start-group"],
link_libs = ["-lstdc++", "-lm", "-ldl"],
)
filegroup(
name = "all",
srcs = glob(["**/**"]),
)
cc_toolchain(
name = "armv7-linux-gnu_toolchain",
all_files = ":all",
ar_files = ":all",
as_files = ":all",
compiler_files = ":all",
dwp_files = ":all",
linker_files = ":all",
objcopy_files = ":all",
strip_files = ":all",
toolchain_config = ":armv7-linux-gnu_toolchain_config",
)
toolchain(
name = "armv7-linux-gnu_toolchain_toolchain",
exec_compatible_with = [
"@platforms//os:linux",
"@platforms//cpu:x86_64",
],
target_compatible_with = [
"@platforms//os:linux",
"@platforms//cpu:armv7",
"{gnu_constraint}",
],
toolchain = ":armv7-linux-gnu_toolchain",
toolchain_type = "@rules_cc//cc:toolchain_type",
)
""".replace("{gnu_constraint}", _GNU_CONSTRAINT).replace("{repo_path}", _EXTERNAL_PREFIX + "cc_toolchain_armv7-linux-gnu-x86_64-linux"),
)
repo_names.append("cc_toolchain_armv7-linux-gnu-x86_64-linux")
http_archive(
name = "cc_toolchain_armv7-linux-musl-x86_64-linux",
urls = ["https://toolchains.bootlin.com/downloads/releases/toolchains/armv7-eabihf/tarballs/armv7-eabihf--musl--stable-2023.08-1.tar.bz2"],
sha256 = "4f06ed760d3b2e779f0d8aec73becd21edce9d04560d2fba53549ca8c12f51ba",
strip_prefix = "armv7-eabihf--musl--stable-2023.08-1",
build_file_content = """
load("@@rules_cc+//cc:defs.bzl", "cc_toolchain")
load("@bazel_tools//tools/cpp:unix_cc_toolchain_config.bzl", "cc_toolchain_config")
BIN_PREFIX = "bin/arm-buildroot-linux-musleabihf-"
REPO = "{repo_path}"
cc_toolchain_config(
name = "armv7-linux-musl_toolchain_config",
abi_libc_version = "1.2.4",
abi_version = "unknown",
compile_flags = [
"-nostdinc++",
"-fPIC",
"-isystem", REPO + "/arm-buildroot-linux-musleabihf/include/c++/12.3.0/",
"-isystem", REPO + "/arm-buildroot-linux-musleabihf/include/c++/12.3.0/arm-buildroot-linux-musleabihf/",
"-isystem", REPO + "/arm-buildroot-linux-musleabihf/sysroot/usr/include/",
"-isystem", REPO + "/lib/gcc/arm-buildroot-linux-musleabihf/12.3.0/include/",
"-isystem", REPO + "/lib/gcc/arm-buildroot-linux-musleabihf/12.3.0/include-fixed/",
],
compiler = "gcc",
cpu = "armv7",
host_system_name = "local",
target_libc = "unknown",
target_system_name = "armv7-linux-musl",
toolchain_identifier = "armv7-linux-musl",
tool_paths = {
"ar": BIN_PREFIX + "ar",
"cpp": BIN_PREFIX + "g++.br_real",
"gcc": BIN_PREFIX + "gcc-12.3.0.br_real",
"dwp": BIN_PREFIX + "dwp",
"gcov": BIN_PREFIX + "gcov",
"ld": BIN_PREFIX + "ld",
"nm": BIN_PREFIX + "nm",
"objcopy": BIN_PREFIX + "objcopy",
"objdump": BIN_PREFIX + "objdump",
"strip": BIN_PREFIX + "strip",
"llvm-cov": BIN_PREFIX + "llvm-cov",
},
link_flags = ["-Wl,--start-group", "-flto", "-static"],
link_libs = ["-Wl,-Bstatic", "-lstdc++", "-lc", "-lgcc", "-lgcc_eh"],
)
filegroup(
name = "all",
srcs = glob(["**/**"]),
)
cc_toolchain(
name = "armv7-linux-musl_toolchain",
all_files = ":all",
ar_files = ":all",
as_files = ":all",
compiler_files = ":all",
dwp_files = ":all",
linker_files = ":all",
objcopy_files = ":all",
strip_files = ":all",
toolchain_config = ":armv7-linux-musl_toolchain_config",
)
toolchain(
name = "armv7-linux-musl_toolchain_toolchain",
exec_compatible_with = [
"@platforms//os:linux",
"@platforms//cpu:x86_64",
],
target_compatible_with = [
"@platforms//os:linux",
"@platforms//cpu:armv7",
"{musl_constraint}",
],
toolchain = ":armv7-linux-musl_toolchain",
toolchain_type = "@rules_cc//cc:toolchain_type",
)
""".replace("{musl_constraint}", _MUSL_CONSTRAINT).replace("{repo_path}", _EXTERNAL_PREFIX + "cc_toolchain_armv7-linux-musl-x86_64-linux"),
)
repo_names.append("cc_toolchain_armv7-linux-musl-x86_64-linux")
return repo_names
# =============================================================================
# Module Extension
# =============================================================================
def _toolchains_impl(ctx):
_create_cpp_toolchains()
toolchains = module_extension(
implementation = _toolchains_impl,
)