mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
Merge pull request #677 from VILLASframework/packaging-nix
Disable warning as error for normal release builds
This commit is contained in:
commit
0445d671dc
9 changed files with 71 additions and 32 deletions
|
@ -7,7 +7,8 @@ variables:
|
|||
DOCKER_IMAGE: registry.git.rwth-aachen.de/acs/public/villas/node
|
||||
DOCKER_IMAGE_DEV: ${DOCKER_IMAGE}/dev-${DISTRO}
|
||||
DOCKER_CLI_EXPERIMENTAL: enabled
|
||||
CMAKE_BUILD_OPTS: "--config Release --parallel 16"
|
||||
CMAKE_BUILD_OPTS: "--parallel 16"
|
||||
CMAKE_EXTRA_OPTS: "-DCMAKE_BUILD_TYPE=Release -DVILLAS_COMPILE_WARNING_AS_ERROR=ON"
|
||||
|
||||
stages:
|
||||
- prepare
|
||||
|
@ -64,7 +65,8 @@ build:source:
|
|||
matrix:
|
||||
- DISTRO: [ fedora, fedora-minimal, debian, rocky, ubuntu ]
|
||||
- DISTRO: fedora-minimal
|
||||
CMAKE_EXTRA_OPTS: -DWITH_API=OFF
|
||||
CMAKE_EXTRA_OPTS: -DVILLAS_COMPILE_WARNING_AS_ERROR=ON
|
||||
-DWITH_API=OFF
|
||||
-DWITH_CLIENTS=OFF
|
||||
-DWITH_CONFIG=OFF
|
||||
-DWITH_DOC=OFF
|
||||
|
@ -183,7 +185,7 @@ pkg:docker:
|
|||
--target ${TARGET}
|
||||
--build-arg ARCH=${ARCH}
|
||||
--build-arg TRIPLET=${TRIPLET}
|
||||
--build-arg CMAKE_OPTS="${CMAKE_OPTS}"
|
||||
--build-arg CMAKE_OPTS="${CMAKE_OPTS} ${CMAKE_EXTRA_OPTS}"
|
||||
--platform ${PLATFORM}
|
||||
--file ${DOCKER_FILE}
|
||||
--tag ${DOCKER_IMAGE}:${DOCKER_TAG}-${ARCH} .
|
||||
|
|
|
@ -54,7 +54,7 @@ include(FindSymbol)
|
|||
include(CMakeDependentOption)
|
||||
|
||||
add_definitions(-D_POSIX_C_SOURCE=200809L -D_GNU_SOURCE)
|
||||
add_compile_options(-Wall -Wno-unknown-pragmas -Werror -fdiagnostics-color=auto)
|
||||
add_compile_options(-Wall -Wno-unknown-pragmas -fdiagnostics-color=auto)
|
||||
|
||||
# Check OS
|
||||
check_include_file("sys/eventfd.h" HAS_EVENTFD)
|
||||
|
@ -213,12 +213,27 @@ cmake_dependent_option(WITH_NODE_WEBRTC "Build with webrtc node-type"
|
|||
cmake_dependent_option(WITH_NODE_WEBSOCKET "Build with websocket node-type" ON "WITH_WEB; LIBWEBSOCKETS_FOUND" OFF)
|
||||
cmake_dependent_option(WITH_NODE_ZEROMQ "Build with zeromq node-type" ON "LIBZMQ_FOUND;NOT WITHOUT_GPL" OFF)
|
||||
|
||||
# set a default for the build type
|
||||
if("${CMAKE_BUILD_TYPE}" STREQUAL "")
|
||||
set(CMAKE_BUILD_TYPE "Debug")
|
||||
endif()
|
||||
|
||||
# Add more build configurations
|
||||
include(cmake/config/Debug.cmake)
|
||||
include(cmake/config/Release.cmake)
|
||||
include(cmake/config/Coverage.cmake)
|
||||
include(cmake/config/Profiling.cmake)
|
||||
|
||||
if(NOT DEFINED VILLAS_COMPILE_WARNING_AS_ERROR)
|
||||
set(VILLAS_COMPILE_WARNING_AS_ERROR ON)
|
||||
endif()
|
||||
|
||||
if(VILLAS_COMPILE_WARNING_AS_ERROR)
|
||||
add_compile_options(-Werror)
|
||||
else()
|
||||
add_compile_options(-Wno-error)
|
||||
endif()
|
||||
|
||||
# Get version info and buildid from Git
|
||||
GetVersion(${PROJECT_SOURCE_DIR} "CMAKE_PROJECT")
|
||||
|
||||
|
|
|
@ -4,3 +4,8 @@
|
|||
# @copyright 2014-2022, Institute for Automation of Complex Power Systems, EONERC
|
||||
# @license Apache 2.0
|
||||
###################################################################################
|
||||
|
||||
# don't treat warnings as errors on normal release builds
|
||||
if("${CMAKE_BUILD_TYPE}" STREQUAL "Release" AND NOT DEFINED VILLAS_COMPILE_WARNING_AS_ERROR)
|
||||
set(VILLAS_COMPILE_WARNING_AS_ERROR OFF)
|
||||
endif()
|
||||
|
|
|
@ -256,8 +256,11 @@ std::optional<ASDUData::Sample> ASDUData::checkASDU(CS101_ASDU const &asdu) cons
|
|||
|
||||
bool ASDUData::addSampleToASDU(CS101_ASDU &asdu, ASDUData::Sample sample) const
|
||||
{
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
|
||||
|
||||
std::optional<CP56Time2a> timestamp = sample.timestamp.has_value()
|
||||
? std::optional { timespec_to_cp56time2a(sample.timestamp.value()) }
|
||||
? std::optional { timespec_to_cp56time2a(*sample.timestamp) }
|
||||
: std::nullopt;
|
||||
|
||||
InformationObject io = nullptr;
|
||||
|
@ -341,6 +344,7 @@ bool ASDUData::addSampleToASDU(CS101_ASDU &asdu, ASDUData::Sample sample) const
|
|||
InformationObject_destroy(io);
|
||||
|
||||
return successfully_added;
|
||||
#pragma GCC diagnostic pop
|
||||
}
|
||||
|
||||
ASDUData::ASDUData(ASDUData::Descriptor const *descriptor, int ioa, int ioa_sequence_start) : ioa(ioa), ioa_sequence_start(ioa_sequence_start), descriptor(descriptor)
|
||||
|
|
|
@ -17,17 +17,19 @@ using namespace villas;
|
|||
int villas::node::pool_init(struct Pool *p, size_t cnt, size_t blocksz, struct memory::Type *m)
|
||||
{
|
||||
int ret;
|
||||
auto logger = logging.get("pool");
|
||||
|
||||
/* Make sure that we use a block size that is aligned to the size of a cache line */
|
||||
p->alignment = kernel::getCachelineSize();
|
||||
p->blocksz = p->alignment * CEIL(blocksz, p->alignment);
|
||||
p->len = cnt * p->blocksz;
|
||||
|
||||
logger->debug("New memory pool: alignment={}, blocksz={}, len={}, memory={}", p->alignment, p->blocksz, p->len, m->name);
|
||||
|
||||
void *buffer = memory::alloc_aligned(p->len, p->alignment, m);
|
||||
if (!buffer)
|
||||
throw MemoryAllocationError();
|
||||
|
||||
auto logger = logging.get("pool");
|
||||
logger->debug("Allocated {:#x} bytes for memory pool", p->len);
|
||||
|
||||
p->buffer_off = (char*) buffer - (char*) p;
|
||||
|
|
|
@ -69,6 +69,7 @@ ADD cmake/toolchains/debian-${ARCH}.cmake /
|
|||
ENV PKG_CONFIG_PATH=/usr/lib/${TRIPLET}/pkgconfig:/usr/local/lib/${TRIPLET}/pkgconfig
|
||||
|
||||
ENV CMAKE_EXTRA_OPTS="-DCMAKE_TOOLCHAIN_FILE=/debian-${ARCH}.cmake \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_PREFIX_PATH=${PREFIX} \
|
||||
-DCMAKE_INSTALL_PREFIX=${PREFIX} \
|
||||
-DCMAKE_INSTALL_LIBDIR=${PREFIX}/lib/${TRIPLET} \
|
||||
|
|
8
packaging/nix/flake.lock
generated
8
packaging/nix/flake.lock
generated
|
@ -90,16 +90,16 @@
|
|||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1686656800,
|
||||
"narHash": "sha256-duScdQZNeZcde0JwmQ9W4XfqlO/Z24MDhlTq2MokuSM=",
|
||||
"lastModified": 1687354544,
|
||||
"narHash": "sha256-1Xu+QzyA10AiY21i27Zu9bqQAaxXBacNKbGUA9OZy7Y=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "2b273c2351fe1ab490158cf8acc8aafad02592ce",
|
||||
"rev": "876181e3ae452cc6186486f6f7300a8a6de237cb",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "release-22.11",
|
||||
"ref": "release-23.05",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
description = "a tool for connecting real-time power grid simulation equipment";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/release-22.11";
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/release-23.05";
|
||||
|
||||
common = {
|
||||
url = "github:VILLASframework/common";
|
||||
|
@ -55,18 +55,23 @@
|
|||
# generate attributes corresponding to all supported combinations of system and crossSystem
|
||||
forSupportedCrossSystems = f: forSupportedSystems (system: lib.genAttrs supportedCrossSystems (f system));
|
||||
|
||||
# this overlay can be applied to nixpkgs (see `pkgsFor` below for an example)
|
||||
overlay = final: prev: packagesWith final;
|
||||
|
||||
# initialize nixpkgs for the specified `system`
|
||||
pkgsFor = system:
|
||||
import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [overlay];
|
||||
overlays = [self.overlays.default];
|
||||
};
|
||||
|
||||
# initialize nixpkgs for cross-compiling from `system` to `crossSystem`
|
||||
crossPkgsFor = system: crossSystem: (pkgsFor system).pkgsCross.${crossSystem};
|
||||
crossPkgsFor = system: crossSystem:
|
||||
(import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [
|
||||
self.overlays.default
|
||||
self.overlays.minimal
|
||||
];
|
||||
})
|
||||
.pkgsCross.${crossSystem};
|
||||
|
||||
# build villas and its dependencies for the specified `pkgs`
|
||||
packagesWith = pkgs: rec {
|
||||
|
@ -113,7 +118,11 @@
|
|||
|
||||
# standard flake attribute allowing you to add the villas packages to your nixpkgs
|
||||
overlays = {
|
||||
default = overlay;
|
||||
default = final: prev: packagesWith final;
|
||||
minimal = final: prev: {
|
||||
mosquitto = prev.mosquitto.override {systemd = final.systemdMinimal;};
|
||||
rdma-core = prev.rdma-core.override {udev = final.systemdMinimal;};
|
||||
};
|
||||
};
|
||||
|
||||
# standard flake attribute for defining developer environments
|
||||
|
@ -122,19 +131,20 @@
|
|||
pkgs = pkgsFor system;
|
||||
shellHook = ''[ -z "$PS1" ] || exec "$SHELL"'';
|
||||
hardeningDisable = ["all"];
|
||||
packages = with pkgs; [bashInteractive criterion];
|
||||
in rec {
|
||||
default = full;
|
||||
|
||||
minimal = pkgs.mkShell {
|
||||
inherit shellHook hardeningDisable;
|
||||
inherit shellHook hardeningDisable packages;
|
||||
name = "minimal";
|
||||
inputsFrom = [pkgs.villas-minimal];
|
||||
inputsFrom = with pkgs; [villas-minimal];
|
||||
};
|
||||
|
||||
full = pkgs.mkShell {
|
||||
inherit shellHook hardeningDisable;
|
||||
inherit shellHook hardeningDisable packages;
|
||||
name = "full";
|
||||
inputsFrom = [pkgs.villas];
|
||||
inputsFrom = with pkgs; [villas];
|
||||
};
|
||||
}
|
||||
);
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <criterion/parameterized.h>
|
||||
|
||||
#include <signal.h>
|
||||
#include <vector>
|
||||
|
||||
#include <villas/pool.hpp>
|
||||
#include <villas/utils.hpp>
|
||||
|
@ -29,14 +30,15 @@ struct param {
|
|||
|
||||
ParameterizedTestParameters(pool, basic)
|
||||
{
|
||||
static struct param params[] = {
|
||||
{ 1, 4096, 150, &memory::heap },
|
||||
{ 1, 128, 8, &memory::mmap },
|
||||
{ 1, 4, 8192, &memory::mmap_hugetlb },
|
||||
{ 1, 1 << 13, 4, &memory::mmap_hugetlb }
|
||||
};
|
||||
static std::vector<struct param> params;
|
||||
|
||||
return cr_make_param_array(struct param, params, ARRAY_LEN(params));
|
||||
params.clear();
|
||||
params.push_back({ 1, 4096, 150, &memory::heap });
|
||||
params.push_back({ 1, 128, 8, &memory::mmap });
|
||||
params.push_back({ 1, 4, 8192, &memory::mmap_hugetlb });
|
||||
params.push_back({ 1, 1 << 13, 4, &memory::mmap_hugetlb });
|
||||
|
||||
return cr_make_param_array(struct param, params.data(), params.size());
|
||||
}
|
||||
|
||||
// cppcheck-suppress unknownMacro
|
||||
|
@ -44,12 +46,10 @@ ParameterizedTest(struct param *p, pool, basic, .init = init_memory)
|
|||
{
|
||||
int ret;
|
||||
struct Pool pool;
|
||||
|
||||
// some strange LTO stuff is going on here..
|
||||
auto *m __attribute__((unused)) = &memory::mmap;
|
||||
|
||||
void *ptr, *ptrs[p->pool_size];
|
||||
|
||||
logging.setLevel("trace");
|
||||
|
||||
if (!utils::isPrivileged() && p->mt == &memory::mmap_hugetlb)
|
||||
cr_skip_test("Skipping memory_mmap_hugetlb tests allocatpr because we are running in an unprivileged environment.");
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue