Beispiel #1
0
def FindLib(conf, lib, hdr, managers = ['port', 'fink']):
    global pkgmans
    if conf.CheckLib(lib) and conf.CheckHeader(hdr):
        return True
    if not IsMac(conf):
        return False

    conf.env.Append(LIBPATH = []) # ensure it exists
    conf.env.Append(CPPPATH = []) # ensure it exists
    for pkgman in managers:
        if pkgman in pkgmans:
            continue # already have it
        loc = WhereIs(pkgman)
        if not loc:
            continue
        loc = os.path.realpath(loc)
        bin = 'bin/%s' % pkgman
        pre, sep, post = loc.partition(bin)
        if sep != bin or post != '':
            continue

        orig_libpath = conf.env['LIBPATH']
        orig_cpppath = conf.env['CPPPATH']
        conf.env.Append(LIBPATH = [pre + "/lib"])
        conf.env.Append(CPPPATH = [pre + "/include"])
        print "Try package manager '%s'..." % pkgman
        if conf.CheckLib(lib) and conf.CheckHeader(hdr):
            pkgmans[pkgman] = True
            return True
        conf.env.Replace(LIBPATH = orig_libpath)
        conf.env.Replace(CPPPATH = orig_cpppath)
    return False
Beispiel #2
0
def FindLib(conf, lib, managers=['port', 'fink']):
    global pkgmans
    if conf.CheckLib(*lib):
        return True
    if not IsMac(conf):
        return False

    conf.env.Append(LIBPATH=[])  # ensure it exists
    for pkgman in managers:
        if pkgman in pkgmans:
            continue  # already have it
        loc = WhereIs(pkgman)
        if not loc:
            continue
        loc = os.path.realpath(loc)
        bin = 'bin/%s' % pkgman
        pre, sep, post = loc.partition(bin)
        if sep != bin or post != '':
            continue

        orig = conf.env['LIBPATH']
        conf.env.Append(LIBPATH=[pre + "/lib"])
        print "Try package manager '%s'..." % pkgman
        if conf.CheckLib(*lib):
            conf.env.Append(CPPPATH=[pre + "/include"])
            pkgmans[pkgman] = True
            return True
        conf.env.Replace(LIBPATH=orig)
    return False
Beispiel #3
0
def generate(env):
    try:
        env["MSGFMT"]
    except KeyError:
        env["XGETTEXT"] = WhereIs("xgettext") or 'xgettext'
        env["MSGFMT"] = WhereIs("msgfmt")
        msgfmt = Builder(action = "$MSGFMT -c --statistics -o $TARGET $SOURCE",
                         src_suffix = ".po",
                         suffix = ".mo",
                         single_source = True)
        env["BUILDERS"]["Msgfmt"] = msgfmt

        env["MSGMERGE"] = WhereIs("msgmerge") or 'msgmerge'
        msgmerge = Builder(action = "$MSGMERGE $TARGET $SOURCE -o $TARGET",
                           src_suffix = ".pot",
                           suffix = ".po",
                           single_source = True)
        env["BUILDERS"]["MsgMerge"] = msgmerge

        env["MSGINIT"] = WhereIs("msginit") or 'msginit'
        msginit = Builder(action = "$MSGINIT -i $SOURCE -o $TARGET --no-translator",
                          src_suffix = ".pot",
                          suffix = ".po",
                          single_source = True)
        env["BUILDERS"]["MsgInit"] = msginit

        def MsgInitMerge(env, target, source):
            #print target[0].path, os.path.exists(target[0].abspath)
            if os.path.exists(target[0].abspath):
                return env.MsgMerge(target, source)
            else:
                return env.MsgInit(target, source)
        env["BUILDERS"]["MsgInitMerge"] = MsgInitMerge
def run_closure_compiler(target, source, env, for_signature):
    closure_bin = os.path.join(os.path.dirname(WhereIs("emcc")), "node_modules", ".bin", "google-closure-compiler")
    cmd = [WhereIs("node"), closure_bin]
    cmd.extend(["--compilation_level", "ADVANCED_OPTIMIZATIONS"])
    for f in env["JSEXTERNS"]:
        cmd.extend(["--externs", f.get_abspath()])
    for f in source:
        cmd.extend(["--js", f.get_abspath()])
    cmd.extend(["--js_output_file", target[0].get_abspath()])
    return " ".join(cmd)
Beispiel #5
0
def generate(env):
    env.AppendENVPath("PATH", join(env["gettextdir"], "bin"))
    env["MSGFMT"] = WhereIs("msgfmt")
    msgfmt = Builder(
        action = "$MSGFMT --check-domain --statistics -o $TARGET $SOURCE",
        src_suffix = ".po",
        suffix = ".mo",
        single_source = True
        )
    env["BUILDERS"]["Msgfmt"] = msgfmt

    env["MSGMERGE"] = WhereIs("msgmerge")
    msgmerge = Builder(
        action = "$MSGMERGE --backup=none --previous -U $TARGET $SOURCE",
        src_suffix = ".pot",
        suffix = ".po",
        single_source = True
        )
    env["BUILDERS"]["MsgMerge"] = msgmerge

    env["MSGINIT"] = WhereIs("msginit")
    msginit = Builder(
        action = "$MSGINIT -i $SOURCE -o $TARGET -l $MSGINIT_LINGUA --no-translator",
        src_suffix = ".pot",
        suffix = ".po",
        single_source = True
        )
    env["BUILDERS"]["MsgInit"] = msginit
    env["ENV"]["LANG"] = os.environ.get("LANG")
    env["MSGINIT_LINGUA"] = "C"

    def MsgInitMerge(env, target, source, **kw):
        if os.path.exists(target + ".po"):
            return env.MsgMerge(target, source, **kw)
        else:
            return env.MsgInit(target, source, **kw)
    env.AddMethod(MsgInitMerge)

    env["PO4A_GETTEXTIZE"] = WhereIs("po4a-gettextize")
    po4a_gettextize = Builder(
        action = "$PO4A_GETTEXTIZE -f $PO4A_FORMAT ${''.join([' -m ' + str(source) for source in SOURCES])} -p $TARGET",
        )
    env["BUILDERS"]["Po4aGettextize"] = po4a_gettextize

    env["PO4A_TRANSLATE"] = WhereIs("po4a-translate")
    po4a_translate = Builder(
        action = "$PO4A_TRANSLATE -f $PO4A_FORMAT -L $PO4A_CHARSET -m ${SOURCES[0]} -p ${SOURCES[1]} -l $TARGET"
        )
    env["BUILDERS"]["Po4aTranslate"] = po4a_translate
Beispiel #6
0
    def find(self, env):
        # Only search for it if not specified already
        if self.pysteScriptPath == None:
            # Try to find it in path somehow
            print "   searching for pyste.py in path..."
            if (WhereIs('pyste.py') != None):
                self.pysteScriptPath = WhereIs('pyste.py')
                self.pysteScriptCommand = "python " + self.pysteScriptPath
                print "   found: %s" % self.pysteScriptPath
            else:
                self.checkRequired("   could not find pyste.py script.\n")
                return

        assert self.pysteScriptPath
        assert self.pysteScriptCommand
Beispiel #7
0
def ParseConfig(env, command, options):
    "Parses xxx-config style output for compilation directives"

    # Run the command
    where = WhereIs(command)
    if not where:
        print '%s not found in PATH' % command
        sys.exit(-1)
    print "Found " + str(command) + ": " + where
    cmd = where + ' ' + string.join(options)
    params = string.split(os.popen(cmd).read())

    # Parse its output
    for arg in params:
        switch = arg[0:1]
        option = arg[1:2]
        if switch == '-':
            if option == 'I':
                env.Append(CPPPATH=[arg[2:]])
            elif option == 'L':
                env.Append(LIBPATH=[arg[2:]])
            elif option == 'l':
                env.Append(LIBS=[arg[2:]])
            elif arg[0:11] == '-Wl,-rpath,':
                env.Append(LINKFLAGS=[arg])
            elif arg[0:15] == '-Wl,-framework,':
                env.Append(LINKFLAGS=[arg])
            else:
                env.Append(CXXFLAGS=[arg])
        else:
            # Must be a static library, add it to the libs
            env.Append(LIBS=[arg])
Beispiel #8
0
def get_fb_info(fbc = 'fbc'):
    """Find fbc and query its version and default target and arch.
    'fbc' is the program name to use."""
    if not os.path.isfile (fbc):
        fbc = WhereIs (fbc)
        if not fbc:
            raise Exception("FreeBasic compiler is not installed!")
    # Newer versions of fbc (1.0+) print e.g. "FreeBASIC Compiler - Version $VER ($DATECODE), built for linux-x86 (32bit)"
    # older versions printed "FreeBASIC Compiler - Version $VER ($DATECODE) for linux"
    # older still printed "FreeBASIC Compiler - Version $VER ($DATECODE) for linux (target:linux)"
    fbcinfo = get_command_output(fbc, ["-version"])
    version, date = re.findall("Version ([0-9.]+) ([0-9()-]+)", fbcinfo)[0]
    fullfbcversion = version + ' ' + date
    # Convert e.g. 1.04.1 into 1041
    fbcversion = (lambda x,y,z: int(x)*1000 + int(y)*10 + int(z))(*version.split('.'))

    fbtarget = re.findall("target:([a-z]*)", fbcinfo)  # Old versions of fbc.
    if len(fbtarget) == 0:
        # New versions of fbc. Format is os-cpufamily, and it is the
        # directory name where libraries are kept in non-standalone builds.
        fbtarget = re.findall(" built for ([a-zA-Z0-9-_]+)", fbcinfo)
        if len(fbtarget) == 0:
            raise Exception("Couldn't determine fbc default target")
    fbtarget = fbtarget[0]
    if fbtarget == 'win64':
        # Special case (including new versions of fbc)
        default_target, default_arch = 'win32', 'x86_64'
    elif '-' in fbtarget:
        # New versions of fbc
        default_target, default_arch = fbtarget.split('-')
    else:
        # Old versions of fbc, and special case for dos, win32, xbox
        default_target, default_arch = fbtarget, 'x86'

    return fbc, fbcversion, fullfbcversion, default_target, default_arch
Beispiel #9
0
    def find(self, env):
        # Quick exit if nothing to find because it is already specified
        if self.baseDir != None:
            assert self.baseDir
            assert self.wxwidgetsconfig_cmd
            return
        else:
            self.checkRequired("wxwidgets base dir not found")
            return

        # Find cppunit-config and call it to get the other arguments
        sys.stdout.write("searching...\n")
        self.wxwidgetsconfig_cmd = WhereIs('wx-config')
        if None == self.wxwidgetsconfig_cmd:
            self.checkRequired(
                "   could not find wx-config. Use %s to specify it: Ex: %s=/usr/local"
                % (self.baseDirKey, self.baseDirKey))
        else:
            sys.stdout.write("   found wx-config.\n")
            found_ver_str = os.popen(self.wxwidgetsconfig_cmd +
                                     " --version").read().strip()
            sys.stdout.write("   version:%s" % found_ver_str)

            # find base dir
            self.baseDir = os.popen(self.wxwidgetsconfig_cmd +
                                    " --prefix").read().strip()
            if not os.path.isdir(self.baseDir):
                self.checkRequired("   returned directory does not exist:%s" %
                                   self.baseDir)
                self.baseDir = None
            else:
                print "   found at: ", self.baseDir
Beispiel #10
0
    def find(self, env):
        # quick exit if nothing to find
        if self.baseDir != None:
            return

        sys.stdout.write("searching...\n")
        self.plxconfig_cmd = WhereIs('plexus-config')
        if None == self.plxconfig_cmd:
            self.checkRequired("   could not find plexus-config")
        else:
            sys.stdout.write("   found plexus-config.\n")
            found_ver_str = os.popen(self.plxconfig_cmd +
                                     " --version").read().strip()
            sys.stdout.write("   version:%s" % found_ver_str)

            self.baseDir = os.popen(self.plxconfig_cmd +
                                    " --prefix").read().strip()

            if not os.path.isdir(self.baseDir):
                self.checkRequired("   returned directory does not exist:%s" %
                                   self.baseDir)

                self.baseDir = None
            else:
                print "   found at: ", self.baseDir
Beispiel #11
0
    def find(self, env):
        # Quick exit if nothing to find
        if self.baseDir != None:
            return

        # Find osg-config and call it to get the other arguments
        sys.stdout.write("searching for osg-config...\n")
        self.osgconfig_cmd = WhereIs('osg-config')
        if not self.osgconfig_cmd:
            self.checkRequired("   could not find osg-config.")
            self.osgconfig_cmd = None
            return
        else:
            try:
                sys.stdout.write("   found osg-config.\n")
                found_ver_str = os.popen(self.osgconfig_cmd +
                                         " --version").read().strip()
                sys.stdout.write("   version:%s" % found_ver_str)

                # find base dir
                self.baseDir = os.popen(self.osgconfig_cmd +
                                        " --prefix").read().strip()
                if not os.path.isdir(self.baseDir):
                    self.checkRequired(
                        "   returned directory does not exist:%s" %
                        self.baseDir)
                    self.baseDir = None
                else:
                    print "   found at: ", self.baseDir
            except Exception, ex:
                print "using osg-config failed."
                self.osgconfig_cmd = None
Beispiel #12
0
def generate_linux(env):
    icc = WhereIs('icc')
    if not icc:
        warnings.warn("icc not found")
    topdir = normpath(pjoin(pdirname(icc), os.pardir, os.pardir))
    abi = get_abi(env)
    return old_generate(env, abi=abi, topdir=topdir)
Beispiel #13
0
    def find(self, env):
        # Quick exit if nothing to find
        if self.baseDir != None:
            return

        # Find cmd-config and call it to get the other arguments
        sys.stdout.write("searching...\n")
        self.configCmdFullPath = WhereIs(self.configCmdName)
        if None == self.configCmdFullPath:
            self.checkRequired("   could not find %s." % self.configCmdName)
        else:
            sys.stdout.write("   found %s.\n" % self.configCmdName)
            found_ver_str = os.popen(self.configCmdFullPath +
                                     " --version").read().strip()
            sys.stdout.write("   version:%s" % found_ver_str)

            # find base dir
            self.baseDir = os.popen(self.configCmdFullPath +
                                    " --prefix").read().strip()
            if not os.path.isdir(self.baseDir):
                self.checkRequired("   returned directory does not exist:%s" %
                                   self.baseDir)
                self.baseDir = None
            else:
                print "   found at: ", self.baseDir
