Commit c9a7008e authored by Michaël Roynard's avatar Michaël Roynard

Fix packaging

parent a804c552
Pipeline #2363 passed with stages
in 1 minute and 49 seconds
......@@ -14,14 +14,13 @@ variables:
BUILD_DIRECTORY: "build-in-docker" # build directory name
SOURCE_DIRECTORY: ".." # where cmake search source files from the build directory
TARGET: "check" # target to invoke
CLEAN: "OFF" # whether to rm -rf * in build directory before running cmake
TESTS: "ON" # build and run unit tests
stages:
- build
- doc
- package
.job-basic-build-linux: &distcheck-basic-linux
.job-basic-build-linux: &distcheck-basic-build-linux
stage: build
image: mroynard/ubuntu-toolset:stable
script:
......@@ -32,7 +31,6 @@ stages:
- $CXX --version
- mkdir -p $BUILD_DIRECTORY
- cd $BUILD_DIRECTORY
- if [ "$CLEAN" == "ON" ]; then rm -rf ./*; fi
- conan remote add $CONAN_REMOTE_NAME $CONAN_REMOTE_URL
- conan user -p $CONAN_API_KEY -r $CONAN_REMOTE_NAME $CONAN_USER
- conan remote list
......@@ -49,36 +47,73 @@ stages:
--output-on-failure
--schedule-random
--verbose
- cd ..
distcheck-build-linux-gcc-release:
<<: *distcheck-basic-build-linux
variables:
CONAN_PROFILE: "gcc-release"
distcheck-build-linux-clang-release:
<<: *distcheck-basic-build-linux
variables:
CC: "clang"
CXX: "clang++"
CONAN_PROFILE: "clang-release"
distcheck-build-linux-gcc-debug:
<<: *distcheck-basic-build-linux
variables:
CONAN_PROFILE: "gcc-debug"
RELEASE_TYPE: "Debug"
distcheck-build-linux-clang-debug:
<<: *distcheck-basic-build-linux
variables:
CC: "clang"
CXX: "clang++"
CONAN_PROFILE: "clang-debug"
RELEASE_TYPE: "Debug"
.job-basic-package-linux: &distcheck-basic-package-linux
stage: package
image: mroynard/ubuntu-toolset:stable
script:
- set -e
- export CC=$CC
- export CXX=$CXX
- $CC --version
- $CXX --version
- conan remote add $CONAN_REMOTE_NAME $CONAN_REMOTE_URL
- conan user -p $CONAN_API_KEY -r $CONAN_REMOTE_NAME $CONAN_USER
- conan remote list
- conan create
--build missing
-pr $CONAN_PROFILE
. $NAME/$VERSION@$CONAN_USER/$TAG-$CONAN_PROFILE
- conan upload
--all
-r $CONAN_REMOTE_NAME
$NAME/$VERSION@$CONAN_USER/$TAG-$CONAN_PROFILE
distcheck-linux-gcc-release:
<<: *distcheck-basic-linux
distcheck-package-linux-gcc-release:
<<: *distcheck-basic-package-linux
variables:
CONAN_PROFILE: "gcc-release"
distcheck-linux-clang-release:
<<: *distcheck-basic-linux
distcheck-package-linux-clang-release:
<<: *distcheck-basic-package-linux
variables:
CC: "clang"
CXX: "clang++"
CONAN_PROFILE: "clang-release"
distcheck-linux-gcc-debug:
<<: *distcheck-basic-linux
distcheck-package-linux-gcc-debug:
<<: *distcheck-basic-package-linux
variables:
CONAN_PROFILE: "gcc-debug"
RELEASE_TYPE: "Debug"
distcheck-linux-clang-debug:
<<: *distcheck-basic-linux
distcheck-package-linux-clang-debug:
<<: *distcheck-basic-package-linux
variables:
CC: "clang"
CXX: "clang++"
......
Param(
[String]$Compiler = "gcc",
[String]$CmakeGenerator = "Ninja",
[String]$BuildDirectory = "build-in-docker",
[String]$SourceDirectory = "..",
[String]$Target = "",
[String]$ConfigType = "Debug",
[String]$Clean = "OFF",
[String]$TestsVerbose = "OFF"
)
$DockerImageToolset = "mroynard/ubuntu-toolset:local"
Write-Host "Compiler: $Compiler"
Write-Host "CmakeGenerator: $CmakeGenerator"
Write-Host "BuildDirectory: $BuildDirectory"
Write-Host "SourceDirectory: $SourceDirectory"
Write-Host "Target: $Target"
Write-Host "ConfigType: $ConfigType"
Write-Host "Clean: $Clean"
# compiler switch
If($Compiler -eq "gcc") {
$CC = "gcc"
$CXX = "g++"
}
Else {
$CC = "clang"
$CXX = "clang++"
}
# starting container
$PwdPath = (Get-Location).Path
Write-Host "*** BUILDING BINARIES ***"
$ContainerID = docker run -itd --rm --mount type=bind,source="$PwdPath",target=/workspace $DockerImageToolset
Write-Host "Running in container $ContainerID"
Trap {
docker exec $ContainerID true
Write-Host "Aborting..."
docker stop $ContainerID
}
# making build directory
$Workdir = docker exec $ContainerID sh -c "mkdir -p $BuildDirectory && cd $BuildDirectory && pwd"
Write-Host "Building in $BuildDirectory (host) -> $Workdir (docker)"
# cleaning if needed
If ($Clean -eq "ON") {
docker exec --workdir $Workdir $ContainerID sh -c "rm -rf ./*"
}
# configure & make
docker exec -w $Workdir $ContainerID sh -c "export CC=$CC && export CXX=$CXX && $CXX --version && cmake -G $CmakeGenerator $SourceDirectory"
docker exec -w $Workdir $ContainerID sh -c "cmake --build . --target $Target --config $ConfigType"
# Launch tests
If ($TestsVerbose -eq "ON") {
docker exec -w $Workdir $ContainerID sh -c "ctest --output-on-failure --schedule-random -C $ConfigType --verbose"
}
Else {
docker exec -w $Workdir $ContainerID sh -c "ctest --output-on-failure --schedule-random -C $ConfigType"
}
#!/bin/bash
set -e
COMPILER="gcc"
CMAKE_GENERATOR="Ninja"
BUILD_DIRECTORY="build-in-docker"
SOURCE_DIRECTORY=".."
TARGET=""
CONFIG_TYPE="Debug"
CLEAN="OFF"
CLEAN_ONLY="OFF"
DOCKER_IMAGE_TOOLSET="mroynard/ubuntu-toolset:local"
VERBOSE_TESTS="OFF"
USAGE="$(basename "$0") [OPTIONS] -- execute a build toolchain
where:
-h --help show this help text
-c --compiler gcc|clang select the compiler to use
default = gcc
-g --cmake-generator Generator use provided cmake generator
default = Unix Makefiles
-b --build-directory Directory use provided build directory for build artifacts (on host)
default = build-in-docker
-s --source-directory Directory use provided source directory to compile
default = ..
-t --target Target build target passed to the generated toolchain (make target)
default = all
-r --config-type ConfigType build type. Release|Debug|RelWithDebInfo|MinSizeRel
default = Debug
-f --clean empty build directory to force a full rebuild
--clean-only only empty build directory and stop
-v --verbose-tests verbose output for unit tests
"
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-h | --help)
echo "$USAGE"
exit
;;
-f | --clean)
CLEAN="ON"
shift
;;
--clean-only)
CLEAN="ON"
CLEAN_ONLY="ON"
shift
;;
-v | --verbose-tests)
VERBOSE_TESTS="ON"
shift
;;
-c | --compiler)
COMPILER="$2"
shift 2
;;
-g | --cmake-generator)
CMAKE_GENERATOR="$2"
shift 2
;;
-b | --build-directory)
BUILD_DIRECTORY="$2"
shift 2
;;
-s | --source-directory)
SOURCE_DIRECTORY="$2"
shift 2
;;
-t | --target)
TARGET="$2"
shift 2
;;
-r | --config-type)
CONFIG_TYPE="$2"
shift 2
;;
--)
shift
;;
*)
shift
;;
esac
done
# compiler switch
if [ "$COMPILER" == "gcc" ]; then
CC="gcc"
CXX="g++"
else
CC="clang"
CXX="clang++"
fi
echo "*** BUILDING BINARIES ***"
# starting container
CONTAINER_ID=$(docker run -itd --rm --mount type=bind,source="$(pwd)",target=/workspace $DOCKER_IMAGE_TOOLSET)
trap "docker exec $CONTAINER_ID true 2> /dev/null && echo 'Aborting...' && docker stop $CONTAINER_ID > /dev/null" EXIT
echo "Running in container $CONTAINER_ID"
# making build directory
WORKDIR=$(docker exec $CONTAINER_ID sh -c "mkdir -p $BUILD_DIRECTORY && cd $BUILD_DIRECTORY && pwd")
echo "Building in $BUILD_DIRECTORY (host) -> $WORKDIR (docker)"
# cleaning if needed
if [ "$CLEAN" == "ON" ]; then
echo "Cleaning directory $WORKDIR ..."
docker exec --workdir $WORKDIR $CONTAINER_ID sh -c "rm -rf ./*"
if [ "$CLEAN_ONLY" == "ON" ]; then
exit 0
fi
fi
# configure & build
docker exec -w $WORKDIR $CONTAINER_ID sh -c "export CC=$CC && export CXX=$CXX && $CXX --version && cmake -G $CMAKE_GENERATOR $SOURCE_DIRECTORY"
docker exec -w $WORKDIR $CONTAINER_ID sh -c "cmake --build . --target $TARGET --config $CONFIG_TYPE"
# launch unit tests
if [ "VERBOSE_TESTS" == "ON" ]; then
docker exec -w $WORKDIR $CONTAINER_ID sh -c "ctest --output-on-failure --schedule-random -C $CONFIG_TYPE --verbose"
else
docker exec -w $WORKDIR $CONTAINER_ID sh -c "ctest --output-on-failure --schedule-random -C $CONFIG_TYPE"
fi
# stopping container
echo "Stopping container $CONTAINER_ID"
docker stop $CONTAINER_ID > /dev/null
from conans import CMake, ConanFile, tools
class GtestconstexprextConan(ConanFile):
name = "gtest-constexpr-ext"
version = "0.1"
license = "MIT"
license = "https://gitlab.lrde.epita.fr/mroynard/gtest-constexpr-ext/blob/master/LICENSE"
url = "https://gitlab.lrde.epita.fr/mroynard/gtest-constexpr-ext"
description = "Add macro to detect whether an expression is compile-time."
settings = "os", "compiler", "arch", "build_type", "cppstd"
requires = "gtest/1.8.0@bincrafters/stable"
generators = "cmake"
no_copy_source = True
def source(self):
git = tools.Git()
git.clone("https://gitlab.lrde.epita.fr/mroynard/gtest-constexpr-ext.git")
git.clone("{}.git".format(self.url))
def build(self):
cmake = CMake(self, generator="Ninja")
......@@ -24,7 +21,15 @@ class GtestconstexprextConan(ConanFile):
cmake.test()
def package(self):
self.copy("*.hpp", dst="include/gtest-constexpr-ext", src="include/gtest-constexpr-ext")
self.copy("*.hpp", dst="include/gtest-constexpr-ext",
src="include/gtest-constexpr-ext")
def package_id(self):
self.info.header_only()
def package_info(self):
self.cpp_info.includedirs = ["include"]
def requirements(self):
self.requires("gtest/1.8.0@dutiona/stable-{}-{}".format(
self.settings.compiler, str(self.settings.build_type).lower()))
#include <gtest-constexpr-ext/gtest-constexpr-ext.hpp>
#include <gtest/gtest.h>
int main() {
return 0;
constexpr int f(int a)
{
if (a == 0) {
throw "Runtime!";
}
else {
return a; // Compiletime!
}
}
template <auto V>
constexpr int ft(int a)
{
if (V) {
return a; // Compiletime!
}
else {
throw "Runtime!";
}
}
TEST(Gtest_Constexpr_Ext, Compiletime)
{
ASSERT_COMPILETIME_EXPR(f, 1);
ASSERT_COMPILETIME_EXPR(ft<true>, 1);
}
TEST(Gtest_Constexpr_Ext, Runtime)
{
ASSERT_RUNTIME_EXPR(f, 0);
ASSERT_RUNTIME_EXPR(ft<false>, 1);
}
int main(int argc, char** argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment