def test_limit(self): with shell.tempDir() as d: shell.mkdir(d + "/A/K/X", createParents=True) shell.mkdir(d + "/A/K/Y", createParents=True) shell.mkdir(d + "/A/L", createParents=True) shell.mkdir(d + "/B") shell.mkdir(d + "/C") shell.touch(d + "/A/L/x.txt") shell.touch(d + "/A/K/x.txt") shell.touch(d + "/A/K/X/x.txt") shell.touch(d + "/A/K/Y/x.txt") shell.touch(d + "/B/x.txt") shell.touch(d + "/C/x.txt") def action(d): self.assertTrue(shell.isFile(d + "/A/K/x.txt")) self.assertTrue(shell.isFile(d + "/A/K/X/x.txt")) self.assertTrue(shell.isFile(d + "/A/K/Y/x.txt")) self.assertTrue(shell.isFile(d + "/C/x.txt")) self.assertFalse(shell.isFile(d + "/B/x.txt")) self.assertFalse(shell.isFile(d + "/A/L/x.txt")) self.assertFalse(shell.isDir(d + "/B")) self.assertFalse(shell.isDir(d + "/A/L")) utils.withLimitedDir(d, ['./C', 'A/K/'], action)
def Checkout(self, tag, module_list, az=None, timestamp=None, nonrecursive=0): tmp = {} for m in module_list: base, mod, dir = self.fix(m, ".") if tmp.has_key(base): tmp[base].append(mod) else: tmp[base] = [mod] for base in tmp.keys(): ns = None if self.shadow: ns = self.shadow + base if az: dir = None else: dir = base shell.mkdir(dir) _Cvs(self.root + base, ns).Checkout(tag, tmp[base], az, timestamp, nonrecursive, dir)
def Checkout(self, tag, module_list, az=None, timestamp=None, nonrecursive=0): tmp={} for m in module_list: base, mod, dir = self.fix(m, ".") if tmp.has_key(base): tmp[base].append( mod ) else: tmp[base]=[mod] for base in tmp.keys(): ns=None if self.shadow: ns=self.shadow + base if az: dir = None else: dir = base shell.mkdir(dir) _Cvs(self.root + base, ns).Checkout(tag, tmp[base], az, timestamp, nonrecursive, dir)
def get_distribution(self, dist_id, profile_id, build_type, search_cvs=1): location = self.find_distribution(dist_id, profile_id, build_type, 1, search_cvs) path = self.natify_path(self.module_name) if location: if location[-4:] == ".rna": import archive archive.Extract(location) else: shell.mkdir(os.path.dirname(path)) shell.cp(location, path) cleanup() if not os.path.exists(path): # FIXME: This error message needs to point to the # (so far nonexistant) documentation outmsg.send("distribution=\"%s\" not found." % ( self.module_name )) return [ self.module_name ]
def checkout( self, root=None, tag=None, date=None, az=None, ## Native path nonrecursive=None, zap=None, download_only=None, system_id=None, profile=None, build_type=None): import distributions import cvs import shell try: if self.checkin_dep_only: return except AttributeError: pass if self.type == "cvs": distributions.setup() tmpdir = distributions.tmpdir() tmpdir = os.path.join(tmpdir, "module") cvs.Checkout(tag or self.cvs_tag, self.cvs_path or self.name, root or self.cvs_root, tmpdir, date or self.cvs_date, nonrecursive, zap) if ((tag or self.cvs_tag) and (date or self.cvs_date) and not os.path.exists(tmpdir)): cvs.Checkout(self.cvs_tag, self.cvs_path or self.name, root or self.cvs_root, tmpdir, self.cvs_date, nonrecursive, zap) if not os.path.exists(tmpdir): raise cvs.cvs_error shell.mkdir(os.path.dirname(az or self.path())) os.rename(tmpdir, az or self.path()) distributions.cleanup() elif self.type == "distribution": df = distributions.DistFinder(self.name, root or self.cvs_root, tag or self.tag, date or self.cvs_date) fun = df.get_distribution if download_only: fun = df.download_distribution if not system_id: system_id = sysinfo.id return df.get_distribution( sysinfo.PLATFORM_HASH.get(system_id).distribution_id, profile, build_type)
def runTest(files, fun): with shell.tempDir() as d: c = mkConfig(d) studDir = shell.pjoin(d, student) shell.mkdir(studDir) for f in files: shell.touch(shell.pjoin(studDir, f)) fun(c)
def copyFileIfNotExists(srcDir, path, targetDir): srcPath = shell.pjoin(srcDir, path) if not shell.isFile(srcPath): raise IOError(f'{srcPath} must be a file') tgtPath = shell.pjoin(targetDir, path) if shell.isDir(tgtPath): raise IOError(f'{tgtPath} must not be a directory') shell.mkdir(shell.dirname(tgtPath), createParents=True) if shell.isFile(tgtPath): if not hasSameContent(srcPath, tgtPath): raise IOError(f'Target file {tgtPath} already exists with content different than in {srcPath}') else: shell.cp(srcPath, tgtPath)
def download_distribution(self, dist_id, profile_id, build_type): """Download the approperiate distribution into ./distribution so that it can be easily found by find_distribution_filesystem""" location = self.find_distribution(dist_id, profile_id, build_type, 0) if location: if string.count(location, tmpdir()): p = string.index(location, tmpdir()) dest = location[:p] + location[p + len(tmpdir()) + 1:] shell.mkdir(os.path.dirname(dest)) shell.cp(location, dest) else: outmsg.send("distribution=\"%s\" not found." % (self.module_name)) cleanup()
def download_distribution(self, dist_id, profile_id, build_type): """Download the approperiate distribution into ./distribution so that it can be easily found by find_distribution_filesystem""" location = self.find_distribution(dist_id, profile_id, build_type, 0) if location: if string.count(location, tmpdir()): p = string.index(location,tmpdir()) dest = location[:p]+location[p+len(tmpdir())+1:] shell.mkdir(os.path.dirname(dest)) shell.cp(location, dest) else: outmsg.send("distribution=\"%s\" not found." % ( self.module_name )) cleanup()
def get_distribution(self, dist_id, profile_id, build_type, search_cvs=1): location = self.find_distribution(dist_id, profile_id, build_type, 1, search_cvs) path = self.natify_path(self.module_name) if location: if location[-4:] == ".rna": import archive archive.Extract(location) else: shell.mkdir(os.path.dirname(path)) shell.cp(location, path) cleanup() if not os.path.exists(path): # FIXME: This error message needs to point to the # (so far nonexistant) documentation outmsg.send("distribution=\"%s\" not found." % (self.module_name)) return [self.module_name]
def checkin(self, file, new_name, root, path, tag): print "Processing %s" % file if not os.path.exists(file): print "No such file or directory!" return setup() cvsdir=os.path.join(tmpdir(),"CVS") shell.mkdir(cvsdir) open(os.path.join(cvsdir,"Root"),"w").write(root+"\n") open(os.path.join(cvsdir,"Repository"),"w").write(path+"\n") open(os.path.join(cvsdir,"Entries"),"w").write("") if tag: open(os.path.join(cvsdir,"Tag"),"w").write("T"+tag+os.linesep) self.run('cvs update "%s"' % new_name, 1) new_path=os.path.join(tmpdir(),new_name) exists=os.path.exists(new_path) shell.cp(file, new_path) if not exists: self.run('cvs add -kb "%s"' % new_name, 1) self.run('cvs commit -m "distribution checkin" "%s"' % new_name) cleanup()
def checkin(self, file, new_name, root, path, tag): print "Processing %s" % file if not os.path.exists(file): print "No such file or directory!" return setup() cvsdir = os.path.join(tmpdir(), "CVS") shell.mkdir(cvsdir) open(os.path.join(cvsdir, "Root"), "w").write(root + "\n") open(os.path.join(cvsdir, "Repository"), "w").write(path + "\n") open(os.path.join(cvsdir, "Entries"), "w").write("") if tag: open(os.path.join(cvsdir, "Tag"), "w").write("T" + tag + os.linesep) self.run('cvs update "%s"' % new_name, 1) new_path = os.path.join(tmpdir(), new_name) exists = os.path.exists(new_path) shell.cp(file, new_path) if not exists: self.run('cvs add -kb "%s"' % new_name, 1) self.run('cvs commit -m "distribution checkin" "%s"' % new_name) cleanup()
def setup(xtra=""): cleanup(xtra) if not os.path.isdir(tmpdir(xtra)): #print "MKDIR: %s" % tmpdir(xtra) shell.mkdir(tmpdir(xtra))
def update(self, tag, module_list, az = None, timestamp = None, nonrecursive = 0, dir = None): ### FIXME: ### test this! if dir: odir=os.getcwd() try: os.chdir(dir) ret=self.checkout(tag, module_list, az, timestamp, nonrecursive) finally: os.chdir(odir) return ret if az: odir=os.getcwd() shell.mkdir("cvs_temp") os.chdir("cvs_temp") self.checkout(tag,module_list, None, timestamp, nonrecursive) os.chdir(odir) for m in module_list: shell.cp(os.path.join(odir, "cvs_temp", m), os.path.join(odir, az)) shell.rm("cvs_temp") return if nonrecursive: e = err.Error() e.Set("Nonrecursive not supported by MacCVS") raise err.error, e session_name = self.cvs_session_path[1:-1] session_name = os.path.basename(session_name) script = ascript.CreateAppleScript( 'tell application %s' % (self.cvs_path), ' activate', ' open alias %s' % (self.cvs_session_path), ' set thesession to session named "%s"' % (session_name), ' set local root of thesession to alias "%s"' % (os.getcwd()), ' with timeout of 99999 seconds') for module in module_list: cmd = 'check out thesession module "%s"' % (module) if tag: cmd = cmd +' revision "%s"' % (tag) if timestamp: cmd = cmd +' date "%s"' % (timestamp) script.Append(cmd) script.Append( ' end timeout', ' quit', 'end tell') if self.script_save_path == '': result = script.CompileAndExecute() else: script.CompileAndSave(self.script_save_path) launch_script = ascript.CreateAppleScript( 'set scriptobj to (load script file "%s")' % ( self.script_save_path), 'tell scriptobj', ' run', 'end tell') result = launch_script.CompileAndExecute() if result and result != '': outmsg.error('cvs checkout error %s' % (result))
def __init__(self, dir="."): self.dir=dir self.new_cvs_dir=None self.cvsdir = os.path.join(dir, "CVS") subdirs=[] entries=[] self.use_fake=0 try: files=os.listdir(dir) except: return for e in files: if e in ["CVS"]: continue path = os.path.join(dir, e) if os.path.isdir(path): ndir = MagicFixDir(path) if ndir.cvsdir: subdirs.append(ndir) if not os.path.isdir(self.cvsdir): if subdirs: self.new_cvs_dir=1 q=subdirs[0].mkparent() for n in subdirs: entries.append(n.get_entry()) #print "===========" #print n.cvsdir #print n.mkparent() #print q #print "===========" if n.use_fake or n.mkparent() != q: self.use_fake=1 shell.mkdir(self.cvsdir) if self.use_fake: print "Adding faux CVS dir: %s" % self.cvsdir faux=os.path.join(os.environ["BUILD_ROOT"],"lib","faux-cvs","CVS") if os.path.isdir(faux): shell.mkdir(self.cvsdir) shell.cp(os.path.join(faux,"Root"), os.path.join(self.cvsdir,"Root")) shell.cp(os.path.join(faux,"Repository"), os.path.join(self.cvsdir,"Repository")) else: print "Faux cvs dir missing, skipping" self.cvsdir=None return else: print "Adding PARENT CVS dir: %s" % self.cvsdir shell.mkdir(self.cvsdir) open(os.path.join(self.cvsdir,"Root"),"w").write(q[0]) open(os.path.join(self.cvsdir,"Repository"),"w").write(q[1]) if q[2]: open(os.path.join(self.cvsdir,"Tag"),"w").write(q[2]) open(os.path.join(self.cvsdir,"Entries"),"w").write(string.join(entries,"")) else: self.cvsdir=None else: for n in subdirs: if n.is_new(): entries.append(n.get_entry()) if entries: print "Adding CVS entries in %s" % self.cvsdir e=open(os.path.join(self.cvsdir,"Entries"),"a") e.write(string.join(entries,""))
def write_macros(self): """Writes all the macros (variables) to the Makefile.""" umake_lib.debug("Project.write_macros") def str_list(list): return string.join(list) self.writeln("## Generated from %s, do not edit, do not commit to cvs!" % (self.project.umakefile_name )) self.writeln("") ## print out all command and command flag variables ## in the platform command list, taking care not to ## print blank lines for commands/command flas which ## do not exist for current_command in self.platform.command_list: command_var = current_command.setup_command_var() flags_var = current_command.setup_flags_var() if len(command_var): self.writeln(command_var) if len(flags_var): self.writeln(flags_var) ## write out env variables for compilers for build_rule in self.platform.build_rules.values(): current_command = build_rule.command command_var = current_command.setup_command_var() flags_var = current_command.setup_flags_var() if len(command_var): self.writeln(command_var) if len(flags_var): self.writeln(flags_var) ## LINKER if not hasattr(self.platform.link, "linker2"): self.writeln(self.platform.link.setup_command_var()) self.writeln(self.platform.link.setup_flags_var()) ## SRCS self.writeln("SRCS=%s" % (self.compat_quote(self.project.sources))) ## COMPILED_OBJS, SOURCE_OBJS, OBJS self.writeln("OBJS=%s %s" % ( self.platform.form_var("COMPILED_OBJS"), self.platform.form_var("SOURCE_OBJS"))) self.writeln("COMPILED_OBJS=%s" % ( self.compat_quote(self.project.objects))) self.writeln('SOURCE_OBJS=%s' % ( self.compat_quote(self.project.objsrcs))) ## INCLUDES self.writeln("INCLUDES=%s" % self.build_quoted_arg_list( self.project.includes, self.platform.include_arg)) ## DEFINES if self.platform.cc.prefix_include_arg: defdir = self.project.output_dir shell.mkdir(defdir) name = os.path.join(self.project.module_directory(), self.project.makefile_name) prefix_file_name = umake_lib.declaw_name(name)+"_ribodefs.h" prefix_file_name=os.path.join(defdir, prefix_file_name) lines=[] defs=self.project.defines defs.sort() for d in defs: ind = string.find(d,"=") if ind == -1: lines.append("#ifndef %s" % (d)) lines.append("#define %s 1" % (d)) else: lines.append("#ifndef %s" % (d[:ind])) lines.append("#define %s %s" % (d[:ind],d[ind+1:])) lines.append("#endif") for include in self.project.prefix_file_include_list: ## Ugly magic stuff if type(include) == types.StringType: if include[0] == '"' or include[0] == '<': lines.append("#include %s" % (include)) elif include[0] == '#': lines.append("%s" % (include)) else: lines.append("#include <%s>" % (include)) elif type(include) == types.ListType: lines.extend(include) data = string.join(lines,"\n")+"\n" umake_lib.write_file(prefix_file_name, data) self.writeln("DEFINES=%s%s %s%s" % ( self.platform.include_arg, os.curdir, self.platform.cc.prefix_include_arg, prefix_file_name)) else: self.writeln("DEFINES=%s" % self.build_quoted_arg_list( self.project.defines, self.platform.define_arg)) ## STATIC_LIBS static_libs = self.project.libraries + self.project.libraries2 + \ self.project.local_libs + self.project.module_libs self.writeln("STATIC_LIBS=%s" % (self.compat_quote(static_libs))) ## DYNAMIC_LIBS self.writeln("DYNAMIC_LIBS=%s %s" % ( self.compat_quote(self.project.dynamic_libraries), self.compat_quote(self.project.sys_libraries, self.platform.sys_lib_arg))) self.writeln("") ## suffixes if len(self.platform.suffix_list): self.writeln(".SUFFIXES: %s" % ( string.join(self.platform.suffix_list))) self.writeln("") ## default/misc build rules for rule in self.platform.build_rules.values(): ## Add custom INCLUDE/DEFINE variables for each compiler ## (Except CC/CXX, which uses INCLUDE/DEFINES) if rule.command.make_var not in [ "CC", "CXX" ]: if rule.command.define_arg and rule.command.make_var: try: defs = None try: defs = rule.command.defines except AttributeError: pass if defs == None: defs = self.project.defines self.writeln("%sDEFINES=%s" % ( rule.command.make_var, self.build_quoted_arg_list(defs, rule.command.define_arg))) self.writeln("") except: pass if rule.command.include_arg and rule.command.make_var: try: includes = None try: includes = rule.command.includes except AttributeError: pass if includes == None: includes = self.project.includes self.writeln("%sINCLUDES=%s" % ( rule.command.make_var, self.build_quoted_arg_list(includes, rule.command.include_arg))) self.writeln("") except: pass if self.platform.build_rules.get(rule.source_suffix,None) == rule: rule_str = "%s%s%s" % ( rule.source_suffix, rule.target_suffix, self.platform.make_depend) self.writeln(rule_str) cmd_str = rule.command.execute( self.platform.make_target, self.platform.make_source) self.writeln("\t%s" % (cmd_str)) self.writeln("")
def __init__(self, mprj): self.mprj = mprj ## start the script and define subroutines script = ascript.CreateAppleScript() self.script = script all = [] self.all = all for sumake in mprj.project.submakes: m_path = macpath.normpath(macpath.join(os.getcwd(), sumake.makefile())) all.extend( [ 'set scriptobj to (load script file "%s")' % (m_path), 'tell scriptobj', ' set myerrors to myerrors & return & all()', 'end tell' ] ) script.Extend(mprj.project.pre_target_buff) self.Clean() if mprj.project.getTargetType() != "": WritePrefixFile(mprj) WriteResourcePrefixFile(mprj) WriteExportFile(mprj) self.VerifyPath() self.ExtractCWErrors() if len(mprj.weak_link_list): self.SetWeakLink() if len(mprj.post_build_script): self.PostBuildScript() if mprj.rtarget: self.DefineResourceProject() ## FIXME, only do this for if asked to 'clean' build all.extend( [ ' --clean out old project and data by default', ' Clean()' ]) ## write the "all" function, like "make all" in a Makefile all.extend( [ ' --make the output directory, and target directory', ' verifypath("%s")' % (mprj.output_dir_path), ' verifypath("%s")' % (mprj.target_dir_path) ] ) if mprj.rtarget: all.extend( [ '--build the windows resource dll', 'myerrors = myerrors & return & ResourceProject()' ] ) self.RunProject() ## for DLL target types, we make a alias to the dll with a .lib ## extention so developers can do implicit linking to DLL's the ## same way they do on Windows ## ## Note: when Windows compiles a DLL, it creates a companion .LIB ## library with the same name; you link to the DLL by linking ## in the stub .LIB absolute_output_dir = os.path.join(os.getcwd(), mprj.output_dir) absolute_output_path = os.path.join(absolute_output_dir, mprj.output_name) if mprj.target_type == "dll": if mprj.project.opt_target_name: alias_name= mprj.project.opt_target_name else: alias_name= mprj.target_name alias_name = "%s.LIB" % (string.upper(alias_name)) absolute_alias_path = os.path.join(absolute_output_dir, alias_name) all.extend( [ 'tell application "Finder"', ' try', ' if (file "%s") exists then' % (absolute_alias_path), ' else', ' make new alias file to (file "%s") at (folder "%s") '\ ' with properties {name:"%s"}' % ( absolute_output_path, absolute_output_dir, alias_name), ' end if', ' on error', ' end try', 'end tell' ]) if len(mprj.post_build_script): all.extend( [ '--execute the custom subroutine', 'DoPostBuild()' ]) ## copy the built target and finish off the script all.extend( [ '-- Copy results to common output folder', 'tell application "Finder"', ' if (file "%s") exists then' % (absolute_output_path), ' Duplicate file "%s" to folder "%s" with replacing' % ( absolute_output_path, mprj.target_dir_path), ' end if', 'end tell' ]) if len(all): script.Append('on all()', 'set myerrors to ""') script.Extend(all) script.Append( 'return myerrors', 'end all', '-- run the "all()" function', 'return all()') script.Extend(mprj.project.post_target_buff) ## for DRM signing if mprj.project.getTargetType() == "dll" and \ mprj.project.BuildOption("drmsign") and \ mprj.project.CheckDRMSign(): import shell shell.mkdir(os.path.dirname(absolute_output_path)) open(absolute_output_path+"--drmsign","w").write("signme!")
def mkdir(self, path): shell.mkdir(self.native_path(path))
def __init__(self, dir="."): self.dir = dir self.new_cvs_dir = None self.cvsdir = os.path.join(dir, "CVS") subdirs = [] entries = [] self.use_fake = 0 try: files = os.listdir(dir) except: return for e in files: if e in ["CVS"]: continue path = os.path.join(dir, e) if os.path.isdir(path): ndir = MagicFixDir(path) if ndir.cvsdir: subdirs.append(ndir) if not os.path.isdir(self.cvsdir): if subdirs: self.new_cvs_dir = 1 q = subdirs[0].mkparent() for n in subdirs: entries.append(n.get_entry()) #print "===========" #print n.cvsdir #print n.mkparent() #print q #print "===========" if n.use_fake or n.mkparent() != q: self.use_fake = 1 shell.mkdir(self.cvsdir) if self.use_fake: print "Adding faux CVS dir: %s" % self.cvsdir faux = os.path.join(os.environ["BUILD_ROOT"], "lib", "faux-cvs", "CVS") if os.path.isdir(faux): shell.mkdir(self.cvsdir) shell.cp(os.path.join(faux, "Root"), os.path.join(self.cvsdir, "Root")) shell.cp(os.path.join(faux, "Repository"), os.path.join(self.cvsdir, "Repository")) else: print "Faux cvs dir missing, skipping" self.cvsdir = None return else: print "Adding PARENT CVS dir: %s" % self.cvsdir shell.mkdir(self.cvsdir) open(os.path.join(self.cvsdir, "Root"), "w").write(q[0]) open(os.path.join(self.cvsdir, "Repository"), "w").write(q[1]) if q[2]: open(os.path.join(self.cvsdir, "Tag"), "w").write(q[2]) open(os.path.join(self.cvsdir, "Entries"), "w").write(string.join(entries, "")) else: self.cvsdir = None else: for n in subdirs: if n.is_new(): entries.append(n.get_entry()) if entries: print "Adding CVS entries in %s" % self.cvsdir e = open(os.path.join(self.cvsdir, "Entries"), "a") e.write(string.join(entries, ""))
def checkout(self, root=None, tag=None, date=None, az=None, ## Native path nonrecursive = None, zap=None, download_only=None, system_id=None, profile=None, build_type=None): import distributions import cvs import shell try: if self.checkin_dep_only: return except AttributeError: pass if self.type == "cvs": distributions.setup() tmpdir=distributions.tmpdir() tmpdir=os.path.join(tmpdir,"module") cvs.Checkout(tag or self.cvs_tag, self.cvs_path or self.name, root or self.cvs_root, tmpdir, date or self.cvs_date, nonrecursive, zap) if ( ( tag or self.cvs_tag) and (date or self.cvs_date) and not os.path.exists(tmpdir) ): cvs.Checkout(self.cvs_tag, self.cvs_path or self.name, root or self.cvs_root, tmpdir, self.cvs_date, nonrecursive, zap) if not os.path.exists(tmpdir): raise cvs.cvs_error shell.mkdir(os.path.dirname(az or self.path())) os.rename(tmpdir, az or self.path()) distributions.cleanup() elif self.type == "distribution": df=distributions.DistFinder(self.name, root or self.cvs_root, tag or self.tag, date or self.cvs_date) fun = df.get_distribution if download_only: fun=df.download_distribution if not system_id: system_id = sysinfo.id return df.get_distribution( sysinfo.PLATFORM_HASH.get(system_id).distribution_id, profile, build_type)
def update(self, tag, module_list, az=None, timestamp=None, nonrecursive=0, dir=None): ### FIXME: ### test this! if dir: odir = os.getcwd() try: os.chdir(dir) ret = self.checkout(tag, module_list, az, timestamp, nonrecursive) finally: os.chdir(odir) return ret if az: odir = os.getcwd() shell.mkdir("cvs_temp") os.chdir("cvs_temp") self.checkout(tag, module_list, None, timestamp, nonrecursive) os.chdir(odir) for m in module_list: shell.cp(os.path.join(odir, "cvs_temp", m), os.path.join(odir, az)) shell.rm("cvs_temp") return if nonrecursive: e = err.Error() e.Set("Nonrecursive not supported by MacCVS") raise err.error, e session_name = self.cvs_session_path[1:-1] session_name = os.path.basename(session_name) script = ascript.CreateAppleScript( 'tell application %s' % (self.cvs_path), ' activate', ' open alias %s' % (self.cvs_session_path), ' set thesession to session named "%s"' % (session_name), ' set local root of thesession to alias "%s"' % (os.getcwd()), ' with timeout of 99999 seconds') for module in module_list: cmd = 'check out thesession module "%s"' % (module) if tag: cmd = cmd + ' revision "%s"' % (tag) if timestamp: cmd = cmd + ' date "%s"' % (timestamp) script.Append(cmd) script.Append(' end timeout', ' quit', 'end tell') if self.script_save_path == '': result = script.CompileAndExecute() else: script.CompileAndSave(self.script_save_path) launch_script = ascript.CreateAppleScript( 'set scriptobj to (load script file "%s")' % (self.script_save_path), 'tell scriptobj', ' run', 'end tell') result = launch_script.CompileAndExecute() if result and result != '': outmsg.error('cvs checkout error %s' % (result))
def write_macros(self): """Writes all the macros (variables) to the Makefile.""" umake_lib.debug("Project.write_macros") def str_list(list): return string.join(list) self.writeln( "## Generated from %s, do not edit, do not commit to cvs!" % (self.project.umakefile_name)) self.writeln("") ## print out all command and command flag variables ## in the platform command list, taking care not to ## print blank lines for commands/command flas which ## do not exist for current_command in self.platform.command_list: command_var = current_command.setup_command_var() flags_var = current_command.setup_flags_var() if len(command_var): self.writeln(command_var) if len(flags_var): self.writeln(flags_var) ## write out env variables for compilers for build_rule in self.platform.build_rules.values(): current_command = build_rule.command command_var = current_command.setup_command_var() flags_var = current_command.setup_flags_var() if len(command_var): self.writeln(command_var) if len(flags_var): self.writeln(flags_var) ## LINKER if not hasattr(self.platform.link, "linker2"): self.writeln(self.platform.link.setup_command_var()) self.writeln(self.platform.link.setup_flags_var()) ## SRCS self.writeln("SRCS=%s" % (self.compat_quote(self.project.sources))) ## COMPILED_OBJS, SOURCE_OBJS, OBJS self.writeln("OBJS=%s %s" % (self.platform.form_var("COMPILED_OBJS"), self.platform.form_var("SOURCE_OBJS"))) self.writeln("COMPILED_OBJS=%s" % (self.compat_quote(self.project.objects))) self.writeln('SOURCE_OBJS=%s' % (self.compat_quote(self.project.objsrcs))) ## INCLUDES self.writeln("INCLUDES=%s" % self.build_quoted_arg_list( self.project.includes, self.platform.include_arg)) ## DEFINES if self.platform.cc.prefix_include_arg: defdir = self.project.output_dir shell.mkdir(defdir) name = os.path.join(self.project.module_directory(), self.project.makefile_name) prefix_file_name = umake_lib.declaw_name(name) + "_ribodefs.h" prefix_file_name = os.path.join(defdir, prefix_file_name) lines = [] defs = self.project.defines defs.sort() for d in defs: ind = string.find(d, "=") if ind == -1: lines.append("#ifndef %s" % (d)) lines.append("#define %s 1" % (d)) else: lines.append("#ifndef %s" % (d[:ind])) lines.append("#define %s %s" % (d[:ind], d[ind + 1:])) lines.append("#endif") for include in self.project.prefix_file_include_list: ## Ugly magic stuff if type(include) == types.StringType: if include[0] == '"' or include[0] == '<': lines.append("#include %s" % (include)) elif include[0] == '#': lines.append("%s" % (include)) else: lines.append("#include <%s>" % (include)) elif type(include) == types.ListType: lines.extend(include) data = string.join(lines, "\n") + "\n" umake_lib.write_file(prefix_file_name, data) self.writeln( "DEFINES=%s%s %s%s" % (self.platform.include_arg, os.curdir, self.platform.cc.prefix_include_arg, prefix_file_name)) else: self.writeln("DEFINES=%s" % self.build_quoted_arg_list( self.project.defines, self.platform.define_arg)) ## STATIC_LIBS static_libs = self.project.libraries + self.project.libraries2 + \ self.project.local_libs + self.project.module_libs self.writeln("STATIC_LIBS=%s" % (self.compat_quote(static_libs))) ## DYNAMIC_LIBS self.writeln("DYNAMIC_LIBS=%s %s" % (self.compat_quote(self.project.dynamic_libraries), self.compat_quote(self.project.sys_libraries, self.platform.sys_lib_arg))) self.writeln("") ## suffixes if len(self.platform.suffix_list): self.writeln(".SUFFIXES: %s" % (string.join(self.platform.suffix_list))) self.writeln("") ## default/misc build rules for rule in self.platform.build_rules.values(): ## Add custom INCLUDE/DEFINE variables for each compiler ## (Except CC/CXX, which uses INCLUDE/DEFINES) if rule.command.make_var not in ["CC", "CXX"]: if rule.command.define_arg and rule.command.make_var: try: defs = None try: defs = rule.command.defines except AttributeError: pass if defs == None: defs = self.project.defines self.writeln("%sDEFINES=%s" % (rule.command.make_var, self.build_quoted_arg_list( defs, rule.command.define_arg))) self.writeln("") except: pass if rule.command.include_arg and rule.command.make_var: try: includes = None try: includes = rule.command.includes except AttributeError: pass if includes == None: includes = self.project.includes self.writeln("%sINCLUDES=%s" % (rule.command.make_var, self.build_quoted_arg_list( includes, rule.command.include_arg))) self.writeln("") except: pass if self.platform.build_rules.get(rule.source_suffix, None) == rule: rule_str = "%s%s%s" % (rule.source_suffix, rule.target_suffix, self.platform.make_depend) self.writeln(rule_str) cmd_str = rule.command.execute(self.platform.make_target, self.platform.make_source) self.writeln("\t%s" % (cmd_str)) self.writeln("")