Beispiel #14
0
    def __init__(self, moduleName, fpcFile=None):
        " moduleName: The config command to call "
        self.moduleName = moduleName
        self.fpcFile = fpcFile
        if self.fpcFile is not None:
            self.fpcFile = self.fpcFile.strip()
        self.valid = True

        self.flagpoll_cmd = WhereIs('flagpoll')
        if None == self.flagpoll_cmd:
            print "FlagPollParser: Could not find flagpoll."
            self.valid = False
            return
        if self.fpcFile is not None and not os.path.isfile(self.fpcFile):
            print "FlagPollParser: Could not find fpc file:", self.fpcFile
            self.valid = False
            return

        # All calls to flagpoll need module name now.
        if 'win32' == GetPlatform():
            self.flagpoll_cmd = '"%s" %s' % (self.flagpoll_cmd,
                                             self.moduleName)
        else:
            self.flagpoll_cmd += " %s" % self.moduleName

        # Find out if the module exists.
        exists_resp = self.callFlagPoll("--exists")
        if "yes" != exists_resp.strip().lower():
            self.valid = False
            return

        # Initialize regular expressions
        # Res that when matched against config output should match the options we want
        # In future could try to use INCPREFIX and other platform neutral stuff
        self.inc_re = re.compile(r'(?: |^)[-/]I\s*("[^"]+"|\S+)', re.MULTILINE)
        self.framework_re = re.compile(r'(?: |^)-framework (\S+)',
                                       re.MULTILINE)
        self.link_flag_re = re.compile(r'(?: |^)([-/]\S*)', re.MULTILINE)

        if 'win32' == GetPlatform():
            self.lib_re = re.compile(r'(?: |^)(\S*\.lib)', re.MULTILINE)
            self.cxx_flags_re = re.compile(r'(?: |^)/D(\S*)', re.MULTILINE)
            #self.lib_path_re = re.compile(r'(?: |^)/LIBPATH:(\S*)', re.M | re.I)
            self.lib_path_re = re.compile(r'(?: |^)/LIBPATH:("[^"]+"|\S+)',
                                          re.M | re.I)
        else:
            self.lib_re = re.compile(r'(?: |^)-l(\S*)', re.MULTILINE)
            self.lib_path_re = re.compile(r'(?: |^)-L(\S*)', re.MULTILINE)
            self.cxx_flags_re = re.compile(r'(?: |^)-D(\S*)', re.MULTILINE)
Beispiel #15
0
def strip_nonfunction_symbols(binary, target_prefix, builddir, env):
    """Modifies a binary in-place, stripping symbols for global variables
    and undefined symbols (e.g. left behind by --gc-sections)"""
    nm = WhereIs(target_prefix + "nm")
    syms = get_command_output(nm, [binary], False)
    symfilename = os.path.relpath(builddir + binary + '.unwanted_symbols')
    with open(symfilename, 'w') as symfile:
        for line in syms.split('\n'):
            toks = line.strip().split(' ')
            if len(toks) == 3:
                address, symtype, symbol = toks
            else:
                symtype, symbol = toks
            assert len(symtype) == 1
            # Remove the following symbols:
            # U: undefined symbols
            # b/B, d/D, r/R: local/global variables (uninitialised, initalised, readonly)
            #    These are no use to the crash handler, only to gdb.
            # i: DLL junk (Windows only), not needed in a linked binary
            if symtype in 'UbBdDrRi':
                if symbol not in keep_symbols:
                    symfile.write(symbol + '\n')
    objcopy = WhereIs(target_prefix + "objcopy")
    env.Execute(objcopy + ' --strip-symbols ' + symfilename + ' ' + binary)
Beispiel #16
0
def generate(env):
    env["MSGFMT"] = WhereIs("msgfmt")
    action = [[
        "$MSGFMT",
        "--check-format",
        "--check-domain",
        "-f",
        "-o", "$TARGET",
        "$SOURCE"
    ]]
    env["GETTEXTSTR"] = action

    env["BUILDERS"]["Gettext"] = Builder(
        action = Action( action, "$GETTEXTSTR" ),
        src_suffix = ".po",
        suffix = ".mo",
        single_source = True
    )
Beispiel #17
0
def findtool(module, envvars, toolname, always_expand=False):
    """Look for a callable program, checking envvars, module variables, relative paths, PATH,
    and $target_prefix.
    Returns None if not found."""
    if not isinstance(envvars, (list, tuple)):
        envvars = envvars,
    for envvar in envvars:
        if os.environ.get(envvar):
            ret = os.environ.get(envvar)
            break
    else:
        if WhereIs(module['target_prefix'] + toolname):
            ret = module['target_prefix'] + toolname
        else:
            ret = toolname
    # standalone builds of FB on Windows do not search $PATH for binaries,
    # so we have to do so for it!
    ret = expand_tool_path(ret, module['win32'] or always_expand)
    return ret
