forked from cmu-db/noisepage
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile-utils
More file actions
140 lines (125 loc) · 4.41 KB
/
Jenkinsfile-utils
File metadata and controls
140 lines (125 loc) · 4.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/usr/bin/env groovy
ENABLED = 'ON'
DISABLED = 'OFF'
UBUNTU = 'ubuntu'
DEBUG_BUILD = 'Debug'
RELEASE_BUILD = 'Release'
/**
* noisePageBuild will create a build directory and compile and build the
* noisepage binary in that directory. The options passed into the method
* determine the compilation and build options. Refer to the defaultArgs
* for the different options that can be passed in.
*/
void noisePageBuild(Map args = [:]) {
Map defaultArgs = [
useCache: true,
buildType: DEBUG_BUILD,
os: UBUNTU,
isBuildTests: true,
useASAN: false,
isBuildBenchmarks: false,
isCodeCoverage: false,
isJumboTest: false,
isRecordTime: false,
isBuildSelfDrivingTests: false,
]
Map config = defaultArgs << args
String compileCmd = generateCompileCmd(config)
String buildCmd = generateBuildCmd(config)
String buildScript = generateBuildScript(compileCmd, buildCmd, config.isRecordTime)
sh script:'echo y | sudo ./script/installation/packages.sh all', label: 'Installing packages'
sh script:buildScript, label: 'Build'
}
/**
* generateCompileCmd creates the cmake command string. It is based on the
* config passed into the function. The config arguments are the same as the
* defaultArgs in noisePageBuild.
*/
String generateCompileCmd(Map config = [:]) {
Map cmakeArgs = [
'-DCMAKE_BUILD_TYPE': config.buildType,
'-DNOISEPAGE_UNITY_BUILD': ENABLED,
'-DNOISEPAGE_TEST_PARALLELISM': 1,
'-DNOISEPAGE_USE_ASAN': DISABLED,
'-DNOISEPAGE_USE_JEMALLOC': DISABLED,
'-DNOISEPAGE_BUILD_TESTS': ENABLED,
'-DNOISEPAGE_GENERATE_COVERAGE': DISABLED,
'-DNOISEPAGE_BUILD_BENCHMARKS': DISABLED,
'-DNOISEPAGE_USE_JUMBOTESTS': DISABLED,
'-DNOISEPAGE_BUILD_SELF_DRIVING_TESTS': DISABLED,
]
if (config.useCache) {
// currently ccache is only configured for ubuntu images
// For more info: https://github.com/cmu-db/noisepage/pull/830
cmakeArgs['-DCMAKE_CXX_COMPILER_LAUNCHER'] = 'ccache'
}
if (config.useASAN) {
cmakeArgs['-DNOISEPAGE_USE_ASAN'] = ENABLED
}
if (config.buildType == RELEASE_BUILD && !config.isBuildTests && !config.useASAN) {
cmakeArgs['-DNOISEPAGE_USE_JEMALLOC'] = ENABLED
}
if (config.isCodeCoverage) {
cmakeArgs['-DNOISEPAGE_GENERATE_COVERAGE'] = ENABLED
cmakeArgs['-DNOISEPAGE_UNITY_BUILD'] = DISABLED
// unity builds can throw off the accuracy of code coverage
}
if (config.isBuildTests) {
// Different OS have different commands to get number of cpus
if (config.os == UBUNTU) {
cmakeArgs['-DNOISEPAGE_TEST_PARALLELISM'] = config.os == UBUNTU ? "\$(nproc)" : 1
}
if (config.isJumboTest) {
cmakeArgs['-DNOISEPAGE_USE_JUMBOTESTS'] = ENABLED
}
} else {
cmakeArgs['-DNOISEPAGE_BUILD_TESTS'] = DISABLED
}
if (config.isBuildBenchmarks || config.isBuildSelfDrivingTests) {
cmakeArgs['-DNOISEPAGE_BUILD_BENCHMARKS'] = ENABLED
}
if (config.isBuildSelfDrivingTests) {
cmakeArgs['-DNOISEPAGE_BUILD_SELF_DRIVING_TESTS'] = ENABLED
}
String compileCmd = 'cmake -GNinja'
cmakeArgs.each { arg, value -> compileCmd += " $arg=$value" }
compileCmd += ' ..'
return compileCmd
}
/*
generateBuildCmd creates the build command string based on the config passed
in. The config arguments are the same as the defaultArgs in noisePageBuild.
*/
String generateBuildCmd(Map config = [:]) {
String buildCmd = 'ninja'
if (config.isBuildSelfDrivingTests) {
buildCmd += ' mini_runners'
}
else if (!config.isBuildBenchmarks && !config.isBuildTests) {
buildCmd += ' noisepage'
}
return buildCmd
}
/**
* generateBuildScript creates the full script string, including the commands to
* create the directory. It even allows us to wrap the compile command in a timer
* if we want to time how long the build takes. This time will be output to a
* file.
*/
String generateBuildScript(String compileCmd, String buildCmd, Boolean isRecordTime) {
String script = '''
mkdir build
cd build
'''
if (isRecordTime) {
script += """
/usr/bin/time -o /tmp/noisepage-compiletime.txt -f %e sh -c \"$compileCmd
$buildCmd\""""
} else {
script += """
$compileCmd
$buildCmd"""
}
return script
}
return this