Exemplo n.º 1
0
def examples_work(env):
    """External entry point for non-command line invocations.
    Initialize the environment, build libxed, the examples, the kit
    and run the tests"""
    xbc.prep(env)
    verify_args(env)
    start_time = mbuild.get_time()
    xbc.init_once(env)

    init(env)

    if 'clean' in env['targets'] or env['clean']:
        xbc.xed_remove_files_glob(env)
        if len(env['targets']) <= 1:
            xbc.cexit(0)

    mbuild.cmkdir(env['build_dir'])

    work_queue = mbuild.work_queue_t(env['jobs'])

    xbc.get_libxed_names(env, work_queue)
    retval = build_examples(env, work_queue)
    end_time = mbuild.get_time()
    mbuild.msgb("EXAMPLES BUILD ELAPSED TIME",
                mbuild.get_elapsed_time(start_time, end_time))
    return retval
Exemplo n.º 2
0
def setup(env):
    mbuild.msgb("Using build_kit.setup")
    init_common_requirements(env)
    locate_pin_tree(env)
    init_pin_environment_compile(env)
    if not env['standalone_program']:
        init_pintool_environment_link(env)
    init_pintool_compiler_env(env)
Exemplo n.º 3
0
def early_init(env, build_kit=False):
    """Called before parsing knobs for early init"""
    mbuild.msgb("Using build_kit.early_init")
    knobs(env)
    if not build_kit:
        #The buildkit's mfile is using this script as well.
        #The buildkit does not need the build_config information
        #and does not have access to it. So we import it only here.
        import build_config
        env['kit_info'] = build_config.kit_info()
Exemplo n.º 4
0
def _test_map_all_zero(vv, phash_map_lu):
    """phash_map_lu is a dict[maps][0...255] pointing to a 2nd level
       lookup or it might be None indicating an empty map."""
    all_zero_map= collections.defaultdict(bool) # Default False
    for xmap in phash_map_lu.keys():
        omap = phash_map_lu[xmap]
        if omap == None:
            all_zero_map[xmap]=True
            mbuild.msgb("ALL ZEROS", "VV={} MAP={}".format(vv, xmap))
    return all_zero_map
Exemplo n.º 5
0
def work():
    env = mbuild.env_t()
    env.parser.add_option(
        "--bulk-make-tests",
        "-b",
        dest="bulk_tests",
        action="append",
        default=[],
        help=
        "List of bulk tests from which to create test references. Repeatable")
    env.parser.add_option(
        "--rebase-tests",
        dest="rebase_tests",
        action="store_true",
        default=False,
        help="Update the reference output files. Do not compare.")
    env.parser.add_option("--tests",
                          dest="tests",
                          action="append",
                          default=[],
                          help="Directory where tests live.")
    env.parser.add_option("--otests",
                          dest="otests",
                          action="store",
                          default='tests-base',
                          help="Directory where tests live.")
    env.parser.add_option("-c",
                          "--code",
                          dest="codes",
                          action="append",
                          default=[],
                          help="Codes for test subsetting (DEC, ENC, AVX, " +
                          "AVX512X, AVX512PF, XOP, KNC)." +
                          " Only used for running tests, not creating them.")
    env.parse_args()

    if not env['tests']:
        env['tests'] = ['tests-base']

    xed = mbuild.join(env['build_dir'], 'xed')
    #xedexe = xed + ".exe"
    #if not os.path.exists(xed) and not os.path.exists(xedexe):
    #    mbuild.die("Need the xed command line tool: %s or %s\n\n" % (xed,xedexe))

    if len(env['bulk_tests']) != 0:
        mbuild.msgb("MAKE BULK TESTS")
        make_bulk_tests(env)
        sys.exit(0)

    if env['rebase_tests']:
        rebase_tests(env)
        sys.exit(0)

    errors = run_tests(env)
    sys.exit(errors)
Exemplo n.º 6
0
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")
Exemplo n.º 7
0
def xed_remove_files_glob(env):
    """Clean up"""
    mbuild.msgb("CLEANING")
    try:
        if 'build_dir' in env:
            path = env['build_dir']
            if path != '.' and path != '..':
                mbuild.remove_tree(path)
                return
    except:
        cdie("clean failed")
Exemplo n.º 8
0
def init_pintool_compiler_env(env):
    if env['compiler'] == 'ms':
        init_ms_env_compile(env)
        if not env['standalone_program']:
            init_ms_env_link_tool(env)
    elif env['compiler'] in ['gnu', 'clang']:
        init_gnu_env_compile(env)
        if not env['standalone_program']:
            init_gnu_env_link_tool(env)
    else:
        mbuild.msgb("Unsupported compiler: %s" % (env['compiler']))
Exemplo n.º 9
0
def locate_pin_tree(env):

    if 'pin' not in env:
        find_build_kit_path(env)
        env['pin'] = mbuild.join(env['build_kit_path'], 'pinkit')
    if not env['pin']:
        mbuild.die('Pin directory is not setup ' +
                   'properly in the environment {0}'.format(env['pin']))
    if not os.path.exists(env['pin']):
        mbuild.die('cannot find the PIN directory: {0:s}'.format(env['pin']))
    mbuild.msgb("FOUND PIN KIT", env['pin'])
    env['kit'] = True
Exemplo n.º 10
0
def strip_file(env, fn, options=''):
    if env.on_windows():
        return
    fne = env.expand(fn)
    mbuild.msgb("STRIPPING", fne)
    strip_cmd = " ".join([env['strip'], options, fne])
    #mbuild.msgb("STRIP CMD", strip_cmd)
    (retcode, stdout, stderr) = mbuild.run_command(strip_cmd)
    if retcode != 0:
        dump_lines("strip stdout", stdout)
        dump_lines("strip stderr", stderr)
        cdie("Could not strip " + fne)
Exemplo n.º 11
0
def find_path(cmd):
    mbuild.msgb("Checking location of %s (on PATH)" % (cmd))
    path = os.getenv("PATH")
    for p in path.split(os.pathsep):
        f = os.path.join(p, cmd)
        if os.path.exists(f):
            return p
    # this relies on "which" being available....
    cmd = "which %s" % (cmd)
    (retcode, stdout, stderr) = mbuild.run_command_unbufferred(cmd)
    if retcode == 0:
        return os.path.dirname(stdout[0])
    return 'unknown'
Exemplo n.º 12
0
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
Exemplo n.º 13
0
def copy_system_libraries(env, kitdir, files, extra_ld_library_paths=[]):
    """copy system libraries to kit on Linux systems. Return True on success."""

    # Make a temporary environment for running ldd that includes any required
    # LD_LIBRARY_PATH additions.
    osenv = None
    if extra_ld_library_paths:
        osenv = copy.deepcopy(os.environ)
        s = None
        if 'LD_LIBRARY_PATH' in osenv:
            s = osenv['LD_LIBRARY_PATH']
        osenv['LD_LIBRARY_PATH'] = ":".join(extra_ld_library_paths)
        if s:
            osenv['LD_LIBRARY_PATH'] += ":" + s

    okay = True
    if env.on_linux() or env.on_freebsd() or env.on_netbsd():
        system_libraries = set()
        for binary_executable in files:
            if os.path.exists(binary_executable):
                (retval, lines, stderr) = mbuild.run_command(
                    "ldd {}".format(binary_executable), osenv=osenv)
                for line in lines:
                    line = line.rstrip()
                    print("\t{}".format(line))
                if retval != 0:  # error handling
                    if len(lines) >= 1:
                        if lines[0].find("not a dynamic executable") != -1:
                            continue
                        elif lines[0].find(
                                "not a dynamic ELF executable") != -1:
                            continue
                    mbuild.warn("Could not run ldd on [%s]" %
                                binary_executable)
                    return False
                if env.on_freebsd() or env.on_netbsd():
                    lines = lines[1:]
                ldd_okay, files = _grab_ldd_libraries(lines)
                if not ldd_okay:
                    okay = False
                for lib in files:
                    if not _file_to_avoid(env, lib):
                        system_libraries.add(lib)

        for slib in system_libraries:
            mbuild.msgb("TO COPY", slib)
        for slib in system_libraries:
            mbuild.copy_file(src=slib, tgt=kitdir)
    return okay
Exemplo n.º 14
0
def find_build_kit_path(env):
    if 'build_kit_path' not in env:
        try:
            env['build_kit_path'] = os.getenv("SDE_BUILD_KIT")
            mbuild.msgb("SDE_BUILD_KIT env var", env['build_kit_path'])
        except:
            mbuild.die("Could not find SDE_BUILD_KIT in the shell environment")

    if not env['build_kit_path']:
        mbuild.die("Could not find build_kit_path is not set properly")

    if os.path.exists(env['build_kit_path']):
        return
    mbuild.die("Could not find build kit at {0:s}".format(
        env['build_kit_path']))
Exemplo n.º 15
0
def  _greater_than_gcc(env,amaj,amin,aver):
    gcc = env.expand('%(CC)s')
    vstr = mbuild.get_gcc_version(gcc)
    mbuild.msgb("GCC VERSION", vstr)
    try:
        (vmaj, vmin, vver) = vstr.split('.')
    except:
        return False
    if vmaj > amaj:
        return True
    if vmaj == amaj and vmin > amin:
        return True
    if vmaj == amaj and vmin == amin and vver >= aver:
        return True
    return False
Exemplo n.º 16
0
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")
Exemplo n.º 17
0
def _test_map_all_zero(vv, phash_map_lu):
    """phash_map_lu is a dict[maps][0...255] pointing to a 2nd level lookup  """
    all_zero_map = {}
    for xmap in list(phash_map_lu.keys()):
        omap = phash_map_lu[xmap]
        all_zero = True
        for i in range(0, 256):
            value = omap[hex(i)]
            #mbuild.msgb("MAP VAL", "VV={} MAP={} OPCODE={} VALUE={}".format(
            #    vv, xmap, i, value))
            if value != '(xed3_find_func_t)0':
                all_zero = False
                break
        if all_zero:
            mbuild.msgb("ALL ZEROS", "VV={} MAP={}".format(vv, xmap))
            all_zero_map[xmap] = True
        else:
            all_zero_map[xmap] = False
    return all_zero_map
Exemplo n.º 18
0
def cond_add_elf_dwarf(env):
    "Set up for using libelf/libdwarf on linux."

    if 'ext_libs' not in env:
        env['ext_libs'] = []

    if env['use_elf_dwarf']:
        if not env.on_linux():
            die("No libelf/dwarf for this platform")
    else:
        return

    mbuild.msgb("ADDING ELF/DWARF")
    # set up the preprocessor define and linker requirements.
    _use_elf_dwarf(env)

    if env['use_elf_dwarf_precompiled']:
        mbuild.msgb("ADDING ELF/DWARF PRECOMPILED")
        _add_elf_dwarf_precompiled(env)
    else:
        env.add_include_dir('/usr/include/libdwarf')
Exemplo n.º 19
0
def cond_add_elf_dwarf(env):
    "Set up for using libelf/libdwarf on linux."

    if 'ext_libs' not in env:
        env['ext_libs'] = []

    if env['use_elf_dwarf']:
        if not env.on_linux():
            die("No libelf/dwarf for this platform")
    else:
        return

    mbuild.msgb("ADDING ELF/DWARF")
    # set up the preprocessor define and linker requirements.
    _use_elf_dwarf(env)

    if not env['use_elf_dwarf_precompiled']:
        # presumably the user is supplying their own & setting rpaths, etc.
        return
    mbuild.msgb("ADDING ELF/DWARF PRECOMPILED")
    _add_elf_dwarf_precompiled(env)
Exemplo n.º 20
0
def one_test(env,test_dir):

    cmd_fn = os.path.join(test_dir,"cmd")
    cmd = open(cmd_fn,'r').readlines()[0]

    # abspath required for windoze
    build_dir = mbuild.posix_slashes(os.path.abspath(env['build_dir']))
    cmd2 = re.sub('BUILDDIR',build_dir,cmd)
    cmd2 = cmd2.strip()
    print(cmd2)

    (retcode, stdout,stderr) = mbuild.run_command(cmd2,separate_stderr=True)
    print("Retcode %s" % (str(retcode)))
    if stdout:
        stdout = _prep_stream(stdout,"STDOUT")
    if stderr:
        stderr = _prep_stream(stderr,"STDERR")

    ret_match = compare_file(os.path.join(test_dir,"retcode.reference"), [ str(retcode) ])
    stdout_match = compare_file(os.path.join(test_dir,"stdout.reference"), stdout)
    stderr_match = compare_file(os.path.join(test_dir,"stderr.reference"), stderr)
    
    okay = True
    if not ret_match:
        mbuild.msgb("RETCODE MISMATCH")
        okay = False
    if not stdout_match:
        mbuild.msgb("STDOUT MISMATCH")
        okay = False
    if not stderr_match:
        mbuild.msgb("STDERR MISMATCH")
        okay = False
    print("-"*40 + "\n\n\n")
    return okay
Exemplo n.º 21
0
def _modify_search_path_mac(env, fn):
    """Make example tools refer to the libxed.so from the lib directory
   if doing and install. Mac only."""
    if not env['shared']:
        return
    if not env.on_mac():
        return
    if not installing(env):
        return
    env['odll'] = '%(build_dir)s/libxed.dylib'
    env['ndll'] = '"@loader_path/../lib/libxed.dylib"'
    cmd = 'install_name_tool -change %(odll)s %(ndll)s ' + fn
    cmd = env.expand(cmd)
    env['odll'] = None
    env['ndll'] = None

    mbuild.msgb("SHDOBJ SEARCH PATH", cmd)
    (retcode, stdout, stderr) = mbuild.run_command(cmd)
    if retcode != 0:
        dump_lines("install_name_tool stdout", stdout)
        dump_lines("install_name_tool stderr", stderr)
        cdie("Could not modify dll path: " + cmd)
Exemplo n.º 22
0
def _customize_doxygen_file(env, subs):
    """Change the $(*) strings to the proper value in the config file.
    Returns True on success"""

    # doxygen wants quotes around paths with spaces
    for k, s in subs.iteritems():
        if re.search(' ', s):
            if not re.search('^".*"$', s):
                mbuild.die(
                    "Doxygen requires quotes around strings with spaces: [%s]->[%s]"
                    % (k, s))
                return False

    # input and output files
    try:
        lines = file(env['doxygen_config']).readlines()
    except:
        mbuild.msgb("Could not open input file: " + env['doxygen_config'])
        return False

    env['doxygen_config_customized'] = \
             env.build_dir_join(os.path.basename(env['doxygen_config']) + '.customized')
    try:
        ofile = open(env['doxygen_config_customized'], 'w')
    except:
        mbuild.msgb("Could not open output file: " +
                    env['doxygen_config_customized'])
        return False

    # compile the patterns
    rsubs = {}
    for k, v in subs.iteritems():
        rsubs[k] = re.compile(r'(?P<tag>[$][(]' + k + '[)])')

    olines = []
    for line in lines:
        oline = line
        for k, p in rsubs.iteritems():
            #print 'searching for', k, 'to replace it with', subs[k]
            m = p.search(oline)
            while m:
                #print 'replacing', k, 'with', subs[k]
                oline = _replace_match(oline, m, subs[k], 'tag')
                m = p.search(oline)
        olines.append(oline)

    try:
        for line in olines:
            ofile.write(line)
    except:
        ofile.close()
        mbuild.msgb("Could not write output file: " +
                    env['doxygen_config_customized'])
        return False

    ofile.close()
    return True
Exemplo n.º 23
0
def _get_xed_min_size(env):
    if not env.on_linux():
        return
    
    xed_min = None    
    #check if we have xed-min test
    for exe in env['example_exes']:
        if 'xed-min' in exe:
            xed_min = exe

    if not xed_min:
        return 
    
    xbc.strip_file(env,xed_min)
    
    #get the size in MB
    size_bytes = os.path.getsize(xed_min)
    size_meg = size_bytes / (1024*1024.0) 
    mbuild.msgb("XED-MIN SIZE", "%d = %.2fMB" % (size_bytes,size_meg))

    import elf_sizes
    d = elf_sizes.work(xed_min,die_on_errors=False)
    if d:
        elf_sizes.print_table(d)
Exemplo n.º 24
0
def one_test(env, test_dir):

    cmd_fn = os.path.join(test_dir, "cmd")
    cmd = open(cmd_fn, 'r').readlines()[0]

    # abspath required for windoze
    build_dir = mbuild.posix_slashes(os.path.abspath(env['build_dir']))
    cmd2 = re.sub('BUILDDIR', build_dir, cmd)
    cmd2 = cmd2.strip()
    print(cmd2)

    (retcode, stdout, stderr) = mbuild.run_command(cmd2, separate_stderr=True)
    print("Retcode %s" % (str(retcode)))
    if stdout:
        if len(stdout) == 1:
            stdout = stdout[0].split("\n")
        if len(stdout) == 1 and stdout[0] == '':
            stdout = []
        if len(stdout) > 0 and len(stdout[-1]) == 0:
            stdout.pop()
        for line in stdout:
            print("[STDOUT] %d %s" % (len(line), line))
    if stderr:
        if len(stderr) == 1:
            stderr = stderr[0].split("\n")
        if len(stderr) == 1 and stderr[0] == '':
            stderr = []
        for line in stderr:
            print("[STDERR] %s" % (line))

    ret_match = compare_file(os.path.join(test_dir, "retcode.reference"),
                             [str(retcode)])
    stdout_match = compare_file(os.path.join(test_dir, "stdout.reference"),
                                stdout)
    stderr_match = compare_file(os.path.join(test_dir, "stderr.reference"),
                                stderr)

    okay = True
    if not ret_match:
        mbuild.msgb("RETCODE MISMATCH")
        okay = False
    if not stdout_match:
        mbuild.msgb("STDOUT MISMATCH")
        okay = False
    if not stderr_match:
        mbuild.msgb("STDERR MISMATCH")
        okay = False
    print("-" * 40 + "\n\n\n")
    return okay
Exemplo n.º 25
0
def compare_file(reference, this_test):
    ref_lines = open(reference,'r').readlines()
    ref_lines = [ x.rstrip() for x in ref_lines]
    this_test = [ x.rstrip() for x in  this_test]
    for line in difflib.unified_diff(ref_lines, this_test,
                                     fromfile=reference, tofile="current"):
        sys.stdout.write(line.rstrip()+'\n')
    if len(ref_lines) != len(this_test):
        mbuild.msgb("DIFFERENT NUMBER OF LINES", "ref %d test %d" % (len(ref_lines),len(this_test)))
        for ref in ref_lines:
            mbuild.msgb("EXPECTED",'%s' % (ref.strip()))
        return False
    for (ref,test) in zip(ref_lines,this_test):
        if ref.strip() != test.strip():
            if ref.find("XED version") != -1:  # skip the version lines
                continue
            mbuild.msgb("DIFFERENT", "\n\tref  [%s]\n\ttest [%s]" % (ref, test))
            return False
    return True
Exemplo n.º 26
0
def run_tests(env):
    failing_tests = []
    test_dirs = find_tests(env)
    errors = 0
    skipped = 0
    for tdir in test_dirs:
        #if env.on_windows():
        #    time.sleep(1) # try to avoid a bug on windows running commands to quickly
        print('-' * 40)
        mbuild.msgb("TESTING", tdir)

        codes_fn = os.path.join(tdir, "codes")
        codes = open(codes_fn, 'r').readlines()[0].strip().split()

        if all_codes_present(env['codes'], codes):
            okay = one_test(env, tdir)
            if not okay:
                failing_tests.append(tdir)
                errors += 1
        else:
            mbuild.msgb("SKIPPING DUE TO TEST SUBSET RESTRICTION")
            print('-' * 40 + "\n\n\n")
            skipped += 1

    ntests = len(test_dirs)
    tested = ntests - skipped
    mbuild.msgb("TESTS", str(ntests))
    mbuild.msgb("SKIPPED", str(skipped))
    mbuild.msgb("TESTED", str(tested))
    mbuild.msgb("ERRORS", str(errors))
    if tested:
        mbuild.msgb("PASS_PCT",
                    "%2.4f%%" % (100.0 * (tested - errors) / tested))
    else:
        mbuild.msgb("PASS_PCT", '0%')
    failing_tests.sort()
    for t in failing_tests:
        mbuild.msgb("FAIL", t)
    return errors
Exemplo n.º 27
0
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)
Exemplo n.º 28
0
def set_env_gnu(env):
    """Example of setting up the GNU GCC environment for compilation"""
    env['LINK'] = env['CC']

    flags = ''

    #coverage testing  using the local compiler
    #flags += ' -fprofile-arcs -ftest-coverage'
    #env['LIBS'] += ' -lgcov'

    flags += ' -Wall'
    # the windows compiler finds this stuff so flag it on other platforms
    flags += ' -Wunused'

    # 2018-11-28: I am working on hammering out all the issues found by these knobs:
    #flags += ' -Wconversion'
    #flags += ' -Wsign-conversion'

    if env['use_werror']:
        flags += ' -Werror'
    if env['compiler'] != 'icc':
        flags += ' -Wno-long-long'
        flags += ' -Wno-unknown-pragmas'
        flags += ' -fmessage-length=0'
        flags += ' -pipe'

    # -pg is incompatible with -fomit-frame-pointer
    if (re.search(r' -pg', env['CXXFLAGS']) == None
            and re.search(r' -pg', env['CCFLAGS']) == None and
        (env['compiler'] != 'icc' or env['icc_version'] not in ['7', '8'])):
        flags += ' -fomit-frame-pointer'

    if env['compiler'] != 'icc' or (env['compiler'] == 'icc'
                                    and env['icc_version'] != '7'):
        flags += ' -fno-exceptions'

    # 2019-06-05: disabled - no longer needed
    # required for gcc421 xcode to avoidundefined symbols when linking tools.
    #if env.on_mac():
    #    flags += ' -fno-common'

    if env['build_os'] == 'win' or _greater_than_gcc(env, 4, 9, 0):
        flags += ' -Wformat-security'
        flags += ' -Wformat'
    else:
        # gcc3.4.4 on windows has problems with %x for xed_int32_t.
        # gcc4.9.2 works well.
        flags += ' -Wno-format'
        flags += ' -Wno-format-security'

    if env['compiler'] != 'icc':
        # c99 is required for c++ style comments.
        env['CSTD'] = 'c99'
        env['CCFLAGS'] += ' -std=%(CSTD)s '
        if env['pedantic']:
            env['CCFLAGS'] += ' -pedantic '

    if env['shared']:
        if not env.on_windows():
            # -fvisibility=hidden only works on gcc>4. If not gcc,
            # assume it works. Really only a problem for older icc
            # compilers.
            if env['compiler'] == 'gcc':
                vstr = _gcc_version_string(env)
                mbuild.msgb("GCC VERSION", vstr)
            if env['compiler'] != 'gcc' or _greater_than_gcc(env, 4, 0, 0):
                hidden = ' -fvisibility=hidden'
                env['LINKFLAGS'] += hidden
                flags += hidden

    env['CCFLAGS'] += flags
    env['CCFLAGS'] += ' -Wstrict-prototypes'
    env['CCFLAGS'] += ' -Wwrite-strings'
    if env['compiler'] != 'icc':
        env['CCFLAGS'] += ' -Wredundant-decls'

    # Disabled the following. Generates too many silly errors/warnings
    #env['CCFLAGS'] += ' -Wmissing-prototypes'

    env['CXXFLAGS'] += flags
Exemplo n.º 29
0
#  See the License for the specific language governing permissions and
#  limitations under the License.
#
#END_LEGAL

import os, sys

sys.path = ['..'] + sys.path
import mbuild

env = mbuild.env_t()
env.parse_args()

env['jobs'] = 1
work_queue = mbuild.work_queue_t(env['jobs'])
all_cmds = ['python -c "1+1"']
subs = {}
command_list = []
for cmd in all_cmds:
    cmd = cmd % (subs)
    mbuild.msgb('ADDING', cmd)
    c = mbuild.command_t(cmd, output_file_name="foo")
    work_queue.add(c)
    command_list.append(cmd)

phase = "BUILD"
okay = work_queue.build()
if not okay:
    mbuild.die("[%s] failed. dying..." % phase)
mbuild.msgb(phase, "succeeded")
Exemplo n.º 30
0
#  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")