Revision 27363
branches/v2_0_0_prep/build/buildman/doc/depman-linux-gcc3.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<depman> |
|
3 |
<package> |
|
4 |
<group>es.upv.ai2</group><!-- requerido --> |
|
5 |
<artifact>buildman</artifact><!-- requerido --> |
|
6 |
<version>1.0-SNAPSHOT</version><!-- requerido --> |
|
7 |
<platform>all</platform><!-- no requerido pero se puede sobreescribir --> |
|
8 |
<compiler>all</compiler><!-- idem --> |
|
9 |
<arch>all</arch><!-- idem --> |
|
10 |
<libraryType>none</libraryType><!-- requerido --> |
|
11 |
|
|
12 |
<!-- upload no requerido si aparece entonces se debe de subir --> |
|
13 |
<!--<upload/> !--><!-- Esta opción usaría los valores por defecto --> |
|
14 |
<!--<upload> --><!-- Esta opción usaría los valores asignados abajo, no son requeridos y se puede sobreescribir solo algunos de ellos --> |
|
15 |
<!-- <sshserver>murray.ai2.upv.es</sshserver> --> |
|
16 |
<!-- <destdir>/projects/AI2/www-aliases/depman/</destdir> --> |
|
17 |
<!-- <username>depman</username> --> |
|
18 |
<!--</upload> --> |
|
19 |
</package> |
|
20 |
<dependencies platform="linux"> |
|
21 |
<!-- others platform same configuration --> |
|
22 |
<dependency> |
|
23 |
<group>org.openscenegraph</group> |
|
24 |
<artifact>openscenegraph</artifact> |
|
25 |
<version>2.2.0-SNAPSHOT</version> |
|
26 |
<compiler>gcc3</compiler> |
|
27 |
<type>dynamic</type> |
|
28 |
</dependency> |
|
29 |
<dependency> |
|
30 |
<group>jogl</group> |
|
31 |
<artifact>jogl</artifact> |
|
32 |
<version>1.1.0</version> |
|
33 |
<type>dynamic</type> |
|
34 |
</dependency> |
|
35 |
<dependency> |
|
36 |
<group>org.gdal</group> |
|
37 |
<artifact>gdal-gvsig</artifact> |
|
38 |
<version>1.10</version> |
|
39 |
<type>dynamic</type> |
|
40 |
</dependency> |
|
41 |
<dependency url="http://larry.ai2.upv.es:8080/~depman/" > |
|
42 |
<group>es.upv.ai2</group> |
|
43 |
<artifact>libjosg</artifact> |
|
44 |
<version>2.0-SNAPSHOT</version> |
|
45 |
<compiler>gcc3</compiler> |
|
46 |
<type>dynamic</type> |
|
47 |
</dependency> |
|
48 |
</dependencies> |
|
49 |
</depman> |
|
50 |
|
branches/v2_0_0_prep/build/buildman/doc/depman.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<depman> |
|
3 |
<package> |
|
4 |
<group>es.upv.ai2</group><!-- requerido --> |
|
5 |
<artifact>buildman</artifact><!-- requerido --> |
|
6 |
<version>1.0-SNAPSHOT</version><!-- requerido --> |
|
7 |
<libraryType>dynamic</libraryType><!-- requerido --> |
|
8 |
<!-- upload no requerido si aparece entonces se configura el servidor donde subir el paquete --> |
|
9 |
<upload> <!-- Esta opción usaría los valores asignados abajo, no son requeridos y se puede sobreescribir solo algunos de ellos --> |
|
10 |
<sshserver>larry.ai2.upv.es</sshserver> |
|
11 |
<destdir>public_html/</destdir> |
|
12 |
<username>depman</username> |
|
13 |
</upload> |
|
14 |
</package> |
|
15 |
<package platform="linux,mac"> |
|
16 |
<platform>all</platform><!-- no requerido pero se puede sobreescribir --> |
|
17 |
<compiler>gcc4</compiler><!-- idem --> |
|
18 |
<arch>all</arch><!-- idem --> |
|
19 |
</package> |
|
20 |
<package platform="win"> |
|
21 |
<compiler>vs7</compiler><!-- idem --> |
|
22 |
<arch>i386</arch><!-- idem --> |
|
23 |
</package> |
|
24 |
<dependencies platform="win"> |
|
25 |
<dependency> |
|
26 |
<group>org.openscenegraph</group> |
|
27 |
<artifact>openscenegraph</artifact> |
|
28 |
<version>2.2.0-SNAPSHOT</version> |
|
29 |
<type>dynamic</type> |
|
30 |
</dependency> |
|
31 |
<dependency> |
|
32 |
<group>org.gdal</group> |
|
33 |
<artifact>gdal</artifact> |
|
34 |
<version>1.2.6</version> |
|
35 |
<type>dynamic</type> |
|
36 |
<compiler>vs6</compiler> |
|
37 |
</dependency> |
|
38 |
<dependency> |
|
39 |
<group>jogl</group> |
|
40 |
<artifact>jogl</artifact> |
|
41 |
<version>1.1.0</version> |
|
42 |
<type>dynamic</type> |
|
43 |
<compiler>all</compiler> |
|
44 |
</dependency> |
|
45 |
|
|
46 |
</dependencies> |
|
47 |
<dependencies platform="linux"> |
|
48 |
<!-- others platform same configuration --> |
|
49 |
<dependency> |
|
50 |
<group>org.openscenegraph</group> |
|
51 |
<artifact>openscenegraph</artifact> |
|
52 |
<version>2.2.0-SNAPSHOT</version> |
|
53 |
<type>dynamic</type> |
|
54 |
</dependency> |
|
55 |
<dependency> |
|
56 |
<group>jogl</group> |
|
57 |
<artifact>jogl</artifact> |
|
58 |
<version>1.1.0</version> |
|
59 |
<type>dynamic</type> |
|
60 |
</dependency> |
|
61 |
<dependency> |
|
62 |
<group>org.gdal</group> |
|
63 |
<artifact>gdal-gvsig</artifact> |
|
64 |
<version>1.10</version> |
|
65 |
<type>dynamic</type> |
|
66 |
</dependency> |
|
67 |
<dependency url="http://larry.ai2.upv.es:8080/~depman/" > |
|
68 |
<group>es.upv.ai2</group> |
|
69 |
<artifact>libjosg</artifact> |
|
70 |
<version>2.0-SNAPSHOT</version> |
|
71 |
<type>dynamic</type> |
|
72 |
</dependency> |
|
73 |
</dependencies> |
|
74 |
<dependencies platform="mac"> |
|
75 |
<!-- others platform same configuration --> |
|
76 |
<dependency> |
|
77 |
<group>org.openscenegraph</group> |
|
78 |
<artifact>openscenegraph</artifact> |
|
79 |
<version>2.2.0-SNAPSHOT</version> |
|
80 |
<type>dynamic</type> |
|
81 |
<architecture>universal</architecture> |
|
82 |
</dependency> |
|
83 |
<dependency> |
|
84 |
<group>jogl</group> |
|
85 |
<artifact>jogl</artifact> |
|
86 |
<version>1.1.0</version> |
|
87 |
<type>dynamic</type> |
|
88 |
<compiler>all</compiler> |
|
89 |
</dependency> |
|
90 |
<!--dependency> |
|
91 |
<group>org.gdal</group> |
|
92 |
<artifact>gdal</artifact> |
|
93 |
<version>1.4.0</version> |
|
94 |
<type>framework</type> |
|
95 |
</dependency--> |
|
96 |
<dependency url="http://larry.ai2.upv.es:8080/~depman/" > |
|
97 |
<group>es.upv.ai2</group> |
|
98 |
<artifact>libjosg</artifact> |
|
99 |
<version>2.0-SNAPSHOT</version> |
|
100 |
<type>dynamic</type> |
|
101 |
<architecture>universal</architecture> |
|
102 |
</dependency> |
|
103 |
</dependencies> |
|
104 |
|
|
105 |
</depman> |
|
106 |
|
branches/v2_0_0_prep/build/buildman/doc/buildman.xml | ||
---|---|---|
1 |
<buildman> |
|
2 |
<goals platform="linux,mac"> |
|
3 |
<delete path="/tmp/osgVP" /> |
|
4 |
</goals> |
|
5 |
<goals platform="win"> |
|
6 |
<delete path="./osgVP" /> |
|
7 |
</goals> |
|
8 |
<goals> |
|
9 |
<svn option="co" url="https://josgplanets.ai2.upv.es/svn/josgplanets/trunk/libjni-osgvp" project-path="/tmp/osgVP" /> |
|
10 |
<clean all="False" /> |
|
11 |
<update file="/tmp/osgVP/build-scripts/depman.xml" /> |
|
12 |
</goals> |
|
13 |
<goals platform="linux,mac"> |
|
14 |
<create-solution project-path="/tmp/osgVP" generator="unix" install="/tmp/osgVP-install" /> |
|
15 |
<compile-solution project-path="/tmp/osgVP" project-name="libjosg" install="True" /> |
|
16 |
</goals> |
|
17 |
<goals platform="win"> |
|
18 |
<create-solution project-path="./osgVP" project-gen-path="./osgVP/CMake-VS7" generator="vs7" install="./osgVP-install" /> |
|
19 |
<compile-solution project-path="./osgVP" project-name="libjosg" project-gen-path="./osgVP/CMake-VS7" install="True" /> |
|
20 |
</goals> --> |
|
21 |
<goals platform="linux"> |
|
22 |
<create from-xml="/tmp/osgVP/build-scripts/depman.xml" path="/tmp/binaries/linux32" /> |
|
23 |
</goals> |
|
24 |
<goals platform="mac"> |
|
25 |
<create from-xml="/tmp/osgVP/build-scripts/depman.xml" path="/tmp/binaries/mac"/> |
|
26 |
</goals> |
|
27 |
<goals platform="win"> |
|
28 |
<create from-xml="./osgVP/build-scripts/depman.xml" path="./osgVP/binaries/win32" /> |
|
29 |
</goals> |
|
30 |
</buildman> |
branches/v2_0_0_prep/build/buildman/bin/bmn.py | ||
---|---|---|
1 |
#!/usr/bin/env python |
|
2 |
|
|
3 |
|
|
4 |
__authors__=["Rafael Gaitan <rgaitan@ai2.upv.es>","Pedro Jorquera <pjorquera@okode.com>","Enrique Medina <quiqueiii@gmail.com>"] |
|
5 |
__date__="30 Nov 2007" |
|
6 |
__copyright__="Copyright 2007 AI2/OKODE" |
|
7 |
__license__="GPL" |
|
8 |
__version__="1.0.0" |
|
9 |
__URL__="https://murray.ai2.upv.es/svn/buildman" |
|
10 |
|
|
11 |
import sys |
|
12 |
from bmcore import * |
|
13 |
|
|
14 |
#main |
|
15 |
def main(): |
|
16 |
|
|
17 |
arguments = ArgumentParser(sys.argv) |
|
18 |
arguments.getApplicationUsage().setDescription(arguments.getApplicationName() + "is a set of scripts to create automatic and continuous build systems") |
|
19 |
arguments.getApplicationUsage().addCommandLineOption("--help", "Gets this help") |
|
20 |
arguments.getApplicationUsage().addCommandLineOption("--help-all", "Gets the help for all existing tasks") |
|
21 |
arguments.getApplicationUsage().addCommandLineOption("--help-goal [goal]", "Gets the help for the given task") |
|
22 |
|
|
23 |
if len(sys.argv)<2: |
|
24 |
arguments.writeHelpMessages() |
|
25 |
return |
|
26 |
|
|
27 |
if arguments.read("--help"): |
|
28 |
arguments.writeHelpMessages() |
|
29 |
return |
|
30 |
|
|
31 |
help_goal = False |
|
32 |
help_all = False |
|
33 |
goal = [""] |
|
34 |
if arguments.read("--help-goal",goal): |
|
35 |
help_goal = True |
|
36 |
if arguments.read("--help-all"): |
|
37 |
help_all = True |
|
38 |
|
|
39 |
bmn = BuildMan(arguments) |
|
40 |
|
|
41 |
if help_goal: |
|
42 |
arguments.writeGoalHelpMessages(goal[0]) |
|
43 |
return |
|
44 |
|
|
45 |
if help_all: |
|
46 |
arguments.writeHelpMessages() |
|
47 |
return |
|
48 |
if arguments.errors(): |
|
49 |
arguments.writeErrorMessages() |
|
50 |
return |
|
51 |
|
|
52 |
if not bmn.run(): |
|
53 |
bmn.writeErrorMessages() |
|
54 |
|
|
55 |
|
|
56 |
if __name__ == '__main__': main() |
|
57 |
|
|
0 | 58 |
branches/v2_0_0_prep/build/buildman/bin/bmcore/ApplicationUsage.py | ||
---|---|---|
1 |
""" |
|
2 |
ApplicationUsage manage the options of the application |
|
3 |
and plugins. |
|
4 |
""" |
|
5 |
class ApplicationUsage: |
|
6 |
def __init__(self): |
|
7 |
self._applicationName = "" |
|
8 |
self._commandLineOptions = [] |
|
9 |
self._commandLineGoals = dict() |
|
10 |
self._commandLineGoalsDescriptions = dict() |
|
11 |
self._description = "" |
|
12 |
|
|
13 |
def setApplicationName(self,name): |
|
14 |
self._applicationName = name |
|
15 |
|
|
16 |
def getApplicationName(self): |
|
17 |
return self._applicationName |
|
18 |
|
|
19 |
def addCommandLineGoalOption(self,goal,option,description): |
|
20 |
self._commandLineGoals[goal].append((option,description)) |
|
21 |
|
|
22 |
def addCommandLineGoal(self,goal,description): |
|
23 |
self._commandLineGoals[goal] = [] |
|
24 |
self._commandLineGoalsDescriptions[goal] = description |
|
25 |
|
|
26 |
def addCommandLineOption(self,option,description): |
|
27 |
self._commandLineOptions.append((option,description)) |
|
28 |
|
|
29 |
def getCommandLineGoalDescription(self,goal): |
|
30 |
if goal in self._commandLineGoalsDescriptions: |
|
31 |
return self._commandLineGoalsDescriptions[goal] |
|
32 |
return None |
|
33 |
|
|
34 |
def getCommandLineGoals(self): |
|
35 |
return self._commandLineGoals |
|
36 |
|
|
37 |
def getCommandLineGoalOptions(self,goal): |
|
38 |
return self._commandLineGoals[goal] |
|
39 |
|
|
40 |
def getCommandLineOptionDescription(self,option): |
|
41 |
for v in self._commandLineOptions: |
|
42 |
(opt,desc) = v |
|
43 |
if opt == option: |
|
44 |
return desc |
|
45 |
return None |
|
46 |
|
|
47 |
def getCommandLineOptions(self): |
|
48 |
return self._commandLineOptions |
|
49 |
|
|
50 |
def setDescription(self, str): |
|
51 |
self._description = str |
|
52 |
|
|
53 |
def getDescription(self): |
|
54 |
return self._description |
|
55 |
|
|
56 |
|
branches/v2_0_0_prep/build/buildman/bin/bmcore/BuildMan.py | ||
---|---|---|
1 |
from bmbase.PlugInManager import PlugInManager |
|
2 |
|
|
3 |
""" |
|
4 |
BuildMan manages the loading of plugins and |
|
5 |
dispatch the requested tasks to the appropiate |
|
6 |
plug-in. Each plug-in defines its parameters and |
|
7 |
its help environment, so an ArgumentParse is |
|
8 |
necessary in the construction. |
|
9 |
""" |
|
10 |
class BuildMan: |
|
11 |
# constructor |
|
12 |
def __init__(self,arguments): |
|
13 |
self._arguments = arguments |
|
14 |
self._errorMessages = [] |
|
15 |
self.__configurePlugins(self._arguments) |
|
16 |
|
|
17 |
# configure arguments of the automatic loaded plugins |
|
18 |
def __configurePlugins(self, arguments): |
|
19 |
for plugin in PlugInManager().getPlugInInstances().values(): |
|
20 |
plugin.initArguments(arguments) |
|
21 |
for plugin in PlugInManager().getPlugInInstances().values(): |
|
22 |
plugin.init() |
|
23 |
if plugin.error(): |
|
24 |
self._errorMessages += plugin.getErrorMessages() |
|
25 |
|
|
26 |
# execute all plugins, any plugin with his arguments has the responsability of do the correct |
|
27 |
def run(self): |
|
28 |
for plugin in PlugInManager().getPlugInInstances().values(): |
|
29 |
plugin.run() |
|
30 |
if plugin.error(): |
|
31 |
self._errorMessages += plugin.getErrorMessages() |
|
32 |
return False |
|
33 |
return True |
|
34 |
|
|
35 |
|
|
36 |
def writeErrorMessages(self): |
|
37 |
for error in self._errorMessages: |
|
38 |
print "ERROR: " + error + "\n" |
|
39 |
|
|
40 |
|
|
41 |
|
branches/v2_0_0_prep/build/buildman/bin/bmcore/BMUtil.py | ||
---|---|---|
1 |
import os |
|
2 |
import os.path |
|
3 |
import zipfile |
|
4 |
import difflib |
|
5 |
import tarfile |
|
6 |
import md5 |
|
7 |
import urllib2 |
|
8 |
import sys |
|
9 |
import shutil |
|
10 |
import re |
|
11 |
|
|
12 |
class BMUtil: |
|
13 |
def buildmanPath(self): |
|
14 |
dr = os.getenv("BUILDMAN_PATH") |
|
15 |
if not dr is None: |
|
16 |
return dr |
|
17 |
if sys.platform == "linux2" or sys.platform == "linux1": |
|
18 |
dr = os.getenv("HOME")+os.path.sep+".buildman" |
|
19 |
if sys.platform == "win32" or sys.platform == "win64": |
|
20 |
#ex: c:\documents and setting\user\DepMan |
|
21 |
dr = os.getenv("USERPROFILE")+os.path.sep+"BuildMan" |
|
22 |
if sys.platform == "darwin": |
|
23 |
dr = os.path.sep + "Developer" + os.path.sep + "BuildMan" |
|
24 |
if dr is None: |
|
25 |
return None |
|
26 |
else: |
|
27 |
return dr |
|
28 |
|
|
29 |
def buildmanPlugInPath(self): |
|
30 |
dr = self.buildmanPath() |
|
31 |
if dr is None: |
|
32 |
return None |
|
33 |
else: |
|
34 |
return os.path.join(dr,'plugins') |
|
35 |
|
|
36 |
|
|
37 |
def mkdir(self,newdir): |
|
38 |
"""works the way a good mkdir should :) |
|
39 |
- already exists, silently complete |
|
40 |
- regular file in the way, raise an exception |
|
41 |
- parent directory(ies) does not exist, make them as well |
|
42 |
""" |
|
43 |
if os.path.isdir(newdir): |
|
44 |
pass |
|
45 |
elif os.path.isfile(newdir): |
|
46 |
raise OSError("a file with the same name as the desired " \ |
|
47 |
"dir, '%s', already exists." % newdir) |
|
48 |
else: |
|
49 |
head, tail = os.path.split(newdir) |
|
50 |
if head and not os.path.isdir(head): |
|
51 |
self.mkdir(head) |
|
52 |
if tail: |
|
53 |
os.mkdir(newdir) |
|
54 |
|
|
55 |
#recursively directory tree removing |
|
56 |
def rmdir(self,path): |
|
57 |
if not os.path.isdir(path): |
|
58 |
return |
|
59 |
|
|
60 |
shutil.rmtree(path) |
|
61 |
#files=os.listdir(path) |
|
62 |
|
|
63 |
#for x in files: |
|
64 |
# fullpath=os.path.join(path, x) |
|
65 |
|
|
66 |
# if os.path.isfile(fullpath): |
|
67 |
# os.remove(fullpath) |
|
68 |
|
|
69 |
# elif os.path.isdir(fullpath): |
|
70 |
# rmdir(fullpath) |
|
71 |
# os.rmdir(fullpath) |
|
72 |
|
|
73 |
|
|
74 |
def unzip(self,file, dir): |
|
75 |
mkdir(dir) |
|
76 |
zfobj = zipfile.ZipFile(open(file)) |
|
77 |
for name in zfobj.namelist(): |
|
78 |
if name.endswith('/'): |
|
79 |
mkdir(os.path.join(dir, name)) |
|
80 |
else: |
|
81 |
outfile = open(os.path.join(dir, name), 'wb') |
|
82 |
outfile.write(zfobj.read(name)) |
|
83 |
outfile.close() |
|
84 |
|
|
85 |
def targz(self,file, dir): |
|
86 |
cwd = os.getcwd() |
|
87 |
os.chdir(dir) |
|
88 |
dirs = os.listdir(".") |
|
89 |
if ".svn" in dirs: |
|
90 |
dirs.remove(".svn") |
|
91 |
if ".cvsignore" in dirs: |
|
92 |
dirs.remove(".cvsignore") |
|
93 |
tar = tarfile.open(str(file),"w|gz") |
|
94 |
for f in dirs: |
|
95 |
tar.add(f) |
|
96 |
tar.close() |
|
97 |
os.chdir(cwd) |
|
98 |
|
|
99 |
|
|
100 |
|
|
101 |
def untargz(self,file, dir): |
|
102 |
tar = tarfile.open(file) |
|
103 |
for tarinfo in tar: |
|
104 |
tar.extract(tarinfo,dir) |
|
105 |
tar.close() |
|
106 |
|
|
107 |
def untargzFiltered(self,file,dir,filter): |
|
108 |
filter=filter.replace("*","(\S)*") |
|
109 |
filter="^(\S)*"+filter+"$" |
|
110 |
#print "filter: ",filter |
|
111 |
tar = tarfile.open(file) |
|
112 |
for tarinfo in tar: |
|
113 |
if re.match(filter,tarinfo.name): |
|
114 |
print "[file] ",tarinfo.name |
|
115 |
tar.extract(tarinfo,dir) |
|
116 |
|
|
117 |
tar.close() |
|
118 |
|
|
119 |
def diff(self,f1name, f2name): |
|
120 |
try: |
|
121 |
f1 = open(f1name) |
|
122 |
f2 = open(f2name) |
|
123 |
a = f1.readlines(); f1.close() |
|
124 |
b = f2.readlines(); f2.close() |
|
125 |
for line in difflib.unified_diff(a, b): |
|
126 |
print line, |
|
127 |
if line != "": |
|
128 |
return True |
|
129 |
return False |
|
130 |
except: |
|
131 |
return True |
|
132 |
|
|
133 |
#creates the given fouput md5 file from the finput file |
|
134 |
def createMD5(self,finput,foutput): |
|
135 |
#input file |
|
136 |
file_in=open(finput,"rb") |
|
137 |
md5cpm=md5.new() |
|
138 |
|
|
139 |
while True: |
|
140 |
data = file_in.read(8096) |
|
141 |
if not data: |
|
142 |
break |
|
143 |
md5cpm.update(data) |
|
144 |
|
|
145 |
file_in.close() |
|
146 |
|
|
147 |
|
|
148 |
md5string=md5cpm.hexdigest() |
|
149 |
|
|
150 |
file_out=open(foutput,"w") |
|
151 |
file_out.write(md5string) |
|
152 |
file_out.close() |
|
153 |
|
|
154 |
|
|
155 |
|
|
156 |
def checkUrl(self,uri): |
|
157 |
try: |
|
158 |
fd=urllib2.urlopen(uri) |
|
159 |
fd.close() |
|
160 |
return True |
|
161 |
except: |
|
162 |
return False |
|
163 |
|
|
164 |
|
|
165 |
def download(self,uri,fout): |
|
166 |
try: |
|
167 |
fdes=urllib2.urlopen(uri) |
|
168 |
foutdes=open(fout,"wb") |
|
169 |
uinfo=fdes.info() |
|
170 |
size = uinfo.get('content-length') |
|
171 |
size=int(size) |
|
172 |
|
|
173 |
uristr=uri[uri.rfind("/")+1:] |
|
174 |
|
|
175 |
#lets read the file in 1kbyte blocks |
|
176 |
completed=0 |
|
177 |
x=completed*100/size |
|
178 |
tstr="* downloading ["+str(x)+" %] "+uristr |
|
179 |
sys.stdout.write(tstr) |
|
180 |
while True: |
|
181 |
block=fdes.read(1024) |
|
182 |
if not block: |
|
183 |
break |
|
184 |
foutdes.write(block) |
|
185 |
|
|
186 |
completed=completed+len(block) |
|
187 |
x=completed*100/size |
|
188 |
sys.stdout.write("\r") |
|
189 |
tstr="* downloading ["+str(x)+" %] "+uristr |
|
190 |
sys.stdout.write(tstr) |
|
191 |
#insert write op here |
|
192 |
|
|
193 |
foutdes.close() |
|
194 |
|
|
195 |
sys.stdout.write("\n") |
|
196 |
|
|
197 |
#print "* downloaded ",uri," [",size,"] bytes" |
|
198 |
return True |
|
199 |
except: |
|
200 |
return False |
|
201 |
|
|
202 |
|
branches/v2_0_0_prep/build/buildman/bin/bmcore/ArgumentParser.py | ||
---|---|---|
1 |
from ApplicationUsage import ApplicationUsage |
|
2 |
from bmbase.PlugInManager import PlugInManager |
|
3 |
|
|
4 |
|
|
5 |
""" |
|
6 |
ArgumentParser is a helper in the task of |
|
7 |
reading parameters from command line. |
|
8 |
""" |
|
9 |
class ArgumentParser: |
|
10 |
def __init__(self,argv): |
|
11 |
self._argv = argv |
|
12 |
self._argc = len(self._argv) |
|
13 |
self._error = False |
|
14 |
self._errorMessages = [] |
|
15 |
self._applicationUsage = ApplicationUsage() |
|
16 |
self._applicationUsage.setApplicationName(self.getApplicationName()) |
|
17 |
|
|
18 |
def errors(self): |
|
19 |
return self._error |
|
20 |
|
|
21 |
def writeErrorMessages(self): |
|
22 |
for error in self._errorMessages: |
|
23 |
print error + "\n" |
|
24 |
|
|
25 |
def writeGoalHelpMessages(self,goal): |
|
26 |
if goal in self._applicationUsage.getCommandLineGoals().keys(): |
|
27 |
print "Goal supported by " + str(PlugInManager().getPlugInInstanceByGoal(goal).__class__) + " plugin:" |
|
28 |
print goal + "\t" + self._applicationUsage.getCommandLineGoalDescription(goal) + "\n" |
|
29 |
for option,value in self._applicationUsage.getCommandLineGoalOptions(goal): |
|
30 |
print "\t" + option + "\t" + value + "\n" |
|
31 |
else: |
|
32 |
print "Goal `" + goal +"` not supported, try --help-all option" |
|
33 |
|
|
34 |
def writeHelpMessages(self): |
|
35 |
print "BuildMan options:" |
|
36 |
print "-----------------" + "\n" |
|
37 |
for option,value in self._applicationUsage.getCommandLineOptions(): |
|
38 |
print option + "\t" + value + "\n" |
|
39 |
if len(self._applicationUsage.getCommandLineGoals().keys())>0: |
|
40 |
print "Supported Goals:" |
|
41 |
print "----------------" + "\n" |
|
42 |
for goal in self._applicationUsage.getCommandLineGoals().keys(): |
|
43 |
print goal + "\t" + self._applicationUsage.getCommandLineGoalDescription(goal) + "\n" |
|
44 |
for option,value in self._applicationUsage.getCommandLineGoalOptions(goal): |
|
45 |
print "\t" + option + "\t" + value + "\n" |
|
46 |
|
|
47 |
def getApplicationUsage(self): |
|
48 |
return self._applicationUsage |
|
49 |
|
|
50 |
def getApplicationName(self): |
|
51 |
return self._argv[0] |
|
52 |
|
|
53 |
def isOption(self, str): |
|
54 |
return (len(str) > 1 and str[0]=='-') |
|
55 |
|
|
56 |
def argc(self): |
|
57 |
return self._argc |
|
58 |
|
|
59 |
def argv(self): |
|
60 |
return self._argv |
|
61 |
|
|
62 |
def find(self,str): |
|
63 |
for pos in range(1,self._argc): |
|
64 |
if str == self._argv[pos]: |
|
65 |
return pos |
|
66 |
return 0 |
|
67 |
|
|
68 |
def match(self,pos,str): |
|
69 |
return (pos<self._argc and str==self._argv[pos]) |
|
70 |
|
|
71 |
def containsOptions(self): |
|
72 |
for op in self._argv: |
|
73 |
if self.isOption(op): |
|
74 |
return True |
|
75 |
return False |
|
76 |
|
|
77 |
def remove(self,pos,num): |
|
78 |
if num==0: return |
|
79 |
removeList = [] |
|
80 |
for i in range(pos,pos+num): |
|
81 |
removeList.append(self._argv[i]) |
|
82 |
for r in removeList: |
|
83 |
self._argv.remove(r) |
|
84 |
self._argc-=num |
|
85 |
|
|
86 |
|
|
87 |
def read(self,str,values=[]): |
|
88 |
pos = self.find(str) |
|
89 |
if pos<=0: |
|
90 |
return False |
|
91 |
if len(values)==0: |
|
92 |
self.remove(pos,1) |
|
93 |
return True |
|
94 |
return self.__read(pos,str,values) |
|
95 |
|
|
96 |
def __read(self,pos,str,values): |
|
97 |
if self.match(pos,str): |
|
98 |
if pos+len(values)<self._argc: |
|
99 |
inc = 1 |
|
100 |
for i in range(len(values)): |
|
101 |
values[i] = self._argv[pos+inc] |
|
102 |
inc+=1 |
|
103 |
self.remove(pos,len(values)+1) |
|
104 |
return True |
|
105 |
self.__reportError("argument to `"+str+"` is missing") |
|
106 |
return False |
|
107 |
return False |
|
108 |
|
|
109 |
def __reportError(self, str): |
|
110 |
self._error = True |
|
111 |
self._errorMessages.append(str) |
branches/v2_0_0_prep/build/buildman/bin/bmcore/__init__.py | ||
---|---|---|
1 |
""" |
|
2 |
Main modules of the Build Manteinance Tool |
|
3 |
""" |
|
4 |
__version__="1.0.0" |
|
5 |
|
|
6 |
from ArgumentParser import ArgumentParser |
|
7 |
from BuildMan import BuildMan |
|
8 |
from ApplicationUsage import ApplicationUsage |
|
9 |
from BMUtil import BMUtil |
|
10 |
|
branches/v2_0_0_prep/build/buildman/bin/bmbase/PlugInManager.py | ||
---|---|---|
1 |
""" |
|
2 |
PlugInManager is a singleton class that manages |
|
3 |
plugininstances, and register methods. Each |
|
4 |
plugin should call to register itself |
|
5 |
""" |
|
6 |
class PlugInManager: |
|
7 |
_pluginInstances = {} |
|
8 |
|
|
9 |
def registerPlugIn(self, id, pluginInstance): |
|
10 |
PlugInManager._pluginInstances[id] = pluginInstance |
|
11 |
pluginInstance.setId(id) |
|
12 |
|
|
13 |
def getPlugInInstances(self): |
|
14 |
return PlugInManager._pluginInstances |
|
15 |
|
|
16 |
def getPlugInInstance(self,id): |
|
17 |
return PlugInManager._pluginInstances[id] |
|
18 |
|
|
19 |
def getPlugInInstanceByGoal(self,goal): |
|
20 |
for plugin in PlugInManager._pluginInstances.values(): |
|
21 |
if goal in plugin.getGoals().keys(): |
|
22 |
return plugin |
|
23 |
return None |
|
24 |
|
|
25 |
def supportedGoals(self): |
|
26 |
goals = [] |
|
27 |
for plugin in PlugInManager._pluginInstances.values(): |
|
28 |
for g in plugin.getGoals().keys(): |
|
29 |
goals.append(g) |
|
30 |
return goals |
|
31 |
|
|
32 |
#loading plugins |
|
33 |
from bmplugins import * |
|
34 |
|
|
35 |
|
branches/v2_0_0_prep/build/buildman/bin/bmbase/__init__.py | ||
---|---|---|
1 |
""" |
|
2 |
Bases classes to extend and create new plugins |
|
3 |
""" |
|
4 |
|
branches/v2_0_0_prep/build/buildman/bin/bmbase/IPlugIn.py | ||
---|---|---|
1 |
from xml.dom import minidom |
|
2 |
|
|
3 |
''' |
|
4 |
Defines a interface for plugins |
|
5 |
''' |
|
6 |
class IPlugIn: |
|
7 |
def __init__(self): |
|
8 |
self._errorMessages = [] |
|
9 |
self._error = False |
|
10 |
self._id = "" |
|
11 |
self._goals = dict() |
|
12 |
self._arguments = None |
|
13 |
self._execute = False |
|
14 |
|
|
15 |
def initArguments(self,arguments): |
|
16 |
self._arguments = arguments |
|
17 |
|
|
18 |
def init(self): |
|
19 |
pass |
|
20 |
|
|
21 |
def initFromXML(self,node): |
|
22 |
pass |
|
23 |
|
|
24 |
def execute(self): |
|
25 |
pass |
|
26 |
|
|
27 |
def loadXMLFile(self,xmlfile): |
|
28 |
xmldoc=minidom.parse(xmlfile) |
|
29 |
node = xmldoc.firstChild |
|
30 |
self.initFromXML(node) |
|
31 |
|
|
32 |
def getExecute(self): |
|
33 |
return self._execute |
|
34 |
|
|
35 |
def setExecute(self,value): |
|
36 |
self._execute = value |
|
37 |
|
|
38 |
def run(self): |
|
39 |
if self._execute: |
|
40 |
self.execute() |
|
41 |
|
|
42 |
|
|
43 |
def reportError(self,s): |
|
44 |
self._errorMessages.append(str(self.__class__)+":"+s) |
|
45 |
self._error = True |
|
46 |
|
|
47 |
def error(self): |
|
48 |
return self._error |
|
49 |
|
|
50 |
def getErrorMessages(self): |
|
51 |
return self._errorMessages |
|
52 |
|
|
53 |
def setId(self,id): |
|
54 |
self._id = id |
|
55 |
|
|
56 |
def getId(self): |
|
57 |
return self._id |
|
58 |
|
|
59 |
def addGoal(self,goal,description): |
|
60 |
self._goals[goal] = [] |
|
61 |
self._arguments.getApplicationUsage().addCommandLineGoal(goal,description) |
|
62 |
|
|
63 |
def addGoalOption(self,goal,option,description): |
|
64 |
self._goals[goal].append(option) |
|
65 |
self._arguments.getApplicationUsage().addCommandLineGoalOption(goal,option,description) |
|
66 |
|
|
67 |
def getGoals(self): |
|
68 |
return self._goals |
|
69 |
|
branches/v2_0_0_prep/build/buildman/bin/bmplugins/DepManGetPlugIn.py | ||
---|---|---|
1 |
from bmbase.IPlugIn import IPlugIn |
|
2 |
from bmbase.PlugInManager import PlugInManager |
|
3 |
from bmcore.BMUtil import BMUtil |
|
4 |
from xml.dom import minidom |
|
5 |
import os |
|
6 |
|
|
7 |
class DepManGetPlugIn(IPlugIn): |
|
8 |
def __init__(self): |
|
9 |
IPlugIn.__init__(self) |
|
10 |
self._default_repository = "" |
|
11 |
self._url = "" |
|
12 |
self._group = "" |
|
13 |
self._artifact = "" |
|
14 |
self._version = "" |
|
15 |
self._platform = "" |
|
16 |
self._distribution = "" |
|
17 |
self._artifact = "" |
|
18 |
self._compiler = "" |
|
19 |
self._arch = "" |
|
20 |
self._ltype = "" |
|
21 |
self._forceCache = False |
|
22 |
self._isInteractive = True |
|
23 |
|
|
24 |
def setURL(self,url): |
|
25 |
self._url = url |
|
26 |
|
|
27 |
def setGroup(self,group): |
|
28 |
self._group = group |
|
29 |
|
|
30 |
def setArtifact(self,artifact): |
|
31 |
self._artifact = artifact |
|
32 |
|
|
33 |
def setVersion(self,version): |
|
34 |
self._version = version |
|
35 |
|
|
36 |
def setPlatform(self,platform): |
|
37 |
self._platform = platform |
|
38 |
|
|
39 |
def setDistribution(self,distribution): |
|
40 |
self._distribution = distribution |
|
41 |
|
|
42 |
def setCompiler(self,compiler): |
|
43 |
self._compiler = compiler |
|
44 |
|
|
45 |
def setArch(self,arch): |
|
46 |
self._arch = arch |
|
47 |
|
|
48 |
def setLibraryType(self,ltype): |
|
49 |
self._ltype = ltype |
|
50 |
|
|
51 |
def setForceCache(self): |
|
52 |
self._forceCache = True |
|
53 |
self._isInteractive = False |
|
54 |
|
|
55 |
def setForceRemote(self): |
|
56 |
self._forceCache = False |
|
57 |
self._isInteractive = False |
|
58 |
|
|
59 |
def init(self): |
|
60 |
self.addGoal("get", "downloads an artifact if not in cache.") |
|
61 |
self.addGoalOption("get","--url", "URL base for the DepMan repository.") |
|
62 |
self.addGoalOption("get","--group", "Group namespace of the artifact.") |
|
63 |
self.addGoalOption("get","--artifact", "Name of the artifact to download.") |
|
64 |
self.addGoalOption("get","--version", "Version of the artifact.") |
|
65 |
self.addGoalOption("get","--platform", "Platform of the artifact.") |
|
66 |
self.addGoalOption("get","--distribution", "Distribution of the artifact.") |
|
67 |
self.addGoalOption("get","--compiler", "Selects the compiler version that was used to compile the artifact.") |
|
68 |
self.addGoalOption("get","--arch", "Selects the architecture of the artifact.") |
|
69 |
self.addGoalOption("get","--ltype", "Type of library of the artifact.") |
|
70 |
self.addGoalOption("get","--cache", "Forces the use of cache files without asking.") |
|
71 |
self.addGoalOption("get","--remote", "Forces the download of remote without the use of the cache and without asking.") |
|
72 |
|
|
73 |
self._dmplugin = PlugInManager().getPlugInInstance("DepManPlugIn") |
|
74 |
if self._dmplugin == None: |
|
75 |
self.reportError("PlugIn `depman` not found") |
|
76 |
return |
|
77 |
self._default_repository = self._dmplugin.getDepManPath() |
|
78 |
|
|
79 |
isGet = False |
|
80 |
while self._arguments.read("get"): |
|
81 |
isGet = True |
|
82 |
|
|
83 |
if not isGet: |
|
84 |
return |
|
85 |
|
|
86 |
args=[""] |
|
87 |
if self._arguments.read("--url",args): |
|
88 |
self._url = args[0] |
|
89 |
|
|
90 |
args=[""] |
|
91 |
if self._arguments.read("--group",args): |
|
92 |
self._group = args[0] |
|
93 |
|
|
94 |
args=[""] |
|
95 |
if self._arguments.read("--artifact",args): |
|
96 |
self._artifact = args[0] |
|
97 |
|
|
98 |
args=[""] |
|
99 |
if self._arguments.read("--version",args): |
|
100 |
self._version = args[0] |
|
101 |
|
|
102 |
args=[""] |
|
103 |
if self._arguments.read("--platform",args): |
|
104 |
self._platform = args[0] |
|
105 |
|
|
106 |
args=[""] |
|
107 |
if self._arguments.read("--distribution",args): |
|
108 |
self._distribution = args[0] |
|
109 |
|
|
110 |
args=[""] |
|
111 |
if self._arguments.read("--compiler",args): |
|
112 |
self._compiler = args[0] |
|
113 |
|
|
114 |
args=[""] |
|
115 |
if self._arguments.read("--arch",args): |
|
116 |
self._arch = args[0] |
|
117 |
|
|
118 |
args=[""] |
|
119 |
if self._arguments.read("--ltype",args): |
|
120 |
self._ltype = args[0] |
|
121 |
|
|
122 |
if self._arguments.read("--cache"): |
|
123 |
self._forceCache = True |
|
124 |
self._isInteractive = False |
|
125 |
|
|
126 |
if self._arguments.read("--remote"): |
|
127 |
self._forceCache = False |
|
128 |
self._isInteractive = False |
|
129 |
|
|
130 |
self.setExecute(True) |
|
131 |
|
|
132 |
|
|
133 |
def initFromXML(self,node): |
|
134 |
pass |
|
135 |
#TODO: . . . |
|
136 |
|
|
137 |
def execute(self): |
|
138 |
print "Executing Plugin:" + str(self.__class__) |
|
139 |
if self._url == "": |
|
140 |
self.reportError("Missing url option") |
|
141 |
return |
|
142 |
if self._artifact == "": |
|
143 |
self.reportError("Missing artifact option") |
|
144 |
return |
|
145 |
if self._group == "": |
|
146 |
self.reportError("Missing group option") |
|
147 |
return |
|
148 |
if self._version == "": |
|
149 |
self.reportError("Missing version option") |
|
150 |
return |
|
151 |
if self._platform == "": |
|
152 |
self.reportError("Missing platform option") |
|
153 |
return |
|
154 |
if self._platform!="all": |
|
155 |
if self._distribution == "": |
|
156 |
self.reportError("Missing distribution option") |
|
157 |
return |
|
158 |
if self._compiler == "": |
|
159 |
self.reportError("Missing compiler option") |
|
160 |
return |
|
161 |
if self._arch == "": |
|
162 |
self.reportError("Missing artifact option") |
|
163 |
return |
|
164 |
if self._ltype == "": |
|
165 |
self.reportError("Missing library type option") |
|
166 |
return |
|
167 |
|
|
168 |
|
|
169 |
if self._platform not in self._dmplugin.getSupportedPlatforms(): |
|
170 |
self.reportError("* Platform not supported: " + self._platform) |
|
171 |
return |
|
172 |
|
|
173 |
if self._platform!="all": |
|
174 |
|
|
175 |
if self._compiler not in self._dmplugin.getSupportedCompilers(): |
|
176 |
self.reportError("* Compiler not supported: "+ self._compiler) |
|
177 |
return |
|
178 |
|
|
179 |
if self._arch not in self._dmplugin.getSupportedArchs(): |
|
180 |
self.reportError("* Architecture not supported: "+ self._arch) |
|
181 |
return |
|
182 |
|
|
183 |
if self._ltype not in self._dmplugin.getSupportedLibraryTypes(): |
|
184 |
self.reportError("* Library type not supported: " + self._ltype) |
|
185 |
return |
|
186 |
|
|
187 |
if self._platform!=self._dmplugin.getOSPlatform() and self._platform!="all": |
|
188 |
print "* Warning: Forced platform ",self._platform |
|
189 |
return self.get() |
|
190 |
|
|
191 |
def get(self, unPackList = None): |
|
192 |
#transform namespaces org.foo to org/foo |
|
193 |
group=self._group.replace(".","/") |
|
194 |
|
|
195 |
print "[",self._artifact,"]" |
|
196 |
|
|
197 |
file_name=self._artifact+"-"+self._version+"-"+self._platform |
|
198 |
if self._platform!="all": |
|
199 |
file_name=file_name+"-"+self._distribution+"-"+self._compiler+"-"+self._arch+"-"+self._ltype |
|
200 |
tarname=file_name+".tar.gz" |
|
201 |
md5name=tarname+".md5" |
|
202 |
|
|
203 |
download_path = group+os.path.sep+self._artifact+os.path.sep+self._version+os.path.sep+self._platform+os.path.sep+self._compiler+os.path.sep+self._arch+os.path.sep+self._ltype |
|
204 |
if self._platform!="all": |
|
205 |
download_path = download_path+os.path.sep+self._distribution+os.path.sep+self._compiler+os.path.sep+self._arch+os.path.sep+self._ltype |
|
206 |
|
|
207 |
download_dir = group+"/"+self._artifact+"/"+self._version+"/"+self._platform |
|
208 |
if self._platform!="all": |
|
209 |
download_dir = download_dir+"/"+self._distribution+"/"+self._compiler+"/"+self._arch+"/"+self._ltype |
|
210 |
|
|
211 |
cache_path = self._default_repository+os.path.sep+".cache"+os.path.sep+download_path |
|
212 |
|
|
213 |
|
|
214 |
tstr=self._version.lower() |
|
215 |
if tstr.find("snapshot")!=-1: |
|
216 |
is_snapshot=True |
|
217 |
else: |
|
218 |
is_snapshot=False |
|
219 |
|
|
220 |
dmutil = BMUtil() |
|
221 |
|
|
222 |
is_tar=True |
|
223 |
is_md5=True |
|
224 |
if not dmutil.checkUrl(self._url+"/"+download_dir+"/"+md5name): |
|
225 |
#print "Error: File ",baseurl+"/"+download_dir+"/"+md5name, " not found in the repository" |
|
226 |
is_md5=False |
|
227 |
|
|
228 |
if not dmutil.checkUrl(self._url+"/"+download_dir+"/"+tarname): |
|
229 |
#print "Error: File ",baseurl+"/"+download_dir+"/"+tarname, " not found in the repository" |
|
230 |
is_tar=False |
|
231 |
|
|
232 |
dmutil.mkdir(cache_path) |
|
233 |
|
|
234 |
|
|
235 |
if not os.path.isfile(cache_path+os.path.sep+md5name): |
|
236 |
is_cache=False |
|
237 |
else: |
|
238 |
is_cache=True |
|
239 |
|
|
240 |
#Once all variables have been collected, lets decide what to do with the artifact |
|
241 |
must_download=False |
|
242 |
|
|
243 |
if (not is_md5 or not is_tar) and not is_cache: |
|
244 |
print "Error: Artifact ",tarname," not found" |
|
245 |
return False |
|
246 |
|
|
247 |
if not is_md5 and not is_tar and is_cache: |
|
248 |
print "* file not found in repository, using cache..." |
|
249 |
must_download=False |
|
250 |
|
|
251 |
if is_md5 and is_tar and not is_cache: |
|
252 |
print "* file is not in cache, downloading..." |
|
253 |
must_download=True |
|
254 |
|
|
255 |
if is_md5 and is_tar and is_cache: |
|
256 |
if is_snapshot: |
|
257 |
if self._isInteractive: |
|
258 |
repo=raw_input("What snapshot do you want to use? (cache/remote): ") |
|
259 |
else: |
|
260 |
if self._forceCache: |
|
261 |
repo="cache" |
|
262 |
else: |
|
263 |
repo="remote" |
|
264 |
|
|
265 |
must_download=False |
|
266 |
|
|
267 |
#in case of misspeling, using cache by default |
|
268 |
if repo!="cache" and repo!="remote": |
|
269 |
repo="cache" |
|
270 |
else: |
|
271 |
repo="remote" |
|
272 |
|
|
273 |
if repo=="remote": |
|
274 |
print "* file cached, checking md5..." |
|
275 |
dmutil.download(self._url+"/"+download_dir+"/"+md5name,cache_path+os.path.sep+md5name+".new") |
|
276 |
|
|
277 |
if dmutil.diff(cache_path+os.path.sep+md5name,cache_path+os.path.sep+md5name+".new"): |
|
278 |
print "* no md5 matching, re-downloading..." |
|
279 |
must_download=True |
|
280 |
else: |
|
281 |
print "* md5 matching succesful" |
|
282 |
must_download=False |
|
283 |
os.remove(cache_path+os.path.sep+md5name+".new") |
|
284 |
|
|
285 |
if must_download==True: |
|
286 |
print "URL :", self._url |
|
287 |
dmutil.download(self._url+"/"+download_dir+"/"+md5name,cache_path+os.path.sep+md5name) |
|
288 |
#print "* downloaded [",md5name,"]" |
|
289 |
dmutil.download(self._url+"/"+download_dir+"/"+tarname,cache_path+os.path.sep+tarname) |
|
290 |
#print "* downloaded[",tarname,"]" |
|
291 |
if unPackList != None: |
|
292 |
if (cache_path+os.path.sep+tarname) not in unPackList: |
|
293 |
unPackList.append(cache_path+os.path.sep+tarname) |
|
294 |
|
|
295 |
return True |
|
296 |
|
|
297 |
PlugInManager().registerPlugIn("DepManGetPlugIn",DepManGetPlugIn()) |
|
298 |
|
|
299 |
|
branches/v2_0_0_prep/build/buildman/bin/bmplugins/DepManPlugIn.py | ||
---|---|---|
1 |
from bmbase.IPlugIn import IPlugIn |
|
2 |
from bmbase.PlugInManager import PlugInManager |
|
3 |
from bmcore.BMUtil import BMUtil |
|
4 |
from xml.dom import minidom |
|
5 |
import os |
|
6 |
import sys |
|
7 |
|
|
8 |
class DepManPlugIn(IPlugIn): |
|
9 |
def __init__(self): |
|
10 |
IPlugIn.__init__(self) |
|
11 |
self._depmanDataPath = sys.path[0]+os.path.sep+".."+os.path.sep+"plugins-data"+os.path.sep+"depman" |
|
12 |
self._supportedPlatforms = ["all","mac","linux","win"] |
|
13 |
self._supportedArchs = ["all","i386","ppc","ppc64","x86_64","universal"] |
|
14 |
self._supportedLibraryTypes = ["none","dynamic","static","framework"] |
|
15 |
self._supportedCompilers = ["all","vs6","vs7","vs8","gcc3","gcc4"] |
|
16 |
#tries to guess host OS values |
|
17 |
self._osplatform="unknown" |
|
18 |
self._osdistribution="unknown" |
|
19 |
self._osarch="unknown" |
|
20 |
self._oscompiler="unknown" |
|
21 |
if sys.platform=="darwin": |
|
22 |
self._osplatform="mac" |
|
23 |
self._osarch="universal" |
|
24 |
self._oscompiler="gcc4" |
|
25 |
elif sys.platform == "linux2" or sys.platform == "linux1": |
|
26 |
self._osplatform="linux" |
|
27 |
self._osarch="i386" |
|
28 |
self._oscompiler="gcc4" |
|
29 |
elif sys.platform == "win32" or sys.platform == "win64": |
|
30 |
self._osplatform="win" |
|
31 |
self._osarch="i386" |
|
32 |
self._oscompiler="vs8" |
|
33 |
|
|
34 |
def init(self): |
|
35 |
pass |
|
36 |
|
|
37 |
def initFromXML(self,node): |
|
38 |
pass |
|
39 |
|
|
40 |
def execute(self): |
|
41 |
pass |
|
42 |
|
|
43 |
def getSupportedPlatforms(self): |
|
44 |
return self._supportedPlatforms |
|
45 |
|
|
46 |
def getSupportedArchs(self): |
|
47 |
return self._supportedArchs |
|
48 |
|
|
49 |
def getSupportedLibraryTypes(self): |
|
50 |
return self._supportedLibraryTypes |
|
51 |
|
|
52 |
def getSupportedCompilers(self): |
|
53 |
return self._supportedCompilers |
|
54 |
|
|
55 |
def getOSPlatform(self): |
|
56 |
return self._osplatform |
|
57 |
|
|
58 |
def getOSDistribution(self): |
|
59 |
return self._osdistribution |
|
60 |
|
|
61 |
def getOSArch(self): |
|
62 |
return self._osarch |
|
63 |
|
|
64 |
def getOSCompiler(self): |
|
65 |
return self._oscompiler |
|
66 |
|
|
67 |
def getDepManPath(self): |
|
68 |
dr = os.getenv("DEPMAN_REPO") |
|
69 |
if not dr is None: |
|
70 |
return dr; |
|
71 |
if sys.platform == "linux2" or sys.platform == "linux1": |
|
72 |
dr = os.getenv("HOME")+os.path.sep+".depman" |
|
73 |
return dr; |
|
74 |
if sys.platform == "win32" or sys.platform == "win64": |
|
75 |
#ex: c:\documents and setting\user\DepMan |
|
76 |
dr = os.getenv("USERPROFILE")+os.path.sep+"DepMan" |
|
77 |
return dr; |
|
78 |
if sys.platform == "darwin": |
|
79 |
dr = os.path.sep + "Developer" + os.path.sep + "DepMan" |
|
80 |
return dr; |
|
81 |
return None |
|
82 |
|
|
83 |
def getDepManDataPath(self): |
|
84 |
return self._depmanDataPath |
|
85 |
|
|
86 |
PlugInManager().registerPlugIn("DepManPlugIn",DepManPlugIn()) |
|
87 |
|
|
88 |
|
branches/v2_0_0_prep/build/buildman/bin/bmplugins/CompileSolutionPlugIn.py | ||
---|---|---|
1 |
from bmbase.IPlugIn import IPlugIn |
|
2 |
from bmbase.PlugInManager import PlugInManager |
|
3 |
from bmcore.BMUtil import BMUtil |
|
4 |
import os |
|
5 |
import sys |
|
6 |
|
|
7 |
class CompileSolutionPlugIn(IPlugIn): |
|
8 |
def __init__(self): |
|
9 |
IPlugIn.__init__(self) |
|
10 |
self._targetType = "Release" # only vs7/vs8 compilers |
|
11 |
self._projectPath = "" |
|
12 |
self._install = False |
|
13 |
self._projectName = "" |
|
14 |
self._projectGenerationPath = "" |
|
15 |
self._supportedCompilers = dict() |
|
16 |
self._supportedCompilers["vs8"]="devenv.exe" |
|
17 |
self._supportedCompilers["vs7"]="devenv.exe" |
|
18 |
self._supportedCompilers["gcc4"]="make" |
|
19 |
self._supportedCompilers["gcc3"]="make" |
|
20 |
self._compiler = "" |
|
21 |
|
|
22 |
|
|
23 |
def init(self): |
|
24 |
self.addGoal("compile-solution", "Compiles the solution based on Makefiles or VisualStudio for Win/Linux/Mac") |
|
25 |
self.addGoalOption("compile-solution", "--project-path", "sets the path of the project.") |
|
26 |
self.addGoalOption("compile-solution", "--project-gen-path", "sets the path of the Makefiles/VS build files. Default: ${project-path}/BMCMake") |
|
27 |
self.addGoalOption("compile-solution", "--project-name", "sets the name of the project. If not given it uses the name of the project directory.") |
|
28 |
self.addGoalOption("compile-solution", "--install", "Executes target install after compilation.") |
|
29 |
self.addGoalOption("compile-solution", "--compiler", "Forces the compiler. If not try to determine using current platform\n" + |
|
30 |
"Supported Compilers:\n" + |
|
31 |
str(self._supportedCompilers)) |
|
32 |
execute = False |
|
33 |
if self._arguments.read("compile-solution"): |
|
34 |
execute = True |
|
35 |
if execute: |
|
36 |
args = [""] |
|
37 |
if self._arguments.read("--project-path", args): |
|
38 |
self._projectPath=args[0] |
|
39 |
|
|
40 |
args = [""] |
|
41 |
if self._arguments.read("--project-gen-path", args): |
|
42 |
self._projectGenerationPath=args[0] |
|
43 |
|
|
44 |
args = [""] |
|
45 |
if self._arguments.read("--project-name", args): |
|
46 |
self._projectName=args[0] |
|
47 |
|
|
48 |
args = [""] |
|
49 |
if self._arguments.read("--compiler", args): |
|
50 |
if args[0] in self._supportedCompilers: |
|
51 |
self._compiler=args[0] |
|
52 |
|
|
53 |
if self._arguments.read("--install"): |
|
54 |
self._install=True |
|
55 |
|
|
56 |
self.setExecute(True) |
|
57 |
|
|
58 |
def initFromXML(self, node): |
|
59 |
if node.localName=="compile-solution": |
|
60 |
if node.hasAttributes(): |
|
61 |
if node.attributes.has_key("project-path"): |
|
62 |
self._projectPath = node.attributes.get("project-path").value |
|
63 |
if node.attributes.has_key("project-gen-path"): |
|
64 |
self._projectGenerationPath = node.attributes.get("project-gen-path").value |
|
65 |
if node.attributes.has_key("project-name"): |
|
66 |
self._projectName = node.attributes.get("project-name").value |
|
67 |
if node.attributes.has_key("compiler"): |
|
68 |
value = node.attributes.get("compiler").value |
|
69 |
if args[0] in self._supportedCompilers: |
|
70 |
self._compiler = value |
|
71 |
if node.attributes.has_key("install"): |
|
72 |
value = node.attributes.get("install").value |
|
73 |
if value == "True" or value == "true": |
|
74 |
self._install = True |
|
75 |
|
|
76 |
def execute(self): |
|
77 |
dmplugin = PlugInManager().getPlugInInstance("DepManPlugIn") |
|
78 |
if dmplugin == None: |
|
79 |
self.reportError("DepMan PlugIn not found") |
|
80 |
return False |
|
81 |
if self._projectPath=="": |
|
82 |
self.reportError("Missing required project path option") |
|
83 |
return False |
|
84 |
|
|
85 |
self._projectPath = os.path.abspath(self._projectPath) |
|
86 |
if self._compiler=="": |
|
87 |
self._compiler = dmplugin.getOSCompiler() |
|
88 |
|
|
89 |
if self._projectName == "": |
|
90 |
self._projectName = os.path.basename(self._projectPath) |
|
91 |
|
|
92 |
if self._projectGenerationPath == "": |
|
93 |
self._projectGenerationPath = os.path.join(self._projectPath, "BMCMake") |
|
94 |
else: |
|
95 |
self._projectGenerationPath = os.path.abspath(self._projectGenerationPath) |
|
96 |
|
|
97 |
print "Executing Plugin:" + str(self.__class__) |
|
98 |
platform = dmplugin.getOSPlatform() |
|
99 |
if platform == "linux" or platform == "mac": |
|
100 |
self.__executeUnix() |
|
101 |
else: |
|
102 |
self.__executeVS() |
|
103 |
return True |
|
104 |
|
|
105 |
def __executeUnix(self): |
|
106 |
#make install |
|
107 |
print "CPUs Detected:" + str(self.__cpuCount()) |
|
108 |
cmdCompiler = self._supportedCompilers[self._compiler] + " -j"+str(self.__cpuCount()) |
|
109 |
if self._install: |
|
110 |
cmdCompiler += " install" |
|
111 |
olddir = os.getcwd() |
|
112 |
os.chdir(self._projectGenerationPath) |
|
113 |
os.system(cmdCompiler) |
|
114 |
os.chdir(olddir) |
|
115 |
|
|
116 |
def __executeVS(self): |
|
117 |
#devenv.exe /build Release /project INSTALL ../CMake/libjosg.sln |
|
118 |
cmdCompiler = self._supportedCompilers[self._compiler] |
|
119 |
cmdCompiler += " " + self._projectName + ".sln" |
|
120 |
cmdCompiler += " /build Release" |
|
121 |
if self._install: |
|
122 |
cmdCompiler += " /project INSTALL" |
|
123 |
else: |
|
124 |
cmdCompiler += " /project ALL_BUILD" |
|
125 |
olddir = os.getcwd() |
|
126 |
os.chdir(self._projectGenerationPath) |
|
127 |
os.system(cmdCompiler) |
|
128 |
os.chdir(olddir) |
|
129 |
|
|
130 |
def __cpuCount(self): |
|
131 |
''' |
|
132 |
Returns the number of CPUs in the system |
|
133 |
''' |
|
134 |
if sys.platform == 'win32': |
|
135 |
try: |
|
136 |
num = int(os.environ['NUMBER_OF_PROCESSORS']) |
|
137 |
except (ValueError, KeyError): |
|
138 |
pass |
|
139 |
elif sys.platform == 'darwin': |
|
140 |
try: |
|
141 |
num = int(os.popen('sysctl -n hw.ncpu').read()) |
|
142 |
except ValueError: |
|
143 |
pass |
|
144 |
else: |
|
145 |
try: |
|
146 |
num = os.sysconf('SC_NPROCESSORS_ONLN') |
|
147 |
except (ValueError, OSError, AttributeError): |
|
148 |
pass |
|
149 |
|
|
150 |
if num >= 1: |
|
151 |
return num |
|
152 |
return 1 |
|
153 |
|
|
154 |
|
|
155 |
PlugInManager().registerPlugIn("CompileSolutionPlugIn", CompileSolutionPlugIn()) |
|
156 |
|
|
157 |
|
branches/v2_0_0_prep/build/buildman/bin/bmplugins/SVNPlugIn.py | ||
---|---|---|
1 |
from bmbase.IPlugIn import IPlugIn |
|
2 |
from bmbase.PlugInManager import PlugInManager |
|
3 |
from bmcore.BMUtil import BMUtil |
|
4 |
import os |
|
5 |
|
|
6 |
class SVNPlugIn(IPlugIn): |
|
7 |
def __init__(self): |
|
8 |
IPlugIn.__init__(self) |
|
9 |
self._options = ['co','up', 'checkout', 'update'] |
|
10 |
self._option = "" |
|
11 |
self._projectPath = "" |
|
12 |
self._svnUrl = "" |
|
13 |
|
|
14 |
|
|
15 |
def init(self): |
|
16 |
self.addGoal("svn", "This plugin is able to do checkout or update of a svn repository") |
|
17 |
self.addGoalOption("svn","--option", "sets the option of subversion: "+ str(self._options)) |
|
18 |
self.addGoalOption("svn","--project-path", "sets the path of the project.") |
|
19 |
self.addGoalOption("svn","--url", "sets the path of the url") |
|
20 |
execute = False |
|
21 |
while self._arguments.read("svn"): |
|
22 |
execute = True |
|
23 |
if execute: |
|
24 |
args = [""] |
|
25 |
while self._arguments.read("--option",args): |
|
26 |
self._option = args[0] |
|
27 |
|
|
28 |
args = [""] |
|
29 |
while self._arguments.read("--project-path",args): |
|
30 |
self._projectPath=args[0] |
|
31 |
|
|
32 |
args = [""] |
|
33 |
while self._arguments.read("--url",args): |
|
34 |
self._svnUrl=args[0] |
|
35 |
|
|
36 |
self.setExecute(True) |
|
37 |
|
|
38 |
def initFromXML(self,node): |
|
39 |
if node.localName=="svn": |
|
40 |
if node.hasAttributes(): |
|
41 |
if node.attributes.has_key("option"): |
|
42 |
self._option = node.attributes.get("option").value |
|
43 |
if node.attributes.has_key("project-path"): |
|
44 |
self._projectPath = node.attributes.get("project-path").value |
|
45 |
if node.attributes.has_key("url"): |
|
46 |
self._svnUrl = node.attributes.get("url").value |
|
47 |
|
|
48 |
def execute(self): |
|
49 |
if self._option=="": |
|
50 |
self.reportError("Missing svn option, use one of " + str(self._options)) |
|
51 |
return False |
|
52 |
if self._option not in self._options: |
|
53 |
self.reportError("not supported svn option, use one of " + str(self._options)) |
|
54 |
return False |
|
55 |
if self._projectPath=="": |
|
56 |
self.reportError("Missing required project path option") |
|
57 |
return False |
|
58 |
if self._option == "co" or self._option == "checkout": |
|
59 |
if self._svnUrl == "": |
|
60 |
self.reportError("Missing required svn url ption") |
|
61 |
return False |
|
62 |
|
|
63 |
self._projectPath = os.path.abspath(self._projectPath) |
|
64 |
projectName = os.path.basename(self._projectPath) |
|
65 |
|
|
66 |
print "Executing Plugin:" + str(self.__class__) |
|
67 |
bmutil = BMUtil() |
|
68 |
svnCommand = "svn " + self._option |
|
69 |
if self._option in ['co', 'checkout']: |
|
70 |
svnCommand += " " + self._svnUrl + " " + self._projectPath |
|
71 |
else: |
|
72 |
if self._option in ['up', 'update']: |
|
73 |
svnCommand += " " + self._projectPath |
|
74 |
os.system(svnCommand) |
|
75 |
return True |
|
76 |
|
|
77 |
PlugInManager().registerPlugIn("SVNPlugIn",SVNPlugIn()) |
|
78 |
|
|
79 |
|
branches/v2_0_0_prep/build/buildman/bin/bmplugins/DepManCleanPlugIn.py | ||
---|---|---|
1 |
from bmbase.IPlugIn import IPlugIn |
|
2 |
from bmbase.PlugInManager import PlugInManager |
|
3 |
from bmcore.BMUtil import BMUtil |
|
4 |
from xml.dom import minidom |
|
5 |
import os |
|
6 |
|
|
7 |
class DepManCleanPlugIn(IPlugIn): |
|
8 |
def __init__(self): |
|
9 |
IPlugIn.__init__(self) |
|
10 |
self._delete_cache = False |
|
11 |
self._default_repository = "" |
|
12 |
|
|
13 |
def init(self): |
|
14 |
self.addGoal("clean", "Cleans dependency files") |
|
15 |
self.addGoalOption("clean","--all", "Cleans also cache files") |
|
16 |
|
Also available in: Unified diff