Beispiel #1
0
def transferFls(src,
                dest,
                plat,
                debug,
                mVars,
                mFuns,
                foldersToFollow,
                parents=[]):
    if len(parents) == 0:
        print "Transfering files for " + plat + "..."
    for fil in bash.ls(src):
        fpath = src + "/" + fil
        if bash.isdir(fpath):
            if fil[0] == "_":
                if fil == rawFolder:
                    dpath = dest
                    for parent in parents:
                        dpath += "/" + parent
                        if not bash.exists(dpath):
                            bash.mkdir(dpath)
                    for f in bash.ls(fpath):
                        bash.cp_r(fpath + "/" + f, dpath + "/" + f)
                elif not fil in ignoreFolders:
                    transferLeaf(fpath, dest, plat, debug, mVars, mFuns,
                                 parents, fil in mergeFolders)
            elif fil in foldersToFollow:
                transferFls(fpath, dest, plat, debug, mVars, mFuns, uSet,
                            parents + [fil])
    htmlPath = src + "/" + indexHTML
    if bash.exists(htmlPath):
        transferLeaf(htmlPath, dest, plat, debug, mVars, mFuns, parents, True)
Beispiel #2
0
def compileTemplateToJava(src, package):
    types, params, content = compileTemplateInner(src);
    className = src[src.rfind("/")+1:];
    className = className[0].upper() + className[1:];
    packagePath = javaTmpltDir;
    packageName = "templates";
    if not bash.exists(packagePath):
        bash.mkdir(packagePath);
    for pack in package:
        packagePath += "/"+pack;
        packageName += "."+pack;
        if not bash.exists(packagePath):
            bash.mkdir(packagePath);

    outfil = bash.writefile(packagePath + "/" + className + ".java");
    outfil.write(   "package "+packageName+";\n\n"+
                    "public class "+className+" {\n"+
                    "\tpublic static String run(");
    for i in xrange(0, len(types)):
        if i > 0:
            outfil.write(", ");
        outfil.write(("Object" if types[i] == None else types[i]) + " " +
                    params[i]);
    outfil.write(") {\n\t\treturn\t"+content+";\n\t}\n}");
    outfil.close();
Beispiel #3
0
def compileTemplates(path, parentsOfT, parentsInT=[]):
    jsPath = path + "/.."*len(parentsInT) + "/../" + jsFolder;
    if not bash.exists(jsPath):
        bash.mkdir(jsPath);
    for fil in bash.ls(path):
        if bash.isdir(path+"/"+fil):
            compileTemplates(path+"/"+fil, parentsOfT, parentsInT+[fil]);
        elif fil.endswith(tmpltExt):
            fil = fil[:len(fil)-len(tmpltExt)];
            compileTemplate(path+"/"+fil, jsPath + "/templates." +
                ".".join(parentsInT) + ("." if len(parentsInT) > 0 else "") +
                fil + ".js", parentsInT);
Beispiel #4
0
def compileTemplates(path, parentsOfT, parentsInT=[]):
    jsPath = path + "/.." * len(parentsInT) + "/../" + jsFolder
    if not bash.exists(jsPath):
        bash.mkdir(jsPath)
    for fil in bash.ls(path):
        if bash.isdir(path + "/" + fil):
            compileTemplates(path + "/" + fil, parentsOfT, parentsInT + [fil])
        elif fil.endswith(tmpltExt):
            fil = fil[:len(fil) - len(tmpltExt)]
            compileTemplate(
                path + "/" + fil,
                jsPath + "/templates." + ".".join(parentsInT) +
                ("." if len(parentsInT) > 0 else "") + fil + ".js", parentsInT)
