Merge branch 'devel_anabatic' of ssh://bop.soc.lip6.fr/users/largo2/git/coriolis into devel_anabatic

This commit is contained in:
EricLaoGitHub 2017-04-18 11:59:29 +02:00
commit 3d919ef7b0
3 changed files with 115 additions and 89 deletions

View File

@ -23,59 +23,61 @@
OUTPUT_VARIABLE LD_MESSAGE OUTPUT_VARIABLE LD_MESSAGE
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_STRIP_TRAILING_WHITESPACE
) )
string(REGEX REPLACE "GNU ld version ([^ ]+) .*" "\\1" BINUTILS_VERSION ${LD_MESSAGE} ) if(RETURN_CODE EQUAL 0)
message("-- Using system specific BFD library: " ${BINUTILS_VERSION}) string(REGEX REPLACE "GNU ld version ([^ ]+) .*" "\\1" BINUTILS_VERSION ${LD_MESSAGE} )
message("-- Using system specific BFD library: " ${BINUTILS_VERSION})
find_path(LIBBFD_INCLUDE_DIRS NAMES bfd.h find_path(LIBBFD_INCLUDE_DIRS NAMES bfd.h
dis-asm.h dis-asm.h
PATHS /usr/include PATHS /usr/include
/usr/local/include /usr/local/include
/opt/local/include /opt/local/include
/opt/include /opt/include
ENV CPATH) ENV CPATH)
# Ugly, yes ugly... # Ugly, yes ugly...
find_library(LIBBFD_BFD_LIBRARY NAMES bfd-${BINUTILS_VERSION} find_library(LIBBFD_BFD_LIBRARY NAMES bfd-${BINUTILS_VERSION} bfd
PATHS /usr/lib PATHS /usr/lib
/usr/lib64 /usr/lib64
/usr/local/lib /usr/local/lib
/usr/local/lib64 /usr/local/lib64
/usr/include /usr/include
/opt/local/lib /opt/local/lib
/opt/usr/lib64 /opt/usr/lib64
ENV LIBRARY_PATH ENV LIBRARY_PATH
ENV LD_LIBRARY_PATH) ENV LD_LIBRARY_PATH)
#find_library (LIBBFD_IBERTY_LIBRARY NAMES iberty #find_library (LIBBFD_IBERTY_LIBRARY NAMES iberty
# PATHS /usr/lib # PATHS /usr/lib
# /usr/lib64 # /usr/lib64
# /usr/local/lib # /usr/local/lib
# /usr/local/lib64 # /usr/local/lib64
# /usr/include # /usr/include
# /opt/local/lib # /opt/local/lib
# /opt/usr/lib64 # /opt/usr/lib64
# ENV LIBRARY_PATH # ENV LIBRARY_PATH
# ENV LD_LIBRARY_PATH) # ENV LD_LIBRARY_PATH)
#find_library (LIBBFD_OPCODES_LIBRARY NAMES opcodes #find_library (LIBBFD_OPCODES_LIBRARY NAMES opcodes
# PATHS /usr/lib # PATHS /usr/lib
# /usr/lib64 # /usr/lib64
# /usr/local/lib # /usr/local/lib
# /usr/local/lib64 # /usr/local/lib64
# /usr/include # /usr/include
# /opt/local/lib # /opt/local/lib
# /opt/usr/lib64 # /opt/usr/lib64
# ENV LIBRARY_PATH # ENV LIBRARY_PATH
# ENV LD_LIBRARY_PATH) # ENV LD_LIBRARY_PATH)
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LIBBFD DEFAULT_MSG find_package_handle_standard_args(LIBBFD DEFAULT_MSG
LIBBFD_BFD_LIBRARY LIBBFD_BFD_LIBRARY
# LIBBFD_IBERTY_LIBRARY # LIBBFD_IBERTY_LIBRARY
# LIBBFD_OPCODES_LIBRARY # LIBBFD_OPCODES_LIBRARY
LIBBFD_INCLUDE_DIRS) LIBBFD_INCLUDE_DIRS)
endif()
if(LIBBFD_FOUND) if(LIBBFD_FOUND)
add_definitions(-DHAVE_LIBBFD) add_definitions(-DHAVE_LIBBFD)
endif() endif()

View File

