1+ $Global :BUILD_TYPE = ' Release'
2+ $Global :BUILD_TESTS = 0
3+ $Global :BUILD_COVERAGE = 0
4+ $Global :BUILD_INSTALL = 0
5+
6+ $Global :PROGNAME = $ (Get-Item $PSCommandPath ).Basename
7+ $Global :Arguments = $args
8+
9+ function sub-options {
10+ for ($i = 0 ; $i -lt $Arguments.Length ; $i ++ ) {
11+ $option = $Arguments [$i ]
12+ if ( " $option " -eq " debug" ) {
13+ echo " Build all scripts in debug mode"
14+ $Global :BUILD_TYPE = ' Debug'
15+ }
16+ if ( " $option " -eq " release" ) {
17+ echo " Build all scripts in release mode"
18+ $Global :BUILD_TYPE = ' Release'
19+ }
20+ if ( " $option " -eq " relwithdebinfo" ) {
21+ echo " Build all scripts in release mode with debug symbols"
22+ $Global :BUILD_TYPE = ' RelWithDebInfo'
23+ }
24+ if ( " $option " -eq " tests" ) {
25+ echo " Build and run all tests"
26+ $Global :BUILD_TESTS = 1
27+ }
28+ if ( " $option " -eq " coverage" ) {
29+ echo " Build coverage reports"
30+ $Global :BUILD_COVERAGE = 1
31+ }
32+ if ( " $option " -eq " install" ) {
33+ echo " Install all libraries"
34+ $Global :BUILD_INSTALL = 1
35+ }
36+ }
37+ }
38+
39+ function sub-build {
40+
41+ # Build the project
42+ echo " Building MetaCall..."
43+ cmake -- build . " -j$ ( (Get-CimInstance Win32_ComputerSystem).NumberOfLogicalProcessors) "
44+
45+ # Tests (coverage needs to run the tests)
46+ if ( ($BUILD_TESTS -eq 1 ) -or ($BUILD_COVERAGE -eq 1 ) ) {
47+ echo " Running the tests..."
48+ ctest " -j$ ( (Get-CimInstance Win32_ComputerSystem).NumberOfLogicalProcessors) " -- output- on- failure -- test-output - size- failed 3221000000 - C $BUILD_TYPE
49+ }
50+
51+ # Coverage
52+ <# if ( $BUILD_COVERAGE = 1 ) {
53+ # TODO (copied): Remove -k, solve coverage issues
54+ # TODO: Migrate to Windows
55+ echo "Reporting coverage..."
56+ make -k gcov
57+ make -k lcov
58+ make -k lcov-genhtml
59+ } #>
60+
61+ # Install
62+ if ( $BUILD_INSTALL -eq 1 ) {
63+ echo " Building and installing MetaCall..."
64+ cmake -- build . -- target install
65+ }
66+ }
67+
68+ function sub-help {
69+ echo " Usage: $PROGNAME list of options"
70+ echo " Options:"
71+ echo " debug | release | relwithdebinfo: build type"
72+ echo " tests: build and run all tests"
73+ echo " coverage: build coverage reports"
74+ echo " install: install all libraries"
75+ echo " "
76+ }
77+
78+ switch ($args.length ) {
79+ 0 {
80+ sub- help
81+ Break
82+ }
83+ Default {
84+ sub- options
85+ sub- build
86+ }
87+ }
0 commit comments