-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SCons: Update SCons build scripts to support Python 3 and SCons 3
Add parentheses to print statements Use subprocess.check_output instead of commands.getstatusoutput to run external processes Use pickle instead of cPickle library This allows building on Linux distributions that have switched to python 3 by default but also retains backwards compatibility with python 2.7
- Loading branch information
Brock York
committed
Jun 12, 2020
1 parent
1f6d29e
commit db2c35a
Showing
4 changed files
with
62 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
# TTimo <[email protected]> | ||
# http://scons.org/ | ||
|
||
import sys, os, platform, cPickle | ||
import sys, os, platform, pickle | ||
|
||
import utils, config | ||
|
||
|
@@ -43,10 +43,10 @@ active_configs = [] | |
# load up configurations from the save file | ||
if ( os.path.exists( conf_filename ) ): | ||
f = open( conf_filename ) | ||
print 'reading saved configuration from site.conf' | ||
print( 'reading saved configuration from site.conf' ) | ||
try: | ||
while ( True ): | ||
c = cPickle.load( f ) | ||
c = pickle.load( f ) | ||
active_configs.append( c ) | ||
except: | ||
pass | ||
|
@@ -57,12 +57,12 @@ active_configs = config.ConfigParser().parseStatements( active_configs, config_s | |
assert( len( active_configs ) >= 1 ) | ||
|
||
# save the config | ||
print 'saving updated configuration' | ||
print( 'saving updated configuration' ) | ||
f = open( conf_filename, 'wb' ) | ||
for c in active_configs: | ||
cPickle.dump( c, f, -1 ) | ||
pickle.dump( c, f, -1 ) | ||
|
||
print 'emit build rules' | ||
print( 'emit build rules' ) | ||
for c in active_configs: | ||
print 'emit configuration: %s' % repr( c ) | ||
print( 'emit configuration: %s' % repr( c ) ) | ||
c.emit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,14 +3,14 @@ | |
# TTimo <[email protected]> | ||
# http://scons.org/ | ||
|
||
import os, commands, platform, xml.sax, re, string, platform | ||
import os, subprocess, platform, xml.sax, re, string, platform | ||
|
||
class vcxproj( xml.sax.handler.ContentHandler ): | ||
def __init__( self, filepath ): | ||
self.source_files = [] | ||
self.misc_files = [] | ||
self._files = [] | ||
print 'parse %s' % filepath | ||
print( 'parse %s' % filepath ) | ||
xml.sax.parse( filepath, self ) | ||
|
||
def getSourceFiles( self ): | ||
|
@@ -30,39 +30,40 @@ def filterSource( self, expression, filelist = None ): | |
|
||
def startElement( self, name, attrs ): | ||
if ( name == 'ClCompile' ): | ||
if ( attrs.has_key('Include') ): | ||
self._files.append( attrs.getValue('Include') ) | ||
if ( 'Include' in attrs.getNames() ): | ||
self._files.append( attrs.getValue('Include') ) | ||
|
||
def endDocument( self ): | ||
# split into source and headers, remap path seperator to the platform | ||
for f in self._files: | ||
if ( platform.system() != 'Windows' ): | ||
f = f.replace( '\\', '/' ) | ||
if ( f[-2:] == '.c' or f[-4:] == '.cpp' ): | ||
self.source_files.append( f.encode('ascii') ) | ||
self.source_files.append( f ) | ||
else: | ||
self.misc_files.append( f ) | ||
print '%d source files' % len( self.source_files ) | ||
print( '%d source files' % len( self.source_files ) ) | ||
|
||
# action uses LDD to verify that the source doesn't hold unresolved symbols | ||
# setup as an AddPostAction of a regular SharedLibrary call | ||
def CheckUnresolved( source, target, env ): | ||
# TODO: implement this for OSX | ||
if ( platform.system() == 'Darwin' ): | ||
return None | ||
# TODO: implement this for FreeBSD | ||
if ( platform.system() == 'FreeBSD' ): | ||
return None | ||
print 'CheckUnresolved %s' % target[0].abspath | ||
# TODO: implement this for FreeBSD | ||
if ( platform.system() == 'FreeBSD' ): | ||
return None | ||
print( 'CheckUnresolved %s' % target[0].abspath ) | ||
if ( not os.path.isfile( target[0].abspath ) ): | ||
print 'CheckUnresolved: %s does not exist' % target[0] | ||
return 1 # fail | ||
( status, output ) = commands.getstatusoutput( 'ldd -r %s' % target[0] ) | ||
if ( status != 0 ): | ||
print 'CheckUnresolved: ldd command failed (exit code %d)' % status | ||
os.system( 'rm %s' % target[ 0 ] ) | ||
print( 'CheckUnresolved: %s does not exist' % target[0] ) | ||
return 1 # fail | ||
lines = string.split( output, '\n' ) | ||
try: | ||
stdout = subprocess.check_output( ['ldd', '-r', str(target[0])] ).decode( 'utf-8' ) | ||
except subprocess.CalledProcessError as cpe: | ||
print( 'CheckUnresolved: ldd command failed (exit code {})'.format( cpe.returncode ) ) | ||
os.system( 'rm %s' % target[ 0 ] ) | ||
return 1 # fail | ||
lines = stdout.split( '\n' ) | ||
have_undef = 0 | ||
for i_line in lines: | ||
regex = re.compile('undefined symbol: (.*)\t\\((.*)\\)') | ||
|
@@ -73,8 +74,8 @@ def CheckUnresolved( source, target, env ): | |
except: | ||
have_undef = 1 | ||
if ( have_undef ): | ||
print output | ||
print "CheckUnresolved: undefined symbols" | ||
print( output ) | ||
print( "CheckUnresolved: undefined symbols" ) | ||
os.system('rm %s' % target[0]) | ||
return 1 | ||
|
||
|