def sign(project): try: project.signjars except: project.signjars = [] try: project.output except: print "Nothing to sign." return if not project.output: print "Nothing to sign." return timestamp_flags = "-tsa http://tsa.starfieldtech.com" digest_flags = "-digestalg SHA1" alias = Settings.get("keystore_name") alias = alias if alias else "" print "Signing %s..." % project.output cmd = "%s -storepass %s %s %s %s %s" % ( os.path.join(project.javapath,"jarsigner"), Settings.get("keystore_pass"), timestamp_flags, digest_flags, project.output, alias ) print cmd os.system(cmd) # sign libs too (TODO: make optional) for signjars in project.signjars: print "signjars dir: %s" % signjars if os.path.isdir(signjars): for fn in os.listdir(signjars): #if fn.lower().endswith(".%s" % project.bin_ext): if fn.lower().endswith(".jar"): #print "Signing %s..." % fn cmd = "%s -storepass %s %s %s %s %s" % ( os.path.join(project.javapath, "jarsigner"), Settings.get("keystore_pass"), timestamp_flags, digest_flags, os.path.join(signjars,fn), alias ) print cmd os.system(cmd) # TODO: if system call returns with error, then return Status.FAILURE, regardless of --strict #return Status.FAILURE if Args.option("strict") else Status.UNSUPPORTED return Status.SUCCESS
def update(project): try: project.makepath = os.path.abspath(os.path.expanduser(Settings.get('make_path'))) except: project.makepath = "" # make sure theres a make step after cmake make_step = Plugin("steps", "make", "makefile") project.clean_commands = ["%s clean" % os.path.join(project.makepath,"make")] clean_step = Plugin("steps", "clean", "clean") if make_step in project.steps: project.steps.remove(make_step) if clean_step in project.steps: project.steps.remove(clean_step) i = 0 for s in project.steps: if s.type == "make" and s.name == "cmake": # TODO: check for user support (because of -r flag) if clean.clean.compatible(project) & Support.USER: project.steps.insert(i, clean_step) project.steps.insert(i+2, make_step) else: project.steps.insert(i+1, make_step) break i += 1
def update(project): try: project.makepath = os.path.abspath( os.path.expanduser(Settings.get('make_path'))) except: project.makepath = "" # make sure theres a make step after cmake make_step = Plugin("steps", "make", "makefile") conf_step = Plugin("steps", "make", "configure") project.clean_commands = [ "%s clean" % os.path.join(project.makepath, "make") ] clean_step = Plugin("steps", "clean", "clean") if make_step in project.steps: project.steps.remove(make_step) if clean_step in project.steps: project.steps.remove(clean_step) if conf_step in project.steps: project.steps.remove(conf_step) i = 0 for s in project.steps: if s.type == "make" and s.name == "cmake": # TODO: check for user support (because of -r flag) if clean.clean.compatible(project) & Support.USER: project.steps.insert(i, clean_step) project.steps.insert(i + 2, make_step) else: project.steps.insert(i + 1, make_step) break i += 1
def make(project): import psutil # relink a broken tmpfs-based obj dir if os.path.islink("obj") and not os.path.exists("obj"): os.unlink("obj") prefix = "sg-" + os.environ.get("LOGNAME") + "-" + project.name + "-" os.symlink(tempfile.mkdtemp(prefix=prefix), "obj") try: project.makepath = os.path.abspath(os.path.expanduser(Settings.get("make_path"))) except: project.makepath = "" try: project.makefile_params except: project.makefile_params = [] cores = multiprocessing.cpu_count() threads = int(cores * 1.5 + 0.5) # to prevent ram overusage (and thus HD hits), cap thread count to # GB of ram / 2 threads = int(min(threads, math.ceil(psutil.virtual_memory().total / 1024 / 1024 / 1024.0) / 1.5)) project.makefile_params += ["-j" + str(threads)] # example makefile params (add in project sg file): # makefile_params="CXX=\'clang++\'" # makefile_params="CXX=\'gccfilter -c -a g++\'" cmdline = [os.path.join(project.makepath, "make")] if project.makefile_params: cmdline += project.makefile_params try: os.chdir(project.build_dir) except: pass try: subprocess.check_call(cmdline) except subprocess.CalledProcessError: try: if project.build_dir: os.chdir("..") except: pass return Status.FAILURE try: if project.build_dir: os.chdir("..") except: pass # os.system("%s%s" % # (os.path.join(project.makepath,"make"), # " %s" % project.makefile_params # ) # ) return Status.SUCCESS
def make(project): try: project.npmpath = os.path.abspath(os.path.expanduser(Settings.get('npm_path'))) except: project.npmpath = "" if os.path.isfile("package.json.ls") or os.path.isfile("package.lson"): try: project.lscpath = os.path.abspath(os.path.expanduser(Settings.get('lsc_path'))) except: project.lscpath = "" if os.path.isfile("package.json.ls") : lscmd = [ os.path.join(project.lscpath,"lsc"), "-jc", "package.json.ls" ] elif os.path.isfile("package.lson"): lscmd = [ os.path.join(project.lscpath,"lsc"), "-jc", "package.lson" ] try: call(lscmd) except subprocess.CalledProcessError: return Status.FAILURE #try: # project.npm_params #except: # project.npm_params = [] cmdline = [os.path.join(project.npmpath,"npm"), "install"] #if project.npm_params: # cmdline += project.npm_params #print " ".join(cmdline) try: call(cmdline) except subprocess.CalledProcessError: return Status.FAILURE return Status.SUCCESS
def make(project): try: project.npmpath = os.path.abspath( os.path.expanduser(Settings.get('npm_path'))) except: project.npmpath = "" if os.path.isfile("package.json.ls") or os.path.isfile("package.lson"): try: project.lscpath = os.path.abspath( os.path.expanduser(Settings.get('lsc_path'))) except: project.lscpath = "" if os.path.isfile("package.json.ls"): lscmd = [ os.path.join(project.lscpath, "lsc"), "-jc", "package.json.ls" ] elif os.path.isfile("package.lson"): lscmd = [ os.path.join(project.lscpath, "lsc"), "-jc", "package.lson" ] try: call(lscmd) except subprocess.CalledProcessError: return Status.FAILURE #try: # project.npm_params #except: # project.npm_params = [] cmdline = [os.path.join(project.npmpath, "npm"), "install"] #if project.npm_params: # cmdline += project.npm_params #print " ".join(cmdline) try: call(cmdline) except subprocess.CalledProcessError: return Status.FAILURE return Status.SUCCESS
def sign(project): try: project.signjars except: project.signjars = [] try: project.output except: print "Nothing to sign." return if not project.output: print "Nothing to sign." return timestamp_flags = "-tsa http://tsa.starfieldtech.com" digest_flags = "-digestalg SHA1" alias = Settings.get("keystore_name") alias = alias if alias else "" print "Signing %s..." % project.output cmd = "%s -storepass %s %s %s %s %s" % (os.path.join( project.javapath, "jarsigner"), Settings.get("keystore_pass"), timestamp_flags, digest_flags, project.output, alias) print cmd os.system(cmd) # sign libs too (TODO: make optional) for signjars in project.signjars: print "signjars dir: %s" % signjars if os.path.isdir(signjars): for fn in os.listdir(signjars): #if fn.lower().endswith(".%s" % project.bin_ext): if fn.lower().endswith(".jar"): #print "Signing %s..." % fn cmd = "%s -storepass %s %s %s %s %s" % ( os.path.join(project.javapath, "jarsigner"), Settings.get("keystore_pass"), timestamp_flags, digest_flags, os.path.join(signjars, fn), alias) print cmd os.system(cmd) # TODO: if system call returns with error, then return Status.FAILURE, regardless of --strict #return Status.FAILURE if Args.option("strict") else Status.UNSUPPORTED return Status.SUCCESS
def make(project): try: project.sconspath = os.path.abspath(os.path.expanduser(Settings.get('scons_path'))) except: project.sconspath = "" os.system(os.path.join(project.sconspath,"scons")) return Status.SUCCESS
def update(project): try: project.generate except: project.generate = [] if "premake" in project.generate: generate(project) # can throw try: project.makepath = os.path.abspath(os.path.expanduser(Settings.get('make_path'))) except: project.makepath = "" # make sure theres a make step after premake make_step = Plugin("steps", "make", "makefile") conf_step = Plugin("steps", "make", "configure") if os.name == "nt": msb_step = Plugin("steps", "make", "msbuild") project.clean_commands = ["%s clean" % os.path.join(project.makepath,"make")] try: project.makefile_params except: project.makefile_params = [] if Args.option("debug"): project.makefile_params += ["config=debug"] else: project.makefile_params += ["config=release"] clean_step = Plugin("steps", "clean", "clean") if make_step in project.steps: project.steps.remove(make_step) if conf_step in project.steps: project.steps.remove(conf_step) if os.name == "nt": if msb_step in project.steps: project.steps.remove(msb_step) if clean_step in project.steps: project.steps.remove(clean_step) i = 0 if os.name == "nt": make_step = msb_step for s in project.steps: if s.type == "make" and s.name == "premake": # TODO: check for user support (because of -r flag) if clean.clean.compatible(project) & Support.USER: project.steps.insert(i, clean_step) project.steps.insert(i+2, make_step) else: project.steps.insert(i+1, make_step) break i += 1 make_step.call("update", project)
def obfuscate(project): obf_path = Settings.get("allatori_path") if not obf_path: return Status.UNSUPPORTED obf_path = os.path.abspath(os.path.expanduser(obf_path)) if not os.path.isfile(obf_path): return Status.FAILURE os.system("%s -jar %s %s" % (os.path.join(project.javapath, "java"), obf_path, os.path.join(os.getcwd(), "allatori.xml"))) return Status.SUCCESS
def make(project): try: project.sconspath = os.path.abspath( os.path.expanduser(Settings.get('scons_path'))) except: project.sconspath = "" os.system(os.path.join(project.sconspath, "scons")) return Status.SUCCESS
def compatible(project): # always deny compatibility, step can be added only by registered by another other addon or user script support = Support.PROJECT | Support.ENVIRONMENT #if(Settings.get("keystore_pass") and Settings.get("keystore_name")): if Settings.get("keystore_pass"): support |= Support.USER return support
def compatible(project): # always deny compatibility, step can be added only by registered by another other addon or user script support = Support.PROJECT | Support.ENVIRONMENT #if(Settings.get("keystore_pass") and Settings.get("keystore_name")): if Settings.get("keystore_pass"): support |= Support.USER return support
def obfuscate(project): obf_path = Settings.get("allatori_path") if not obf_path: return Status.UNSUPPORTED obf_path = os.path.abspath(os.path.expanduser(obf_path)) if not os.path.isfile(obf_path): return Status.FAILURE os.system("%s -jar %s %s" % (os.path.join(project.javapath, "java"), obf_path, os.path.join(os.getcwd(), "allatori.xml"))) return Status.SUCCESS
def make(project): try: project.gruntpath = os.path.abspath(os.path.expanduser(Settings.get('grunt_path'))) except: project.gruntpath = "" if os.path.isfile("Gruntfile.ls"): try: project.lscpath = os.path.abspath(os.path.expanduser(Settings.get('lsc_path'))) except: project.lscpath = "" lscmd = [ os.path.join(project.lscpath,"lsc"), "-c", "Gruntfile.ls" ] try: subprocess.check_call(lscmd) except subprocess.CalledProcessError: return Status.FAILURE #try: # project.grunt_params #except: # project.grunt_params = [] cmdline = [os.path.join(project.gruntpath,"grunt")] #if project.grunt_params: # cmdline += project.grunt_params #print " ".join(cmdline) try: subprocess.check_call(cmdline) except subprocess.CalledProcessError: return Status.FAILURE return Status.SUCCESS
def make(project): try: project.bowerpath = os.path.abspath(os.path.expanduser(Settings.get('bower_path'))) except: project.bowerpath = "" cmdline = [os.path.join(project.bowerpath,"bower"), "install"] try: call(cmdline) except subprocess.CalledProcessError: return Status.FAILURE return Status.SUCCESS
def make(project): try: project.yarnpath = os.path.abspath( os.path.expanduser(Settings.get('yarn_path'))) except: project.yarnpath = "" cmdline = [os.path.join(project.yarnpath, "yarn")] try: call(cmdline) except subprocess.CalledProcessError: return Status.FAILURE return Status.SUCCESS
def make(project): try: project.bowerpath = os.path.abspath( os.path.expanduser(Settings.get('bower_path'))) except: project.bowerpath = "" cmdline = [os.path.join(project.bowerpath, "bower"), "install"] try: call(cmdline) except subprocess.CalledProcessError: return Status.FAILURE return Status.SUCCESS
def update(project): try: project.qmake except: project.qmake = "qmake" #project.qmake = Settings.get('qmake') #if not project.qmake: # project.qmake = "qmake" project.qmakepath = Settings.get('qmake_path') if project.qmakepath: project.qmakepath = os.path.abspath(project.qmakepath) else: project.qmakepath = "" make_step = Plugin("steps", "make", "makefile") try: project.makepath except: project.makepath = "" project.clean_commands = [ "%s clean" % os.path.join(project.makepath, "make") ] clean_step = Plugin("steps", "clean", "clean") if make_step in project.steps: project.steps.remove(make_step) if clean_step in project.steps: project.steps.remove(clean_step) i = 0 for s in project.steps: if s.type == "make" and s.name == "qmake": # TODO: check for user support (because of -r flag) if clean.clean.compatible(project) & Support.USER: project.steps.insert(i, clean_step) project.steps.insert(i + 2, make_step) else: project.steps.insert(i + 1, make_step) break i += 1
def make(project): try: project.makepath = os.path.abspath(os.path.expanduser(Settings.get('make_path'))) except: project.makepath = "" # TODO: detect a suitable vcvars if the environment isn't init cmdline = [os.path.join(project.makepath,"msbuild")] cmdline += ["/p:Platform=Win32"] if Args.option("debug"): cmdline += ["/p:Configuration=Debug"] else: cmdline += ["/p:Configuration=Release"] if project.msbuild_params: cmdline += project.msbuild_params try: os.chdir(project.build_dir) except: pass try: call(cmdline) except subprocess.CalledProcessError: try: if project.build_dir: os.chdir("..") except: pass return Status.FAILURE try: if project.build_dir: os.chdir("..") except: pass return Status.SUCCESS
def update(project): try: project.qmake except: project.qmake = "qmake" #project.qmake = Settings.get('qmake') #if not project.qmake: # project.qmake = "qmake" project.qmakepath= Settings.get('qmake_path') if project.qmakepath: project.qmakepath = os.path.abspath(project.qmakepath) else: project.qmakepath = "" make_step = Plugin("steps", "make", "makefile") try: project.makepath except: project.makepath = "" project.clean_commands = ["%s clean" % os.path.join(project.makepath,"make")] clean_step = Plugin("steps", "clean", "clean") if make_step in project.steps: project.steps.remove(make_step) if clean_step in project.steps: project.steps.remove(clean_step) i = 0 for s in project.steps: if s.type == "make" and s.name == "qmake": # TODO: check for user support (because of -r flag) if clean.clean.compatible(project) & Support.USER: project.steps.insert(i, clean_step) project.steps.insert(i+2, make_step) else: project.steps.insert(i+1, make_step) break i += 1
def make(project): try: project.dockerpath = os.path.abspath( os.path.expanduser(Settings.get('docker_path'))) except: project.dockerpath = "" #try: # project.sudocmd = os.path.abspath(os.path.expanduser(Settings.get('sudo_command'))) #except: # project.sudo_command = "sudo" cmdline = [ os.path.join(project.dockerpath, "docker"), "-D=true", "build", "--no-cache", "-t=%s" % project.name, ".", ] #try: # call(os.path.join(project.dockerpath,"docker"), stdout=None, stderr=None) #except subprocess.CalledProcessError: # pass # TODO: only do this next block if current user is not part of docker group # or is not root #print "Docker needs root permissions (C-c to cancel)" #cmdline = [project.sudo_command] + cmdline #project.event("status", "preauth") try: call(cmdline) except subprocess.CalledProcessError: return Status.FAILURE return Status.SUCCESS
def make(project): try: project.dockerpath = os.path.abspath(os.path.expanduser(Settings.get('docker_path'))) except: project.dockerpath = "" #try: # project.sudocmd = os.path.abspath(os.path.expanduser(Settings.get('sudo_command'))) #except: # project.sudo_command = "sudo" cmdline = [ os.path.join(project.dockerpath,"docker"), "-D=true", "build", "--no-cache", "-t=%s"%project.name, ".", ] #try: # call(os.path.join(project.dockerpath,"docker"), stdout=None, stderr=None) #except subprocess.CalledProcessError: # pass # TODO: only do this next block if current user is not part of docker group # or is not root #print "Docker needs root permissions (C-c to cancel)" #cmdline = [project.sudo_command] + cmdline #project.event("status", "preauth") try: call(cmdline) except subprocess.CalledProcessError: return Status.FAILURE return Status.SUCCESS
def make(project): for folder in (project.classdir, project.output_path): try: os.mkdir(os.path.join(os.getcwd(), folder)) except OSError: pass classpath = "" # classpathlist = os.pathsep.join(project.classpath) for entry in project.classpath: if os.path.isfile(entry): if classpath: classpath += os.pathsep + entry else: classpath = entry continue for (path, dirs, files) in os.walk(os.path.join(os.getcwd(), entry)): for fn in files: if fn.lower().endswith(".jar"): rel_path = os.path.relpath(path, fn) rel_path = rel_path[len(os.pardir) + len(os.sep) : len(rel_path)] if classpath: classpath = os.pathsep.join((classpath, os.path.join(rel_path, fn))) else: classpath = os.path.join(rel_path, fn) if classpath: classpath = os.pathsep.join((classpath, os.pathsep.join(project.classpath))) else: classpath = os.pathsep.join(project.classpath) sourcepath = "" for entry in project.sourcepath: if os.path.isfile(entry): if sourcepath: sourcepath = sourcepath + os.linesep + os.path.join(rel_path, fn) else: sourcepath = os.path.join(rel_path, fn) continue for (path, dirs, files) in os.walk(os.path.join(os.getcwd(), entry)): for fn in files: for ext in project.src_ext: if fn.lower().endswith(".%s" % ext): rel_path = os.path.relpath(path, fn) rel_path = rel_path[len(os.pardir) + len(os.sep) : len(rel_path)] if sourcepath: sourcepath = "%s %s" % (sourcepath, os.path.join(rel_path, fn)) else: sourcepath = os.path.join(rel_path, fn) project.javapath = Settings.get("java_path") if project.javapath: project.javapath = os.path.abspath(project.javapath) else: project.javapath = "" # if project.javapath: # if project.javapath[-1] != os.sep and os.altsep and Settings.get('java_path')[-1] != os.altsep: # project.javapath += os.sep # else: # project.javapath = "" project.output = os.path.join(project.output_path, project.name + ".jar") # TODO: boostrap class path # removed: -source 1.6 -target 1.6 misc_params = " ".join(project.javac_params) os.system( "%s %s -d %s %s -cp %s" % (os.path.join(project.javapath, "javac"), misc_params, project.classdir, sourcepath, classpath) ) os.system( "%s cmf %s %s -C %s ." % (os.path.join(project.javapath, "jar"), project.manifest, project.output, project.classdir) ) # TODO wrap stdout from above commands and detect errors if not os.path.isfile(project.output): return Status.FAILURE return Status.SUCCESS
def make(project): for folder in (project.classdir, project.output_path): try: os.mkdir(os.path.join(os.getcwd(), folder)) except OSError: pass classpath = "" #classpathlist = os.pathsep.join(project.classpath) for entry in project.classpath: if os.path.isfile(entry): if classpath: classpath += os.pathsep + entry else: classpath = entry continue for (path, dirs, files) in os.walk(os.path.join(os.getcwd(), entry)): for fn in files: if fn.lower().endswith(".jar"): rel_path = os.path.relpath(path, fn) rel_path = rel_path[len(os.pardir) + len(os.sep):len(rel_path)] if classpath: classpath = os.pathsep.join( (classpath, os.path.join(rel_path, fn))) else: classpath = os.path.join(rel_path, fn) if classpath: classpath = os.pathsep.join( (classpath, os.pathsep.join(project.classpath))) else: classpath = os.pathsep.join(project.classpath) sourcepath = "" for entry in project.sourcepath: if os.path.isfile(entry): if sourcepath: sourcepath = sourcepath + os.linesep + os.path.join( rel_path, fn) else: sourcepath = os.path.join(rel_path, fn) continue for (path, dirs, files) in os.walk(os.path.join(os.getcwd(), entry)): for fn in files: for ext in project.src_ext: if fn.lower().endswith(".%s" % ext): rel_path = os.path.relpath(path, fn) rel_path = rel_path[len(os.pardir) + len(os.sep):len(rel_path)] if sourcepath: sourcepath = "%s %s" % (sourcepath, os.path.join(rel_path, fn)) else: sourcepath = os.path.join(rel_path, fn) project.javapath = Settings.get('java_path') if project.javapath: project.javapath = os.path.abspath(project.javapath) else: project.javapath = "" #if project.javapath: # if project.javapath[-1] != os.sep and os.altsep and Settings.get('java_path')[-1] != os.altsep: # project.javapath += os.sep #else: # project.javapath = "" project.output = os.path.join(project.output_path, project.name + ".jar") # TODO: boostrap class path # removed: -source 1.6 -target 1.6 misc_params = " ".join(project.javac_params) os.system("%s %s -d %s %s -cp %s" % (os.path.join(project.javapath, "javac"), misc_params, project.classdir, sourcepath, classpath)) os.system("%s cmf %s %s -C %s ." % (os.path.join(project.javapath, "jar"), project.manifest, project.output, project.classdir)) # TODO wrap stdout from above commands and detect errors if not os.path.isfile(project.output): return Status.FAILURE return Status.SUCCESS
def update(project): try: project.generate except: project.generate = [] if "premake" in project.generate: generate(project) # can throw try: project.makepath = os.path.abspath( os.path.expanduser(Settings.get('make_path'))) except: project.makepath = "" # make sure theres a make step after premake make_step = Plugin("steps", "make", "makefile") conf_step = Plugin("steps", "make", "configure") if os.name == "nt": msb_step = Plugin("steps", "make", "msbuild") project.clean_commands = [ "%s clean" % os.path.join(project.makepath, "make") ] try: project.makefile_params except: project.makefile_params = [] if Args.option("debug"): project.makefile_params += ["config=debug"] else: project.makefile_params += ["config=release"] clean_step = Plugin("steps", "clean", "clean") if make_step in project.steps: project.steps.remove(make_step) if conf_step in project.steps: project.steps.remove(conf_step) if os.name == "nt": if msb_step in project.steps: project.steps.remove(msb_step) if clean_step in project.steps: project.steps.remove(clean_step) i = 0 if os.name == "nt": make_step = msb_step for s in project.steps: if s.type == "make" and s.name == "premake": # TODO: check for user support (because of -r flag) if clean.clean.compatible(project) & Support.USER: project.steps.insert(i, clean_step) project.steps.insert(i + 2, make_step) else: project.steps.insert(i + 1, make_step) break i += 1 make_step.call("update", project)