configfile: Move all toolchain executable names to configfile to make them overridable.

Now we can override all toolchain executable names in pisi.conf file to use another compiler like clang or for cross-compile purposes.
This commit is contained in:
Gökçen Eraslan
2011-10-13 16:14:16 +00:00
parent 62b8024709
commit 4276c30363
5 changed files with 48 additions and 28 deletions
+10 -21
View File
@@ -34,6 +34,7 @@ class BinutilsError(pisi.actionsapi.Error):
# Globals
env = pisi.actionsapi.variables.glb.env
dirs = pisi.actionsapi.variables.glb.dirs
config = pisi.actionsapi.variables.glb.config
generals = pisi.actionsapi.variables.glb.generals
def curDIR():
@@ -164,41 +165,29 @@ def qtDIR():
# Binutils Variables
def getBinutilsInfo(util):
cross_build_name = '%s-%s' % (HOST(), util)
if not pisi.util.search_executable(cross_build_name):
if not pisi.util.search_executable(util):
raise BinutilsError(_('Util %s cannot be found') % util)
else:
ctx.ui.debug(_('Warning: %s does not exist, using plain name %s') \
% (cross_build_name, util))
return util
else:
return cross_build_name
def AR():
return getBinutilsInfo('ar')
return config.values.build.ar
def AS():
return getBinutilsInfo('as')
return config.values.build.assembler
def CC():
return getBinutilsInfo('gcc')
return config.values.build.cc
def CXX():
return getBinutilsInfo('g++')
return config.values.build.cxx
def LD():
return getBinutilsInfo('ld')
return config.values.build.ld
def NM():
return getBinutilsInfo('nm')
return config.values.build.nm
def RANLIB():
return getBinutilsInfo('ranlib')
return config.values.build.ranlib
def F77():
return getBinutilsInfo('g77')
return config.values.build.f77
def GCJ():
return getBinutilsInfo('gcj')
return config.values.build.gcj
+4 -2
View File
@@ -14,6 +14,7 @@ import os
# Pisi-Core Modules
import pisi.context as ctx
import pisi.util
# Set individual information, that are generally needed for ActionsAPI
@@ -35,8 +36,9 @@ def exportFlags():
os.environ['JOBS'] = values.build.jobs
# http://liste.pardus.org.tr/gelistirici/2009-January/016442.html
os.environ['CC'] = "%s-gcc" % values.build.host
os.environ['CXX'] = "%s-g++" % values.build.host
os.environ['CC'] = values.build.cc
os.environ['CXX'] = values.build.cxx
os.environ['LD'] = values.build.ld
class Env(object):
'''General environment variables used in actions API'''
+25
View File
@@ -30,6 +30,17 @@
#cflags= -mtune=generic -march=i686 -O2 -pipe -fomit-frame-pointer -fstack-protector -D_FORTIFY_SOURCE=2
#cxxflags= -mtune=generic -march=i686 -O2 -pipe -fomit-frame-pointer -fstack-protector -D_FORTIFY_SOURCE=2
#ldflags= -Wl,-O1 -Wl,-z,relro -Wl,--hash-style=gnu -Wl,--as-needed -Wl,--sort-common
#ar = "ar"
#assembler = "as"
#cc = "gcc"
#cxx = "g++"
#ld = "ld"
#nm = "nm"
#ranlib = "ranlib"
#f77 = "g77"
#gcj = "gcj"
#strip = "strip"
#objcopy= "objcopy"
#buildhelper = None / ccache / icecream
#compressionlevel = 1
#fallback = "ftp://ftp.pardus.org.tr/pub/source/2011"
@@ -87,6 +98,20 @@ class BuildDefaults:
enableSandbox = True
cflags = "-mtune=generic -march=i686 -O2 -pipe -fomit-frame-pointer -fstack-protector -D_FORTIFY_SOURCE=2"
cxxflags = "-mtune=generic -march=i686 -O2 -pipe -fomit-frame-pointer -fstack-protector -D_FORTIFY_SOURCE=2"
# Toolchain defaults
ar = "ar"
assembler = "as"
cc = "gcc"
cxx = "g++"
ld = "ld"
nm = "nm"
ranlib = "ranlib"
f77 = "g77"
gcj = "gcj"
strip = "strip"
objcopy= "objcopy"
ldflags = "-Wl,-O1 -Wl,-z,relro -Wl,--hash-style=gnu -Wl,--as-needed -Wl,--sort-common"
buildhelper = None
compressionlevel = 1
+6 -2
View File
@@ -408,12 +408,14 @@ class Builder:
# First check icecream, if not found use ccache
# TODO: Add support for using both of them
if ctx.config.values.build.buildhelper == "icecream":
if os.path.exists("/opt/icecream/bin/gcc"):
if os.path.exists("/opt/icecream/bin/%s" % ctx.config.values.build.cc):
self.has_icecream = True
os.environ["PATH"] = "/opt/icecream/bin:%(PATH)s" % os.environ
else:
ctx.ui.warning(_("Specified compiler is not supported by icecream, it will be disabled."))
elif ctx.config.values.build.buildhelper == "ccache":
if os.path.exists("/usr/lib/ccache/bin/gcc"):
if os.path.exists("/usr/lib/ccache/bin/%s" % ctx.config.values.build.cc):
self.has_ccache = True
os.environ["PATH"] = "/usr/lib/ccache/bin:%(PATH)s" \
@@ -421,6 +423,8 @@ class Builder:
# Force ccache to use /root/.ccache instead of $HOME/.ccache
# as $HOME can be modified through actions.py
os.environ["CCACHE_DIR"] = "/root/.ccache"
else:
ctx.ui.warning(_("Specified compiler is not supported by ccache, it will be disabled."))
def fetch_files(self):
self.fetch_patches()
+3 -3
View File
@@ -552,7 +552,7 @@ def do_patch(sourceDir, patchFile, level=0, name=None, reverse=False):
def strip_file(filepath, fileinfo, outpath):
"""Strip an elf file from debug symbols."""
def run_strip(f, flags=""):
p = os.popen("strip %s %s" %(flags, f))
p = os.popen("%s %s %s" %(ctx.config.values.build.strip, flags, f))
ret = p.close()
if ret:
ctx.ui.warning(_("strip command failed for file '%s'!") % f)
@@ -566,13 +566,13 @@ def strip_file(filepath, fileinfo, outpath):
def save_elf_debug(f, o):
"""copy debug info into file.debug file"""
p = os.popen("objcopy --only-keep-debug %s %s%s" % (f, o, ctx.const.debug_file_suffix))
p = os.popen("%s --only-keep-debug %s %s%s" % (ctx.config.values.build.objcopy, f, o, ctx.const.debug_file_suffix))
ret = p.close()
if ret:
ctx.ui.warning(_("objcopy (keep-debug) command failed for file '%s'!") % f)
"""mark binary/shared objects to use file.debug"""
p = os.popen("objcopy --add-gnu-debuglink=%s%s %s" % (o, ctx.const.debug_file_suffix, f))
p = os.popen("%s --add-gnu-debuglink=%s%s %s" % (ctx.config.values.build.objcopy, o, ctx.const.debug_file_suffix, f))
ret = p.close()
if ret:
ctx.ui.warning(_("objcopy (add-debuglink) command failed for file '%s'!") % f)