Beispiel #18
0
def expand_tool_path(path, always_expand=False):
    """Try to find the file a path refers to, allowing absolute and relative
    paths and checking PATH; returns None if it can't be found.
    If it's in PATH, expand only if always_expand.
    """
    path = os.path.expanduser(path)  # expand ~
    if os.path.isfile(path):
        return path
    ret = WhereIs(path)
    if ret:
        if always_expand:
            return ret
        return path
    # The CWD gets changed to build/ while SConscript is processed, so look
    # relative to original directory, but then it gets changed back to original
    # dir while compiling, so convert to abspath
    ret = os.path.join("..", path)
    if os.path.isfile(ret):
        return os.path.abspath(ret)
    return None
Beispiel #19
0
   def find(self, env):
      # Quick exit if nothing to find because it is already specified
      if self.baseDir !=None:
         assert self.baseDir
         return

      # Find gmtl-config and call it to get the other arguments
      sys.stdout.write("searching...\n")
      self.gmtlconfig_cmd = WhereIs('gmtl-config')
      if None == self.gmtlconfig_cmd:
         self.checkRequired("   could not find gmtl-config")
      else:
         sys.stdout.write("   found gmtl-config.\n")
         # find base dir
         self.baseDir = os.popen(self.gmtlconfig_cmd + " --prefix").read().strip()
         if not os.path.isdir(self.baseDir):
            self.checkRequired("   returned directory does not exist:%s"%self.baseDir)
            self.baseDir = None
         else:
            print "   found at: ", self.baseDir
def _build_scons(environment, source, arguments, target):
    """Builds another SCons script.

    @param  environment  Environment that will be used to search for the SCons executable
    @param  source       Input file(s) for the build
    @param  arguments    Arguments that will be passed to SCons
    @param  target       Output file(s) produced by the build
    @returns A scons build action producing the target file"""

    # Clone the environment and use the real search PATH. This will not pollute
    # the environment in which the SCons subprocess runs, but is the only way
    # to invoke SCons in Windows because it's a batch file that exepcts Python
    # to also be in the system search PATH.
    cloned_environment = environment.Clone(ENV=os.environ)

    # Try to locate SCons with the environment's new search path
    scons_path = cloned_environment.WhereIs('scons')

    # If not found, try with SCons.Util.WhereIs() which actually works differently
    # from environment.WhereIs()...
    if scons_path is None:
        scons_path = WhereIs('scons')

    # Still not found? Just blindly shout 'scons' and if it fails that will
    # at least produce a meaningful error message that might make the user add
    # SCons to the system search PATH.
    if scons_path is None:
        scons_path = 'scons'

    if platform.system() == 'Windows':
        return cloned_environment.Command(
            source = source,
            action = '"' + scons_path + '" ' + arguments,
            target = target
        )
    else:
        return cloned_environment.Command(
            source = source,
            action = scons_path + ' ' + arguments,
            target = target
        )
Beispiel #21
0
def find_sundials_config(env):
    """
  Try and figure out if sundials-config is installed on this machine, and if so, where.
  """
    if SCons.Util.can_read_reg:
        # If we can read the registry, get the NSIS command from it
        try:
            # 0x20019 is KEY_READ,
            k = SCons.Util.RegOpenKeyEx(SCons.Util.hkey_mod.HKEY_LOCAL_MACHINE,
                                        'SOFTWARE\\SUNDIALS', 0, 0x20019)
            val, tok = SCons.Util.RegQueryValueEx(k, None)
            ret = val + os.path.sep + 'makensis.exe'
            if os.path.exists(ret):
                return '"' + ret + '"'
            else:
                return None
        except:
            pass  # Couldn't find the key, just act like we can't read the registry
    # Hope it's on the path, but note that we have to be careful with PATHEXT since sundials-config doesn't have an
    # an executable-signifying suffix (seems like a weakness with env.WhereIs in SCons??
    return WhereIs('sundials-config', path=os.environ['PATH'], pathext="")
Beispiel #22
0
    def find(self, env):
        # Quick exit if nothing to find because it is already specified
        if self.baseDir != None:
            assert self.baseDir
            return

        # Find osg2-config and call it to get the other arguments
        sys.stdout.write("searching...\n")
        self.config_script = WhereIs('osg2-config', pathext='')
        if None == self.config_script:
            self.checkRequired("   could not find osg2-config")
        else:
            sys.stdout.write("   found osg2-config.\n")
            full_command = sys.executable + ' ' + self.config_script
            # find base dir
            self.baseDir = os.popen(full_command + " --prefix").read().strip()
            if not os.path.isdir(self.baseDir):
                self.checkRequired("   returned directory does not exist:%s" %
                                   self.baseDir)
                self.baseDir = None
            else:
                print "   found at: ", self.baseDir
Beispiel #23
0
def can_build():
    return WhereIs("emcc") is not None
Beispiel #24
0
    def test_WhereIs(self):
        test = TestCmd.TestCmd(workdir='')

        sub1_xxx_exe = test.workpath('sub1', 'xxx.exe')
        sub2_xxx_exe = test.workpath('sub2', 'xxx.exe')
        sub3_xxx_exe = test.workpath('sub3', 'xxx.exe')
        sub4_xxx_exe = test.workpath('sub4', 'xxx.exe')

        test.subdir('subdir', 'sub1', 'sub2', 'sub3', 'sub4')

        if sys.platform != 'win32':
            test.write(sub1_xxx_exe, "\n")

        os.mkdir(sub2_xxx_exe)

        test.write(sub3_xxx_exe, "\n")
        os.chmod(sub3_xxx_exe, 0o777)

        test.write(sub4_xxx_exe, "\n")
        os.chmod(sub4_xxx_exe, 0o777)

        env_path = os.environ['PATH']

        try:
            pathdirs_1234 = [
                test.workpath('sub1'),
                test.workpath('sub2'),
                test.workpath('sub3'),
                test.workpath('sub4'),
            ] + env_path.split(os.pathsep)

            pathdirs_1243 = [
                test.workpath('sub1'),
                test.workpath('sub2'),
                test.workpath('sub4'),
                test.workpath('sub3'),
            ] + env_path.split(os.pathsep)

            os.environ['PATH'] = os.pathsep.join(pathdirs_1234)
            wi = WhereIs('xxx.exe')
            assert wi == test.workpath(sub3_xxx_exe), wi
            wi = WhereIs('xxx.exe', pathdirs_1243)
            assert wi == test.workpath(sub4_xxx_exe), wi
            wi = WhereIs('xxx.exe', os.pathsep.join(pathdirs_1243))
            assert wi == test.workpath(sub4_xxx_exe), wi

            wi = WhereIs('xxx.exe', reject=sub3_xxx_exe)
            assert wi == test.workpath(sub4_xxx_exe), wi
            wi = WhereIs('xxx.exe', pathdirs_1243, reject=sub3_xxx_exe)
            assert wi == test.workpath(sub4_xxx_exe), wi

            os.environ['PATH'] = os.pathsep.join(pathdirs_1243)
            wi = WhereIs('xxx.exe')
            assert wi == test.workpath(sub4_xxx_exe), wi
            wi = WhereIs('xxx.exe', pathdirs_1234)
            assert wi == test.workpath(sub3_xxx_exe), wi
            wi = WhereIs('xxx.exe', os.pathsep.join(pathdirs_1234))
            assert wi == test.workpath(sub3_xxx_exe), wi

            if sys.platform == 'win32':
                wi = WhereIs('xxx', pathext='')
                assert wi is None, wi

                wi = WhereIs('xxx', pathext='.exe')
                assert wi == test.workpath(sub4_xxx_exe), wi

                wi = WhereIs('xxx', path=pathdirs_1234, pathext='.BAT;.EXE')
                assert wi.lower() == test.workpath(sub3_xxx_exe).lower(), wi

                # Test that we return a normalized path even when
                # the path contains forward slashes.
                forward_slash = test.workpath('') + '/sub3'
                wi = WhereIs('xxx', path=forward_slash, pathext='.EXE')
                assert wi.lower() == test.workpath(sub3_xxx_exe).lower(), wi

            del os.environ['PATH']
            wi = WhereIs('xxx.exe')
            assert wi is None, wi

        finally:
            os.environ['PATH'] = env_path