Beispiel #5
0
Datei: build.py Projekt: chkex/cx
def compileServerOnlyTemplates(src, mVars, mFuns, package=[]):
    tmpPath = src+"/"+tmpFolder;
    if not bash.exists(tmpPath):
        bash.mkdir(tmpPath);
    for fil in bash.ls(src):
        path = src+"/"+fil;
        if bash.isdir(path) and fil != tmpFolder:
            compileServerOnlyTemplates(path, mVars, mFuns, package+[fil]);
        elif fil.endswith(tmpltExt):
            fil = fil[:len(fil)-len(tmpltExt)];
            assert(bash.exists(src+"/"+fil+".tspec"));
            tmpTmplt = tmpPath+"/"+fil+".tmplt"; 
            tmpTspec = tmpPath+"/"+fil+".tspec"; 
            bash.cp_r(src+"/"+fil+".tmplt", tmpTmplt);
            bash.cp_r(src+"/"+fil+".tspec", tmpTspec);
            macros.run(tmpTmplt, mVars, mFuns);
            macros.run(tmpTspec, mVars, mFuns);
            compileTemplateToJava(tmpPath+"/"+fil, package);
    bash.rm_r(tmpPath);
Beispiel #6
0
def compileServerOnlyTemplates(src, mVars, mFuns, package=[]):
    tmpPath = src + "/" + tmpFolder
    if not bash.exists(tmpPath):
        bash.mkdir(tmpPath)
    for fil in bash.ls(src):
        path = src + "/" + fil
        if bash.isdir(path) and fil != tmpFolder:
            compileServerOnlyTemplates(path, mVars, mFuns, package + [fil])
        elif fil.endswith(tmpltExt):
            fil = fil[:len(fil) - len(tmpltExt)]
            assert (bash.exists(src + "/" + fil + ".tspec"))
            tmpTmplt = tmpPath + "/" + fil + ".tmplt"
            tmpTspec = tmpPath + "/" + fil + ".tspec"
            bash.cp_r(src + "/" + fil + ".tmplt", tmpTmplt)
            bash.cp_r(src + "/" + fil + ".tspec", tmpTspec)
            macros.run(tmpTmplt, mVars, mFuns)
            macros.run(tmpTspec, mVars, mFuns)
            compileTemplateToJava(tmpPath + "/" + fil, package)
    bash.rm_r(tmpPath)
Beispiel #7
0
def transferFls(src,dest,plat,debug,mVars,mFuns,foldersToFollow,parents=[]):
    if len(parents) == 0:
        print "Transfering files for "+plat+"..."
    for fil in bash.ls(src):
        fpath = src + "/" + fil;
        if bash.isdir(fpath):
            if fil[0] == "_":
                if fil == rawFolder:
                    dpath = dest;
                    for parent in parents:
                        dpath += "/"+parent;
                        if not bash.exists(dpath):
                            bash.mkdir(dpath);
                    for f in bash.ls(fpath):
                        bash.cp_r(fpath+"/"+f, dpath+"/"+f);
                elif not fil in ignoreFolders:
                    transferLeaf(fpath, dest, plat, debug, mVars, mFuns,
                                            parents, fil in mergeFolders);
            elif fil in foldersToFollow:
                transferFls(fpath, dest, plat, debug, mVars, mFuns, uSet,
                                                            parents+[fil])
    htmlPath = src+"/"+indexHTML;
    if bash.exists(htmlPath):
        transferLeaf(htmlPath,dest,plat,debug,mVars,mFuns,parents,True);
Beispiel #8
0
def compileTemplateToJava(src, package):
    types, params, content = compileTemplateInner(src)
    className = src[src.rfind("/") + 1:]
    className = className[0].upper() + className[1:]
    packagePath = javaTmpltDir
    packageName = "templates"
    if not bash.exists(packagePath):
        bash.mkdir(packagePath)
    for pack in package:
        packagePath += "/" + pack
        packageName += "." + pack
        if not bash.exists(packagePath):
            bash.mkdir(packagePath)

    outfil = bash.writefile(packagePath + "/" + className + ".java")
    outfil.write("package " + packageName + ";\n\n" + "public class " +
                 className + " {\n" + "\tpublic static String run(")
    for i in xrange(0, len(types)):
        if i > 0:
            outfil.write(", ")
        outfil.write(("Object" if types[i] == None else types[i]) + " " +
                     params[i])
    outfil.write(") {\n\t\treturn\t" + content + ";\n\t}\n}")
    outfil.close()
Beispiel #9
0
def transferLeaf(src, dest, plat, debug, mVars, mFuns, parents, merge):
    if merge:
        assert(len(parents) > 0);
    isDir = bash.isdir(src)
    wantsMacros = not (isDir and (os.path.basename(src) in noTemplating));
    ext = src[src.rfind("/_")+2:] if isDir else src[src.rfind(".")+1:];
    outPath = dest+("/"+ext if isDir else "");
    for parent in parents:
        if not bash.exists(outPath):
            bash.mkdir(outPath);
        outPath += "/" + parent;
    if not merge and not bash.exists(outPath):
        bash.mkdir(outPath);

    if isDir:
        # Get list of files to transfer 
        baseFolders = ["",  "/_"+plat] + (["/"+debugFolder,
                            "/_"+plat+"/"+debugFolder] if debug else []);

        # Actually transfer
        if merge:
            ofpath = outPath+"."+ext;
            outfil = bash.writefile(ofpath);
            i = 0;
            while i < len(baseFolders):
                baseFolder = src+baseFolders[i];
                if bash.exists(baseFolder):
                    fils = bash.ls(baseFolder);
                    oFil = baseFolder+"/"+orderFile;
                    if bash.exists(oFil):
                        oFilReader = bash.readfile(oFil);
                        o = oFilReader.read().strip().split();
                        oFilReader.close();
                        fils = o+list(set(fils).difference(o));
                    for fil in fils:
                        fname = baseFolder+"/"+fil;
                        if bash.isdir(fname):
                            if fil[0] != '_':
                                baseFolders.insert(i+1, fname[len(src):]);
                        elif fil.endswith("."+ext):
                            infil = bash.readfile(fname);
                            outfil.write(infil.read()+"\n");
                            infil.close()
                i += 1;
            outfil.close();
            if wantsMacros:
                macros.run(ofpath, mVars, mFuns);
            if ext == "js" and not debug:
                print "\tCompressing \""+ofpath+"\"..."
                bash.compressJS(ofpath, (plat != webPlat));
        else:
            for baseFolder in baseFolders:
                baseFolder = src+baseFolder;
                if bash.exists(baseFolder):
                    for fil in bash.ls(baseFolder):
                        fname = baseFolder+"/"+fil;
                        if fil[0] != '_' or not bash.isdir(fname):
                            oPath = outPath+"/"+fil;
                            bash.cp_r(fname, oPath);
                            if wantsMacros:
                                macros.run(oPath, mVars, mFuns);
    else:
        oPath = outPath + ("."+ext if merge else "");
        bash.cp_r(src, oPath);
        if wantsMacros:
            macros.run(oPath, mVars, mFuns);
Beispiel #10
0
    bash.rm_r(javaTmpltDir);
compileServerOnlyTemplates("server/templates", mVars, mFuns);

platforms = ["web", "iOS"];
platformPaths = [javaProjDir+"/war", "iOS/Checkout Express/www"];

if bash.exists(tmpFolder):
    bash.rm_r(tmpFolder);
bash.cp_r("webprojects", tmpFolder);
compileFolder(tmpFolder);
for i in xrange(0, len(platforms)):
    if bash.exists(platformPaths[i]):
        clearFolder(platformPaths[i],
            "server/protected_war.csv" if i == 0 else None)
    else:
        bash.mkdir(platformPaths[i])
    plat = platforms[i];
    native = plat != webPlat;
    path = platformPaths[i];
    mVars['PLATFORM'] = plat;
    mVars['NATIVE'] = "true" if native else "false";
    mVars['SERVER'] = server if native else "";
    mVars['MODERN'] = "true" if (native or 
                                    mVars['TEST'] == "true") else "false";
    transferFls(tmpFolder, path, plat, debug, mVars, mFuns,
                                        uSet if i == 0 else projectsForApp);
    # Download channel API
    if native:
        apiPath = "_ah/channel/jsapi";
        bash.mkdir(os.path.join(path, "_ah"));
        bash.mkdir(os.path.join(path, "_ah/channel"));
Beispiel #11
0
def transferLeaf(src, dest, plat, debug, mVars, mFuns, parents, merge):
    if merge:
        assert (len(parents) > 0)
    isDir = bash.isdir(src)
    wantsMacros = not (isDir and (os.path.basename(src) in noTemplating))
    ext = src[src.rfind("/_") + 2:] if isDir else src[src.rfind(".") + 1:]
    outPath = dest + ("/" + ext if isDir else "")
    for parent in parents:
        if not bash.exists(outPath):
            bash.mkdir(outPath)
        outPath += "/" + parent
    if not merge and not bash.exists(outPath):
        bash.mkdir(outPath)

    if isDir:
        # Get list of files to transfer
        baseFolders = ["", "/_" + plat] + (
            ["/" + debugFolder, "/_" + plat + "/" +
             debugFolder] if debug else [])

        # Actually transfer
        if merge:
            ofpath = outPath + "." + ext
            outfil = bash.writefile(ofpath)
            i = 0
            while i < len(baseFolders):
                baseFolder = src + baseFolders[i]
                if bash.exists(baseFolder):
                    fils = bash.ls(baseFolder)
                    oFil = baseFolder + "/" + orderFile
                    if bash.exists(oFil):
                        oFilReader = bash.readfile(oFil)
                        o = oFilReader.read().strip().split()
                        oFilReader.close()
                        fils = o + list(set(fils).difference(o))
                    for fil in fils:
                        fname = baseFolder + "/" + fil
                        if bash.isdir(fname):
                            if fil[0] != '_':
                                baseFolders.insert(i + 1, fname[len(src):])
                        elif fil.endswith("." + ext):
                            infil = bash.readfile(fname)
                            outfil.write(infil.read() + "\n")
                            infil.close()
                i += 1
            outfil.close()
            if wantsMacros:
                macros.run(ofpath, mVars, mFuns)
            if ext == "js" and not debug:
                print "\tCompressing \"" + ofpath + "\"..."
                bash.compressJS(ofpath, (plat != webPlat))
        else:
            for baseFolder in baseFolders:
                baseFolder = src + baseFolder
                if bash.exists(baseFolder):
                    for fil in bash.ls(baseFolder):
                        fname = baseFolder + "/" + fil
                        if fil[0] != '_' or not bash.isdir(fname):
                            oPath = outPath + "/" + fil
                            bash.cp_r(fname, oPath)
                            if wantsMacros:
                                macros.run(oPath, mVars, mFuns)
    else:
        oPath = outPath + ("." + ext if merge else "")
        bash.cp_r(src, oPath)
        if wantsMacros:
            macros.run(oPath, mVars, mFuns)
Beispiel #12
0
    bash.rm_r(javaTmpltDir)
compileServerOnlyTemplates("server/templates", mVars, mFuns)

platforms = ["web", "iOS"]
platformPaths = [javaProjDir + "/war", "iOS/Checkout Express/www"]

if bash.exists(tmpFolder):
    bash.rm_r(tmpFolder)
bash.cp_r("webprojects", tmpFolder)
compileFolder(tmpFolder)
for i in xrange(0, len(platforms)):
    if bash.exists(platformPaths[i]):
        clearFolder(platformPaths[i],
                    "server/protected_war.csv" if i == 0 else None)
    else:
        bash.mkdir(platformPaths[i])
    plat = platforms[i]
    native = plat != webPlat
    path = platformPaths[i]
    mVars['PLATFORM'] = plat
    mVars['NATIVE'] = "true" if native else "false"
    mVars['SERVER'] = server if native else ""
    mVars['MODERN'] = "true" if (native
                                 or mVars['TEST'] == "true") else "false"
    transferFls(tmpFolder, path, plat, debug, mVars, mFuns,
                uSet if i == 0 else projectsForApp)
    # Download channel API
    if native:
        apiPath = "_ah/channel/jsapi"
        bash.mkdir(os.path.join(path, "_ah"))
        bash.mkdir(os.path.join(path, "_ah/channel"))