def testFileIsOutput(self): grd = self.MakeGrd() dirname = util.TempDir({}) try: tool = build.RcBuilder() tool.o = grit_runner.Options() tool.output_directory = dirname.GetPath() tool.res = grd tool.Process() self.failUnless(os.path.isfile(dirname.GetPath('de_GoogleDesktop.adm'))) self.failUnless(os.path.isfile(dirname.GetPath('de_README.txt'))) finally: dirname.CleanUp()
def testFileIsOutput(self): grd = self.MakeGrd() dirname = tempfile.mkdtemp() try: tool = build.RcBuilder() tool.o = grit_runner.Options() tool.output_directory = dirname tool.res = grd tool.Process() self.failUnless(os.path.isfile( os.path.join(dirname, 'de_GoogleDesktop.adm'))) self.failUnless(os.path.isfile( os.path.join(dirname, 'de_README.txt'))) finally: for f in os.listdir(dirname): os.unlink(os.path.join(dirname, f)) os.rmdir(dirname)
def _Builder(target, source, env): # We fork GRIT into a separate process so we can use more processes between # scons and GRIT. This already runs as separate threads, but because of the # python GIL, all these threads have to share the same process. By using # fork, we can use multiple processes and processors. pid = os.fork() if pid != 0: pid, exit_code = os.waitpid(pid, 0) if exit_code != 0: raise SCons.Errors.BuildError(errstr="see grit error") return try: try: child_exit_code = 0 from grit import grit_runner from grit.tool import build options = grit_runner.Options() # This sets options to default values. options.ReadOptions(['-v']) options.input = _SourceToFile(source) # TODO(joi) Check if we can get the 'verbose' option from the environment. builder = build.RcBuilder() # Get the CPP defines from the environment. for flag in env.get('RCFLAGS', []): if flag.startswith('/D'): flag = flag[2:] name, val = build.ParseDefine(flag) # Only apply to first instance of a given define if name not in builder.defines: builder.defines[name] = val # To ensure that our output files match what we promised SCons, we # use the list of targets provided by SCons and update the file paths in # our .grd input file with the targets. builder.scons_targets = [str(t) for t in target] builder.Run(options, []) except: child_exit_code = -1 finally: # Exit the child process. os._exit(child_exit_code)
def _Builder(target, source, env): print _SourceToFile(source) from grit import grit_runner from grit.tool import build options = grit_runner.Options() # This sets options to default values options.ReadOptions([]) options.input = _SourceToFile(source) # TODO(joi) Check if we can get the 'verbose' option from the environment. builder = build.RcBuilder(defines=_ParseRcFlags(env['RCFLAGS'])[0]) # To ensure that our output files match what we promised SCons, we # use the list of targets provided by SCons and update the file paths in # our .grd input file with the targets. builder.scons_targets = [str(t) for t in target] builder.Run(options, []) return None # success
def MakeOptions(): from grit import grit_runner return grit_runner.Options()