Exemplo n.º 1
0
def buildall_intern(redo_final=False):
    for t in targets:
        for s in t:
            s.build = False

    for t in targets:
        filter_srcs(t)

    build_final = redo_final

    for t in targets:
        build_final |= build_target(t)

    build_final |= do_copy_targets()

    if build_final:
        ok = build_platforms()

        if not ok:
            sys.stderr.write(util.termColor("Build failed\n", "red"))

            note.showNote(THENOTE, NOTETITLE, "Build failed")
            note.sleep(1.0)
            note.hideNote(THENOTE)
            return 0
        else:
            util.doprint("Finished build")

            note.showNote(THENOTE, NOTETITLE, "Finished Build")
            note.sleep(1.0)
            note.hideNote(THENOTE)

    return 1
Exemplo n.º 2
0
def build_chrome_package():
    util.doprint("Building chrome app. . .")

    zf = zipfile.ZipFile("chromeapp.zip", "w")

    if not os.path.exists("./dist/chromeapp/fcontent/"):
        os.makedirs("./dist/chromeapp/fcontent/")

    for f in os.listdir("./dist/chromeapp"):
        path = "./dist/chromeapp/" + f
        if f == "fcontent": continue

        zf.write(path, f)

    for f in os.listdir("./dist/chromeapp/icons"):
        path = "./dist/chromeapp/icons/" + f

        zf.write(path, "icons/" + f)

    print("  copying files")
    for f in os.listdir("./build"):
        if not f.startswith("chrome") and f.endswith(".js"):
            continue

        path = "build/" + f
        file = open(path, "rb")
        buf = file.read()
        file.close()

        zf.write(path, "fcontent/" + f)

        path = "dist/chromeapp/fcontent/" + f
        file = open(path, "wb")
        file.write(buf)
        file.close()

    print("done")
Exemplo n.º 3
0
def build_target(files):
    global db, db_depend, procs

    with DataBase("jbuild.db") as db:
        with DataBase("jbuild_dependencies.db") as db_depend:
            if build_cmd == "cleanbuild":
                print("CLEAN BUILD 2!")

                for k in db:
                    db[k] = 0
                db.sync()

            built_files = []
            failed_files = []
            fi = 0

            filtered = list(iter_files(files))
            build_final = False
            first = True

            commands = []

            for f, target, abspath, rebuild in filtered:
                fname = os.path.split(abspath)[1]
                sf = files[fi]
                fi += 1

                build_final |= rebuild in [REBUILD, WASBUILT]
                if rebuild != REBUILD: continue

                if first:
                    note.clearNote(THENOTE)
                    note.showNote(THENOTE, NOTETITLE, "Starting Build")
                    first = False

                sf.build = WASBUILT

                built_files.append([abspath, safe_stat(abspath), f])
                pathtime = built_files[-1]

                re_size = 0
                use_popen = None
                for k in handlers:
                    if re.match(k, f) and len(k) > re_size:
                        cmd = handlers[k].func(np(f), np(target))
                        use_popen = handlers[k].use_popen
                        re_size = len(k)

                perc = int((float(len(filtered) - fi) / len(filtered)) * 100.0)
                """
            dcmd = cmd.replace(JCC, "js_cc").replace(PYBIN, "")
            dcmd = dcmd.split(" ")
            dcmd2 = ""
            for n in dcmd:
              if n.strip() == "": continue
              n = n.strip()
              if "/" in n or "\\" in n:
                n = os.path.split(n)[1]
              dcmd2 += n + " "
            dcmd = dcmd2
            """

                dcmd = os.path.split(f)[1] if ("/" in f or "\\" in f) else f
                dcmd = (util.termColor("[%i%%] " % perc, "cyan") +
                        dcmd.strip())

                #execute build command

                if len(failed_files) > 0: continue

                if False and use_popen:
                    #shlex doesn't like backslashes
                    if win32:
                        cmd = cmd.replace("\\", "/")
                    else:
                        cmd = cmd.replace("\\", "\\\\")

                    cmdlist = shlex.split(cmd)

                    commands.append([cmdlist, dcmd, f])
                else:
                    print(cmd)
                    ret = os.system(cmd)

                    if failed_ret(ret):
                        failed_files.append(f)
                    else:
                        db[pathtime[0]] = pathtime[1]

            while len(procs) > 0 or len(commands) > 0:
                for i, c in enumerate(commands[:]):
                    if len(procs) >= num_cores:
                        break

                    cmdlist, dcmd, f = commands.pop()

                    reportbuf = dcmd  #" ".join(cmdlist)
                    print(reportbuf)
                    note.appendNote(THENOTE, reportbuf)

                    proc = subprocess.Popen(cmdlist)
                    procs.append([proc, f, pathtime])

                newprocs = []
                for p in procs:
                    if p[0].poll() == None:
                        newprocs.append(p)
                    else:
                        ret = p[0].returncode

                        if failed_ret(ret):
                            failed_files.append(p[1])

                procs = newprocs
                note.sleep(0.05)

            if len(failed_files) == 0 and len(built_files) > 0:
                note.showNote(THENOTE, NOTETITLE, "Done!")
                note.sleep(1)

            if len(failed_files) > 0:
                note.showNote(THENOTE, NOTETITLE, "Build Failed")
                note.sleep(1)

                print("build failure\n\n", failed_files)

                for f in failed_files:
                    for i, f2 in enumerate(built_files):
                        if f2[2] == f: break

                    built_files.pop(i)

                for pathtime in built_files:
                    db[pathtime[0]] = pathtime[1]

                sys.stdout.flush()

                if build_cmd != "loop":
                    note.destroy()
                    sys.exit(-1)
                else:
                    return 0

            #note.hideNote(THENOTE)

            for pathtime in built_files:
                if pathtime[0] in db:
                    print("saving", db[pathtime[0]], pathtime[1])

                db[pathtime[0]] = pathtime[1]

            #write aggregate, minified file
            if build_final:
                #note.showNote(THENOTE, NOTETITLE, "\n\nwriting %s..." % (target_path+files.target))
                #note.sleep(0.5);
                #note.hideNote(THENOTE)

                print("\n\nwriting %s..." % (target_path + files.target))
                sys.stdout.flush()
                aggregate(files, target_path + files.target)
                print("done.")

            if build_cmd != "loop":
                util.doprint("build finished")

    return build_final
