-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add bazel build for native code (#1224)
Adds an experimental bazel build for C/C++ artifacts, along with a submodule of common build files. Co-authored-by: Krzysztof Naglik <krzysztofnaglik96@gmail.com>
- Loading branch information
1 parent
16500e5
commit ddc35f1
Showing
7 changed files
with
192 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
workspace(name = "root") | ||
|
||
new_local_repository( | ||
name = "my-check", | ||
build_file = "bazel/check.BUILD", | ||
path = "c/third_party/check", | ||
) | ||
|
||
local_repository( | ||
name = "my-googletest", | ||
path = "c/third_party/googletest", | ||
) | ||
|
||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
|
||
http_archive( | ||
name = "rules_foreign_cc", | ||
strip_prefix = "rules_foreign_cc-c65e8cfbaa002bcd1ce9c26e9fec63b0b866c94b", | ||
url = "https://github.com/bazelbuild/rules_foreign_cc/archive/c65e8cfbaa002bcd1ce9c26e9fec63b0b866c94b.tar.gz", | ||
) | ||
|
||
load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies") | ||
|
||
rules_foreign_cc_dependencies() | ||
|
||
# Hedron's Compile Commands Extractor for Bazel | ||
# Used to create compile_commands.json file | ||
http_archive( | ||
name = "hedron_compile_commands", | ||
sha256 = "4b251a482a85de6c5cb0dc34c5671e73190b9ff348e9979fa2c033d81de0f928", | ||
strip_prefix = "bazel-compile-commands-extractor-5bb5ff2f32d542a986033102af771aa4206387b9", | ||
url = "https://github.com/hedronvision/bazel-compile-commands-extractor/archive/5bb5ff2f32d542a986033102af771aa4206387b9.tar.gz", | ||
) | ||
|
||
load("@hedron_compile_commands//:workspace_setup.bzl", "hedron_compile_commands_setup") | ||
|
||
hedron_compile_commands_setup() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
load("@rules_cc//cc:defs.bzl", "cc_library") | ||
load("@hedron_compile_commands//:refresh_compile_commands.bzl", "refresh_compile_commands") | ||
|
||
SBP_INCLUDE = glob(["include/**/*.h"]) | ||
|
||
SBP_INCLUDE_INTERNAL = glob(["src/**/*.h"]) | ||
|
||
refresh_compile_commands( | ||
name = "refresh_compile_commands", | ||
) | ||
|
||
cc_library( | ||
name = "sbp", | ||
srcs = [ | ||
"src/edc.c", | ||
"src/sbp.c", | ||
"src/v4/string/sbp_string.c", | ||
"src/v4/string/multipart.c", | ||
"src/v4/string/null_terminated.c", | ||
"src/v4/string/double_null_terminated.c", | ||
"src/v4/string/unterminated.c", | ||
# generated files | ||
"src/v4/acquisition.c", | ||
"src/v4/bootload.c", | ||
"src/v4/ext_events.c", | ||
"src/v4/file_io.c", | ||
"src/v4/flash.c", | ||
"src/v4/gnss.c", | ||
"src/v4/imu.c", | ||
"src/v4/integrity.c", | ||
"src/v4/linux.c", | ||
"src/v4/logging.c", | ||
"src/v4/mag.c", | ||
"src/v4/navigation.c", | ||
"src/v4/ndb.c", | ||
"src/v4/observation.c", | ||
"src/v4/orientation.c", | ||
"src/v4/piksi.c", | ||
"src/v4/sbas.c", | ||
"src/v4/settings.c", | ||
"src/v4/signing.c", | ||
"src/v4/solution_meta.c", | ||
"src/v4/ssr.c", | ||
"src/v4/system.c", | ||
"src/v4/tracking.c", | ||
"src/v4/user.c", | ||
"src/v4/vehicle.c", | ||
], | ||
hdrs = SBP_INCLUDE + SBP_INCLUDE_INTERNAL, | ||
copts = ["-Ic/src/include"], | ||
includes = [ | ||
"include", | ||
], | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
SBP_LEGACY_C_SOURCES = glob(["test/legacy/auto*.c"]) | ||
|
||
cc_test( | ||
name = "sbp-legacy-test", | ||
srcs = [ | ||
"test/check_main_legacy.c", | ||
"test/check_edc.c", | ||
"test/check_sbp.c", | ||
"test/check_bitfield_macros.c", | ||
"test/check_suites_legacy.h", | ||
] + SBP_LEGACY_C_SOURCES, | ||
includes = [ | ||
"include/libsbp", | ||
], | ||
deps = [ | ||
":sbp", | ||
"@my-check//:check", | ||
], | ||
) | ||
|
||
SBP_V4_C_SOURCES = glob(["test/auto*.c"]) | ||
|
||
cc_test( | ||
name = "sbp-v4-test", | ||
srcs = [ | ||
"test/check_main.c", | ||
"test/check_edc.c", | ||
"test/check_sbp.c", | ||
"test/check_bitfield_macros.c", | ||
"test/check_suites.h", | ||
] + SBP_V4_C_SOURCES, | ||
includes = ["include/libsbp"], | ||
deps = [ | ||
":sbp", | ||
"@my-check//:check", | ||
], | ||
) | ||
|
||
SBP_CPP_V4_C_SOURCES = glob(["test/cpp/auto*.cc"]) | ||
|
||
cc_test( | ||
name = "sbp-cpp-v4-test", | ||
srcs = SBP_CPP_V4_C_SOURCES, | ||
deps = [ | ||
":sbp", | ||
"@my-googletest//:gtest_main", | ||
], | ||
) | ||
|
||
cc_test( | ||
name = "sbp-string-test", | ||
srcs = [ | ||
"test/string/test_double_null_terminated.cc", | ||
"test/string/test_multipart.cc", | ||
"test/string/test_null_terminated.cc", | ||
"test/string/test_unterminated.cc", | ||
], | ||
includes = [ | ||
"src/include", | ||
], | ||
deps = [ | ||
":sbp", | ||
"@my-googletest//:gtest_main", | ||
], | ||
) | ||
|
||
SBP_CPP_LEGACY_SOURCES = glob(["test/legacy/cpp/auto*.cc"]) | ||
|
||
cc_test( | ||
name = "sbp-cpp-legacy-test", | ||
srcs = [ | ||
"test/legacy/cpp/test_sbp_stdio.cc", | ||
] + SBP_CPP_LEGACY_SOURCES, | ||
data = [ | ||
"test/legacy/cpp/sbp_data/gnss_data.sbp", | ||
], | ||
deps = [ | ||
":sbp", | ||
"@my-googletest//:gtest_main", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters