def _find_doxygen(env): """Find the right version of doxygen. Return a tuple of the command name and a boolean indicating whether or not the version checked out.""" if env['doxygen_cmd'] == '': doxygen_cmd_intel = "/usr/intel/bin/doxygen" doxygen_cmd_cygwin = "C:/cygwin/bin/doxygen" doxygen_cmd_mac = \ "/Applications/Doxygen.app/Contents/Resources/doxygen" doxygen_cmd = "doxygen" if env['build_os'] == 'win': if os.path.exists(doxygen_cmd_cygwin): doxygen_cmd = doxygen_cmd_cygwin else: mbuild.msgb( 'DOXYGEN', "Could not find cygwin's doxygen," + "trying doxygen from PATH") elif env['build_os'] == 'lin': if mbuild.verbose(1): mbuild.msgb("CHECKING FOR", doxygen_cmd_intel) if os.path.exists(doxygen_cmd_intel): doxygen_cmd = doxygen_cmd_intel elif env['build_os'] == 'mac': if mbuild.verbose(1): mbuild.msgb("CHECKING FOR", doxygen_cmd_mac) if os.path.exists(doxygen_cmd_mac): doxygen_cmd = doxygen_cmd_mac else: doxygen_cmd = env['doxygen_cmd'] doxygen_cmd = env.escape_string(doxygen_cmd) doxygen_okay = False if mbuild.verbose(1): mbuild.msgb('Checking doxygen version', '...') if mbuild.check_python_version(2, 4): try: (retval, output, error_output) = \ mbuild.run_command(doxygen_cmd + " --version") if retval == 0: if len(output) > 0: first_line = output[0].strip() if mbuild.verbose(1): mbuild.msgb("Doxygen version", first_line) doxygen_okay = _doxygen_version_okay(first_line, 1, 4, 6) else: for o in output: mbuild.msgb("Doxygen-version-check STDOUT", o) if error_output: for line in error_output: mbuild.msgb("STDERR ", line.rstrip()) except: mbuild.die("Doxygen required by the command line options " + "but no doxygen found") return (doxygen_cmd, doxygen_okay)
def _build_doxygen_main(args, env): """Customize the doxygen input file. Run the doxygen command, copy in any images, and put the output in the right place.""" if type(args) is types.ListType: if len(args) < 2: mbuild.die( "Need subs dictionary and dummy file arg for the doxygen command " + "to indicate its processing") else: mbuild.die("Need a list for _build_doxygen_main with the subs " + "dictionary and the dummy file name") (subs, dummy_file) = args (doxygen_cmd, doxygen_okay) = _find_doxygen(env) if not doxygen_okay: msg = 'No good doxygen available on this system; ' + \ 'Your command line arguments\n\trequire it to be present. ' + \ 'Consider dropping the "doc" and "doc-build" options\n\t or ' + \ 'specify a path to doxygen with the --doxygen knob.\n\n\n' return (1, [msg]) # failure else: env['DOXYGEN'] = doxygen_cmd try: okay = _customize_doxygen_file(env, subs) except: mbuild.die("CUSTOMIZE DOXYGEN INPUT FILE FAILED") if not okay: return (1, ['Doxygen customization failed']) cmd = env['DOXYGEN'] + ' ' + \ env.escape_string(env['doxygen_config_customized']) if mbuild.verbose(1): mbuild.msgb("RUN DOXYGEN", cmd) (retval, output, error_output) = mbuild.run_command(cmd) for line in output: mbuild.msgb("DOX", line.rstrip()) if error_output: for line in error_output: mbuild.msgb("DOX-ERROR", line.rstrip()) if retval != 0: mbuild.msgb("DOXYGEN FAILED") mbuild.die("Doxygen run failed. Retval=", str(retval)) mbuild.touch(dummy_file) mbuild.msgb("DOXYGEN", "succeeded") return (0, []) # 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")
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 _wk_show_errors_only(): #True means show errors only when building. if mbuild.verbose(1): return False # show output return True # show errors only.