예제 #1
0
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
예제 #2
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
예제 #3
0
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