Skip to content
Open
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
1 change: 0 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ build --credential_helper=*.qnx.com=%workspace%/scripts/internal/qnx_creds.py
# Common test flags for all platforms
test --test_output=errors
test --@score_baselibs//score/json:base_library=nlohmann
test --cxxopt=-Wno-deprecated-declarations

# Coverage configuration for C++
coverage --features=coverage
Expand Down
47 changes: 11 additions & 36 deletions config/common_cc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,48 +12,23 @@
# *******************************************************************************
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("//config:common_opts.bzl", "SANITIZER_CXXOPTS", "SANITIZER_LINKOPTS")

_def_or_empty = lambda v: v if v else []
COMMON_OPTIONS = [
"-Wall",
"-Wextra",
"-Werror",
]

def cc_library_with_common_opts(
name,
srcs = None,
hdrs = None,
deps = None,
cxxopts = None,
linkopts = None,
omit_common_cxxopts = False,
omit_common_linkopts = False,
**kwargs):
base_cxx = [] if omit_common_cxxopts else SANITIZER_CXXOPTS
base_link = [] if omit_common_linkopts else SANITIZER_LINKOPTS
def cc_library_with_common_options(**kwargs):
cc_library(
name = name,
srcs = _def_or_empty(srcs),
hdrs = _def_or_empty(hdrs),
deps = _def_or_empty(deps),
cxxopts = base_cxx + _def_or_empty(cxxopts),
linkopts = base_link + _def_or_empty(linkopts),
copts = COMMON_OPTIONS + kwargs.pop("copts", []),
cxxopts = COMMON_OPTIONS + kwargs.pop("cxxopts", []),
**kwargs
)

def cc_binary_with_common_opts(
name,
srcs = None,
deps = None,
cxxopts = None,
linkopts = None,
omit_common_cxxopts = False,
omit_common_linkopts = False,
**kwargs):
base_cxx = [] if omit_common_cxxopts else SANITIZER_CXXOPTS
base_link = [] if omit_common_linkopts else SANITIZER_LINKOPTS
def cc_binary_with_common_options(**kwargs):
cc_binary(
name = name,
srcs = _def_or_empty(srcs),
deps = _def_or_empty(deps),
cxxopts = base_cxx + _def_or_empty(cxxopts),
linkopts = base_link + _def_or_empty(linkopts),
copts = COMMON_OPTIONS + kwargs.pop("copts", []),
cxxopts = COMMON_OPTIONS + kwargs.pop("cxxopts", []),
**kwargs
)
30 changes: 0 additions & 30 deletions config/common_opts.bzl

This file was deleted.

4 changes: 2 additions & 2 deletions examples/c_supervised_app/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
load("@rules_cc//cc:defs.bzl", "cc_binary")
load("//config:common_cc.bzl", "cc_binary_with_common_options")