@ -9,26 +9,35 @@ import subprocess
import optparse import optparse
coriolisPattern = re.compile ( r".*coriolis.*" ) reCoriolisPattern = re.compile( r".*coriolis.*" )
reReleaseSharedPattern = re.compile( r".*Release\.Shared.*" )
reReleaseStaticPattern = re.compile( r".*Release\.Static.*" )
reDebugSharedPattern = re.compile( r".*Debug\.Shared.*" )
reDebugStaticPattern = re.compile( r".*Debug\.Static.*" )
def stripPath ( pathName ): def scrubPath ( pathName ):
pathEnv = os.getenv ( pathName ) pathEnv = os.getenv( pathName )
if not pathEnv: return "" if not pathEnv: return ""
pathList = string.split ( pathEnv, ':' ) pathList = string.split( pathEnv, ':' )
strippedList = [] scrubbedList = []
for pathElement in pathList: for pathElement in pathList:
if not coriolisPattern.match(pathElement): if reCoriolisPattern .match(pathElement) \
strippedList += [ pathElement ] or reReleaseSharedPattern.match(pathElement) \
or reReleaseStaticPattern.match(pathElement) \
or reDebugSharedPattern .match(pathElement) \
or reDebugStaticPattern .match(pathElement):
continue
scrubbedList += [ pathElement ]
if len(strippedList) == 0: return "" if len(scrubbedList) == 0: return ""
strippedEnv = strippedList[0] scrubbedEnv = scrubbedList[0]
for pathElement in strippedList[1:]: for pathElement in scrubbedList[1:]:
strippedEnv += ":" + pathElement scrubbedEnv += ":" + pathElement
return strippedEnv return scrubbedEnv
def guessOs (): def guessOs ():
@ -131,25 +140,31 @@ def guessOs ():
return (osType,libDir,useDevtoolset2) return (osType,libDir,useDevtoolset2)
def guessCsh ():
cshBins = [ '/usr/bin/tcsh'
, '/bin/tcsh'
, '/usr/pkg/bin/tcsh'
, '/usr/bin/csh'
, '/bin/csh'
, '/usr/pkg/bin/csh'
]
for cshBin in cshBins:
if os.path.isfile(cshBin): return cshBin
return None
def guessShell (): def guessShell ():
if os.environ.has_key('SHELL'): return os.environ['SHELL'] # This environement variable cannot be trusted as it is set once when
# the user logs in. If aftewards it changes it that variable is *not*
# affected :-(.
#if os.environ.has_key('SHELL'): return os.environ['SHELL']
# If SHELL is not set, it is likely we are under C-Shell variant. psCommand = subprocess.Popen ( ['ps', '-p', str(os.getppid()) ], stdout=subprocess.PIPE )
# Look for standard places where the binaries are expecteds. shell = psCommand.stdout.readlines()[1][:-1].split()[-1]
return guessCsh() whichCommand = subprocess.Popen ( ['which', shell ], stdout=subprocess.PIPE )
shellPath = whichCommand.stdout.readlines()[0][:-1]
isBourneShell = True
cshBins = [ '/usr/bin/tcsh'
, '/bin/tcsh'
, '/usr/pkg/bin/tcsh'
, '/usr/local/bin/tcsh'
, '/usr/bin/csh'
, '/bin/csh'
, '/usr/pkg/bin/csh'
, '/usr/local/bin/csh'
]
if shellPath in cshBins: isBourneShell = False
#print 'GUESSED SHELL: "%s"' % shellPath
return shellPath, isBourneShell
@ -159,13 +174,12 @@ if __name__ == "__main__":
buildType = "Release" buildType = "Release"
linkType = "Shared" linkType = "Shared"
rootDir = None rootDir = None
shellBin = guessShell() shellBin, isBourneShell = guessShell()
parser = optparse.OptionParser () parser = optparse.OptionParser ()
# Build relateds. # Build relateds.
parser.add_option ( "--query-inst-root", action="store_true" , dest="queryInstRoot" ) parser.add_option ( "--query-inst-root", action="store_true" , dest="queryInstRoot" )
parser.add_option ( "--query-isys-root", action="store_true" , dest="queryISysRoot" ) parser.add_option ( "--query-isys-root", action="store_true" , dest="queryISysRoot" )
parser.add_option ( "--csh" , action="store_true" , dest="csh" )
parser.add_option ( "--release" , action="store_true" , dest="release" ) parser.add_option ( "--release" , action="store_true" , dest="release" )
parser.add_option ( "--debug" , action="store_true" , dest="debug" ) parser.add_option ( "--debug" , action="store_true" , dest="debug" )
parser.add_option ( "--devel" , action="store_true" , dest="devel" ) parser.add_option ( "--devel" , action="store_true" , dest="devel" )
@ -176,7 +190,6 @@ if __name__ == "__main__":
parser.add_option ( "--root" , action="store" , type="string", dest="rootDir" ) parser.add_option ( "--root" , action="store" , type="string", dest="rootDir" )
( options, args ) = parser.parse_args () ( options, args ) = parser.parse_args ()
if options.csh: shellBin = guessCsh()
if options.release: buildType = "Release" if options.release: buildType = "Release"
if options.debug: buildType = "Debug" if options.debug: buildType = "Debug"
if options.devel: buildType = "Debug" if options.devel: buildType = "Debug"
@ -184,13 +197,16 @@ if __name__ == "__main__":
if options.shared: linkType = "Shared" if options.shared: linkType = "Shared"
if options.rootDir: rootDir = options.rootDir if options.rootDir: rootDir = options.rootDir
scriptPath = os.path.abspath(os.path.dirname(sys.argv[0]))
if 'Debug.' in scriptPath: buildType = 'Debug'
if not shellBin: if not shellBin:
print 'echo "[ERROR] coriolisEnv.py was not able to guess/find the current shell interpeter."' print 'echo "[ERROR] coriolisEnv.py was not able to guess/find the current shell interpeter."'
sys.exit( 1 ) sys.exit( 1 )
strippedPath = stripPath ( "PATH" ) strippedPath = scrubPath( "PATH" )
strippedLibraryPath = stripPath ( "LD_LIBRARY_PATH" ) strippedLibraryPath = scrubPath( "LD_LIBRARY_PATH" )
strippedPythonPath = stripPath ( "PYTHONPATH" ) strippedPythonPath = scrubPath( "PYTHONPATH" )
shellScriptSh = \ shellScriptSh = \
'echo "%(MESSAGE)s";' \ 'echo "%(MESSAGE)s";' \
@ -246,6 +262,10 @@ if __name__ == "__main__":
strippedPath = "%s/bin:%s" % ( coriolisTop, strippedPath ) strippedPath = "%s/bin:%s" % ( coriolisTop, strippedPath )
strippedLibraryPath = "%s:%s" % ( absLibDir , strippedLibraryPath ) strippedLibraryPath = "%s:%s" % ( absLibDir , strippedLibraryPath )
if not os.path.exists(coriolisTop):
print 'echo "[ERROR] coriolisEnv.py, top directory <%s> do not exists."' % coriolisTop
sys.exit( 1 )
if not options.nopython: if not options.nopython:
pyVersion = sys.version_info pyVersion = sys.version_info
version = "%d.%d" % (pyVersion[0],pyVersion[1]) version = "%d.%d" % (pyVersion[0],pyVersion[1])
@ -281,11 +301,13 @@ if __name__ == "__main__":
shellScriptSh += "hash -r;" shellScriptSh += "hash -r;"
shellScriptCsh += "rehash;" shellScriptCsh += "rehash;"
if options.csh: shellScript = shellScriptCsh if isBourneShell: shellScript = shellScriptSh
else: shellScript = shellScriptSh else: shellScript = shellScriptCsh
if useDevtoolset2: if useDevtoolset2:
shellScript += ' scl enable devtoolset-2 %(SHELL)s' shellScript += \
' echo "Launching a devtoolset-2 subshell though scl (CTRL+D to exit).";' \
' scl enable devtoolset-2 %(SHELL)s'
evalScript = shellScript % { "PATH" : strippedPath evalScript = shellScript % { "PATH" : strippedPath
, "LD_LIBRARY_PATH" : strippedLibraryPath , "LD_LIBRARY_PATH" : strippedLibraryPath

View File

@ -82,6 +82,8 @@
#if (defined __linux__ || defined __FreeBSD__ || defined __APPLE__) #if (defined __linux__ || defined __FreeBSD__ || defined __APPLE__)
#include <execinfo.h> #include <execinfo.h>
#ifdef HAVE_LIBBFD #ifdef HAVE_LIBBFD
#define PACKAGE "Hurricane"
#define PACKAGE_VERSION "no_version"
#include <bfd.h> #include <bfd.h>
#endif #endif
#endif #endif