def CleanOne(name): if not GetOption("clean"): return # Remove output files for path in Outputs(name): path = excons.out_dir + "/" + path if os.path.isfile(path): os.remove(path) excons.Print("Removed: '%s'" % excons.NormalizedRelativePath(path, excons.out_dir), tool="cmake") # Remove build temporary files buildDir = BuildDir(name) if os.path.isdir(buildDir): shutil.rmtree(buildDir) excons.Print("Removed: '%s'" % excons.NormalizedRelativePath(buildDir, excons.out_dir), tool="cmake") path = ConfigCachePath(name) if os.path.isfile(path): os.remove(path) excons.Print("Removed: '%s'" % excons.NormalizedRelativePath(path, excons.out_dir), tool="cmake") path = OutputsCachePath(name) if os.path.isfile(path): os.remove(path) excons.Print("Removed: '%s'" % excons.NormalizedRelativePath(path, excons.out_dir), tool="cmake")
def CleanOne(name): if not SCons.Script.GetOption("clean"): return # Remove output files for path in Outputs(name): path = excons.out_dir + "/" + path if os.path.isfile(path): os.remove(path) excons.Print("Removed: '%s'" % excons.NormalizedRelativePath(path, excons.out_dir), tool="automake") # Remove build temporary files buildDir = BuildDir(name) if os.path.isdir(buildDir): subprocess.Popen("cd \"%s\"; make distclean" % buildDir, shell=True).communicate() shutil.rmtree(buildDir) excons.Print("Removed: '%s'" % excons.NormalizedRelativePath(buildDir, excons.out_dir), tool="automake") path = ConfigCachePath(name) if os.path.isfile(path): os.remove(path) excons.Print("Removed: '%s'" % excons.NormalizedRelativePath(path, excons.out_dir), tool="automake") path = OutputsCachePath(name) if os.path.isfile(path): os.remove(path) excons.Print("Removed: '%s'" % excons.NormalizedRelativePath(path, excons.out_dir), tool="automake")
def Build(name, target=None): if SCons.Script.GetOption("clean"): return True ccf = ConfigCachePath(name) cof = OutputsCachePath(name) if not os.path.isfile(ccf): return False outfiles = set() symlinks = {} if target is None: target = "install" njobs = SCons.Script.GetOption("num_jobs") cmd = "cd \"%s\"; make" % BuildDir(name) if njobs > 1: cmd += " -j %d" % njobs if excons.GetArgument("show-cmds", 0, int): cmd += " V=1" cmd += " %s" % target excons.Print("Run Command: %s" % cmd, tool="automake") p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) buf = "" while p.poll() is None: r = p.stdout.readline(512) buf += r lines = buf.split("\n") if len(lines) > 1: buf = lines[-1] ParseOutputsInLines(lines[:-1], outfiles, symlinks) ParseOutputsInLines(buf.split("\n"), outfiles, symlinks) excons.Print(buf, tool="automake") if p.returncode == 0: with open(cof, "w") as f: lst = list(outfiles) # Add symlinks ll = len(lst) for i in xrange(ll): bn = os.path.basename(lst[i]) if bn in symlinks: dn = os.path.dirname(lst[i]) for l in symlinks[bn]: sln = dn + "/" + l if not sln in lst: lst.append(sln) #print("ADD - %s" % sln) lst.sort() f.write("\n".join(excons.NormalizedRelativePaths(lst, excons.out_dir))) return True else: if os.path.isfile(cof): os.remove(cof) return False
def Configure(name, topdir=None, opts={}, min_mscver=None, flags=None): if SCons.Script.GetOption("clean"): return True if topdir is None: topdir = os.path.abspath(".") bld = BuildDir(name) relpath = os.path.relpath(topdir, bld) cmd = "cd \"%s\" %s cmake " % (bld, CmdSep) if sys.platform == "win32": try: mscver = float(excons.GetArgument("mscver", "10.0")) if min_mscver is not None and mscver < min_mscver: mscver = min_mscver if mscver == 9.0: cmd += "-G \"Visual Studio 9 2008 Win64\" " elif mscver == 10.0: cmd += "-G \"Visual Studio 10 2010 Win64\" " elif mscver == 11.0: cmd += "-G \"Visual Studio 11 2012 Win64\" " elif mscver == 12.0: cmd += "-G \"Visual Studio 12 2013 Win64\" " elif mscver == 14.0: cmd += "-G \"Visual Studio 14 2015 Win64\" " elif mscver == 14.1: cmd += "-G \"Visual Studio 15 2017 Win64\" " else: excons.Print("Unsupported visual studio version %s" % mscver, tool="cmake") return False except: return False if flags: if not cmd.endswith(" "): cmd += " " cmd += flags if not flags.endswith(" "): cmd += " " for k, v in opts.iteritems(): cmd += "-D%s=%s " % (k, ("\"%s\"" % v if type(v) in (str, unicode) else v)) cmd += "-DCMAKE_INSTALL_PREFIX=\"%s\" " % excons.OutputBaseDirectory() if sys.platform != "win32": cmd += "-DCMAKE_SKIP_BUILD_RPATH=0 " cmd += "-DCMAKE_BUILD_WITH_INSTALL_RPATH=0 " cmd += "-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=0 " if sys.platform == "darwin": cmd += "-DCMAKE_MACOSX_RPATH=1 " cmd += relpath excons.Print("Run Command: %s" % cmd, tool="cmake") p = subprocess.Popen(cmd, shell=True) p.communicate() return (p.returncode == 0)
def Configure(name, topdir=None, opts={}): if GetOption("clean"): return True if topdir is None: topdir = os.path.abspath(".") bld = BuildDir(name) relpath = os.path.relpath(topdir, bld) success = False cmd = "cd \"%s\"; %s/configure " % (bld, relpath) for k, v in opts.iteritems(): if type(v) == bool: if v: cmd += "%s " % k else: cmd += "%s=%s " % (k, ("\"%s\"" % v if type(v) in (str, unicode) else v)) cmd += "--prefix=\"%s\"" % excons.OutputBaseDirectory() excons.Print("Run Command: %s" % cmd, tool="automake") p = subprocess.Popen(cmd, shell=True) p.communicate() return (p.returncode == 0)
def ParseOutputsInLines(lines, outfiles, symlinks): for line in lines: excons.Print(line, tool="automake") m = InstallExp.match(line.strip()) if m is not None: f = m.group(7) if os.path.isdir(f): items = filter(lambda y: len(y) > 0, map(lambda x: x.strip(), m.group(4).split(" "))) for item in items: o = f + "/" + os.path.basename(item) outfiles.add(o) #print("ADD - %s" % o) else: outfiles.add(f) #print("ADD - %s" % f) else: m = SymlinkExp.search(line.strip()) if m: srcdst = filter( lambda y: len(y) > 0, map(lambda x: x.strip(), m.group(3).split(" "))) count = len(srcdst) if count % 2 == 0: mid = count / 2 src = " ".join(srcdst[:mid]) dst = " ".join(srcdst[mid:]) lst = symlinks.get(src, []) lst.append(dst) symlinks[src] = lst
def ParseOutputsInLines(lines, outfiles): for line in lines: excons.Print(line, tool="cmake") m = InstallExp.match(line.strip()) if m is not None: f = m.group(2) if not os.path.isdir(f): outfiles.add(f)
def CleanOne(name): if not SCons.Script.GetOption("clean"): return # Remove output files for path in Outputs(name): path = excons.out_dir + "/" + path if os.path.isfile(path): os.remove(path) excons.Print("Removed: '%s'" % excons.NormalizedRelativePath(path, excons.out_dir), tool="automake") # Remove build temporary files buildDir = BuildDir(name) if os.path.isdir(buildDir): env = None if sys.platform != "win32": _env = excons.devtoolset.GetDevtoolsetEnv(excons.GetArgument( "devtoolset", ""), merge=True) if _env: env = os.environ.copy() env.update(_env) subprocess.Popen("cd \"%s\"; make distclean" % buildDir, shell=True, env=env).communicate() shutil.rmtree(buildDir) excons.Print("Removed: '%s'" % excons.NormalizedRelativePath(buildDir, excons.out_dir), tool="automake") path = ConfigCachePath(name) if os.path.isfile(path): os.remove(path) excons.Print("Removed: '%s'" % excons.NormalizedRelativePath(path, excons.out_dir), tool="automake") path = OutputsCachePath(name) if os.path.isfile(path): os.remove(path) excons.Print("Removed: '%s'" % excons.NormalizedRelativePath(path, excons.out_dir), tool="automake")
def AutoconfAction(target, source, env): configure = env["AUTOMAKE_CONFIGURE"] autogen = env["AUTOMAKE_AUTOGEN"] if os.path.isfile(autogen): cmd = "sh %s" % autogen elif os.path.isfile(configure + ".ac"): cmd = "autoreconf -vif" if cmd is not None: cmd = "cd \"%s\"; %s" % (env["AUTOMAKE_TOPDIR"], cmd) excons.Print("Run Command: %s" % cmd, tool="automake") p = subprocess.Popen(cmd, shell=True) p.communicate() if p.returncode != 0 or not os.path.isfile(configure): raise Exception("Failed to generate Automake 'configure' file") return None
def Configure(name, topdir=None, opts=None): if SCons.Script.GetOption("clean"): return True if opts is None: opts = {} if topdir is None: topdir = os.path.abspath(".") bld = BuildDir(name) relpath = os.path.relpath(topdir, bld) cmd = "cd \"%s\"; %s/configure " % (bld, relpath) for k, v in opts.iteritems(): if type(v) == bool: if v: cmd += "%s " % k else: cmd += "%s=%s " % (k, ("\"%s\"" % v if type(v) in (str, unicode) else v)) cmd += "--prefix=\"%s\"" % excons.OutputBaseDirectory() env = None if sys.platform != "win32": _env = excons.devtoolset.GetDevtoolsetEnv(excons.GetArgument( "devtoolset", ""), merge=True) if _env: env = os.environ.copy() env.update(_env) excons.Print("Run Command: %s" % cmd, tool="automake") p = subprocess.Popen(cmd, env=env, shell=True) p.communicate() return (p.returncode == 0)
def Build(name, config=None, target=None): if GetOption("clean"): return True ccf = ConfigCachePath(name) cof = OutputsCachePath(name) if not os.path.isfile(ccf): return False success = False outfiles = set() if config is None: config = excons.mode_dir if target is None: target = "install" cmd = "cd \"%s\" %s cmake --build . --config %s --target %s" % ( BuildDir(name), CmdSep, config, target) extraargs = "" njobs = GetOption("num_jobs") if njobs > 1: if sys.platform == "win32": extraargs += " /m:%d" % njobs else: extraargs += " -j %d" % njobs if excons.GetArgument("show-cmds", 0, int): if sys.platform == "win32": extraargs += " /v:n" # normal verbosity else: extraargs += " V=1" else: if sys.platform == "win32": extraargs += " /v:m" # minimal verbosity if extraargs: cmd += " --" + extraargs excons.Print("Run Command: %s" % cmd, tool="cmake") p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) buf = "" while p.poll() is None: r = p.stdout.readline(512) buf += r lines = buf.split("\n") if len(lines) > 1: buf = lines[-1] ParseOutputsInLines(lines[:-1], outfiles) ParseOutputsInLines(buf.split("\n"), outfiles) excons.Print(buf, tool="cmake") # Write list of outputed files if p.returncode == 0: with open(cof, "w") as f: lst = list(outfiles) lst.sort() f.write("\n".join( excons.NormalizedRelativePaths(lst, excons.out_dir))) return True else: if os.path.isfile(cof): os.remove(cof) return False
def Build(name, config=None, target=None): if SCons.Script.GetOption("clean"): return True ccf = ConfigCachePath(name) cof = OutputsCachePath(name) if not os.path.isfile(ccf): return False outfiles = set() if config is None: config = excons.mode_dir if target is None: target = "install" cmd = "cd \"%s\" %s %s --build . --config %s --target %s" % ( BuildDir(name), CmdSep, excons.GetArgument("with-cmake", "cmake"), config, target) env = None extraargs = "" njobs = SCons.Script.GetOption("num_jobs") if njobs > 1: if sys.platform == "win32": extraargs += " /m:%d" % njobs else: extraargs += " -j %d" % njobs if excons.GetArgument("show-cmds", 0, int): if sys.platform == "win32": extraargs += " /v:n" # normal verbosity else: extraargs += " V=1" else: if sys.platform == "win32": extraargs += " /v:m" # minimal verbosity if extraargs and (sys.platform != "win32" or float(excons.GetArgument("mscver", "10.0")) >= 10.0): cmd += " --" + extraargs if sys.platform != "win32": _env = excons.devtoolset.GetDevtoolsetEnv(excons.GetArgument( "devtoolset", ""), merge=True) if _env: env = os.environ.copy() env.update(_env) excons.Print("Run Command: %s" % cmd, tool="cmake") p = subprocess.Popen(cmd, shell=True, env=env, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) buf = "" while p.poll() is None: r = p.stdout.readline(512) buf += r lines = buf.split("\n") if len(lines) > 1: buf = lines[-1] ParseOutputsInLines(lines[:-1], outfiles) ParseOutputsInLines(buf.split("\n"), outfiles) excons.Print(buf, tool="cmake") # Write list of outputed files if p.returncode == 0: with open(cof, "w") as f: lst = filter(VC_Filter, outfiles) lst.sort() f.write("\n".join( excons.NormalizedRelativePaths(lst, excons.out_dir))) return True else: if os.path.isfile(cof): os.remove(cof) return False