def createDoc(name, classname): Utils.mkdir('docs') src = loadTemplate("templateDoc.cpp.py.txt") with open(os.path.join('docs', classname + ".cpp.py"), "w") as docfile: docfile.write(src.format(name=name, classname=classname)) src = loadTemplate("templateIDL.txt") with open(os.path.join('docs', name + ".idl"), "w") as docfile: docfile.write(src.format(name=name, classname=classname))
def createVar(name, classname): for path in [ 'tests', os.path.join('tests', 'gunittest'), os.path.join('tests', 'jsunittest'), os.path.join('tests', 'jsautotest') ]: Utils.mkdir(path) with open(os.path.join(path, ".gitignore"), "w") as cppfile: cppfile.write('') with open(".gitignore", "w") as cppfile: cppfile.write('*.pyc\nkonstruct.log\nlockfile\nbuild\nthird-party\n')
def packageServer(): name = getPackageName() tmpDir = os.path.join("build", "package", "nidium-server") Utils.mkdir(tmpDir) Utils.run("echo \"%s\" > %s/LICENSE" % (LICENSE, tmpDir)) shutil.copy(OUTPUT_BINARY, tmpDir) with Utils.Chdir("build/package/"): Utils.run("tar -czvf %s.tar.gz nidium-server/" % (name)) shutil.rmtree(tmpDir);
def createmodule(name, classname, path): """Create a new Native Module.""" if classname is None: classname = name if path is None: path = os.getcwd() moduleDir = (os.path.abspath(os.path.join(path, name))) if os.path.exists(moduleDir): ret = Utils.promptYesNo( "Directory %s exists, any default module files will be overriden. Continue ? " % moduleDir) if not ret: Utils.exit() else: if not Utils.promptYesNo( "module will be created in %s directory. Continue ?" % moduleDir): Utils.exit() Utils.mkdir(moduleDir) with Utils.Chdir(moduleDir): createConfigure(name) createGyp(name, classname) createSource(name, classname) createDoc(name, classname) createVar(name, classname) print( "Your module is now ready. It can be build by adding the argument --module=%s to the configure script of NativeStudio or NativeServer" % (os.path.abspath(os.path.join(path, name)))) print( "You may want to create a repository for your module with 'git init {0}" .format(name))
def signCode(path): if SIGN_IDENTITY is None: Log.info("No identity providen, not signing app") return Log.info("Signing nidium package...") code, output = Utils.run(" ".join([ "codesign", "--force", "--sign", "'Developer ID Application: %s '" % SIGN_IDENTITY, path ]), failExit=False) if code != 0: Log.error("WARNING : App signing failed with identity %s. Not signing app" % identity) Log.error(output) Log.info(path)
def stripExecutable(): Log.info("Striping executable") Utils.run("strip " + OUTPUT_BINARY)
def packageFrontend(): import tarfile path = "bin/" baseResources = "resources/" name = getPackageName() tmpDir = os.path.join("build", "package", "nidium.tmp") Utils.mkdir(tmpDir) Utils.run("echo \"%s\" > %s/LICENSE" % (LICENSE, tmpDir)) if Platform.system == "Darwin": signCode(path + "nidium.app") Log.info("Create dmg...") resources = "%s/osx/" % (baseResources) name += ".dmg" cmd = [ "tools/installer/osx/create-dmg", "--volname 'Nidium'", "--no-internet-enable", "--volicon " + resources + "/nidium.icns", "--background " + resources + "/dmg-background.png", "--window-size 555 418", "--icon-size 96", "--eula %s/LICENSE" % tmpDir, "--app-drop-link 460 290", "--icon 'nidium.app' 460 80", "build/package/%s" % name, path + "nidium.app/" ] code, output = Utils.run(" ".join(cmd)) if code != 0: Utils.exit("Failed to build dmg") elif Platform.system == "Linux": resources = "%s/linux/" % (baseResources) name += ".run" Utils.mkdir(tmpDir + "/dist/") Utils.mkdir(tmpDir + "/resources/") shutil.copy(resources + "/nidium.desktop", tmpDir + "/resources/") shutil.copy(resources + "/x-application-nidium.xml", tmpDir + "/resources/") shutil.copy(baseResources + "/icons/nidium.iconset/[email protected]", tmpDir + "/resources/nidium.png") shutil.copy(resources + "/installer.sh", tmpDir) shutil.copy(path + "nidium", tmpDir + "/dist/") # XXX : Uncomment once breakpad & landing net are back #shutil.copy(path + "nidium-crash-reporter", tmpDir + "dist/") Utils.run("tools/installer/linux/makeself.sh --license %s/LICENSE %s build/package/%s 'Nidium installer' ./installer.sh " % (tmpDir, tmpDir, name)) else: # Window TODO print("TODO") shutil.rmtree(tmpDir);
Log.info("Packaging %s" % FLAVOUR) if FLAVOUR == "frontend": packageFrontend() elif FLAVOUR == "server": packageServer() if __name__ == '__main__': # First, parse command line arguments, so we # can print the help message (if needed) and # exit before doing anything else CommandLine.parse() if FLAVOUR is None: Utils.exit("Please specify a flavour to package with --frontend or --server"); if FLAVOUR == "frontend": configure = imp.load_source("configure", "configure_frontend"); # Make sure we are using the correct deps for the # current configuration before building dir2nvfs Deps._process() # Build dir2nvfs and the embed file configure.addEmbed() else: imp.load_source("configure", "configure_server"); Konstruct.start()
def packageFrontend(): import tarfile path = "bin/" baseResources = "resources/" name = getPackageName() tmpDir = os.path.join("build", "package", "nidium.tmp") Utils.mkdir(tmpDir) Utils.run("echo \"%s\" > %s/LICENSE" % (LICENSE, tmpDir)) if Platform.system == "Darwin": signCode(path + "nidium.app") Log.info("Create dmg...") resources = "%s/osx/" % (baseResources) name += ".dmg" cmd = [ "tools/installer/osx/create-dmg", "--volname 'Nidium'", "--no-internet-enable", "--volicon " + resources + "/nidium.icns", "--background " + resources + "/dmg-background.png", "--window-size 555 418", "--icon-size 96", "--eula %s/LICENSE" % tmpDir, "--app-drop-link 460 290", "--icon 'nidium.app' 460 80", "build/package/%s" % name, path + "nidium.app/" ] code, output = Utils.run(" ".join(cmd)) if code != 0: Utils.exit("Failed to build dmg") elif Platform.system == "Linux": resources = "%s/linux/" % (baseResources) name += ".run" Utils.mkdir(tmpDir + "/dist/") Utils.mkdir(tmpDir + "/resources/") shutil.copy(resources + "/nidium.desktop", tmpDir + "/resources/") shutil.copy(resources + "/x-application-nidium.xml", tmpDir + "/resources/") shutil.copy(baseResources + "/icons/nidium_64x64.png", tmpDir + "/resources/nidium.png") shutil.copy(resources + "/installer.sh", tmpDir) shutil.copy(path + "nidium", tmpDir + "/dist/") # XXX : Uncomment once breakpad & landing net are back #shutil.copy(path + "nidium-crash-reporter", tmpDir + "dist/") Utils.run("tools/installer/linux/makeself.sh --license %s/LICENSE %s build/package/%s 'Nidium installer' ./installer.sh " % (tmpDir, tmpDir, name)) else: # Window TODO print("TODO") shutil.rmtree(tmpDir);
def createGyp(name, classname): Utils.mkdir("gyp") src = loadTemplate("templateGyp.txt") with open(os.path.join("gyp", name + ".gyp"), "w") as gypfile: gypfile.write(src.format(name, classname))