-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add bazel support for easier external integration
Signed-off-by: Evgeny Petrov <evgeny@epetrov.net>
- Loading branch information
1 parent
7a6ac6e
commit 44c2f3e
Showing
22 changed files
with
573 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
build --cxxopt='-std=c++17' |
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 @@ | ||
6.4.0 |
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,21 @@ | ||
name: Bazel Build | ||
run-name: ${{ github.actor }} is building with bazel | ||
on: [push] | ||
jobs: | ||
bazel-build: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- run: echo branch name is ${{ github.ref }} | ||
- name: Checkout | ||
uses: actions/checkout@v4.1.0 | ||
- name: Mount bazel cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: "~/.cache/bazel" | ||
key: "bazel-cache" | ||
- name: Build all | ||
run: > | ||
bazel build //... | ||
- name: Try to run something | ||
run: > | ||
bazel run //:manager -- --help |
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,56 @@ | ||
genrule( | ||
name = "compile_time_settings", | ||
outs = ["include/everest/compile_time_settings.hpp"], | ||
cmd = """ | ||
echo "#define EVEREST_INSTALL_PREFIX \\"/usr\\"" > $@ | ||
echo "#define EVEREST_NAMESPACE (\\"everest\\")" >> $@ | ||
""", | ||
) | ||
|
||
cc_library( | ||
name = "framework", | ||
hdrs = glob(["include/**/*.hpp"]) + [":compile_time_settings"], | ||
srcs = glob(["lib/*.cpp"]), | ||
deps = [ | ||
"@com_github_everest_liblog//:liblog", | ||
"@com_github_HowardHinnant_date//:date", | ||
"@com_github_nlohmann_json//:json", | ||
"@com_github_fmtlib_fmt//:fmt", | ||
"@com_github_biojppm_rapidyaml//:ryml", | ||
"@com_github_pboettch_json-schema-validator//:json-schema-validator", | ||
"@com_github_LiamBindle_mqtt-c//:libmqtt", | ||
"@boost//:uuid", | ||
"@boost//:program_options", | ||
], | ||
strip_include_prefix = "include", | ||
) | ||
|
||
cc_library( | ||
name = "controller-ipc", | ||
srcs = glob(["src/controller/*.cpp"]), | ||
hdrs = glob(["src/controller/*.hpp"]), | ||
deps = [ | ||
"@com_github_nlohmann_json//:json", | ||
"@com_github_fmtlib_fmt//:fmt", | ||
"@com_github_biojppm_rapidyaml//:ryml", | ||
"@com_github_everest_liblog//:liblog", | ||
":framework", | ||
"@com_github_warmcatt_libwebsockets//:libwebsockets", | ||
], | ||
strip_include_prefix = "src", | ||
) | ||
|
||
cc_binary( | ||
name = "manager", | ||
srcs = [ | ||
"src/manager.cpp" | ||
], | ||
deps = [ | ||
"@com_github_everest_liblog//:liblog", | ||
"@com_github_fmtlib_fmt//:fmt", | ||
":framework", | ||
"@com_github_pboettch_json-schema-validator//:json-schema-validator", | ||
":controller-ipc", | ||
"@boost//:program_options", | ||
] | ||
) |
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,10 @@ | ||
workspace(name = "com_github_everest_everest-framework") | ||
|
||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") | ||
|
||
load("//bazel:repos.bzl", "everest_framework_repos") | ||
everest_framework_repos() | ||
|
||
load("//bazel:deps.bzl", "everest_framework_deps") | ||
everest_framework_deps() |
Empty file.
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,25 @@ | ||
# using everst-framework from bazel workspace. | ||
|
||
Add the following to your WORKSPACE file: | ||
``` | ||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
EVEREST_FRAMEWORK_REVISION = "4c0488de5eca3a9bc7c9258fc3715c5d6aab8c10" | ||
http_archive( | ||
name = "com_github_everest_everest-framework", | ||
url = "https://github.com/EVerest/everest-framework/archive/{}.tar.gz".format(EVEREST_FRAMEWORK_REVISION), | ||
strip_prefix = "everest-framework-4c0488de5eca3a9bc7c9258fc3715c5d6aab8c10", | ||
) | ||
# This load some definitions need to load dependencies on the next step | ||
load("@com_github_everest_everest-framework//bazel:repos.bzl", "everest_framework_repos") | ||
everest_framework_repos() | ||
# Load all dependencies | ||
load("@com_github_everest_everest-framework//bazel:deps.bzl", "everest_framework_deps") | ||
everest_framework_deps() | ||
``` | ||
|
||
After that, framework library will be available as `@com_github_everest_everest-framework//:framework` and the manager binary as `@com_github_everest_everest-framework//:manager` |
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,138 @@ | ||
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("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies") | ||
load("@com_github_nelhage_rules_boost//:boost/boost.bzl", "boost_deps") | ||
|
||
|
||
def everest_framework_deps(repo_mapping = {}): | ||
boost_deps() | ||
rules_foreign_cc_dependencies() | ||
|
||
maybe( | ||
git_repository, | ||
name = "boringssl", | ||
commit = "b9232f9e27e5668bc0414879dcdedb2a59ea75f2", | ||
remote = "https://boringssl.googlesource.com/boringssl", | ||
shallow_since = "1637714942 +0000", | ||
repo_mapping = repo_mapping, | ||
) | ||
|
||
maybe( | ||
http_archive, | ||
name = "com_github_curl_curl", | ||
url = "https://github.com/curl/curl/archive/refs/tags/curl-7_83_0.tar.gz", | ||
sha256 = "9350985ab43591ecd04b087f9c9dad84b952c35c6012e2a08ae355ae797db988", | ||
strip_prefix = "curl-curl-7_83_0", | ||
build_file = "@com_github_everest_everest-framework//bazel/third-party:BUILD.curl.bazel", | ||
repo_mapping = repo_mapping, | ||
) | ||
|
||
maybe( | ||
http_archive, | ||
name = "com_github_everest_liblog", | ||
url = "https://github.com/EVerest/liblog/archive/5c132fb0bcdfb41d6285c4f834ae4657d7a6bff6.tar.gz", | ||
sha256 = "19b017a8ef4948bd0692f1d683d0031e76daa21d43a4bddff818bb77e0827fac", | ||
strip_prefix = "liblog-5c132fb0bcdfb41d6285c4f834ae4657d7a6bff6", | ||
build_file = "@com_github_everest_everest-framework//bazel/third-party:BUILD.liblog.bazel", | ||
repo_mapping = repo_mapping, | ||
) | ||
|
||
maybe( | ||
http_archive, | ||
name = "com_github_pboettch_json-schema-validator", | ||
url = "https://github.com/pboettch/json-schema-validator/archive/f4194d7e24e2e2365660ff35b57a7c4e088b27fa.tar.gz", | ||
sha256 = "f71f2fbef135a61ad7bd9444f4202f9698a4b1c70279cb1e9b2567a6d996aaa1", | ||
strip_prefix = "json-schema-validator-f4194d7e24e2e2365660ff35b57a7c4e088b27fa", | ||
build_file = "@com_github_everest_everest-framework//bazel/third-party:BUILD.json-schema-validator.bazel", | ||
repo_mapping = repo_mapping, | ||
) | ||
|
||
maybe( | ||
http_archive, | ||
name = "com_github_HowardHinnant_date", | ||
url = "https://github.com/HowardHinnant/date/archive/2ef74cb41a31dcd03b39dd5e9bf8b340669f48a4.tar.gz", | ||
sha256 = "3446ad7e2ba07c9105769bf6fd9b521d4e3a2f2dd0a955643a20f4adb1870efa", | ||
strip_prefix = "date-2ef74cb41a31dcd03b39dd5e9bf8b340669f48a4", | ||
build_file = "@com_github_everest_everest-framework//bazel/third-party:BUILD.date.bazel", | ||
repo_mapping = repo_mapping, | ||
) | ||
|
||
maybe( | ||
http_archive, | ||
name = "com_github_biojppm_rapidyaml", | ||
url = "https://github.com/biojppm/rapidyaml/archive/213b201d264139cd1b887790197e08850af628e3.tar.gz", | ||
sha256 = "c206d4565ccfa721991a8df90821d1a1f747e68385a0f3f5b9ab995e191c06be", | ||
strip_prefix = "rapidyaml-213b201d264139cd1b887790197e08850af628e3", | ||
build_file = "@com_github_everest_everest-framework//bazel/third-party:BUILD.rapidyaml.bazel", | ||
repo_mapping = repo_mapping, | ||
) | ||
|
||
maybe( | ||
http_archive, | ||
name = "com_github_biojppm_c4core", | ||
url = "https://github.com/biojppm/c4core/archive/d35c7c9bf370134595699d791e6ff8db018ddc8d.tar.gz", | ||
sha256 = "b768c8fb5dd4740317b7e1a3e43a0b32615d4d4e1e974d7ab515a80d2f1f318d", | ||
strip_prefix = "c4core-d35c7c9bf370134595699d791e6ff8db018ddc8d", | ||
build_file = "@com_github_everest_everest-framework//bazel/third-party:BUILD.c4core.bazel", | ||
repo_mapping = repo_mapping, | ||
) | ||
|
||
maybe( | ||
http_archive, | ||
name = "com_github_biojppm_debugbreak", | ||
url = "https://github.com/biojppm/debugbreak/archive/5dcbe41d2bd4712c8014aa7e843723ad7b40fd74.tar.gz", | ||
sha256 = "4b424d23dad957937c57c142648d32571a78a6c6b2e473709748e5c1bb8a0f92", | ||
strip_prefix = "debugbreak-5dcbe41d2bd4712c8014aa7e843723ad7b40fd74", | ||
build_file = "@com_github_everest_everest-framework//bazel/third-party:BUILD.debugbreak.bazel", | ||
repo_mapping = repo_mapping, | ||
) | ||
|
||
maybe( | ||
http_archive, | ||
name = "com_github_fastfloat_fastfloat", | ||
url = "https://github.com/fastfloat/fast_float/archive/32d21dcecb404514f94fb58660b8029a4673c2c1.tar.gz", | ||
sha256 = "8035a9ca28a8e3dfee332c7960af3c06ef0ab5169d5f31228b89c469e882bef7", | ||
strip_prefix = "fast_float-32d21dcecb404514f94fb58660b8029a4673c2c1", | ||
build_file = "@com_github_everest_everest-framework//bazel/third-party:BUILD.fastfloat.bazel", | ||
repo_mapping = repo_mapping, | ||
) | ||
|
||
maybe( | ||
http_archive, | ||
name = "com_github_warmcatt_libwebsockets", | ||
url = "https://github.com/warmcat/libwebsockets/archive/b0a749c8e7a8294b68581ce4feac0e55045eb00b.tar.gz", | ||
sha256 = "5c3d6d482e73a0c105f3f14ce9b03c27b5d51c3938f8483b7eb8e6d535baa25f", | ||
strip_prefix = "libwebsockets-b0a749c8e7a8294b68581ce4feac0e55045eb00b", | ||
build_file = "@com_github_everest_everest-framework//bazel/third-party:BUILD.libwebsockets.bazel", | ||
) | ||
|
||
maybe( | ||
http_archive, | ||
name = "com_github_LiamBindle_mqtt-c", | ||
url = "https://github.com/LiamBindle/MQTT-C/archive/f69ce1e7fd54f3b1834c9c9137ce0ec5d703cb4d.tar.gz", | ||
sha256 = "0b3ab84e5bca3c0c29be6b84af6f9840d92a0ae4fc00ca74fdcacc30b2b0a1e9", | ||
strip_prefix = "MQTT-C-f69ce1e7fd54f3b1834c9c9137ce0ec5d703cb4d", | ||
build_file = "@com_github_everest_everest-framework//bazel/third-party:BUILD.mqtt-c.bazel", | ||
repo_mapping = repo_mapping, | ||
) | ||
|
||
maybe( | ||
http_archive, | ||
name = "com_github_nlohmann_json", | ||
urls = ["https://github.com/nlohmann/json/archive/refs/tags/v3.11.2.tar.gz"], | ||
strip_prefix = "json-3.11.2", | ||
sha256 = "d69f9deb6a75e2580465c6c4c5111b89c4dc2fa94e3a85fcd2ffcd9a143d9273", | ||
build_file = "@com_github_everest_everest-framework//bazel/third-party:BUILD.nlohmann_json.bazel", | ||
repo_mapping = repo_mapping, | ||
) | ||
|
||
maybe( | ||
http_archive, | ||
name = "com_github_fmtlib_fmt", | ||
urls = ["https://github.com/fmtlib/fmt/archive/refs/tags/10.1.1.tar.gz"], | ||
strip_prefix = "fmt-10.1.1", | ||
sha256 = "78b8c0a72b1c35e4443a7e308df52498252d1cefc2b08c9a97bc9ee6cfe61f8b", | ||
build_file = "@com_github_everest_everest-framework//bazel/third-party:BUILD.fmt.bazel", | ||
repo_mapping = repo_mapping, | ||
) |
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,28 @@ | ||
""" In this file we pull a couple of repos that have own | ||
macros to pull other repos. | ||
""" | ||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") | ||
|
||
def everest_framework_repos(repo_mapping = {}): | ||
maybe( | ||
http_archive, | ||
name = "com_github_nelhage_rules_boost", | ||
|
||
# Replace the commit hash in both places (below) with the latest, rather than using the stale one here. | ||
# Even better, set up Renovate and let it do the work for you (see "Suggestion: Updates" in the README). | ||
url = "https://github.com/nelhage/rules_boost/archive/4ab574f9a84b42b1809978114a4664184716f4bf.tar.gz", | ||
sha256 = "2215e6910eb763a971b1f63f53c45c0f2b7607df38c96287666d94d954da8cdc", | ||
strip_prefix = "rules_boost-4ab574f9a84b42b1809978114a4664184716f4bf", | ||
# When you first run this tool, it'll recommend a sha256 hash to put here with a message like: "DEBUG: Rule 'com_github_nelhage_rules_boost' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = ..." | ||
) | ||
|
||
maybe( | ||
http_archive, | ||
name = "rules_foreign_cc", | ||
url = "https://github.com/bazelbuild/rules_foreign_cc/archive/0.5.1.tar.gz", | ||
sha256 = "33a5690733c5cc2ede39cb62ebf89e751f2448e27f20c8b2fbbc7d136b166804", | ||
strip_prefix = "rules_foreign_cc-0.5.1", | ||
repo_mapping = repo_mapping, | ||
) | ||
|
Empty file.
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,16 @@ | ||
cc_library( | ||
name = "c4", | ||
srcs = glob(["src/**/*.cpp"]), | ||
hdrs = glob([ | ||
"src/**/*.hpp", | ||
"src/**/*.h" | ||
]), | ||
visibility = [ | ||
"//visibility:public", | ||
], | ||
strip_include_prefix = "src", | ||
deps = [ | ||
"@com_github_biojppm_debugbreak//:debugbreak", | ||
"@com_github_fastfloat_fastfloat//:fastfloat", | ||
] | ||
) |
Oops, something went wrong.