-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathSConstruct
146 lines (121 loc) · 6.73 KB
/
SConstruct
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
EnsureSConsVersion( 1, 2 )
EnsurePythonVersion( 2, 5 )
import os
import sys
sys.path.append('tools')
from sconsProject import SConsProject
class KaliscopeMatchProject( SConsProject ):
'''
The project compilation object.
This class extends the default SConsProject object with some specific
utilities for OpenFX.
'''
def getOfxPlatformName( self ) :
'''Get the standard openfx name of the current platform.
One of the followings :
* MacOS - for Apple Macintosh OS X (compiled 32 bit)
* Win32 - for Microsoft Windows (compiled 32 bit)
* IRIX - for SGI IRIX plug-ins (compiled 32 bit)
* IRIX64 - for SGI IRIX plug-ins (compiled 64 bit)
* Linux-x86 - for Linux on intel x86 CPUs (compiled 32 bit)
* Linux-x86-64 - for Linux on intel x86 CPUs running AMD's 64 bit extensions
'''
if self.osname == "posix" :
if self.sysplatform.find("linux") >= 0 :
if self.bits == 64:
return 'Linux-x86-64'
return 'Linux-x86'
elif self.sysplatform.find("cygwin") >= 0 :
if self.bits == 64:
return 'Linux-x86-64'
return 'Linux-x86'
elif self.sysplatform.find("darwin") >= 0 :
return 'MacOS'
elif self.sysplatform.find("irix") >= 0:
if self.bits == 64:
return 'IRIX64'
return 'IRIX'
elif self.osname == "nt":
if self.sysplatform.startswith("win"):
return 'Win' + str(self.bits)
elif self.sysplatform.find("cygwin") >= 0:
return 'Win' + str(self.bits)
raise "Unknown Platform (%s,%s)" % (osname,sysplatform)
def getOutputOfxResources( self, pluginFilename ):
return self.dir_output_plugin + os.sep + pluginFilename + '.ofx.bundle/Contents/Resources'
def getOutputOfxPlugin( self, pluginFilename ):
'''Return plugin name in the output directory "xxx/bin/pluginname.ofx.bundle/Contents/ofxplatformname/pluginname.ofx" .'''
return os.path.join( self.dir_output_plugin, pluginFilename + '.ofx.bundle/Contents', self.getOfxPlatformName(), pluginFilename + '.ofx' )
def retrieveOfxPluginVersions( self, filename ):
'''
Return plugins versions (major, minor).
This information is extracted from the version defined inside the plugin main file.
'''
versionMajor = -1
versionMinor = -1
f = open( filename, 'r' )
try:
line = f.readline()
while line:
if line.startswith('#define OFXPLUGIN_VERSION_M'):
l = line.split()
if len(l) != 3:
raise ValueError( 'Syntax error declaring the OFX plugin version in file : "'+filename+'"' )
if l[1].endswith('MAJOR'):
versionMajor = int(l[2])
if versionMinor != -1:
break;
if l[1].endswith('MINOR'):
versionMinor = int(l[2])
if versionMajor != -1:
break;
line = f.readline()
if versionMajor == -1 or versionMinor == -1:
raise ValueError( 'Version not found in OFX plugin file : "'+filename+'"' )
except ValueError as e:
raise ValueError( str(e) + '\n' +
'Valid syntax is : \n'+
'#define OFXPLUGIN_VERSION_MAJOR 1\n'+
'#define OFXPLUGIN_VERSION_MINOR 0\n' )
finally:
f.close()
return ( versionMajor, versionMinor )
def createOfxPlugin( self,
sources=[], libraries=[], dirs=[],
mainFile='src/mainEntry.cpp', includes=[],
env=None, localEnvFlags={}, replaceLocalEnvFlags={}, externEnvFlags={}, globalEnvFlags={},
dependencies=[], install=True
):
'''
Create an openfx plugin from sources files and libraries dependencies.
'''
pluginName = self.getName() # eg. 'Foo'
versions = self.retrieveOfxPluginVersions( os.path.join(self.getRealAbsoluteCwd(), mainFile) )
pluginFilename = pluginName + '-' + str(versions[0]) + '.' + str(versions[1]) # eg. 'Foo-1.0'
if self.env['mode'] == 'production' and versions[0] <= 0:
print '''Don't create "''' + pluginFilename + '" in "production" mode.'
return None
pluginInstall = self.SharedLibrary( pluginName,
sources=sources, dirs=dirs, libraries=libraries, includes=includes,
env=env, localEnvFlags=localEnvFlags, replaceLocalEnvFlags=replaceLocalEnvFlags, externEnvFlags=externEnvFlags, globalEnvFlags=globalEnvFlags,
dependencies=dependencies, installAs=self.getOutputOfxPlugin(pluginFilename), install=install,
public=False )
envLocal = self.env
resources_dir = os.path.join( self.getRealAbsoluteCwd(), 'Resources' )
if os.path.isdir( resources_dir ):
plugin_resources = envLocal.InstallAs( self.getOutputOfxResources(pluginFilename), resources_dir )
envLocal.Depends( plugin_resources, pluginInstall )
envLocal.Alias( pluginName, plugin_resources )
envLocal.Alias( pluginName, pluginInstall )
envLocal.Alias( 'ofxplugins', pluginName )
envLocal.Alias( 'all', 'ofxplugins' )
return pluginInstall
#______________________________________________________________________________#
project = KaliscopeMatchProject()
project.libs.qt_default = project.libs.qt5
Export('project')
Export({'libs':project.libs})
#______________________________________________________________________________#
project.begin()
project.SConscript()
project.end()