Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Michaël Roynard
gtest-constexpr-ext
Commits
c9a7008e
Commit
c9a7008e
authored
Jun 08, 2018
by
Michaël Roynard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix packaging
parent
a804c552
Pipeline
#2363
passed with stages
in 1 minute and 49 seconds
Changes
5
Pipelines
13
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
99 additions
and
223 deletions
+99
-223
.gitlab-ci.yml
.gitlab-ci.yml
+49
-14
build-in-docker.ps1
build-in-docker.ps1
+0
-63
build-in-docker.sh
build-in-docker.sh
+0
-137
conanfile.py
conanfile.py
+12
-7
test_package/test_package.cpp
test_package/test_package.cpp
+38
-2
No files found.
.gitlab-ci.yml
View file @
c9a7008e
...
...
@@ -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++"
...
...
build-in-docker.ps1
deleted
100644 → 0
View file @
a804c552
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
"
}
build-in-docker.sh
deleted
100755 → 0
View file @
a804c552
#!/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
conanfile.py
View file @
c9a7008e
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
()))
test_package/test_package.cpp
View file @
c9a7008e
#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
();
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment