root / branches / v2_0_0_prep / build / buildman / bin / bmplugins / DepManPlugIn.py @ 28403
History | View | Annotate | Download (4.93 KB)
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 |
import platform |
8 |
import string |
9 |
import commands |
10 |
|
11 |
|
12 |
|
13 |
class DepManPlugIn(IPlugIn): |
14 |
def __init__(self): |
15 |
IPlugIn.__init__(self)
|
16 |
self._depmanDataPath = sys.path[0]+os.path.sep+".."+os.path.sep+"plugins-data"+os.path.sep+"depman" |
17 |
self._supportedPlatforms = ["all","mac","linux","win"] |
18 |
self._supportedArchs = ["all","i386","ppc","ppc64","x86_64","universal"] |
19 |
self._supportedLibraryTypes = ["none","dynamic","static","framework"] |
20 |
self._supportedCompilers = ["all","vs6","vs7","vs8","vs9","gcc3","gcc4"] |
21 |
#tries to guess host OS values
|
22 |
self._osplatform="unknown" |
23 |
self._osdistribution="unknown" |
24 |
self._osarch="unknown" |
25 |
self._oscompiler="unknown" |
26 |
if sys.platform=="darwin": |
27 |
self._osplatform="mac" |
28 |
self._osarch="universal" |
29 |
self._oscompiler="gcc4" |
30 |
self._osdistribution, null, null=platform.mac_ver()
|
31 |
elif sys.platform == "linux2" or sys.platform == "linux1": |
32 |
self._osplatform="linux" |
33 |
self._osarch="i386" |
34 |
self._oscompiler="gcc4" |
35 |
self._osdistribution, null, null = platform.dist()
|
36 |
if self._osdistribution == "debian" or self._osdistribution == "Ubuntu": |
37 |
self._osdistribution = string.replace(commands.getoutput("lsb_release -ds")," ","-") |
38 |
elif sys.platform == "win32" or sys.platform == "win64": |
39 |
self._osplatform="win" |
40 |
self._osarch="i386" |
41 |
self._oscompiler="vs8" |
42 |
self._osdistribution,null,null,null,null = sys.getwindowsversion()
|
43 |
|
44 |
self._getDepManPath = False |
45 |
|
46 |
|
47 |
self._file = "depman.xml" |
48 |
self._node = None |
49 |
|
50 |
|
51 |
def init(self): |
52 |
self.addGoal("depman", "depman information plugin") |
53 |
self.addGoalOption("depman","--depman-path", "returns depman path") |
54 |
self.addGoalOption("depman","--file", "changes the default file") |
55 |
|
56 |
if self._arguments.read("depman"): |
57 |
self.setExecute(True) |
58 |
|
59 |
if self._arguments.read("--depman-path"): |
60 |
self._getDepManPath = True |
61 |
|
62 |
args=[""]
|
63 |
while self._arguments.read("--file",args): |
64 |
self._file = args[0] |
65 |
|
66 |
def initFromXML(self,node): |
67 |
self._node = node
|
68 |
|
69 |
def execute(self): |
70 |
self.loadXMLFile(self._file) |
71 |
if self._getDepManPath: |
72 |
print self.getDepManPath() |
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 |
def getSupportedPlatforms(self): |
79 |
return self._supportedPlatforms |
80 |
|
81 |
def getSupportedArchs(self): |
82 |
return self._supportedArchs |
83 |
|
84 |
def getSupportedLibraryTypes(self): |
85 |
return self._supportedLibraryTypes |
86 |
|
87 |
def getSupportedCompilers(self): |
88 |
return self._supportedCompilers |
89 |
|
90 |
def getOSPlatform(self): |
91 |
return self._osplatform |
92 |
|
93 |
def getOSDistribution(self): |
94 |
return self._osdistribution |
95 |
|
96 |
def getOSArch(self): |
97 |
return self._osarch |
98 |
|
99 |
def getOSCompiler(self): |
100 |
return self._oscompiler |
101 |
|
102 |
def getDepManPath(self): |
103 |
dr = os.getenv("DEPMAN_REPO")
|
104 |
if not dr is None: |
105 |
return dr;
|
106 |
if sys.platform == "linux2" or sys.platform == "linux1": |
107 |
dr = os.getenv("HOME")+os.path.sep+".depman" |
108 |
return dr;
|
109 |
if sys.platform == "win32" or sys.platform == "win64": |
110 |
#ex: c:\documents and setting\user\DepMan
|
111 |
dr = os.getenv("USERPROFILE")+os.path.sep+"DepMan" |
112 |
return dr;
|
113 |
if sys.platform == "darwin": |
114 |
dr = os.path.sep + "Developer" + os.path.sep + "DepMan" |
115 |
return dr;
|
116 |
return None |
117 |
|
118 |
def getMavenPath(self): |
119 |
dr = os.getenv("M2_REPO")
|
120 |
if not dr is None: |
121 |
return dr;
|
122 |
if sys.platform == "linux2" or sys.platform == "linux1": |
123 |
dr = os.getenv("HOME")+os.path.sep+".m2" |
124 |
return dr;
|
125 |
if sys.platform == "win32" or sys.platform == "win64": |
126 |
#ex: c:\documents and setting\user\DepMan
|
127 |
dr = os.getenv("USERPROFILE")+os.path.sep+".m2" |
128 |
return dr;
|
129 |
if sys.platform == "darwin": |
130 |
dr = os.getenv("HOME")+os.path.sep+".m2" |
131 |
return dr;
|
132 |
return None |
133 |
|
134 |
def getDepManDataPath(self): |
135 |
return self._depmanDataPath |
136 |
|
137 |
def getNode(self): |
138 |
return self._node |
139 |
|
140 |
def validateDependency(self,dependency): |
141 |
if dependency.group == "": |
142 |
self.reportError("* Group cannot be empty") |
143 |
return False |
144 |
if dependency.artifact == "": |
145 |
self.reportError("* Artifact cannot be empty") |
146 |
return False |
147 |
if dependency.version == "": |
148 |
self.reportError("* Version cannog be empty") |
149 |
return False |
150 |
|
151 |
if dependency.platform not in self.getSupportedPlatforms(): |
152 |
self.reportError("* Platform not supported: " + dependency.platform) |
153 |
return False |
154 |
|
155 |
if dependency.platform!="all": |
156 |
|
157 |
if dependency.compiler not in self.getSupportedCompilers(): |
158 |
self.reportError("* Compiler not supported: "+ dependency.compiler) |
159 |
return False |
160 |
|
161 |
if dependency.arch not in self.getSupportedArchs(): |
162 |
self.reportError("* Architecture not supported: "+ dependency.arch) |
163 |
return False |
164 |
|
165 |
if dependency.libraryType not in self.getSupportedLibraryTypes(): |
166 |
self.reportError("* Library type not supported: " + dependency.libraryType) |
167 |
return False |
168 |
|
169 |
if dependency.platform!=self.getOSPlatform() and dependency.platform!="all": |
170 |
print "* Warning: Forced platform ",dependency.platform |
171 |
|
172 |
return True |
173 |
|
174 |
def getXMLFile(self): |
175 |
return self._file |
176 |
|
177 |
PlugInManager().registerPlugIn("DepManPlugIn",DepManPlugIn())
|
178 |
|
179 |
|