-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
178 lines (162 loc) · 6 KB
/
Jenkinsfile
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#!groovy
library "github.com/melt-umn/jenkins-lib"
melt.setProperties(silverBase: true, ablecBase: true)
melt.trynode('silver-ableC') {
melt.clearGenerated()
def SILVER_ABLEC_BASE = "${env.WORKSPACE}/extensions/silver-ableC"
def SILVER_ABLEC_GEN = "${env.WORKSPACE}/generated"
def ABLEC_BASE = ablec.resolveAbleC()
def SILVER_BASE = silver.resolveSilver()
def newenv = silver.getSilverEnv(SILVER_BASE) + [
"ABLEC_BASE=${ABLEC_BASE}",
"EXTS_BASE=${env.WORKSPACE}/extensions"
]
def SILVER_HOST_GEN = []
if (params.SILVER_GEN != 'no') {
echo "Using existing Silver generated files: ${params.SILVER_GEN}"
SILVER_HOST_GEN << "${params.SILVER_GEN}"
}
if (params.ABLEC_GEN != 'no') {
echo "Using existing ableC generated files: ${params.ABLEC_GEN}"
SILVER_HOST_GEN << "${params.ABLEC_GEN}"
}
newenv << "SILVER_HOST_GEN=${SILVER_HOST_GEN.join(':')}"
stage ("Build") {
// Get Silver-ableC
checkout([
$class: 'GitSCM',
branches: scm.branches,
doGenerateSubmoduleConfigurations: scm.doGenerateSubmoduleConfigurations,
extensions: [
[$class: 'RelativeTargetDirectory', relativeTargetDir: "extensions/silver-ableC"],
[$class: 'CleanCheckout']
],
submoduleCfg: scm.submoduleCfg,
userRemoteConfigs: scm.userRemoteConfigs])
// Get dependancies of silver-ableC
def ext_dependencies = [
"ableC-closure",
"ableC-refcount-closure",
"ableC-templating",
"ableC-string",
"ableC-constructor",
"ableC-algebraic-data-types",
"ableC-template-algebraic-data-types",
]
for (ext in ext_dependencies) {
ablec.checkoutExtension(ext)
}
// Try to get jars and avoid bootstrapping, if this is a fast build
def bootstrapRequired = true
def isFastBuild = (params.ABLEC_GEN != 'no')
if (isFastBuild) {
echo "Trying to get jars from silver-ableC branch ${env.BRANCH_NAME}"
String branchJob = "/melt-umn/silver-ableC/${hudson.Util.rawEncode(env.BRANCH_NAME)}"
try {
// If the last build has artifacts, use those.
dir("${env.WORKSPACE}/extensions/silver-ableC") {
copyArtifacts(projectName: branchJob, selector: lastCompleted())
}
bootstrapRequired = false
melt.annotate("Silver-ableC jar from branch (prev).")
} catch (hudson.AbortException exc2) {
try {
// If there is a last successful build, use those.
dir("${env.WORKSPACE}/extensions/silver-ableC") {
copyArtifacts(projectName: branchJob, selector: lastSuccessful())
}
bootstrapRequired = false
melt.annotate("Silver-ableC jar from branch (successful).")
} catch (hudson.AbortException exc3) {
melt.annotate("Silver-ableC jar from branch (fresh).")
}
}
}
// Try building with previous jars, if available
if (!bootstrapRequired) {
withEnv(newenv) {
dir(SILVER_ABLEC_BASE) {
if (sh(script: './self-compile --one-jar', returnStatus: true) != 0) {
// An error occured, fall back to bootstrapping
echo "Self-compile build failure, falling back to bootstrap build"
melt.annotate("Self-compile failure.")
bootstrapRequired = true
}
}
}
if (bootstrapRequired) {
// Don't leave results of failed self-compile behind for when we try bootstrapping
melt.clearGenerated()
}
}
// Perform a full bootstrap build, if required
if (bootstrapRequired) {
withEnv(newenv) {
dir(SILVER_ABLEC_BASE) {
sh './bootstrap-compile'
// Perform another clean rebuild to ensure that we have a working fixpoint
sh "./self-compile --clean --one-jar"
}
}
}
// Upon succeeding at initial build, archive for future builds
dir(SILVER_ABLEC_BASE) {
archiveArtifacts(artifacts: "jars/*.jar", fingerprint: true)
melt.archiveCommitArtifacts("jars/*.jar")
}
}
stage ("Modular Analyses") {
// No MWDA for now, since Silver itself fails horribly
withEnv(newenv) {
dir(SILVER_ABLEC_BASE) {
sh "./mda-test"
}
}
}
stage ("Integration") {
// All known, stable extensions using silver-ableC to build downstream
def extensions = [
"ableC-closure",
"ableC-refcount-closure",
"ableC-string",
"ableC-vector",
"ableC-interval",
"ableC-watch",
"ableC-nondeterministic-search", "ableC-nondeterministic-search-benchmarks",
"ableC-algebraic-data-types", "ableC-template-algebraic-data-types",
"ableC-unification", "ableC-prolog", "ableC-rewriting",
"ableC-halide",
"ableC-tensor-algebra",
"ableC-tutorials", "ableC-sample-projects",
"carbles-ai"
]
// Currently not maintained:
// "ableC-cilk", "ableC-parallel",
def tasks = [:]
def newargs = [SILVER_BASE: SILVER_BASE,
SILVER_GEN: params.SILVER_GEN == 'no'? SILVER_ABLEC_GEN : params.SILVER_GEN,
ABLEC_BASE: ABLEC_BASE,
ABLEC_GEN: params.ABLEC_GEN == 'no'? SILVER_ABLEC_GEN : params.ABLEC_GEN,
SILVER_ABLEC_BASE: SILVER_ABLEC_BASE]
tasks << extensions.collectEntries { t ->
[(t): { melt.buildProject("/melt-umn/${t}", newargs) }]
}
parallel tasks
}
if (env.BRANCH_NAME == 'develop') {
// Only deploy jars for non-downstream builds or builds downstream from a non-downstream build
if (params.ABLEC_BASE == 'ableC' || // Non-downstream
// Downstream from ableC
(params.SILVER_BASE == silver.SILVER_WORKSPACE && params.ABLEC_BASE.contains('melt-umn_ableC_develop')) ||
// Downstream from Silver
params.SILVER_BASE.contains('melt-umn_silver_develop')) {
stage("Deploy") {
dir(SILVER_ABLEC_BASE) {
sh "cp jars/*.jar ${melt.ARTIFACTS}/"
}
}
}
}
/* If we've gotten all this way with a successful build, don't take up disk space */
melt.clearGenerated()
}