Beispiel #25
0
def where_is(program):
    path = WhereIs(program)
    if path:
        path = os.path.dirname(path)
    return path
Beispiel #26
0
def add_builders(env):
    from sys import executable
    from SCons.Util import WhereIs

    pandoc_exec = WhereIs('pandoc')
    dot_exec = WhereIs('dot')
    assets = ' '.join(["--css=assets/" + str(x) for x in SlideExtraCSSFiles])
    template = ("--template=" +
                SlideTemplateName) if SlideTemplateName else ' '

    env.Append(BUILDERS={

        'WSD':env.Builder(
         action=['{0} -m websequence --style magazine '.format(executable) +
          '--format=png --in $SOURCE --out $TARGET'],
        suffix='.png',
        src_suffix='.wsd'),

        'Dot':env.Builder(
         action=["{0} -Tpng $SOURCE -o $TARGET".format(dot_exec)],
      suffix=".png",
      src_suffix=".dot"),

     'Neato':env.Builder(
      action=["neato -Tpng $SOURCE -o $TARGET"],
      suffix=".png",
      src_suffix=".dot"),

     'Python':env.Builder(
      action=["{0} $SOURCE $TARGET".format(executable)],
         suffix='.png',
         src_suffix='.py'),

        'Shell':env.Builder(
         action=['bash $SOURCE $TARGET'],
         suffix='.png',
         src_suffix='.sh'),

        'Wget':env.Builder(
         action=wget_each_url,
         emitter=yaml_emitter),

        'PandocSlides': env.Builder(
            generator = lambda source, target, env, for_signature: (
                           '{pandoc} -t revealjs -s -V theme={theme}'        \
                           ' --css=assets/{theme}.css'                       \
                           ' --css=assets/{theme}-ucl-overlay.css'           \
                           ' --css=assets/local_styles.css'                  \
                           ' {template} '                                    \
                           ' {assets} '                                      \
                           ' --default-image-extension=png'                  \
                           ' --highlight-style={highlight}'                  \
                           ' --mathjax'                                      \
                           ' -V revealjs-url=http://lab.hakim.se/reveal-js/' \
                           ' {sources} '                                     \
                           '-o {output}'.format(
                             pandoc    = pandoc_exec,
                             theme     = SlideStyle,
                             template  = template,
                             assets    = assets,
                             highlight = SlideSyntaxHighlightingStyle,
                             sources   = ' '.join([str(x) for x in source]),
                             output    = target[0]
                           )
            )
        ),

        'PandocLatex':env.Builder(
         action=['{0} --template=report '.format(pandoc_exec) +
           '-V documentclass=scrartcl ' +
           '-V links-as-notes ' +
           '--filter pandoc-citeproc ' +
           '--default-image-extension=png '+
           '-V linkcolor="uclmidgreen" ' +
           '--number-sections $SOURCES -o $TARGET'],
         ),

        'PandocJekyll':env.Builder(
         action=['{0} -thtml -s --template=jekyll'.format(pandoc_exec)+
           ' --default-image-extension=png'+
           ' --mathjax '+
           ' $SOURCES -o $TARGET']
         ),

              'Browse':env.Builder(action=browse_each_url, emitter=yaml_emitter),

        'Carousel':env.Builder(
         action=carousel.carousel_action,
            suffix=".png",
            src_suffix=".carousel"),

        'Cp':env.Builder(
         action=["cp $SOURCES $TARGET"]
         ),

        'R': env.Builder(
         action=['RScript $SOURCE $TARGET']
         ), # Assume R script expects dest file as first clarg

        'Bib': env.Builder(
         action=tidybib.tidybib_action,
         suffix=".bib",
         source_suffix=".zbib"
        )
          })

    env['ENV']["PYTHONPATH"] = sys.path
Beispiel #27
0
def generate_linux(env):
    ifort = WhereIs('ifort')
    if not ifort:
        warnings.warn("ifort not found")
    return old_generate(env)