-
Notifications
You must be signed in to change notification settings - Fork 1
/
wscript_build
629 lines (533 loc) · 24.4 KB
/
wscript_build
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
#!/usr/bin/env python
"""builds the entire stack"""
#For every matching build change here, that produces new installable
#files, the cloud.spec file and the Debian control files must be
#revised and tested.
import shutil,os
import Utils,Node,Options,Logs,Scripting,Environment,Build,Configure
from os import unlink as _unlink, makedirs as _makedirs, getcwd as _getcwd, chdir as _chdir
from os.path import abspath as _abspath, basename as _basename, dirname as _dirname, exists as _exists, isdir as _isdir, split as _split, join as _join, sep, pathsep, pardir
from glob import glob as _glob
try: set([1,2,3])
except Exception: from Sets import set
import re
import zipfile,tarfile
try:
from os import chmod as _chmod,chown as _chown
import pwd,stat,grp
except ImportError:
_chmod,_chown,pwd,stat,grp = (None,None,None,None,None)
required_env = [
"APISERVERLOG",
"MSLOG",
"PIDDIR",
"CPPATH",
"AGENTSIMULATORCLASSPATH",
"SYSTEMJAVADIR",
"USAGELOG",
"PLUGINJAVADIR",
]
for e in required_env:
if e not in bld.env: raise Utils.WafError("configure required: new variable %s added"%e)
sourcedir = bld.srcnode.abspath()
builddir = bld.path.abspath(bld.env)
buildpremium = _exists(_join(sourcedir,"cloudstack-proprietary"))
filelist = bld.path.ant_glob
sccsinfo = _join(sourcedir,"sccs-info")
if _exists(sccsinfo): bld.install_files("${DOCDIR}","sccs-info")
tgen = bld(features='subst', name='configure-info', source="configure-info.in", target="configure-info")
def gen_configure_info():
lines = []
for key,val in sorted(bld.env.get_merged_dict().items()):
if "CLASSPATH" in key:
lines.append(" %s:"%key)
for v in val.split(pathsep):
lines.append(" %s"%v)
continue
lines.append(" %s: %s"%(key,val))
return "\n".join(lines)
tgen.dict = {"CONFIGUREVARS":gen_configure_info()}
bld.install_files("${DOCDIR}","configure-info")
# ==================== Java compilation ===========================
sfl = lambda filespec: filelist(filespec,src=True,bld=False,dir=False,flat=True)
# discover ant targets and properties
antxmlfiles = _glob(_join("build","*.xml")) + _glob(_join("build","*.properties"))
if buildpremium: antxmlfiles += _glob(_join("build","premium","*.xml")) + _glob(_join("cloudstack-proprietary","build","*.xml"))
targets,antprops = Utils.discover_ant_targets_and_properties(antxmlfiles)
javac_env = bld.env.copy()
# FIXME trigger recompilation / cache avoidance when debuglevel changes. ATM this does not happen.
if antprops.get('debuglevel',None): javac_env.append_value("JAVACFLAGS",["-g:%s"%antprops['debuglevel']])
Implementation_Version = bld.env.VERSION
buildnumber = Utils.getbuildnumber()
if buildnumber: Implementation_Version += "." + buildnumber
# compile .class files using waf
classpathentries = [ _join(builddir,x[2]) for x in targets ]
javawclasspath = pathsep.join( classpathentries + [ _abspath(x) for x in bld.env.CLASSPATH.split(pathsep) ] )
javac_tgens = [
bld( features='javac', name=name, srcdir=srcdir, outdir=classdir,
after=" ".join(deps), classpath=javawclasspath, env=javac_env )
for name,srcdir,classdir,jarpath,deps in targets ]
[ bld.process_after(tgen) for tgen in javac_tgens ]
# compile jar files using ant
# ant only needs to be reinvoked if the version with build number changes
# we here trim all the depended targets from the target list:
build_targets = [ x[0] for x in targets ]
nondep_build_targets = list ( set([ x[0] for x in targets ]) - set([ x for dependencies in [ y[4] for y in targets ] for x in dependencies ]) )
ant_sources = " ".join(antxmlfiles + [ sfl(x[1] + "/**/*.java") for x in targets ])
ant_jars = [ x[3] for x in targets ]
# because build-console-viewer does not use compile-java macro, we have to hardcode it here
ant_args = [
"-Dimpl.version=%s"%Implementation_Version,
"-Dtarget.dir=%s"%Utils.relpath(_join(builddir,"target")),
"-Ddist.dir=%s"%Utils.relpath(_join(builddir,"ant-dist")),
]
if not buildpremium: ant_args += ["-DOSS=true"]
# this is to trigger recompilation / cache avoidance if the relevant environment for ant changes
tgen = bld(features='subst', name='version-info', source="version-info.in", target="version-info")
tgen.dict = { "Implementation_Version":Implementation_Version,"JAVACFLAGS":javac_env.JAVACFLAGS,"ant_args":ant_args }
bld.install_files("${DOCDIR}","version-info")
build_targets += ["version-info"]
ant_sources += " version-info"
bld.path.ensure_dir_node_from_path("target/jar")
tgen = bld(rule=Utils.runant, name='runant', source=ant_sources, target=ant_jars, anttgts = nondep_build_targets, antargs=ant_args, after=build_targets)
bld.process_after(tgen)
# install jar files
[ bld.install_files('${JAVADIR}',jar) for jar in ant_jars if _basename(jar).startswith("cloud-") ]
# ======================= End Java compilation ======================
# =================== C / Python compilation =========================
if bld.env.DISTRO not in ['Windows','Mac']:
# build / install declarations of the daemonization utility - except for Windows
bld(
name='daemonize',
features='cc cprogram',
source='daemonize/daemonize.c',
target='daemonize/cloud-daemonize')
# build / install declarations of vnet
files = """vnetd/connection.c vnetd/select.c vnetd/timer.c vnetd/spinlock.c vnetd/skbuff.c
vnetd/vnetd.c vnet-module/skb_util.c vnet-module/sxpr_util.c vnet-module/timer_util.c
vnet-module/etherip.c vnet-module/vnet.c vnet-module/vnet_eval.c vnet-module/vnet_forward.c
vnet-module/vif.c vnet-module/tunnel.c vnet-module/sa.c vnet-module/varp.c
libxutil/allocate.c libxutil/enum.c libxutil/file_stream.c libxutil/hash_table.c
libxutil/iostream.c libxutil/lexis.c libxutil/socket_stream.c libxutil/string_stream.c
libxutil/sxpr.c libxutil/sxpr_parser.c libxutil/sys_net.c libxutil/sys_string.c libxutil/util.c"""
files = [ "vnet/src/%s"%s for s in Utils.to_list(files) ]
bld(
name='vnetd',
features='cc cprogram',
source= files,
includes="vnet/src/libxutil vnet/src/vnet-module vnet/src/vnetd",
lib='dl pthread'.split(),
target='vnet/%s-vnetd'%bld.env.PACKAGE,
install_path="${SBINDIR}"
)
obj = bld(features = 'py',name='pythonmodules')
obj.find_sources_in_dirs('python/lib', exts=['.py'])
# ===================== End C / Python compilation ==========================
# ================ Third-party / dependency installation ===============
bld.install_files('${JAVADIR}','deps/*.jar')
if buildpremium: bld.install_files('${PREMIUMJAVADIR}','cloudstack-proprietary/thirdparty/*.jar')
# =================== End 3rdparty/dep install ========================
# =================== Build install declaratoin of console proxy project ========
# -> binary unsubstitutable files
start_path = bld.path.find_dir("console-proxy")
bld.install_files("${CPLIBDIR}",
start_path.ant_glob("images/**",src=True,bld=False,dir=False,flat=True),
cwd=start_path,relative_trick=True)
# -> source files with tokens
patterns = 'console-proxy/css/** console-proxy/js/** console-proxy/ui/** console-proxy/scripts/**'
src_files = Utils.to_list(filelist(patterns,flat=True))
subst_files = [ x+".subst" for x in src_files ]
inst_files = [ Utils.relpath(x,"console-proxy") for x in src_files ]
for src,tgt,inst in zip(src_files,subst_files,inst_files):
tgen = bld(features='subst', source=src, target=tgt)
tgen.dict = bld.env.get_merged_dict()
bld.path.find_or_declare(tgt)
bld.install_as("${CPLIBDIR}/%s"%inst, tgt)
# -> configuration
if not Options.options.PRESERVECONFIG:
bld.install_files_filtered("${CPSYSCONFDIR}",filelist("console-proxy/conf.dom0/*"))
# ================== End console proxy ===================
# ================ Creation of patch.tgz's ============================
# done here because the patches require substituted files
patterns = "patches/**"
src_files = Utils.to_list(filelist(patterns,flat=True))
subst_files = [ x+".subst" for x in src_files ]
inst_files = src_files
for src,tgt,inst in zip(src_files,subst_files,inst_files):
tgen = bld(features='subst', name='patchsubst', source=src, target=tgt)
tgen.dict = bld.env.get_merged_dict()
bld.path.find_or_declare(tgt)
# this is a clever little thing
# given a list of nodes, build or source
# construct a tar file containing them
# rooted in the parameter root =, specified in the task generator
# and renaming the names of the files according to a rename(x) function passed to the task generator as well
# if a build node's result of rename() has the same name as a source node, the build node will take precedence
# for as long as the build node appears later than the source node (this is an implementation detail of waf we are relying on)
def tar_up(task):
tgt = task.outputs[0].bldpath(task.env)
if _exists(tgt): _unlink(tgt)
z = tarfile.open(tgt,"w:gz")
fileset = {}
for inp in task.inputs:
src = inp.srcpath(task.env)
if src.startswith(".."):
srcname = Utils.relpath(src,_join("..",".")) # file in source dir
else:
srcname = Utils.relpath(src,_join(task.env.variant(),".")) # file in artifacts dir
if task.generator.rename: srcname = task.generator.rename(srcname)
for dummy in task.generator.root.split("/"):
splittedname = srcname.split("/")
srcname = "/".join(splittedname[1:])
fileset[srcname] = src
for srcname,src in fileset.items():
ti = tarfile.TarInfo(srcname)
ti.mode = 0755
ti.size = os.path.getsize(src)
f = file(src)
z.addfile(ti,fileobj=f)
f.close()
z.close()
return 0
if bld.env.DISTRO != "Windows":
for virttech in [ _basename(x) for x in _glob(_join("patches","*")) ]:
if virttech == "shared":
continue
patchfiles = filelist('patches/%s/** patches/shared/**'%virttech,src=True,bld=True,dir=False,flat=True)
tgen = bld(
rule = tar_up,
source = patchfiles,
target = '%s-patch.tgz'%virttech,
name = '%s-patch_tgz'%virttech,
root = "patches/%s"%virttech,
rename = lambda x: re.sub(".subst$","",x),
after = 'patchsubst',
)
bld.process_after(tgen)
bld.install_as("${AGENTLIBDIR}/scripts/vm/hypervisor/%s/patch.tgz"%virttech, "%s-patch.tgz"%virttech)
tgen = bld(
rule = 'cp ${SRC} ${TGT}',
source = 'xenserver-patch.tgz',
target = 'patch.tgz',
after = 'xenserver-patch_tgz',
name = 'patch_tgz'
)
bld.process_after(tgen)
# ================== End creation of patch.tgz's ====================
# ================== systemvm patch creation ====================
deps = " ".join( Utils.to_list(
"""
deps/cloud-xmlrpc-client-3.1.3.jar
deps/cloud-xmlrpc-common-3.1.3.jar
deps/cloud-log4j.jar
deps/cloud-gson-1.3.jar
deps/cloud-apache-log4j-extras-1.0.jar
deps/cloud-libvirt-0.4.5.jar
deps/cloud-jna.jar
deps/cloud-cglib.jar
deps/cloud-manageontap.jar
"""
) )
thirdparties = " ".join( Utils.to_list(
"""
cloudstack-proprietary/thirdparty/xmlrpc-client-3.1.3.jar
cloudstack-proprietary/thirdparty/xmlrpc-common-3.1.3.jar
cloudstack-proprietary/thirdparty/ws-commons-util-1.0.2.jar
cloudstack-proprietary/thirdparty/manageontap.jar
cloudstack-proprietary/thirdparty/log4j-1.2.15.jar
cloudstack-proprietary/thirdparty/gson-1.3.jar
cloudstack-proprietary/thirdparty/apache-log4j-extras-1.0.jar
cloudstack-proprietary/thirdparty/commons-httpclient-3.1.jar
cloudstack-proprietary/thirdparty/commons-logging-1.1.1.jar
cloudstack-proprietary/thirdparty/commons-collections-3.2.1.jar
cloudstack-proprietary/thirdparty/commons-codec-1.4.jar
cloudstack-proprietary/thirdparty/commons-pool-1.4.jar
cloudstack-proprietary/thirdparty/libvirt-0.4.5.jar
cloudstack-proprietary/thirdparty/jna.jar
cloudstack-proprietary/thirdparty/cglib-nodep-2.2.jar
"""
) )
patterns = Utils.to_list(
"""
console-proxy/css/**
console-proxy/images/**
console-proxy/js/**
console-proxy/ui/**
console-proxy/conf/**
console-proxy/scripts/*.sh
console-proxy/vm-script/*.sh
scripts/storage/secondary/*sh
"""
)
premiumpatterns = patterns + ["cloudstack-proprietary/console-proxy-premium/certs/**"]
artifacts = "target/jar/VMOpsConsoleApplet.jar " + " ".join( "target/jar/cloud-%s.jar"%j for j in "console-proxy console-common agent utils core".split() )
premiumartifacts = artifacts + " target/jar/cloud-console-proxy-premium.jar"
sources = " ".join( [ filelist(x,src=True,bld=False,dir=False,flat=True) for x in patterns ] )
premiumsources = " ".join( [ filelist(x,src=True,bld=False,dir=False,flat=True) for x in premiumpatterns ] )
systemfiles = [ (f,_join(".",_basename(f))) for f in bld.env.SYSTEMCLASSPATH.split(pathsep) ]
systems = " ".join( [ n[1] for n in systemfiles ] )
systemtargetdir = _join(builddir,".")
def copydeps(task):
Utils.check_dir(systemtargetdir)
for src,tgt in systemfiles: shutil.copy(src,systemtargetdir)
return 0
def zip_up(task):
tgt = task.outputs[0].bldpath(task.env)
if _exists(tgt): _unlink(tgt)
z = zipfile.ZipFile(tgt,"w")
for inp in task.inputs:
if inp.id&3==Node.BUILD:
src = inp.bldpath(task.env)
srcname = src
srcname = "/".join(srcname.split("/")[1:]) # chop off default/
if srcname.startswith("target/jar"): srcname = "/".join(srcname.split("/")[2:]) # chop off target/jar
else:
src = inp.srcpath(task.env)
srcname = src
srcname = "/".join(srcname.split("/")[1:]) # chop off ../
if srcname.startswith("cloudstack-proprietary"): srcname = "/".join(srcname.split("/")[1:]) # chop off cloudstack proprietary
srcname = "/".join(srcname.split("/")[1:]) # chop off project name
# post-process the paths
if True in [ srcname.startswith(strt) for strt in [ 'scripts/run','scripts/_run','scripts/config_ssl','scripts/config_auth','scripts/ssvm-check' ] ]:
srcname = "/".join(srcname.split("/")[1:])
elif srcname.startswith('storage'):
srcname = "scripts/" + srcname
elif srcname.startswith('VMOpsConsoleApplet'):
srcname = "applet/" + srcname
elif srcname.startswith('certs'):
srcname = srcname
z.write(src,srcname)
z.close()
return 0
if bld.env.DISTRO not in ["Windows","Mac"]:
tgen = bld(
rule = copydeps,
source = 'wscript_configure',
target = systems,
name = 'getsystemjars',
)
tgen = bld(
rule = zip_up,
source = " ".join( [sources,artifacts,deps,systems] ),
target = 'systemvm.zip',
name = 'systemvm_zip',
after = 'copydeps getsystemjars runant',
)
bld.process_after(tgen)
if buildpremium:
tgen = bld(
rule = zip_up,
source = " ".join( [premiumsources,premiumartifacts,thirdparties] ),
target = 'systemvm-premium.zip',
name = 'systemvm-premium_zip',
after = 'runant',
)
bld.process_after(tgen)
if bld.env.DISTRO not in [ "Windows", "Mac"]:
bld.install_files("${AGENTLIBDIR}/vms", "systemvm.zip")
if buildpremium:
bld.install_files("${AGENTLIBDIR}/vms", "systemvm-premium.zip")
# ================== End systemvm patch creation ====================
# =================== Empty directory / symlink creation on install target ====================
# 7. make log and cache dirs (this actually runs first)
if bld.env.DISTRO in 'Windows Mac': pass
else:
x = ("root",bld.env.MSUSER)
directories = [
("${MSLOGDIR}",0770,x),
("${AGENTLOGDIR}",0770,x),
("${USAGELOGDIR}",0770,x),
("${CPLOGDIR}",0770,x),
("${LOCALSTATEDIR}/cache/${MSPATH}",0770,x),
("${LOCALSTATEDIR}/cache/${MSPATH}/temp",0770,x),
("${LOCALSTATEDIR}/cache/${MSPATH}/work",0770,x),
("${SHAREDSTATEDIR}/${MSPATH}",0770,x),
("${MSMNTDIR}",0770,x),
("${MSCONF}/Catalina",0770,x),
("${MSCONF}/Catalina/localhost",0770,x),
("${MSCONF}/Catalina/localhost/client",0770,x),
("${PIDDIR}",0755,("root","root")),
("${LOCKDIR}",0755,("root","root")),
]
for a,mode,owner in directories:
s = bld.subst_add_destdir(a,bld)
if Options.is_install:
bld.install_dir(a)
bld.setownership(a,owner[0],owner[1],mode)
# 8. create environment symlinks
symlinks = [
('${MSENVIRON}/bin', '${TOMCATHOME}/bin'),
('${MSENVIRON}/lib', '${TOMCATHOME}/lib'),
('${MSENVIRON}/logs', "${MSLOGDIR}"),
('${MSENVIRON}/temp', '${LOCALSTATEDIR}/cache/${MSPATH}/temp'),
('${MSENVIRON}/work','${LOCALSTATEDIR}/cache/${MSPATH}/work'),
('${MSENVIRON}/conf', '${SYSCONFDIR}/${MSPATH}'),
("${AGENTLIBDIR}/css", '${CPLIBDIR}/css'),
("${AGENTLIBDIR}/images", '${CPLIBDIR}/images'),
("${AGENTLIBDIR}/js", '${CPLIBDIR}/js'),
("${AGENTLIBDIR}/ui", '${CPLIBDIR}/ui'),
]
for lnk,dst in symlinks: bld.symlink_as(lnk,Utils.subst_vars(dst,bld.env))
# ================== End empty directory / symlink creation on install target =====================
# =================== Subst / installation of agent scripts project ========
src_files = Utils.to_list(filelist("scripts/** cloudstack-proprietary/scripts/**",flat=True))
subst_files = [ x+".subst" for x in src_files ]
inst_files = src_files
for src,tgt,inst in zip(src_files,subst_files,inst_files):
tgen = bld(features='subst', name='scriptssubst', source=src, target=tgt)
tgen.dict = bld.env.get_merged_dict()
bld.path.find_or_declare(tgt)
if inst.startswith("cloudstack-proprietary"): inst = inst[len("cloudstack-proprietary")+1:]
bld.install_as("${AGENTLIBDIR}/%s"%inst, tgt, chmod=0755)
# ================== End agent scripts ===================
# ================== Subst / installation of scripts in bin directories ========================
bld.install_files_filtered("${LIBEXECDIR}","*/libexec/* cloudstack-proprietary/*/libexec/*",chmod=0755)
bld.install_files_filtered("${BINDIR}","*/bindir/* cloudstack-proprietary/*/bindir/*",chmod=0755)
bld.install_files_filtered("${SBINDIR}","*/sbindir/* cloudstack-proprietary/*/sbindir/*",chmod=0755)
# ================== End subst / installation of scripts in bin directories ========================
# ================== Installation of scripts / bindirs / configuration files ===========================
# build / install declarations of test project
if buildpremium:
proj = 'test'
start_path = bld.path.find_dir("cloudstack-proprietary/test/scripts")
bld.install_files('${LIBDIR}/${PACKAGE}/test',
start_path.ant_glob("**",src=True,bld=False,dir=False,flat=True),
cwd=start_path,relative_trick=True)
start_path = bld.path.find_dir("cloudstack-proprietary/test/metadata")
bld.install_files('${SHAREDSTATEDIR}/${PACKAGE}/test',
start_path.ant_glob("**",src=True,bld=False,dir=False,flat=True),
cwd=start_path,relative_trick=True)
if not Options.options.PRESERVECONFIG:
bld.install_files('${SYSCONFDIR}/%s/%s'%(bld.env.PACKAGE,proj),'cloudstack-proprietary/test/conf/*')
# build / install declarations of server project <- this is actually now in client project
start_path = bld.path.find_dir("client/WEB-INF")
bld.install_files('${MSENVIRON}/webapps/client/WEB-INF',
start_path.ant_glob("**",src=True,bld=False,dir=False,flat=True),
cwd=start_path,relative_trick=True)
if not Options.options.PRESERVECONFIG:
bld.install_files_filtered("${SERVERSYSCONFDIR}","server/conf/*")
# build / install declarations of agent project
proj = 'agent'
start_path = bld.path.find_dir(proj)
bld.install_files("${AGENTLIBDIR}",
start_path.ant_glob("storagepatch/**",src=True,bld=False,dir=False,flat=True),
cwd=start_path,relative_trick=True)
if not Options.options.PRESERVECONFIG:
bld.install_files_filtered("${AGENTSYSCONFDIR}","%s/conf/*"%proj)
# build / install declarations of client UI project
# -> binary unsubstitutable files
start_path = bld.path.find_dir("ui")
bld.install_files("${MSENVIRON}/webapps/client",
start_path.ant_glob("*.ico **/*png **/*jpg **/*gif",src=True,bld=False,dir=False,flat=True),
cwd=start_path,relative_trick=True)
# -> source files with tokens
patterns = 'ui/*html ui/**/*html ui/**/*js ui/**/*css ui/**/*properties ui/**/*jsp'
src_files = Utils.to_list(filelist(patterns,flat=True))
subst_files = [ x+".subst" for x in src_files ]
inst_files = [ Utils.relpath(x,"ui") for x in src_files ]
for src,tgt,inst in zip(src_files,subst_files,inst_files):
tgen = bld(features='subst', source=src, target=tgt)
tgen.dict = bld.env.get_merged_dict()
bld.path.find_or_declare(tgt)
bld.install_as("${MSENVIRON}/webapps/client/%s"%inst, tgt)
# -> minification of UI files
def minifyjs(task):
tgt = task.outputs[0].bldpath(task.env)
inputfiles = []
outputfile = ['--js_output_file',tgt]
for inp in task.inputs:
src = inp.srcpath(task.env)
inputfiles.append(src)
newinputfiles = []
for inputfile in inputfiles:
if inputfile not in newinputfiles:
newinputfiles.append('--js')
newinputfiles.append(inputfile)
compilerjar = _join(sourcedir,'tools','gcc','compiler.jar')
return Utils.exec_command(["java",'-jar',compilerjar] + newinputfiles + outputfile,log=True)
javascripts = [
['ui/scripts/jquery.min.js','ui/scripts/date.js'],
Utils.to_list(filelist('ui/scripts/jquery*js')),
['ui/scripts/cloud.core.js','ui/scripts/cloud.core.callbacks.js'],
Utils.to_list(filelist('ui/scripts/cloud*js')),
]
sourcefiles = []
for lst in javascripts:
for x in lst:
if x not in sourcefiles: sourcefiles.append(x)
tgen = bld(
rule = minifyjs,
source = sourcefiles,
target = 'ui/scripts/cloud.min.js',
name = 'minifyjs',
)
bld.install_files("${MSENVIRON}/webapps/client/scripts", "ui/scripts/cloud.min.js")
# substitute and install generic tomcat config
if not Options.options.PRESERVECONFIG:
bld.install_files_filtered("${MSCONF}","*/tomcatconf/* cloudstack-proprietary/*/tomcatconf/*")
bld.install_files("${MSCONF}",'client/tomcatconf/db.properties',chmod=0640)
bld.setownership("${MSCONF}/db.properties","root",bld.env.MSUSER)
# apply distro-specific config on top of the 'all' generic cloud-management config
globspec = _join("*","distro",bld.env.DISTRO.lower(),"*") # matches premium/distro/centos/SYSCONFDIR
distrospecificdirs=_glob(globspec) + _glob(_join("cloudstack-proprietary",globspec))
for dsdir in distrospecificdirs:
start_path = bld.srcnode.find_dir(dsdir)
subpath,varname = _split(dsdir)
dsdirwithvar = _join("${%s}"%varname)
files = filelist('%s/**'%dsdir,src=True,bld=False,dir=False,flat=True)
mode = 0644
if "SYSCONFDIR" in dsdir:
mode = 0755
if Options.options.PRESERVECONFIG: continue
bld.install_files_filtered(dsdirwithvar, files, cwd=start_path, relative_trick=True,chmod=mode)
# build / install declarations of usage
if buildpremium:
if not Options.options.PRESERVECONFIG:
#print filelist("usage/conf/* cloudstack-proprietary/usage/conf/*")
#assert False
bld.install_files_filtered("${USAGESYSCONFDIR}","usage/conf/* cloudstack-proprietary/usage/conf/*")
bld.symlink_as("${USAGESYSCONFDIR}/db.properties",Utils.subst_vars("${MSCONF}/db.properties",bld.env))
# install db data files
bld.install_files_filtered("${SETUPDATADIR}",filelist("*/db/* cloudstack-proprietary/*/db/*",excl=Node.exclude_regs + "\ncloud-gate\ncloud-bridge"))
# ================== End installation of scripts / bindirs / configuration files ===========================
# ====================== Feature-specific plugins ========================
for plugin in _glob(_join("plugins","*")) + _glob(_join("cloudstack-proprietary","plugins","*")):
if not _exists(_join(plugin,"build.xml")): continue
pluginname = _basename(plugin)
target = 'target/jar/cloud-%s.jar' % pluginname
sources = filelist( '%s/**/*.java' % plugin.replace(sep,"/") , src=True, bld=False, dir=False )
tgen = bld(rule=lambda x: runant("compile-%s"%pluginname), name='compile_%s'%pluginname, source=sources, target=target, after='runant')
bld.install_files('${PLUGINJAVADIR}',target)
# ====================== End feature-specific plugins ====================
# ====================== Vendor-specific plugins ========================
for vendor in _glob(_join("vendor","*")) + _glob(_join("cloudstack-proprietary","vendor","*")):
if not Options.options.PRESERVECONFIG:
bld.install_files_filtered("${MSCONF}/%s"%vendor,filelist("%s/tomcatconf/*"%vendor))
# ====================== End vendor-specific plugins ====================
def generate_xml_api_description(task):
relationship = Utils.relpath(sourcedir,os.getcwd())
cp = [ _join(relationship,x) for x in task.generator.env.CLASSPATH.split(pathsep) ]
buildproducts = [ x.bldpath(task.env) for x in task.inputs ]
jars = [ x for x in buildproducts if x.endswith("jar") ]
properties = [ x for x in buildproducts if x.endswith("properties") ]
cp += jars
cp = pathsep.join(cp)
arguments = ["-f",",".join(properties),"-d",builddir]
ret = Utils.exec_command(["java","-cp",cp,"com.cloud.utils.commandlinetool.BuildCommandLineInputFile"]+arguments,log=True)
return ret
if buildpremium:
props = " client/tomcatconf/commands.properties"
props += " cloudstack-proprietary/premium/tomcatconf/commands-ext.properties"
jarnames = ['utils','server','core']
jarnames += ['server-extras']
tgen = bld(
rule = generate_xml_api_description,
source = " ".join( [ 'target/jar/cloud-%s.jar'%x for x in jarnames ] ) + props,
target = 'commands.xml',
name = 'xmlapi',
after = 'runant',
install_path="${CLIDIR}"
)
bld.process_after(tgen)
bld.install_files("${PYTHONDIR}//cloudtool", 'cloudstack-proprietary/cloud-cli/cloudtool/*')
bld.install_as("${PYTHONDIR}/cloudapis.py", 'cloudstack-proprietary/cloud-cli/cloudapis/cloud.py')