cc_binary(
cc_binary_with_common_options(
name = "c_supervised_app",
srcs = [
"main.c",
Expand Down
9 changes: 7 additions & 2 deletions examples/c_supervised_app/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>

#include <score/mw/lifecycle/alive.h>
#include <score/mw/lifecycle/report_running.h>
Expand All @@ -29,6 +29,11 @@ static void signal_handler(int signal)
}
}

const struct timespec interval = {
.tv_sec = 0,
.tv_nsec = 50000000,
};

int main(void)
{
signal(SIGINT, signal_handler);
Expand All @@ -51,7 +56,7 @@ int main(void)
while (!exit_requested)
{
score_lcm_alive_report_alive(alive);
usleep(50000);
nanosleep(&interval, NULL);
}

score_lcm_alive_deinitialize(alive);
Expand Down
6 changes: 3 additions & 3 deletions examples/control_application/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
load("@rules_cc//cc:defs.bzl", "cc_binary")
load("//config:common_cc.bzl", "cc_binary_with_common_options")

cc_binary(
cc_binary_with_common_options(
name = "lmcontrol",
srcs = [
"control.hpp",
Expand All @@ -35,7 +35,7 @@ cc_binary(
],
)

cc_binary(
cc_binary_with_common_options(
name = "control_daemon",
srcs = [
"control.hpp",
Expand Down
2 changes: 1 addition & 1 deletion examples/control_application/control_daemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void signalHandler(int) {
exitRequested = true;
}

int main(int argc, char** argv) {
int main() {
signal(SIGINT, signalHandler);
signal(SIGTERM, signalHandler);

Expand Down
5 changes: 4 additions & 1 deletion examples/cpp_lifecycle_app/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
cc_binary(

load("//config:common_cc.bzl", "cc_binary_with_common_options")

cc_binary_with_common_options(
name = "cpp_lifecycle_app",
srcs = [
"main.cpp",
Expand Down
4 changes: 2 additions & 2 deletions examples/cpp_supervised_app/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
load("@rules_cc//cc:defs.bzl", "cc_binary")
load("//config:common_cc.bzl", "cc_binary_with_common_options")

cc_binary(
cc_binary_with_common_options(
name = "cpp_supervised_app",
srcs = [
"main.cpp",
Expand Down
2 changes: 1 addition & 1 deletion score/health_monitor/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

load("@rules_cc//cc:defs.bzl", "cc_library")
load("//config:common_cc.bzl", "cc_library_with_common_options")

alias(
name = "health_monitoring_cc",
Expand Down
12 changes: 6 additions & 6 deletions score/health_monitor/src/cpp/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

load("@rules_cc//cc:defs.bzl", "cc_library")
load("@score_baselibs//:bazel/unit_tests.bzl", "cc_gtest_unit_test")
load("//config:common_cc.bzl", "cc_library_with_common_options")

cc_library(
cc_library_with_common_options(
name = "tag",
hdrs = ["tag.h"],
include_prefix = "score/mw/health",
strip_include_prefix = "/score/health_monitor/src/cpp",
visibility = ["//visibility:public"],
)

cc_library(
cc_library_with_common_options(
name = "common",
srcs = ["common.cpp"],
hdrs = ["common.h"],
Expand All @@ -32,7 +32,7 @@ cc_library(
deps = ["@score_baselibs//score/language/futurecpp"],
)

cc_library(
cc_library_with_common_options(
name = "health_monitor",
srcs = ["health_monitor.cpp"],
hdrs = ["health_monitor.h"],
Expand All @@ -49,7 +49,7 @@ cc_library(
],
)

cc_library(
cc_library_with_common_options(
name = "health_monitoring_cc",
visibility = ["//score/health_monitor:__pkg__"],
deps = [
Expand All @@ -58,7 +58,7 @@ cc_library(
],
)

cc_library(
cc_library_with_common_options(
name = "health_monitoring_cc_stub_supervisor",
visibility = ["//score/health_monitor/src/cpp:__pkg__"],
deps = [
Expand Down
4 changes: 2 additions & 2 deletions score/health_monitor/src/cpp/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ class TimeRange
SCORE_LANGUAGE_FUTURECPP_PRECONDITION(min_ms_ <= max_ms_);
}

const uint32_t min_ms() const
uint32_t min_ms() const
{
return min_ms_.count();
}

const uint32_t max_ms() const
uint32_t max_ms() const
{
return max_ms_.count();
}
Expand Down
4 changes: 2 additions & 2 deletions score/health_monitor/src/cpp/deadline/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

load("@rules_cc//cc:defs.bzl", "cc_library")
load("//config:common_cc.bzl", "cc_library_with_common_options")

cc_library(
cc_library_with_common_options(
name = "deadline_monitor",
srcs = ["deadline_monitor.cpp"],
hdrs = ["deadline_monitor.h"],
Expand Down
6 changes: 3 additions & 3 deletions score/health_monitor/src/cpp/details/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

load("@rules_cc//cc:defs.bzl", "cc_library")
load("//config:common_cc.bzl", "cc_library_with_common_options")

cc_library(
cc_library_with_common_options(
name = "log_init",
srcs = ["log_init.cpp"],
visibility = ["//score/health_monitor/src/cpp:__pkg__"],
Expand All @@ -23,7 +23,7 @@ cc_library(
],
)

cc_library(
cc_library_with_common_options(
name = "thread",
srcs = ["thread.cpp"],
hdrs = ["thread.h"],
Expand Down
4 changes: 2 additions & 2 deletions score/health_monitor/src/cpp/heartbeat/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

load("@rules_cc//cc:defs.bzl", "cc_library")
load("//config:common_cc.bzl", "cc_library_with_common_options")

cc_library(
cc_library_with_common_options(
name = "heartbeat_monitor",
srcs = ["heartbeat_monitor.cpp"],
hdrs = ["heartbeat_monitor.h"],
Expand Down
4 changes: 2 additions & 2 deletions score/health_monitor/src/cpp/logic/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

load("@rules_cc//cc:defs.bzl", "cc_library")
load("//config:common_cc.bzl", "cc_library_with_common_options")

cc_library(
cc_library_with_common_options(
name = "logic_monitor",
srcs = ["logic_monitor.cpp"],
hdrs = ["logic_monitor.h"],
Expand Down
6 changes: 3 additions & 3 deletions score/launch_manager/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
load("@rules_cc//cc:defs.bzl", "cc_library")
load("//config:common_cc.bzl", "cc_library_with_common_options")

package(default_visibility = ["//visibility:public"])

Expand Down Expand Up @@ -44,7 +44,7 @@ alias(
actual = "//score/launch_manager/src/daemon:launch_manager",
)

cc_library(
cc_library_with_common_options(
name = "error",
hdrs = ["src/execution_error.h"],
include_prefix = "score/mw/lifecycle",
Expand All @@ -55,7 +55,7 @@ cc_library(
],
)

cc_library(
cc_library_with_common_options(
name = "error_event",
hdrs = [
"src/execution_error.h",
Expand Down
4 changes: 2 additions & 2 deletions score/launch_manager/src/alive/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
load("@rules_cc//cc:defs.bzl", "cc_library")
load("//config:common_cc.bzl", "cc_library_with_common_options")

cc_library(
cc_library_with_common_options(
name = "alive",
srcs = [
"src/alive.cpp",
Expand Down
4 changes: 2 additions & 2 deletions score/launch_manager/src/alive/src/details/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
load("@rules_cc//cc:defs.bzl", "cc_library")
load("//config:common_cc.bzl", "cc_library_with_common_options")

cc_test(
name = "AliveImpl_UT",
Expand All @@ -21,7 +21,7 @@ cc_test(
],
)

cc_library(
cc_library_with_common_options(
name = "alive_impl",
srcs = ["AliveImpl.cpp"],
hdrs = ["AliveImpl.h"],
Expand Down
4 changes: 2 additions & 2 deletions score/launch_manager/src/control_client/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
load("@rules_cc//cc:defs.bzl", "cc_library")
load("//config:common_cc.bzl", "cc_library_with_common_options")

cc_library(
cc_library_with_common_options(
name = "control_client",
srcs = [
"src/control_client.cpp",
Expand Down
Loading
Loading