Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjustments to include EVerest as upstream project #737

Merged
merged 1 commit into from
Jul 9, 2024
Merged
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
3 changes: 0 additions & 3 deletions .github/workflows/bazel_build_and_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 //...
Expand Down
5 changes: 4 additions & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ filegroup(
srcs = glob(["errors/**/*.yaml"]),
)

exports_files(["dependencies.yaml"])
exports_files([
"dependencies.yaml",
"WORKSPACE.bazel",
])
6 changes: 1 addition & 5 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -62,4 +58,4 @@ everest_framework_deps()

load("@everest-utils//third-party/bazel:defs.bzl", "everest_utils_defs")

everest_utils_defs()
everest_utils_defs()
2 changes: 2 additions & 0 deletions cmake/assets/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
exports_files(["logging.ini"])

5 changes: 5 additions & 0 deletions errors/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
filegroup(
name = "errors",
srcs = glob(["*.yaml"]),
visibility = ["//visibility:public"],
)
8 changes: 5 additions & 3 deletions interfaces/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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})`/..
Expand Down
11 changes: 11 additions & 0 deletions modules/DummyTokenValidator/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
load("//modules:module.bzl", "cc_everest_module")

IMPLS = [
"main",
]

cc_everest_module(
name = "DummyTokenValidator",
deps = [],
impls = IMPLS,
)
20 changes: 20 additions & 0 deletions modules/EnergyNode/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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",
],
),
)
8 changes: 5 additions & 3 deletions modules/RsIskraMeter/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1188,7 +1190,7 @@ mod tests {
identification_flags: Vec::new(),
identification_data: None,
identification_level: None,
tariff_text: None
tariff_text: None,
});
}
}
Expand Down Expand Up @@ -1288,7 +1290,7 @@ mod tests {
identification_flags: Vec::new(),
identification_data: None,
identification_level: None,
tariff_text: None
tariff_text: None,
});
}
}
39 changes: 33 additions & 6 deletions modules/module.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -31,42 +31,69 @@ 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)`/.. \
{module_name}
""".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"],
includes = [
".",
"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"],
)
11 changes: 11 additions & 0 deletions third-party/bazel/edm-wrapper.sh
Original file line number Diff line number Diff line change
@@ -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 "$@"
8 changes: 7 additions & 1 deletion third-party/bazel/edm.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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",
),
},
)
5 changes: 2 additions & 3 deletions third-party/bazel/repos.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion types/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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})`
Expand Down
Loading