def register_win_x64_external_ly_identity(self, compiler, configuration): # Do not register as an external library if the source exists if os.path.exists(self.Path('Code/Tools/LyIdentity/wscript')): return platform = 'windows' processor = 'intel64' if compiler not in ('vs2013', 'vs2015'): raise WafError("Invalid compiler value {}", compiler) if configuration not in ('Debug', 'Release'): raise WafError("Invalid configuration value {}", configuration) target_platform = 'win_x64' ly_identity_base_path = self.CreateRootRelativePath( 'Tools/InternalSDKs/LyIdentity') include_path = os.path.join(ly_identity_base_path, 'include') stlib_path = os.path.join(ly_identity_base_path, 'lib', platform, processor, compiler, configuration) shlib_path = os.path.join(ly_identity_base_path, 'bin', platform, processor, compiler, configuration) self.register_3rd_party_uselib('LyIdentity_shared', target_platform, includes=[include_path], defines=['LINK_LY_IDENTITY_DYNAMICALLY'], importlib=['LyIdentity_shared.lib'], sharedlibpath=[shlib_path], sharedlib=['LyIdentity_shared.dll']) self.register_3rd_party_uselib('LyIdentity_static', target_platform, includes=[include_path], libpath=[stlib_path], lib=['LyIdentity_static.lib'])
def run_argv(argv, env, os_env=None, cwd=None, force_no_valgrind=False): proc_env = get_proc_env(os_env) if Options.options.valgrind and not force_no_valgrind: if Options.options.command_template: raise WafError( "Options --command-template and --valgrind are conflicting") if not env['VALGRIND']: raise WafError("valgrind is not installed") argv = [ env['VALGRIND'], "--leak-check=full", "--show-reachable=yes", "--error-exitcode=1" ] + argv proc = subprocess.Popen(argv, env=proc_env, cwd=cwd, stderr=subprocess.PIPE) error = False for line in proc.stderr: sys.stderr.write(line) if "== LEAK SUMMARY" in line: error = True retval = proc.wait() if retval == 0 and error: retval = 1 else: try: WindowsError except NameError: retval = subprocess.Popen(argv, env=proc_env, cwd=cwd).wait() else: try: retval = subprocess.Popen(argv, env=proc_env, cwd=cwd).wait() except WindowsError, ex: raise WafError("Command %s raised exception %s" % (argv, ex))
def configure(cfg): if not cfg.options.cpu: raise WafError('Missing option CPU type not provided') cfg.env.ISIX_CPU_TYPE = cfg.options.cpu cflags = _get_flag(cfg.options.cpu, 'cflags') + _cflags if cfg.options.debug == True: cfg.env.ASFLAGS += ['-gstabs'] cflags += _cflags_debug cfg.env.DEFINES += ['PDEBUG'] else: cflags += _cflags_ndebug cfg.env.LDFLAGS = _ldflags_ndebug # We cant use newlib-nano with exceptions if cfg.options.enable_newlib_nano: if cfg.options.disable_exceptions: cfg.env.LDFLAGS += ['--specs=nano.specs'] else: raise WafError( 'Unable to use nano version of newlib with exceptions enabled') optflag = ['-O%s' % cfg.options.optimize] cfg.env.CFLAGS += cflags + [ '-std=gnu11', '-Werror=implicit-function-declaration' ] + optflag cfg.env.CXXFLAGS += cflags + ['-std=gnu++17'] + optflag cfg.env.ASFLAGS += cflags + ['-Wa,-mapcs-32'] + optflag cfg.env.DEFINES += _get_flag(cfg.options.cpu, 'defs') cfg.env.LDFLAGS += ['-nostdlib', '-nostartfiles'] + cflags + optflag cfg.env.LDFLAGS += ['--specs=nosys.specs'] if cfg.options.disable_isix == True: cfg.env.DEFINES += ['CONFIG_ISIX_WITHOUT_KERNEL=1'] if cfg.options.disable_exceptions == True: cfg.env.CXXFLAGS += ['-fno-exceptions', '-fno-rtti']
def run(self): more_tasks = self.more_tasks = [] gen = self.generator bld = gen.bld env = gen.env metadata_node = self.inputs[0] metadata = metadata_node.read_json() # Retrieve uuid. uuid = getattr(gen, "uuid", None) or metadata["uuid"] if not uuid: raise WafError("missing uuid in {}".format(self)) if bld.is_install: # Retrieve and categorize sources. path = gen.path # Installation has to look at their hierarchy from the correct root to # install generated files into the same location as static ones. nothing, srcnodes, bldnodes, both = partition(categories=4, items=chain((metadata_node, ), bld.node_deps[self.uid()], gen.to_nodes(getattr(self, 'data', []))), # The is_src and is_bld predicates are combined like binary # flags to end up with an integral predicate. predicate=lambda source: source.is_src() + 2 * source.is_bld()) # Check for sources manually added outside the extension tree. bldpath = path.get_bld() nothing = tuple(nothing) if tuple(nothing): raise WafError("files {} neither found below {} nor {}".format( ', '.join(map(str, nothing)), path, bldpath)) both = tuple(both) if tuple(both): raise WafError("files {} found both below {} and {}".format( ', '.join(map(str, nothing)), path, bldpath)) # Install. target = env.EXTDIR.format(uuid) install = partial(gen.add_install_files, install_to=target, relative_trick=True) more_tasks += [install(install_from=srcnodes), install(install_from=bldnodes, cwd=bldpath)] # Collect schemas. schemas = to_list(getattr(gen, 'schemas', [])) if "settings-schema" in metadata: schemas += [metadata["settings-schema"] + '.gschema.xml'] # Pass on to glib2 tool for schema processing. if schemas: gen = bld(features="glib2", settings_schema_files = schemas) gen.env.GSETTINGSSCHEMADIR = env.SCHEMADIR.format(uuid) gen.post() more_tasks += gen.tasks
def run_argv(argv, env, os_env=None, cwd=None, force_no_valgrind=False): proc_env = get_proc_env(os_env) if Options.options.valgrind and not force_no_valgrind: if Options.options.command_template: raise WafError( "Options --command-template and --valgrind are conflicting") if not env['VALGRIND']: raise WafError("valgrind is not installed") # Use the first program found in the env['VALGRIND'] list argv = [ env['VALGRIND'][0], "--leak-check=full", "--show-reachable=yes", "--error-exitcode=1" ] + argv proc = subprocess.Popen(argv, env=proc_env, cwd=cwd, stderr=subprocess.PIPE) stderrdata = proc.communicate()[1] stderrdata = stderrdata.decode('utf-8') error = False for line in stderrdata: sys.stderr.write(line) if "== LEAK SUMMARY" in line: error = True retval = proc.wait() if retval == 0 and error: retval = 1 else: try: WindowsError except NameError: retval = subprocess.Popen(argv, env=proc_env, cwd=cwd).wait() else: try: retval = subprocess.Popen(argv, env=proc_env, cwd=cwd).wait() except WindowsError as ex: raise WafError("Command %s raised exception %s" % (argv, ex)) if retval: signame = None if retval < 0: # signal? import signal for name, val in vars(signal).items(): if len(name) > 3 and name[:3] == 'SIG' and name[3] != '_': if val == -retval: signame = name break if signame: raise WafError( "Command %s terminated with signal %s." " Run it under a debugger to get more information " "(./waf --run <program> --command-template=\"gdb --args %%s <args>\")." % (argv, signame)) else: raise WafError("Command %s exited with code %i" % (argv, retval)) return retval
def outFileNames(ctx, bldpath, inFile, **kw): zcmgen = ctx.env['ZCMGEN'] pkgPrefix = kw.get('pkgPrefix', '') javapkg = kw.get('javapkg', 'zcmtypes') juliapkg = kw.get('juliapkg', 'zcmtypes') juliagenpkgs = kw.get('juliagenpkgs', False) lang = kw.get('lang', []) if isinstance(lang, str): lang = lang.split(' ') if (not lang) and (not juliagenpkgs): # TODO: this should probably be a more specific error type raise WafError('zcmgen requires keword argument: "lang"') cmd = {} if (pkgPrefix): cmd['prefix'] = '--package-prefix %s' % pkgPrefix if ('c_stlib' in lang) or ('c_shlib' in lang): cmd['c'] = '--c --c-cpath %s --c-hpath %s' % (bldpath, bldpath) if 'cpp' in lang: cmd['cpp'] = '--cpp --cpp-hpath %s' % (bldpath) if 'java' in lang: cmd['java'] = '--java --jpath %s --jpkgprefix %s' % (bldpath + '/java', javapkg) if 'python' in lang: cmd['python'] = '--python --ppath %s' % (bldpath) if 'julia' in lang: cmd['julia'] = '--julia --julia-path %s' % (bldpath) if (juliapkg): cmd['julia'] += ' --julia-pkg-prefix %s' % (juliapkg) if (juliagenpkgs): cmd['julia'] += ' --julia-generate-pkg-files' if 'nodejs' in lang: cmd['nodejs'] = '--node --npath %s' % (bldpath) files = ctx.cmd_and_log('zcm-gen --output-files %s %s' % (' '.join(cmd.values()), inFile), output=waflib.Context.STDOUT, quiet=waflib.Context.BOTH).strip().split() for i in range(len(files)): if files[i].startswith(bldpath): files[i] = files[i][len(bldpath):] while (files[i].startswith('/')): files[i] = files[i][1:] else: # Note: just double checking that the output of `zcmgen --output-files` # is placing files in the proper directory (the build directory) raise WafError('ZCMtypes output not in the build path : ', files[i]) return files
def _read_mcu_db(): global _mcus_db try: if _mcus_db == None: fname = os.path.join(_base_dir, 'cpu_database', 'mcu.json') with open(fname) as fh: _mcus_db = json.load(fh) except IOError as e: raise WafError('Unable to read cpudb %s %r' % (fname, e), e) except json.decoder.JSONDecodeError as e: raise WafError('Syntax error in the cpudb %s %r' % (fname, e), e) return _mcus_db
def get_run_program(program_string, command_template=None): """ Return the program name and argv of the process that would be executed by run_program(program_string, command_template). """ #print "get_run_program_argv(program_string=%r, command_template=%r)" % (program_string, command_template) env = bld.env if command_template in (None, '%s'): argv = shlex.split(program_string) #print "%r ==shlex.split==> %r" % (program_string, argv) program_name = argv[0] # if the script name ends with .cc - strip it if program_name.endswith('.cc'): program_name = program_name.rsplit('.', 1)[0] try: program_obj = find_program(program_name, env) except ValueError as ex: raise WafError(str(ex)) program_node = program_obj.path.find_or_declare(program_obj.target) #try: # program_node = program_obj.path.find_build(ccroot.get_target_name(program_obj)) #except AttributeError: # raise Utils.WafError("%s does not appear to be a program" % (program_name,)) execvec = [program_node.abspath()] + argv[1:] else: program_name = program_string # if the script name ends with .cc - strip it if program_name.endswith('.cc'): program_name = program_name.rsplit('.', 1)[0] try: program_obj = find_program(program_name, env) except ValueError as ex: raise WafError(str(ex)) program_node = program_obj.path.find_or_declare(program_obj.target) #try: # program_node = program_obj.path.find_build(ccroot.get_target_name(program_obj)) #except AttributeError: # raise Utils.WafError("%s does not appear to be a program" % (program_name,)) tmpl = command_template % (program_node.abspath(), ) execvec = shlex.split(tmpl.replace('\\', '\\\\')) #print "%r ==shlex.split==> %r" % (command_template % (program_node.abspath(env),), execvec) return program_name, execvec
def shader_header_feature(self): if not hasattr(self, 'vertex'): raise WafError('missing vertex shader') if not hasattr(self, 'fragment'): raise WafError('missing fragment shader') tgt = self.path.get_bld().find_or_declare(self.target) vert = self.path.get_src().find_node(self.vertex) frag = self.path.get_src().find_node(self.fragment) self.create_task('glsl_to_c_header', src=[vert, frag], tgt=tgt)
def register_darwin_external_ly_identity(ctx, configuration): # Do not regsiter as an external library if the source exists if os.path.exists(ctx.Path('Code/Tools/LyIdentity/wscript')): return platform = 'mac' if configuration not in ('Debug', 'Release'): raise WafError("Invalid configuration value {}", configuration) target_platform = 'darwin' ly_identity_base_path = ctx.CreateRootRelativePath( 'Tools/InternalSDKs/LyIdentity') include_path = os.path.join(ly_identity_base_path, 'include') stlib_path = os.path.join(ly_identity_base_path, 'lib', platform, configuration) shlib_path = os.path.join(ly_identity_base_path, 'bin', platform, configuration) ctx.register_3rd_party_uselib('LyIdentity_shared', target_platform, includes=[include_path], defines=['LINK_LY_IDENTITY_DYNAMICALLY'], importlib=['libLyIdentity_shared.dylib'], sharedlibpath=[shlib_path], sharedlib=['libLyIdentity_shared.dylib']) ctx.register_3rd_party_uselib('LyIdentity_static', target_platform, includes=[include_path], libpath=[stlib_path], lib=['libLyIdentity_static.a'])
def register_darwin_external_ly_metrics(self, configuration): # Do not regsiter as an external library if the source exists if os.path.exists(self.Path('Code/Tools/LyMetrics/wscript')): return platform = 'mac' if configuration not in ('Debug', 'Release'): raise WafError("Invalid configuration value {}", configuration) target_platform = 'darwin' ly_identity_base_path = self.CreateRootRelativePath( 'Tools/InternalSDKs/LyMetrics') include_path = os.path.join(ly_identity_base_path, 'include') stlib_path = os.path.join(ly_identity_base_path, 'lib', platform, configuration) self.register_3rd_party_uselib('LyMetricsShared_static', target_platform, includes=[include_path], libpath=[stlib_path], lib=['libLyMetricsShared_static.a']) self.register_3rd_party_uselib('LyMetricsProducer_static', target_platform, includes=[include_path], libpath=[stlib_path], lib=['libLyMetricsProducer_static.a'])
def get_run_program(program_string, command_template=None): """ Return the program name and argv of the process that would be executed by run_program(program_string, command_template). """ #print "get_run_program_argv(program_string=%r, command_template=%r)" % (program_string, command_template) env = bld.env if command_template in (None, '%s'): argv = shlex.split(program_string) #print "%r ==shlex.split==> %r" % (program_string, argv) program_name = argv[0] try: program_obj = find_program(program_name, env) except ValueError, ex: raise WafError(str(ex)) program_node = program_obj.path.find_or_declare(program_obj.target) #try: # program_node = program_obj.path.find_build(ccroot.get_target_name(program_obj)) #except AttributeError: # raise Utils.WafError("%s does not appear to be a program" % (program_name,)) execvec = [program_node.abspath()] + argv[1:]
def do_the_symbol_stuff(self): ins = [x.outputs[0] for x in self.compiled_tasks] self.gen_sym_tasks = [ self.create_task('gen_sym', x, x.change_ext('.%d.sym' % self.idx)) for x in ins ] tsk = self.create_task( 'compile_sym', [x.outputs[0] for x in self.gen_sym_tasks], self.path.find_or_declare( getattr(self, 'sym_filename', self.target + '.def'))) self.link_task.set_run_after(tsk) self.link_task.dep_nodes.append(tsk.outputs[0]) if 'msvc' in (self.env.CC_NAME, self.env.CXX_NAME): self.link_task.env.append_value('LINKFLAGS', ['/def:' + tsk.outputs[0].bldpath()]) elif self.env.DEST_BINFMT == 'pe': #gcc on windows takes *.def as an additional input self.link_task.inputs.append(tsk.outputs[0]) elif self.env.DEST_BINFMT == 'elf': self.link_task.env.append_value( 'LINKFLAGS', ['-Wl,-version-script', '-Wl,' + tsk.outputs[0].bldpath()]) elif self.env.DEST_BINFMT == 'mac-o': self.link_task.env.append_value( 'LINKFLAGS', ['-Wl,-exported_symbols_list,' + tsk.outputs[0].bldpath()]) else: raise WafError('NotImplemented')
def do_the_symbol_stuff(self): def_node = self.path.find_or_declare( getattr(self, "sym_file", self.target + ".def")) compiled_tasks = getattr(self, "compiled_tasks", None) if compiled_tasks: ins = [x.outputs[0] for x in compiled_tasks] self.gen_sym_tasks = [ self.create_task("gen_sym", x, x.change_ext(".%d.sym" % self.idx)) for x in ins ] self.create_task("compile_sym", [x.outputs[0] for x in self.gen_sym_tasks], def_node) link_task = getattr(self, "link_task", None) if link_task: self.link_task.dep_nodes.append(def_node) if "msvc" in (self.env.CC_NAME, self.env.CXX_NAME): self.link_task.env.append_value("LINKFLAGS", ["/def:" + def_node.bldpath()]) elif self.env.DEST_BINFMT == "pe": # gcc on windows takes *.def as an additional input self.link_task.inputs.append(def_node) elif self.env.DEST_BINFMT == "elf": self.link_task.env.append_value( "LINKFLAGS", ["-Wl,-version-script", "-Wl," + def_node.bldpath()]) elif self.env.DEST_BINFMT == "mac-o": self.link_task.env.append_value( "LINKFLAGS", ["-Wl,-exported_symbols_list," + def_node.bldpath()]) else: raise WafError("NotImplemented")
def cxxtest(ctx, **kw): opts = Options.options skipTestOption = opts.skip_tests if 'skip_tests' in vars(opts) else False if ctx.env.SKIP_TESTS or skipTestOption: return # Check if the 'test' directory exists and if there are any tests in it if (ctx.path.find_dir('test') is None): return if 'SRCPATH' not in ctx.env: raise WafError('ctx.env requires : "SRCPATH"') relpath = ctx.path.path_from(ctx.path.find_or_declare(ctx.env.SRCPATH)) excl = kw.pop('excl', []) suites = ctx.path.ant_glob('test/**/*Test.hpp', excl = excl) if (len(suites) == 0): return cxxtestgen = ctx.root.find_or_declare(ctx.env.CXXTESTGEN) cxxtestgen_src = ctx.root.find_or_declare(os.path.join(os.path.dirname(ctx.env.CXXTESTGEN), '../python/python3/cxxtest/cxxtestgen.py')) # generate runner src runnerTg = ctx(rule = cxxtest_generate_runner, target = 'test/runner.cpp', name = relpath + '/test/runner.cpp', shell = False, reentrant = False) runnerTg.post() ctx.add_manual_dependency('test/runner.cpp', cxxtestgen) ctx.add_manual_dependency('test/runner.cpp', cxxtestgen_src) # generate suite src tg = ctx(source = suites) tg.post() for s in tg.source: ctx.add_manual_dependency(s, cxxtestgen) ctx.add_manual_dependency(s, cxxtestgen_src) # compile list of all src cpp_src = [ t.outputs[0] for t in tg.tasks ] cpp_src += [ runnerTg.tasks[0].outputs[0] ] # compile test program kw.pop('target', []) kw.pop('includes', []) kw.pop('source', []) kw['use'] += ['cxxtest'] ctx.program(target = 'test/runner', name = relpath + '/test/runner', includes = '.', source = cpp_src, install_path = None, **kw)
def runnable_status(self): gen = self.generator inp = self.inputs[0] if ('c_stlib' in gen.lang) or ('c_shlib' in gen.lang): filenames = outFileName(gen.bld, inp.abspath(), 'c') outh_node = gen.path.find_or_declare(filenames[0]) outc_node = gen.path.find_or_declare(filenames[1]) self.outputs.append(outh_node) self.outputs.append(outc_node) if 'cpp' in gen.lang: filename = outFileName(gen.bld, inp.abspath(), 'cpp') node = gen.path.find_or_declare(filename) self.outputs.append(node) if 'java' in gen.lang: fileparts = getFileParts(gen.bld, inp.abspath()) fileparts[2] = fileparts[2].replace('.zcm', '.java') if fileparts[1] == "": if not getattr(gen, 'javapkg', None): raise WafError('No package specified for java zcmtype ' \ 'generation. Specify package with a ' \ '"package <pkg>;" statement at the top of ' \ 'the type or with the "javapkg" build keyword') else: fileparts[1] = gen.javapkg.replace('.', '/') else: if getattr(gen, 'javapkg', None): fileparts[1] = (gen.javapkg + "/" + fileparts[1]).replace( '.', '/') else: fileparts[1] = fileparts[1].replace('.', '/') outp = '/'.join(['java', fileparts[1], fileparts[2]]) outp_node = gen.path.get_bld().make_node(outp) self.outputs.append(outp_node) if 'python' in gen.lang: filename = outFileName(gen.bld, inp.abspath(), 'python') node = gen.path.find_or_declare(filename) self.outputs.append(node) if not self.outputs: raise WafError( 'No ZCMtypes generated, ensure a valid lang is specified') return super(zcmgen, self).runnable_status()
def exec_command(ctx, cmd): """ Executes a shell command from a waf script. """ status = ctx.exec_command(cmd) if status != 0: print("Unable to execute the command properly.") raise WafError()
def apply_ns3privateheader(self): if self.module is None: raise WafError("'module' missing on ns3headers object %s" % self) ns3_dir_node = self.bld.path.find_or_declare("ns3/private") for filename in set(self.to_list(self.source)): src_node = self.path.find_resource(filename) if src_node is None: raise WafError("source ns3 header file %s not found" % (filename,)) dst_node = ns3_dir_node.find_or_declare(src_node.name) assert dst_node is not None task = self.create_task('ns3privateheader') task.mode = getattr(self, 'mode', 'install') if task.mode == 'install': task.set_inputs([src_node]) task.set_outputs([dst_node]) else: task.header_to_remove = dst_node self.headers = set(self.to_list(self.source)) self.source = '' # tell WAF not to process these files further
def _ask_for_item_choice(in0): from waflib.Errors import WafError i = 1 print("Please select the application:") print("[0].\tAbort") arr = [] for key, val in in0.items(): print("[{:d}].\t{:s}".format(i, key)) i = i + 1 arr.append(val) try: val = int(input()) except ValueError as err: raise WafError('Invalid input', err) if val >= i: raise WafError('Invalid choice') elif val == 0: raise WafError('Aborted') return arr[val - 1]
def CreateZipFile(project): # DETERMINE IF EITHER SOURCE FILES OR SOURCE DIR WERE SPECIFIED. source_files_supplied = hasattr(project, 'source_files') source_dirs_supplied = hasattr(project, 'source_dirs') if not (source_files_supplied or source_dirs_supplied): error_msg = 'Please specify source files and/or source dirs to zip: ' + project.name raise WafError(error_msg) # DETERMINE IF TARGET WAS SPECIFIED. project.zip_filename = getattr(project, 'target', None) if not project.zip_filename: error_msg = 'Please specify the filepath of the zip file to create: ' + project.name raise WafError(error_msg) # RETRIEVE THE NECESSARY PARAMETERS FOR THIS TASK. if source_dirs_supplied: # GET THE SUPPLIED SOURCE DIRECTORY. project.source_dirs = project.to_nodes(project.source_dirs) else: # NO DIRECTORIES WERE SUPPLIED TO WRITE. project.source_dirs = [] if source_files_supplied: # GET THE SUPPLIED SOURCE FILES. project.source_files = project.to_nodes(project.source_files) else: # NO FILES WERE SUPPLIED TO WRITE. project.source_files = [] # DETERMINE IF FOLDER STRUCTURE SHOULD BE PRESERVED IN THE ZIP FILE. project.preserve_directory_structure = getattr( project, 'preserve_directory_structure', False) # CREATE THE ZIP BUILD TASK. output_node = project.path.get_bld().find_or_declare(project.zip_filename) project.zip_build_task = project.create_task('ZipBuildTask', project.source_files, output_node) # CREATE THE INSTALL TASK. InstallZipFile(project)
def run_argv(argv, env, os_env=None, cwd=None, force_no_valgrind=False): proc_env = get_proc_env(os_env) try: WindowsError except NameError: retval = subprocess.Popen(argv, env=proc_env, cwd=cwd).wait() else: try: retval = subprocess.Popen(argv, env=proc_env, cwd=cwd).wait() except WindowsError, ex: raise WafError("Command %s raised exception %s" % (argv, ex))
def process_gir(gen): scan = gen.to_nodes(getattr(gen, "scan", [])) lib = getattr(gen, "lib", None) if lib: lib_gen = gen.bld.get_tgen_by_name(gen.lib) lib_task = lib_gen.link_task else: lib_task = getattr(gen, 'link_task', None) if lib_task: lib_gen = gen else: try: lib_gen = gen.bld.get_tgen_by_name( scan[0].name.rpartition('.')[0]) except IndexError: raise WafError(f"{gen} lacks a library to introspect " "and does not build one itself") lib_task = lib_gen.link_task if not scan: scan = gen.to_nodes([f"{lib_gen.target}.h"]) namespace = getattr(gen, "namespace", None) or \ ''.join(map(methodcaller('capitalize'), scan[0].name[:-2].split('_'))) version = str(getattr(gen, "version", 0)) gir = gen.path.find_or_declare(f"{namespace}-{version}.gir") scan_task = gen.create_task('gir', tgt=gir, src=scan) env = scan_task.env env.NAMESPACE = namespace env.VERSION = version env.append_value('GIRLIB', [lib_gen.target]) scan_task.dep_nodes.extend(lib_task.outputs) env.append_unique('GIRPATH', [ lib_task.outputs[0].parent.path_from(gen.path)]) for include in gen.to_list(getattr(gen, "include", [])): env.append_value('GIRINC', env[f'GIRINC_{include}']) gen.add_install_files(install_to=env.GIRDIR, install_from=scan_task.outputs) gen.add_install_files(install_to=env.TYPELIBDIR, install_from=gen.create_task('gircompile', gir, gir.change_ext('.typelib')).outputs) try: use = gen.to_list(gen.use) except AttributeError: use = gen.use = [] for include in gen.to_list(getattr(gen, "include", [])): use.extend(gen.env[f'GIRUSE_{include}'])
def run(self): lsyms = [] for line in self.inputs[0].read().split(): lsyms.append(line.strip()) lsyms.sort() if self.env.DEST_BINFMT == 'pe': self.outputs[0].write('EXPORTS\n' + '\n'.join(lsyms)) elif self.env.DEST_BINFMT == 'elf': self.outputs[0].write('{ global:\n' + ';\n'.join(lsyms) + ";\nlocal: *; };\n") elif self.env.DEST_BINFMT == 'mac-o': self.outputs[0].write('\n'.join("_"+sym for sym in lsyms) + '\n') else: raise WafError('NotImplemented')
def get_lv2_base(bld, kw, nframes=3): try: lv2_base = kw['lv2_base'] except KeyError: pass else: return lv2_base, '${LV2DIR}/%s.lv2' % lv2_base cf = inspect.currentframe() for i in range(nframes): cf = cf.f_back fi = inspect.getframeinfo(cf) fn = bld.root.make_node(fi.filename).srcpath() raise WafError( '{}[{}]: lv2_base not set in lv2 task generator:\n{}'.format( fn, fi.lineno, pprint.pformat(kw)))
def run(self): syms = {} for x in self.inputs: slist = eval(x.read()) for s in slist: syms[s] = 1 lsyms = syms.keys() lsyms.sort() if self.env.DEST_BINFMT == 'pe': self.outputs[0].write('EXPORTS\n' + '\n'.join(lsyms)) elif self.env.DEST_BINFMT == 'elf': self.outputs[0].write('{ global:\n' + ';\n'.join(lsyms) + ";\nlocal: *; };\n") else: raise WafError('NotImplemented')
def run(self): syms = {} for x in self.inputs: slist = eval(x.read()) for s in slist: syms[s] = 1 lsyms = list(syms.keys()) lsyms.sort() if self.env.DEST_BINFMT == "pe": self.outputs[0].write("EXPORTS\n" + "\n".join(lsyms)) elif self.env.DEST_BINFMT == "elf": self.outputs[0].write("{ global:\n" + ";\n".join(lsyms) + ";\nlocal: *; };\n") elif self.env.DEST_BINFMT == "mac-o": self.outputs[0].write("\n".join(lsyms) + "\n") else: raise WafError("NotImplemented")
def get_run_program(program_string, command_template=None): env = bld.env if command_template in (None, '%s'): argv = shlex.split(program_string) program_name = argv[0] try: program_obj = find_program(program_name, env) except ValueError, ex: raise WafError(str(ex)) program_node = program_obj.path.find_or_declare(program_obj.target) execvec = [program_node.abspath()] + argv[1:]
def compatible(self, text): """Checks the lines of text and yields all of them that have compatible version markers, all markers removed.""" programs = set() for line in text: match = self.marker.search(line) if match: program = match.group("program") programs.add(program) try: if self.operators[match.group("operator")]( self.get_version(program), version(match.group("version"))): yield self.marker.sub('', line) except TypeError: raise WafError('version missing for program ' + program) else: yield line self.generator.bld.raw_deps[self.uid()] = programs
def outFileName(ctx, inp, lang, absPath=False): fileparts = getFileParts(ctx, inp) def defaultOutFileName(fileparts, absPath): ret = "" if absPath: if fileparts[3] != "": ret = fileparts[3] if fileparts[1] != "": if ret != "": ret = ret + "/" ret = ret + '/'.join(fileparts[1].split('.')) if fileparts[2] != "": if ret != "": ret = ret + "/" ret = ret + fileparts[2] return ret if lang == 'zcm': return defaultOutFileName(fileparts, absPath) if lang == 'c': hfileparts = fileparts[:] cfileparts = fileparts[:] hfileparts[2] = fileparts[2].replace('.zcm', '.h') cfileparts[2] = fileparts[2].replace('.zcm', '.c') if fileparts[1] != "": hfileparts[2] = '_'.join( fileparts[1].split('.')) + "_" + hfileparts[2] cfileparts[2] = '_'.join( fileparts[1].split('.')) + "_" + cfileparts[2] return [ defaultOutFileName(hfileparts, absPath).replace('.zcm', '.h'), defaultOutFileName(cfileparts, absPath).replace('.zcm', '.c') ] if lang == 'cpp': return defaultOutFileName(fileparts, absPath).replace('.zcm', '.hpp') if lang == 'python': return defaultOutFileName(fileparts, absPath).replace('.zcm', '.py') raise WafError('This should not be possible')
def scan(task): try: incn = task.generator.includes_nodes except AttributeError: raise WafError('%r is missing a feature such as "go" or "includes": ' % task.generator) # filter out nodes that are not in the project directory, we don't care # about these nodepaths = [ x for x in incn if x.is_child_of(x.ctx.bldnode) or x.is_child_of(x.ctx.srcnode) ] bldnode = task.generator.bld.bldnode deps = [] for input in task.inputs: file = Utils.readf(input.abspath()) try: gp = GoParser(file) gp.parse() except ParserError: pass for s in gp.statements: if not isinstance(s, ImportSpec): continue # TODO: global paths should be treated as local too, but # no one uses them? if s.path.startswith("./") or s.path.startswith("../"): node = find_local(s.path, bldnode) else: node = find_global(s.path, nodepaths) if node: deps.append(node) return (deps, None)