Пример #1
0
def main():
    global FLAGS, LINK_FLAGS, LINK, DEFINE

    print "initing..."

    if not os.path.exists("wren"):
        print "downloading dependencies..."
        res = os.system("sh install_deps.sh")
        if res != 0:
            sys.exit(res)

    starttime = time.time()

    # Handle args
    build = "release" if "release" in sys.argv else "debug"
    verbose = "verbose" in sys.argv

    # Handle build type
    if build == "debug":
        FLAGS += ["-g"]
    else:
        FLAGS += ["-O3", "-flto"]
        LINK_FLAGS += ["-flto"]
        if platform.system() == "Windows":
            DEFINE += ["NEST_RELEASE"]

    print "building (" + build + ")..."

    # Make sure there arn't any temp files left over from a previous build
    cleanup()

    # Make sure the previous binary is deleted (windows)
    if os.path.isfile(OUTPUT):
        os.remove(OUTPUT)

    # Create directories
    os.makedirs(TEMPSRC_DIR)
    outdir = os.path.dirname(OUTPUT)
    if not os.path.exists(outdir):
        os.makedirs(outdir)

    # Create embedded-file header files
    for filename in os.listdir(EMBED_DIR):
        fullname = EMBED_DIR + "/" + filename
        res = cembed.process(fullname)
        open(TEMPSRC_DIR + "/" + cembed.safename(fullname) + ".h",
             "wb").write(res)

    # Build object files
    for directory in SOURCE:
        for filename in listFiles(directory):
            base, ext = os.path.splitext(os.path.basename(filename))
            if ext == ".c":
                res = compile_object_file(verbose, filename, base + ".o")
                if res != 0:
                    sys.exit(res)

    res = compile_executable(verbose)
    if res != 0:
        sys.exit(res)

    if build == "release":
        print "stripping..."
        os.system("strip %s" % OUTPUT)

    print "cleaning up..."
    cleanup()

    print "done (%.2fs)" % (time.time() - starttime)
Пример #2
0
def main():
  global FLAGS, SOURCE, LINK

  print "initing..."
  starttime = time.time()

  # Handle args
  build = "debug" if "debug" in sys.argv else "release"
  verbose = "verbose" in sys.argv
  
  # Handle build type
  if build == "debug":
    FLAGS += [ "-g" ]
  else:
    FLAGS += [ "-O3" ]

  # Handle "nojit" option -- compile with normal embedded Lua instead
  if "nojit" in sys.argv:
    LINK = filter(lambda x:"lua" not in x, LINK)
    SOURCE += ["src/lib/lua51/*.c"]

  print "building (" + build + ")..."
  
  # Make sure there arn't any temp files left over from a previous build
  clearup()

  # Create directories
  os.makedirs(TEMPSRC_DIR)
  outdir = os.path.dirname(OUTPUT)
  if not os.path.exists(outdir):
    os.makedirs(outdir)

  # Create embedded-file header files
  for filename in os.listdir(EMBED_DIR):
    fullname = EMBED_DIR + "/" + filename
    res = cembed.process(fullname)
    open(TEMPSRC_DIR + "/" + cembed.safename(fullname) + ".h", "wb").write(res)

  # Build
  cmd = fmt(
    "{compiler} -o {output} {flags} {source} {include} {link} {define} " + 
    "{extra}",
    {
      "compiler"  : COMPILER,
      "output"    : OUTPUT,
      "source"    : " ".join(SOURCE),
      "include"   : " ".join(map(lambda x:"-I" + x, INCLUDE)),
      "link"      : " ".join(map(lambda x:"-l" + x, LINK)),
      "define"    : " ".join(map(lambda x:"-D" + x, DEFINE)),
      "flags"     : " ".join(FLAGS),
      "extra"     : EXTRA,
    })
 
  if verbose:
    print cmd

  print "compiling..."
  res = os.system(cmd)

  if build == "release":
    print "stripping..."
    os.system("strip %s" % OUTPUT)

  print "clearing up..."
  clearup()

  if res == 0:
    print "done (%.2fs)" % (time.time() - starttime)
  else:
    print "done with errors"
  sys.exit(res)
Пример #3
0
def main():
    global FLAGS, SOURCE, LINK, DEFINE

    print "initing..."
    starttime = time.time()

    # Handle args

    if "release" in sys.argv: build = "release"
    elif "unsafe" in sys.argv: build = "unsafe"
    elif "size" in sys.argv: build = "size"
    elif "release2" in sys.argv: build = "release 2"
    else: build = "debug"

    verbose = "verbose" in sys.argv

    # Handle build type
    if build == "release":
        FLAGS += ["-funroll-loops", "-O3", "-ftracer"]
    elif build == "unsafe":
        FLAGS += ["-funroll-loops", "-Ofast", "-ftracer"]
    elif build == "release2":
        FLAGS += ["-funroll-loops", "-02", "-ftracer"]
    elif build == "size":
        FLAGS += ["-funroll-loops", "-Os"]
    else:
        FLAGS += ["-Og", "-pg", "-g"]
        DEFINE += ["AR_DEBUG"]

    print "building (" + build + ")..."

    # Make sure there arn't any temp files left over from a previous build
    clearup()

    # Create directories
    os.makedirs(TEMPSRC_DIR)
    outdir = os.path.dirname(OUTPUT)
    if not os.path.exists(outdir):
        os.makedirs(outdir)

    # Create embedded-file header files
    for filename in os.listdir(EMBED_DIR):
        fullname = EMBED_DIR + "/" + filename
        res = cembed.process(fullname)
        open(TEMPSRC_DIR + "/" + cembed.safename(fullname) + ".h",
             "wb").write(res)

    # Build
    cmd = fmt(
        "{compiler} -o {output} {flags} {source} {include} {link} {define} " +
        "{extra}", {
            "compiler": COMPILER,
            "output": OUTPUT,
            "source": " ".join(SOURCE),
            "include": " ".join(map(lambda x: "-I" + x, INCLUDE)),
            "link": " ".join(map(lambda x: "-l" + x, LINK)),
            "define": " ".join(map(lambda x: "-D" + x, DEFINE)),
            "flags": " ".join(FLAGS),
            "extra": " ".join(EXTRA),
        })

    if verbose:
        print cmd

    print "compiling..."
    res = os.system(cmd)

    if build != "debug":
        if os.path.isfile(OUTPUT):
            print "stripping..."
            os.system("strip %s" % OUTPUT)

    print "clearing up..."
    clearup()

    if res == 0:
        print "done (%.2fs)" % (time.time() - starttime)
    else:
        print "done with errors"
    sys.exit(res)