Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / build / buildman / bin / bmplugins / DepManPlugIn.py @ 27642

History | View | Annotate | Download (4.47 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":
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
                self._file = "depman.xml"
47
                self._node = None
48

    
49

    
50
        def init(self):
51
                self.addGoal("depman", "depman information plugin")
52
                self.addGoalOption("depman","--depman-path", "returns depman path")
53
                self.addGoalOption("depman","--file", "changes the default file")
54

    
55
                if self._arguments.read("depman"):
56
                        self.setExecute(True)
57

    
58
                if self._arguments.read("--depman-path"):
59
                        self._getDepManPath = True
60
                
61
                args=[""]
62
                while self._arguments.read("--file",args):
63
                        self._file = args[0]
64

    
65
        def initFromXML(self,node):
66
                self._node = node
67

    
68
        def execute(self):
69
                print "Executing Plugin:" + str(self.__class__)
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 getDepManDataPath(self):
119
                return self._depmanDataPath
120

    
121
        def getNode(self):
122
                return self._node
123

    
124
        def validateDependency(self,dependency):
125
                if dependency.group == "":
126
                        self.reportError("* Group cannot be empty")
127
                        return False
128
                if dependency.artifact == "":
129
                        self.reportError("* Artifact cannot be empty")
130
                        return False
131
                if dependency.version == "":
132
                        self.reportError("* Version cannog be empty")
133
                        return False
134

    
135
                if dependency.platform not in self.getSupportedPlatforms():
136
                        self.reportError("* Platform not supported: " + dependency.platform)
137
                        return False
138
                
139
                if dependency.platform!="all":
140
        
141
                        if dependency.compiler not in self.getSupportedCompilers():
142
                                self.reportError("* Compiler not supported: "+ dependency.compiler)
143
                                return False
144
        
145
                        if dependency.arch not in self.getSupportedArchs():
146
                                self.reportError("* Architecture not supported: "+ dependency.arch)
147
                                return False
148
        
149
                        if dependency.libraryType not in self.getSupportedLibraryTypes():
150
                                self.reportError("* Library type not supported: " + dependency.libraryType)
151
                                return False
152

    
153
                if dependency.platform!=self.getOSPlatform() and dependency.platform!="all":
154
                        print "* Warning: Forced platform ",dependency.platform
155

    
156
                return True
157

    
158
        def getXMLFile(self):
159
                return self._file        
160

    
161
PlugInManager().registerPlugIn("DepManPlugIn",DepManPlugIn())
162

    
163