コード例 #1
0
ファイル: install.py プロジェクト: vn971/wesnoth
def hard_link(dest, src, symlink = False):
    try:
        if symlink:
            os.symlink(src, dest)
        else:
            os.link(src, dest)
    except OSError as e:
        if e.errno == 18:
            hard_link(dest, src, True)
        else:
            os.remove(dest)
            os.link(src, dest)
    except AttributeError:
        copy2(src, dest)

HardLink = ActionFactory(hard_link,
                         lambda dest, src: 'Hardlinking %s to %s' % (src, dest))

def InstallBinary(env, source):
    if not source:
        return source

    binary = source[0].name
    binary = binary.split("-")[0]
    installdir = env.subst(os.path.join(env["destdir"], env["bindir"].lstrip("/")))
    env.Alias("install-" + binary, 
        env.InstallAs(os.path.join(installdir, binary + env["program_suffix"]), source)
    )

def InstallData(env, datadir, component, source, subdir = ""):
    installdir = Dir(env.subst(os.path.join(env["destdir"], env[datadir].lstrip("/"), subdir)))
    sources = map(Entry, Flatten([source]))
コード例 #2
0
ファイル: sconsutils.py プロジェクト: psathyrella/ecgtheow
def wait_func(dest):
    SCons.Node.FS.invalidate_node_memos(dest)
    if not SCons.Util.is_List(dest):
        dest = [dest]
    for entry in dest:
        count = 0
        limit = 30
        while not os.path.isfile(entry) or os.stat(entry).st_size == 0:
            print("waiting for {}...".format(entry))
            time.sleep(2)
            count = count + 1
            if count >limit:
                return 1
    return 0

Wait = ActionFactory(wait_func, lambda dir: 'Wait(%s)' % get_paths_str(dir))

            
# Define one of two versions of the SRun method,
# depending on whether the `srun` command is available or not.
exit_code = subprocess.call("type srun", shell=True, 
                             stdout=subprocess.PIPE, stderr=subprocess.PIPE)
srun_exists = (exit_code == 0)
def SRun(env, target, source, action, srun_args=None, **kwargs):
    if not hasattr(target, '__iter__'):
        target = [target]
    waitfor = target
    if 'chdir' in kwargs:
        waitfor = [os.path.basename(w) for w in waitfor]
    if srun_exists:
        srun_base = "- srun " if kwargs.get('ignore_errors') else "srun "
コード例 #3
0
# podd_utils.py
# Utility functions for Podd SCons build

import os
from SCons.Action import ActionFactory
from SCons.Script.SConscript import SConsEnvironment

SConsEnvironment.OSCommand = ActionFactory(
    os.system, lambda command: 'os.system("%s")' % command)

import SCons.Util


def list_to_path(lst):
    result = ''
    if SCons.Util.is_List(lst):
        for element in lst:
            result += str(element)
            if len(lst) > 1 and element != lst[-1]:
                result += ':'
    else:
        result = lst
    return result


def InstallWithRPATH(env, dest, files, rpath):
    obj = env.Install(dest, files)
    if env['PLATFORM'] == 'posix':
        rpathstr = list_to_path(rpath)
        if env.WhereIs('patchelf'):
            if env.subst('$ADD_INSTALL_RPATH') and rpathstr:
コード例 #4
0
ファイル: PkgMaker.py プロジェクト: tsuibin/magicinstaller2
        prunepathes = prunepathes.split()
    dirlist = [topdir]
    #execlist = []
    fullprunepathes = {}
    for pp in prunepathes:
        fullprunepathes[topdir + '/' + pp] = 'y'
    while dirlist != []:
        curdir = dirlist.pop(0)
        for file in os.listdir(curdir):
            filepath = curdir + '/' + file
            if os.path.islink(filepath):
                # Do nothing on link.
                pass
            elif os.path.isdir(filepath):
                if not fullprunepathes.has_key(filepath):
                    dirlist.append(filepath)
            elif os.path.isfile(filepath):
                # Check common file.
                f = os.popen('file ' + filepath, 'r')
                input = f.readline()
                f.close()
                if input.find('ELF 32-bit LSB') >= 0 and \
                       input.find('not stripped'):
                    print cmd_str % filepath
                    os.system(cmd_str % filepath)
                    #execlist.append(filepath)
    #return execlist


SearchExecAction = ActionFactory(search_exec, search_exec_strfunc)
コード例 #5
0
ファイル: SConscript.ext.py プロジェクト: myaut/tsload
from SCons.Action import ActionFactory
from SCons.Script.SConscript import SConsEnvironment

import os
import sys

PathJoin = os.path.join

Import('env')

SConsEnvironment.Chmod = ActionFactory(os.chmod,
        lambda dest, mode: 'Chmod("%s", 0%o)' % (dest, mode)) 

# Append path to build tools
sys.path.append(PathJoin(env['TSLOAD_DEVEL_PATH'], 'tools', 'build'))

# Load tsload SConscripts
SConscript(PathJoin(env['TSLOAD_DEVEL_PATH'], 'SConscript.env.py'), 'env')
SConscript(PathJoin(env['TSLOAD_DEVEL_PATH'], 'SConscript.plat.py'), 'env')
SConscript(PathJoin(env['TSLOAD_DEVEL_PATH'], 'SConscript.install.py'), 'env')
SConscript(PathJoin(env['TSLOAD_DEVEL_PATH'], 'SConscript.etrace.py'), 'env')

Export('env')
コード例 #6
0
ファイル: SconsUtils.py プロジェクト: dmoody256/BuildUtils
from SCons.Script.Main import Progress
from SCons import Action
from SCons.Defaults import Copy, mkdir_func, get_paths_str
from SCons.Script import Main
from SCons.Node import NodeList
from SCons.Environment import Environment
from SCons.Script.Main import GetOption
from SCons.Errors import BuildError
from SCons.Platform import TempFileMunge
from SCons.Action import ActionFactory

from BuildUtils.ColorPrinter import ColorPrinter
from BuildUtils import get_num_cpus

Mkdir = ActionFactory(
    mkdir_func,
    lambda dir: ColorPrinter().InfoPrint(' Mkdir(%s)' % get_paths_str(dir)))


def SetBuildJobs(env):
    ###################################################
    # Determine number of Jobs
    # start by assuming num_jobs was not set
    NUM_JOBS_SET = False
    if GetOption("num_jobs") == 1:
        # if num_jobs is the default we need to check sys.argv
        # to see if the user happened to set the default
        for arg in sys.argv:
            if arg.startswith("-j") or arg.startswith("--jobs"):
                if arg == "-j" or arg == "--jobs":
                    if int(sys.argv[sys.argv.index(arg) + 1]) == 1: