diff --git a/.github/workflows/bazel_build_and_test.yaml b/.github/workflows/bazel_build_and_test.yaml index 9eeeb0560..002218c03 100644 --- a/.github/workflows/bazel_build_and_test.yaml +++ b/.github/workflows/bazel_build_and_test.yaml @@ -15,9 +15,6 @@ jobs: key: ${{ runner.os }}-bazel-${{ hashFiles('dependencies.yaml', '.bazelversion', '.bazelrc', 'WORKSPACE.bazel', 'third-party/bazel/*') }} restore-keys: | ${{ runner.os }}-bazel- - - name: Setup edm - run: | - pip install git+https://github.com/Everest/everest-dev-environment.git#subdirectory=dependency_manager - name: Build all run: > bazelisk build //... diff --git a/BUILD.bazel b/BUILD.bazel index f8bb5b1af..8839e5aa9 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -7,4 +7,7 @@ filegroup( srcs = glob(["errors/**/*.yaml"]), ) -exports_files(["dependencies.yaml"]) +exports_files([ + "dependencies.yaml", + "WORKSPACE.bazel", +]) diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel index 26895908c..cbe55b61a 100644 --- a/WORKSPACE.bazel +++ b/WORKSPACE.bazel @@ -40,9 +40,6 @@ load("@rules_rust//crate_universe:repositories.bzl", "crate_universe_dependencie crate_universe_dependencies() - - - load("//third-party/bazel:repos.bzl", "everest_core_repos") everest_core_repos() @@ -51,7 +48,6 @@ load("//third-party/bazel:defs.bzl", "everest_core_defs") everest_core_defs() - load("@everest-framework//third-party/bazel:repos.bzl", "everest_framework_repos") everest_framework_repos() @@ -62,4 +58,4 @@ everest_framework_deps() load("@everest-utils//third-party/bazel:defs.bzl", "everest_utils_defs") -everest_utils_defs() \ No newline at end of file +everest_utils_defs() diff --git a/cmake/assets/BUILD.bazel b/cmake/assets/BUILD.bazel new file mode 100644 index 000000000..bc4567019 --- /dev/null +++ b/cmake/assets/BUILD.bazel @@ -0,0 +1,2 @@ +exports_files(["logging.ini"]) + diff --git a/errors/BUILD.bazel b/errors/BUILD.bazel new file mode 100644 index 000000000..6f8c6e168 --- /dev/null +++ b/errors/BUILD.bazel @@ -0,0 +1,5 @@ +filegroup( + name = "errors", + srcs = glob(["*.yaml"]), + visibility = ["//visibility:public"], +) diff --git a/interfaces/BUILD.bazel b/interfaces/BUILD.bazel index 5c38ba0c5..1a5963a60 100644 --- a/interfaces/BUILD.bazel +++ b/interfaces/BUILD.bazel @@ -23,15 +23,17 @@ genrule( outs = cpp_headers, srcs = interface_srcs + [ "@everest-framework//schemas:schemas", - "//types:types", - "//:errors", + "@everest-core//types", + "@everest-core//errors", + "@everest-core//:WORKSPACE.bazel", ], tools = [ "@everest-utils//ev-dev-tools:ev-cli", ], cmd = """ $(location @everest-utils//ev-dev-tools:ev-cli) interface generate-headers \ - --everest-dir . \ + --work-dir `dirname $(location @everest-core//:WORKSPACE.bazel)` \ + --everest-dir `dirname $(location @everest-core//:WORKSPACE.bazel)` \ --schemas-dir external/everest-framework/schemas \ --disable-clang-format \ --output-dir `dirname $(location {some_output})`/.. diff --git a/modules/DummyTokenValidator/BUILD.bazel b/modules/DummyTokenValidator/BUILD.bazel new file mode 100644 index 000000000..04637151e --- /dev/null +++ b/modules/DummyTokenValidator/BUILD.bazel @@ -0,0 +1,11 @@ +load("//modules:module.bzl", "cc_everest_module") + +IMPLS = [ + "main", +] + +cc_everest_module( + name = "DummyTokenValidator", + deps = [], + impls = IMPLS, +) \ No newline at end of file diff --git a/modules/EnergyNode/BUILD.bazel b/modules/EnergyNode/BUILD.bazel new file mode 100644 index 000000000..8c36bef97 --- /dev/null +++ b/modules/EnergyNode/BUILD.bazel @@ -0,0 +1,20 @@ +load("//modules:module.bzl", "cc_everest_module") + +IMPLS = [ + "energy_grid", + "external_limits", +] + +cc_everest_module( + name = "EnergyNode", + impls = IMPLS, + deps = [ + "@sigslot//:sigslot", + ], + srcs = glob( + [ + "*.cpp", + "*.hpp", + ], + ), +) diff --git a/modules/RsIskraMeter/src/main.rs b/modules/RsIskraMeter/src/main.rs index 589213dca..fa6a35075 100644 --- a/modules/RsIskraMeter/src/main.rs +++ b/modules/RsIskraMeter/src/main.rs @@ -46,7 +46,6 @@ use everestrs::serde as everest_serde; use everestrs::serde_json as everest_serde_json; use generated::types::powermeter::{ Powermeter, TransactionRequestStatus, TransactionStartResponse, TransactionStopResponse, - OCMFUserIdentificationStatus, OCMFIdentificationType, }; use generated::types::serial_comm_hub_requests::{StatusCodeEnum, VectorUint16}; use generated::types::units::{Current, Energy, Frequency, Power, ReactivePower, Voltage}; @@ -945,6 +944,9 @@ fn main() { mod tests { use self::generated::types::powermeter::TransactionReq; + use self::generated::types::powermeter::{ + OCMFIdentificationType, OCMFUserIdentificationStatus, + }; use super::*; use mockall::predicate::eq; @@ -1188,7 +1190,7 @@ mod tests { identification_flags: Vec::new(), identification_data: None, identification_level: None, - tariff_text: None + tariff_text: None, }); } } @@ -1288,7 +1290,7 @@ mod tests { identification_flags: Vec::new(), identification_data: None, identification_level: None, - tariff_text: None + tariff_text: None, }); } } diff --git a/modules/module.bzl b/modules/module.bzl index 1a3aef714..dd8c8679d 100644 --- a/modules/module.bzl +++ b/modules/module.bzl @@ -31,22 +31,29 @@ def cc_everest_module( name + ".hpp", ] + binary = name + "__binary" + manifest = native.glob(["manifest.y*ml"], allow_empty = False)[0] + native.genrule( name = "ld-ev", outs = [ "generated/modules/{}/ld-ev.hpp".format(name), "generated/modules/{}/ld-ev.cpp".format(name), ], - srcs = native.glob(["manifest.y*ml"], allow_empty = False) + [ + srcs = [ + manifest, + "@everest-core//types:types", "@everest-framework//schemas:schemas", - "//types:types", + "@everest-core//:WORKSPACE.bazel", + "@everest-core//interfaces:interfaces", ], tools = [ "@everest-utils//ev-dev-tools:ev-cli", ], cmd = """ $(location @everest-utils//ev-dev-tools:ev-cli) module generate-loader \ - --everest-dir . \ + --work-dir `dirname $(location @everest-core//:WORKSPACE.bazel)` \ + --everest-dir ~/foo \ --schemas-dir external/everest-framework/schemas \ --disable-clang-format \ --output-dir `dirname $(location generated/modules/{module_name}/ld-ev.hpp)`/.. \ @@ -54,14 +61,13 @@ def cc_everest_module( """.format(module_name = name) ) - native.cc_binary( - name = name, + name = binary, srcs = depset(srcs + impl_srcs + module_srcs + [ ":ld-ev", ]).to_list(), deps = deps + [ - "//interfaces:interfaces_lib", + "@everest-core//interfaces:interfaces_lib", "@everest-framework//:framework", ], copts = ["-std=c++17"], @@ -69,4 +75,25 @@ def cc_everest_module( ".", "generated/modules/" + name, ], + visibility = ["//visibility:public"], + ) + + native.genrule( + name = "copy_to_subdir", + srcs = [":" + binary, manifest], + outs = [ + "{}/manifest.yaml".format(name), + "{}/{}".format(name, name), + ], + cmd = "mkdir -p $(RULEDIR)/{} && ".format(name) + + "cp $(location {}) $(RULEDIR)/{}/{} && ".format(binary, name, name) + + "cp $(location {}) $(RULEDIR)/{}/".format(manifest, name), + ) + + native.filegroup( + name = name, + srcs = [ + ":copy_to_subdir", + ], + visibility = ["//visibility:public"], ) \ No newline at end of file diff --git a/third-party/bazel/edm-wrapper.sh b/third-party/bazel/edm-wrapper.sh new file mode 100755 index 000000000..06f26b1ba --- /dev/null +++ b/third-party/bazel/edm-wrapper.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +set -eu -o pipefail + +EDM_LINK=git+https://github.com/Everest/everest-dev-environment.git#subdirectory=dependency_manager +mkdir -p venv > /dev/null +TARGET_PATH=$(realpath venv) +pip3 install --upgrade -t $TARGET_PATH $EDM_LINK > /dev/null +export PYTHONPATH=$TARGET_PATH +export PATH=$TARGET_PATH/bin:$PATH + +edm "$@" \ No newline at end of file diff --git a/third-party/bazel/edm.bzl b/third-party/bazel/edm.bzl index 8cd08674a..1acc872a2 100644 --- a/third-party/bazel/edm.bzl +++ b/third-party/bazel/edm.bzl @@ -5,8 +5,9 @@ def _edm_repositories_impl(rctx): build_files_args.append("--build-file") build_files_args.append(str(build_file)) print("build_files_args: ", build_files_args) + edm_tool = rctx.attr._edm_tool exec_result = rctx.execute( - ["edm", "bazel", rctx.attr.dependencies_yaml] + + [edm_tool, "bazel", rctx.attr.dependencies_yaml] + build_files_args, ) if exec_result.return_code != 0: @@ -27,5 +28,10 @@ edm_repositories = repository_rule( allow_files=True, doc="List of build files for external repositories", ), + "_edm_tool": attr.label( + default=Label("@everest-core//third-party/bazel:edm-wrapper.sh"), + allow_single_file=True, + doc="Path to the edm script", + ), }, ) \ No newline at end of file diff --git a/third-party/bazel/repos.bzl b/third-party/bazel/repos.bzl index 8f3a54578..42bc4cfcd 100644 --- a/third-party/bazel/repos.bzl +++ b/third-party/bazel/repos.bzl @@ -3,7 +3,7 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") load("@rules_rust//crate_universe:defs.bzl", "crates_repository", "crate") load("@rules_rust//crate_universe:repositories.bzl", "crate_universe_dependencies") -load("//third-party/bazel:edm.bzl", "edm_repositories") +load("@everest-core//third-party/bazel:edm.bzl", "edm_repositories") def everest_core_repos(): @@ -22,7 +22,6 @@ def everest_core_repos(): strip_prefix = "rules_boost-f02f84fac7673c56bbcfe69dea68044e6e40f92b", ) - crates_repository( name = "everest_core_crate_index", cargo_lockfile = "@everest-core//modules:Cargo.lock", @@ -52,7 +51,7 @@ def everest_core_repos(): edm_repositories( name = "edm_deps", - dependencies_yaml = "//:dependencies.yaml", + dependencies_yaml = "@everest-core//:dependencies.yaml", build_files = [ "@everest-core//third-party/bazel:BUILD.libmodbus.bazel", "@everest-core//third-party/bazel:BUILD.libtimer.bazel", diff --git a/types/BUILD.bazel b/types/BUILD.bazel index 7d3c7e307..8c03e87fd 100644 --- a/types/BUILD.bazel +++ b/types/BUILD.bazel @@ -19,13 +19,15 @@ genrule( outs = cpp_headers, srcs = yaml_srcs + [ "@everest-framework//schemas:schemas", + "@everest-core//:WORKSPACE.bazel", ], tools = [ "@everest-utils//ev-dev-tools:ev-cli", ], cmd = """ $(location @everest-utils//ev-dev-tools:ev-cli) types generate-headers \ - --everest-dir . \ + --work-dir `dirname $(location @everest-core//:WORKSPACE.bazel)` \ + --everest-dir `dirname $(location @everest-core//:WORKSPACE.bazel)` \ --schemas-dir external/everest-framework/schemas \ --disable-clang-format \ --output-dir `dirname $(location {some_header})`