def work(env): #with then env, the dag hash file is put in the build_dir. dag = mbuild.dag_t('circular-test', env=env) work_queue = mbuild.work_queue_t(env['jobs']) env.compile_and_link(dag, ['main.c'], 'main' + env['EXEEXT']) okay = work_queue.build(dag=dag) if not okay: mbuild.die("build failed") mbuild.msgb("SUCCESS")
def _make_doxygen_reference_manual(env, doxygen_inputs, subs, work_queue, hash_file_name='dox'): """Install the doxygen reference manual the doyxgen_output_dir directory. doxygen_inputs is a list of files """ dox_dag = mbuild.dag_t(hash_file_name, env=env) # so that the scanner can find them dirs = {} for f in doxygen_inputs: dirs[os.path.dirname(f)] = True for d in dirs.iterkeys(): env.add_include_dir(d) # make sure the config and top file are in the inptus list doxygen_inputs.append(env['doxygen_config']) doxygen_inputs.append(env['doxygen_top_src']) dummy = env.build_dir_join('dummy-doxygen-' + hash_file_name) # Run it via the builder to make it dependence driven run_always = False if _empty_dir(env['doxygen_install']): run_always = True if run_always: _build_doxygen_main([subs, dummy], env) else: c1 = mbuild.plan_t(command=_build_doxygen_main, args=[subs, dummy], env=env, input=doxygen_inputs, output=dummy) dox1 = dox_dag.add(env, c1) okay = work_queue.build(dag=dox_dag) phase = "DOXYGEN" if not okay: mbuild.die("[%s] failed. dying..." % phase) if mbuild.verbose(1): mbuild.msgb(phase, "build succeeded")
# you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # #END_LEGAL import sys import os import find import mbuild env = mbuild.env_t() env.parse_args() os.environ['LANG']='en_US.UTF-8' mbuild.cmkdir(env['build_dir']) dep_tracker = mbuild.dag_t() cmd1 = dep_tracker.add(env, env.cc_compile('foo.c')) work_queue = mbuild.work_queue_t() okay = work_queue.build(dag=dep_tracker) if not okay: mbuild.die("build failed") mbuild.msgb("SUCCESS")
def build_examples(env, work_queue): """Build the examples""" example_exes = [] env['example_exes'] = [] # used by install examples_dag = mbuild.dag_t('xedexamples', env=env) if not env.on_windows(): for d in env['example_rpaths']: env.add_to_var('example_linkflags', '-Wl,-rpath,{}'.format(d)) env.add_to_var('LINKFLAGS', env['example_linkflags']) # put the examples in their own subdirectory env['build_dir'] = mbuild.join(env['build_dir'], 'examples') mbuild.cmkdir(env['build_dir']) link_libxed = env['link_libxed'] if env['shared']: _add_libxed_rpath(env) # C vs C++: env is for C++ and env_c is for C programs. if env['compiler'] in ['gnu', 'clang', 'icc']: env['LINK'] = env['CXX'] env_c = copy.deepcopy(env) if env_c['compiler'] in ['gnu', 'clang']: env_c['LINK'] = '%(CC)s' if env['pin_crt']: xbc.compile_with_pin_crt_lin_mac_common_cplusplus(env) # shared files cc_shared_files = env.src_dir_join(['xed-examples-util.c']) if env['decoder']: cc_shared_files.extend( env.src_dir_join(['xed-dot.c', 'xed-dot-prep.c'])) if env['encoder']: cc_shared_files += env.src_dir_join(['xed-enc-lang.c']) cc_shared_objs = env.compile(examples_dag, cc_shared_files) # the XED command line tool xed_cmdline_files = [ 'xed-disas-raw.c', 'avltree.c', 'xed-disas-hex.c', 'xed-symbol-table.c' ] if env.on_windows() and env['set_copyright']: xed_cmdline_files.append("xed.rc") extra_libs = [] if env['decoder']: if env.on_linux() or env.on_freebsd() or env.on_netbsd(): xed_cmdline_files.append('xed-disas-elf.c') elif env.on_mac(): xed_cmdline_files.append('xed-disas-macho.c') elif env.on_windows(): xed_cmdline_files.append('xed-disas-pecoff.cpp') if (env['dbghelp'] and env['msvs_version'] not in ['6', '7']): env.add_define("XED_DBGHELP") xed_cmdline_files.append('udhelp.cpp') extra_libs = ['dbghelp.lib', 'version.lib'] xed_cmdline_files = env.src_dir_join(xed_cmdline_files) xed_cmdline_obj = copy.deepcopy(cc_shared_objs) # Env for cmdline tool (with libelf/dwarf on linux.) if env.on_windows(): # still C++ cenv = copy.deepcopy(env) else: # lin/mac are C code only. cenv = copy.deepcopy(env_c) if env.on_linux(): xbc.cond_add_elf_dwarf(cenv) xed_cmdline_obj += cenv.compile(examples_dag, xed_cmdline_files) xed_cmdline = ex_compile_and_link( cenv, examples_dag, env.src_dir_join('xed.c'), xed_cmdline_obj + [link_libxed] + extra_libs) mbuild.msgb("CMDLINE", xed_cmdline) example_exes.append(xed_cmdline) ild_examples = [] other_c_examples = [] small_examples = ['xed-size.c'] if env['encoder']: small_examples += ['xed-ex5-enc.c'] other_c_examples += ['xed-ex3.c'] if env['decoder'] and env['encoder']: other_c_examples += ['xed-ex6.c'] if env['decoder']: ild_examples += ['xed-ex-ild.c'] other_c_examples += [ 'xed-ex1.c', 'xed-ex-ild2.c', 'xed-min.c', 'xed-reps.c', 'xed-ex4.c', 'xed-tester.c', 'xed-dec-print.c', 'xed-ex-agen.c', 'xed-ex7.c', 'xed-ex8.c', 'xed-ex-cpuid.c', 'xed-tables.c', 'xed-dll-discovery.c' ] # compile & link other_c_examples for example in env.src_dir_join(other_c_examples): example_exes.append( ex_compile_and_link(env_c, examples_dag, example, cc_shared_objs + [link_libxed])) # compile & link ild_examples for example in env.src_dir_join(ild_examples): example_exes.append( ex_compile_and_link(env_c, examples_dag, example, [env['link_libild']])) # compile & link small_examples for example in env.src_dir_join(small_examples): example_exes.append( ex_compile_and_link(env_c, examples_dag, example, [link_libxed])) if mbuild.verbose(3): mbuild.msgb("ALL EXAMPLES", "\n\t".join(example_exes)) examples_to_build = example_exes env['example_exes'] = example_exes mbuild.msgb("BUILDING EXAMPLES") okay = work_queue.build(examples_dag, targets=examples_to_build, die_on_errors=env['die_on_errors'], show_progress=True, show_output=True, show_errors_only=_wk_show_errors_only()) if not okay: xbc.cdie("XED EXAMPLES build failed") if mbuild.verbose(2): mbuild.msgb("XED EXAMPLES", "build succeeded") return 0
def build_examples(env, work_queue): """Build the examples""" example_exes = [] env['example_exes'] = [] # used by install examples_dag = mbuild.dag_t('xedexamples', env=env) if not env.on_windows(): for d in env['example_rpaths']: env.add_to_var('example_linkflags', '-Wl,-rpath,{}'.format(d)) env.add_to_var('LINKFLAGS', env['example_linkflags']) env.add_to_var('CCFLAGS', env['example_flags']) env.add_to_var('CXXFLAGS', env['example_flags']) mbuild.cmkdir(env['build_dir']) link_libxed = env['link_libxed'] if env['shared']: _add_libxed_rpath(env) # C vs C++: env is for C++ and env_c is for C programs. if env['compiler'] in ['gnu','clang', 'icc']: env['LINK'] = env['CXX'] env_c = copy.deepcopy(env) if env_c['compiler'] in ['gnu','clang']: env_c['LINK'] = '%(CC)s' if env['pin_crt']: xbc.compile_with_pin_crt_lin_mac_common_cplusplus(env) # shared files cc_shared_files = env.src_dir_join([ 'xed-examples-util.c']) if env['decoder']: cc_shared_files.extend(env.src_dir_join([ 'xed-dot.c', 'xed-dot-prep.c'])) if env['encoder']: cc_shared_files += env.src_dir_join([ 'xed-enc-lang.c']) cc_shared_objs = env.compile( examples_dag, cc_shared_files) # the XED command line tool xed_cmdline_files = [ 'xed-disas-raw.c', 'avltree.c', 'xed-disas-hex.c', 'xed-symbol-table.c'] if env.on_windows() and env['set_copyright']: # AUTOMATICALLY UPDATE YEAR IN THE RC FILE year = time.strftime("%Y") lines = open(env.src_dir_join('xed-rc-template.txt')).readlines() lines = [ re.sub('%%YEAR%%',year,x) for x in lines ] xbc.write_file(env.src_dir_join('xed.rc'), lines) xed_cmdline_files.append("xed.rc") extra_libs = [] if env['decoder']: if env.on_linux() or env.on_freebsd() or env.on_netbsd(): xed_cmdline_files.append('xed-disas-filter.c') xed_cmdline_files.append('xed-nm-symtab.c') elif env.on_mac(): xed_cmdline_files.append('xed-disas-macho.c') elif env.on_windows(): xed_cmdline_files.append('xed-disas-pecoff.cpp') if ( env['dbghelp'] and env['msvs_version'] not in ['6','7'] ): env.add_define("XED_DBGHELP") xed_cmdline_files.append('udhelp.cpp') extra_libs = ['dbghelp.lib', 'version.lib' ] xed_cmdline_files = env.src_dir_join(xed_cmdline_files) xed_cmdline_obj = copy.deepcopy(cc_shared_objs) # Env for cmdline tool (with libelf/dwarf on linux.) if env.on_windows(): # still C++ cenv = copy.deepcopy(env) else: # lin/mac are C code only. cenv = copy.deepcopy(env_c) if env.on_linux(): xbc.cond_add_elf_dwarf(cenv) if env.on_linux() or env.on_freebsd() or env.on_netbsd(): src_elf = env.src_dir_join('xed-disas-elf.c') if env['use_elf_dwarf_precompiled']: cenv2 = copy.deepcopy(cenv) # need to remove -pedantic because of redundant typedef Elf in dwarf header file cenv2.remove_from_var('CCFLAGS','-pedantic') xed_cmdline_obj += cenv2.compile(examples_dag, [src_elf]) else: xed_cmdline_files.append(src_elf) xed_cmdline_obj += cenv.compile(examples_dag, xed_cmdline_files) xed_cmdline = ex_compile_and_link(cenv, examples_dag, env.src_dir_join('xed.c'), xed_cmdline_obj + [link_libxed] + extra_libs) mbuild.msgb("CMDLINE", xed_cmdline) example_exes.append(xed_cmdline) if env['encoder']: exe = build_asmparse(cenv, examples_dag, cc_shared_objs) example_exes.append(exe) ild_examples = [] other_c_examples = [] enc2_examples = [] small_examples = ['xed-size.c'] if env['enc2']: enc2_examples += [ 'xed-enc2-1.c', 'xed-enc2-2.c', 'xed-enc2-3.c' ] if env['encoder']: small_examples += ['xed-ex5-enc.c'] other_c_examples += ['xed-ex3.c'] if env['decoder'] and env['encoder']: other_c_examples += ['xed-ex6.c', 'xed-ex9-patch.c' ] if env['decoder']: ild_examples += [ 'xed-ex-ild.c' ] other_c_examples += ['xed-ex1.c', 'xed-ex-ild2.c', 'xed-min.c', 'xed-reps.c', 'xed-ex4.c', 'xed-tester.c', 'xed-dec-print.c', 'xed-ex-agen.c', 'xed-ex7.c', 'xed-ex8.c', 'xed-ex-cpuid.c', 'xed-tables.c', 'xed-find-special.c', 'xed-dll-discovery.c'] # compile & link other_c_examples for example in env.src_dir_join(other_c_examples): example_exes.append(ex_compile_and_link(env_c, examples_dag, example, cc_shared_objs + [ link_libxed ])) # compile & link ild_examples if os.path.exists(env['link_libild']): for example in env.src_dir_join(ild_examples): example_exes.append(ex_compile_and_link(env_c, examples_dag, example, [ env['link_libild'] ])) # compile & link small_examples for example in env.src_dir_join(small_examples): example_exes.append(ex_compile_and_link(env_c, examples_dag, example, [ link_libxed ])) for example in env.src_dir_join(enc2_examples): example_exes.append(ex_compile_and_link( env_c, examples_dag, example, env['xed_enc2_libs'] + [link_libxed] )) mbuild.vmsgb(4, "ALL EXAMPLES", "\n\t".join(example_exes)) examples_to_build = example_exes env['example_exes'] = example_exes mbuild.msgb("BUILDING EXAMPLES") okay = work_queue.build(examples_dag, targets=examples_to_build, die_on_errors=env['die_on_errors'], show_progress=True, show_output=True, show_errors_only=_wk_show_errors_only()) if not okay: xbc.cdie( "XED EXAMPLES build failed") mbuild.vmsgb(3, "XED EXAMPLES", "build succeeded") return 0
# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # #END_LEGAL import sys # find.py is in the tests dir. It finds mbuild and puts it on the # sys.path. import find import mbuild env = mbuild.env_t(init_verbose=0) env.parse_args() #mbuild.build_env.set_env_icl(env) mbuild.cmkdir(env['build_dir']) dag = mbuild.dag_t() res = env.compile(dag, ['VersionInfo.rc']) objs = env.compile(dag, ['hello.c']) cmd = dag.add(env, env.dynamic_lib(objs + res, env.build_dir_join('hello.dll'))) work_queue = mbuild.work_queue_t(env['jobs']) okay = work_queue.build(dag=dag) if not okay: mbuild.die("build failed") mbuild.msgb("SUCCESS")