Skip to content

Commit b0acdbc

Browse files
author
Manuel Amador (Rudd-O)
committed
Split out build responsibility into per-project wscript_build files. Installation of generic directories like bindir, and creation of systemvms, remain in toplevel wscript_build. Make some waf code useful and reusable in the form of tools.
1 parent 11fb89a commit b0acdbc

16 files changed

Lines changed: 342 additions & 246 deletions

File tree

agent/wscript_build

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import Options
2+
3+
bld.install_files("${AGENTLIBDIR}",
4+
bld.path.ant_glob("storagepatch/**",src=True,bld=False,dir=False,flat=True),
5+
cwd=bld.path,relative_trick=True)
6+
if not Options.options.PRESERVECONFIG:
7+
bld.install_files_filtered("${AGENTSYSCONFDIR}","conf/*")

client/wscript_build

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import Options
2+
3+
start_path = bld.path.find_dir("WEB-INF")
4+
bld.install_files('${MSENVIRON}/webapps/client/WEB-INF',
5+
start_path.ant_glob("**",src=True,bld=False,dir=False,flat=True),
6+
cwd=start_path,relative_trick=True)
7+
8+
if not Options.options.PRESERVECONFIG:
9+
bld.install_files_filtered("${MSCONF}","tomcatconf/*")
10+
bld.install_files("${MSCONF}",'tomcatconf/db.properties',chmod=0640)
11+
bld.setownership("${MSCONF}/db.properties","root",bld.env.MSUSER)

console-proxy/wscript_build

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import Options
2+
3+
# binary unsubstitutable files:
4+
bld.install_files("${CPLIBDIR}",bld.path.ant_glob("images/**",src=True,bld=False,dir=False,flat=True),cwd=bld.path,relative_trick=True)
5+
6+
# text substitutable files (substitute with tokens from the environment bld.env):
7+
bld.substitute('css/** js/** ui/** scripts/**',install_to="${CPLIBDIR}")
8+
9+
# config files (do not replace them if preserve config option is true)
10+
if not Options.options.PRESERVECONFIG: bld.install_files_filtered("${CPSYSCONFDIR}","conf.dom0/*")

daemonize/wscript_build

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
if bld.env.DISTRO not in ['Windows','Mac']:
2+
# build / install declarations of the daemonization utility - except for Windows
3+
bld(
4+
name='daemonize',
5+
features='cc cprogram',
6+
source='daemonize.c',
7+
target='cloud-daemonize')

deps/wscript_build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bld.install_files('${JAVADIR}','*.jar')

patches/wscript_build

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import os, Utils, glob, re
2+
3+
bld.substitute("*/**",name="patchsubst")
4+
5+
for virttech in Utils.to_list(bld.path.ant_glob("*",dir=True)):
6+
if virttech in ["shared","wscript_build"]: continue
7+
patchfiles = bld.path.ant_glob('%s/** shared/**'%virttech,src=True,bld=True,dir=False,flat=True)
8+
tgen = bld(
9+
features = 'tar',#Utils.tar_up,
10+
source = patchfiles,
11+
target = '%s-patch.tgz'%virttech,
12+
name = '%s-patch_tgz'%virttech,
13+
root = "patches/%s"%virttech,
14+
rename = lambda x: re.sub(".subst$","",x),
15+
after = 'patchsubst',
16+
)
17+
bld.process_after(tgen)
18+
if virttech != "xenserver":
19+
# xenserver uses the patch.tgz file later to make an ISO, so we do not need to install it
20+
bld.install_as("${AGENTLIBDIR}/scripts/vm/hypervisor/%s/patch.tgz"%virttech, "%s-patch.tgz"%virttech)
21+
22+
tgen = bld(
23+
rule = 'cp ${SRC} ${TGT}',
24+
source = 'xenserver-patch.tgz',
25+
target = 'patch.tgz',
26+
after = 'xenserver-patch_tgz',
27+
name = 'patch_tgz'
28+
)
29+
bld.process_after(tgen)

python/wscript_build

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
if bld.env.DISTRO not in ['Windows','Mac']:
2+
obj = bld(features = 'py',name='pythonmodules')
3+
obj.find_sources_in_dirs('lib', exts=['.py'])

scripts/wscript_build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bld.substitute('**',"${AGENTLIBDIR}/scripts",chmod=0755)

server/wscript_build

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import Options
2+
3+
if not Options.options.PRESERVECONFIG:
4+
bld.install_files_filtered("${SERVERSYSCONFDIR}","conf/*")

tools/waf/mkisofs.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import Utils
2+
from TaskGen import feature, before
3+
import Task
4+
import os
5+
6+
# fixme: this seems to hang waf with 100% CPU
7+
8+
def detect(conf):
9+
conf.find_program("mkisofs",mandatory=True,var='MKISOFS')
10+
11+
def iso_up(task):
12+
tgt = task.outputs[0].bldpath(task.env)
13+
if os.path.exists(tgt): os.unlink(tgt)
14+
inps = []
15+
for inp in task.inputs:
16+
if inp.id&3==Node.BUILD:
17+
src = inp.bldpath(task.env)
18+
srcname = src
19+
srcname = "/".join(srcname.split("/")[1:]) # chop off default/
20+
else:
21+
src = inp.srcpath(task.env)
22+
srcname = src
23+
srcname = "/".join(srcname.split("/")[1:]) # chop off ../
24+
inps.append(src)
25+
ret = Utils.exec_command(
26+
[
27+
task.generator.env.MKISOFS,
28+
"-quiet",
29+
"-r",
30+
"-o",tgt,
31+
] + inps, shell=False)
32+
if ret != 0: return ret
33+
if task.chmod: os.chmod(tgt,task.chmod)
34+
35+
def apply_iso(self):
36+
Utils.def_attrs(self,fun=iso_up)
37+
self.default_install_path=0
38+
lst=self.to_list(self.source)
39+
self.meths.remove('apply_core')
40+
self.dict=getattr(self,'dict',{})
41+
out = self.path.find_or_declare(self.target)
42+
ins = []
43+
for x in Utils.to_list(self.source):
44+
node = self.path.find_resource(x)
45+
if not node:raise Utils.WafError('cannot find input file %s for processing'%x)
46+
ins.append(node)
47+
if self.dict and not self.env['DICT_HASH']:
48+
self.env=self.env.copy()
49+
keys=list(self.dict.keys())
50+
keys.sort()
51+
lst=[self.dict[x]for x in keys]
52+
self.env['DICT_HASH']=str(Utils.h_list(lst))
53+
tsk=self.create_task('iso',ins,out)
54+
tsk.fun=self.fun
55+
tsk.dict=self.dict
56+
tsk.dep_vars=['DICT_HASH']
57+
tsk.install_path=self.install_path
58+
tsk.chmod=self.chmod
59+
if not tsk.env:
60+
tsk.debug()
61+
raise Utils.WafError('task without an environment')
62+
63+
Task.task_type_from_func('iso',func=iso_up)
64+
feature('iso')(apply_iso)
65+
before('apply_core')(apply_iso)

0 commit comments

Comments
 (0)