Exemplo n.º 4
0
def build_package():
    util.doprint("Building fairmotion_alpha.zip. . .")
    zf = zipfile.ZipFile("fairmotion_alpha.zip", "w")

    def zwrite(path):
        zf.write(path, "fairmotion_alpha/" + path)

    zwrite("build/app.js")
    apath = "build/app0.js"
    i = 1
    while os.path.exists(apath):
        zwrite(apath)
        apath = "build/app%i.js" % i
        i += 1

    zwrite("examples/male character.fmo")
    zwrite("examples/scene.fmo")
    zwrite("examples/wip_animation.fmo")

    target = None
    for t in targets:
        if t.target == "app.js":
            target = t
            break

    for f in target:
        if not os.path.exists(f.target): continue

        if not f.target.lower().endswith(".js"):
            zwrite(f.target)

    for f in os.listdir("pyserver"):
        if f != "config_local.py" and (f.endswith(".py")
                                       or f.endswith(".sql")):
            zwrite("pyserver/" + f)
    run_simple = """#!/usr/bin/env python
#!/usr/bin/env python
import os, os.path, sys

path = os.path.abspath(os.path.normpath(os.getcwd()))

os.chdir("pyserver")
sys.path.append(os.getcwd())

if not os.path.exists("config_local.py"):
  print("generating config_local.py...")
  buf = \"""
serverhost = "127.0.0.1"
serverport = 8080

base_path = "/"
server_root = r"ROOT/pyserver"
doc_root = r"ROOT"

#this isn't used unless you turn off serv_all_local
files_root = r"ROOT/userfiles"

ipaddr = "127.0.0.1"
  \""".replace("ROOT", path)
  f = open("config_local.py", "w")
  f.write(buf)
  f.close()

import serv_simple
"""

    zf.writestr("fairmotion_alpha/run.py", run_simple)
    zf.writestr("fairmotion_alpha/src/core/config_local.js", """'use strict';
  //local config file
  """)

    zf.close()
    print("done.")
Exemplo n.º 5
0

#I hate bugs in different versions of python
def makedirs_safe(p, exist_ok=False):
    if os.path.exists(p) and exist_ok:
        return
    _makedirs(p)


os.makedirs = makedirs_safe
os.makedirs("./dist", True)

try:
    import ply
except:
    util.doprint("Installing PLY")
    os.system("pip install ply")

if not os.path.exists("platforms/build_local.py"):
    f = open("platforms/build_local.py", "w")
    f.write("""
#example build_local.py
#
#import platforms.chromeapp.build
#import platforms.html5.build
#import platforms.PhoneGap.build
#import platforms.Electron.build

#build_platforms = [
#  platforms.chromeapp.build,
#  platforms.html5.build,