Пример #1
0
def build_version_file(env):
    if not env.subst('$EMSCRIPTEN_VERSION_FILE'):
        raise AssertionError('Must set EMSCRIPTEN_VERSION_FILE in environment')
    if not env.subst('$EMSCRIPTEN_TEMP_DIR'):
        raise AssertionError('Must set EMSCRIPTEN_TEMP_DIR in environment')

    EMSCRIPTEN_DEPENDENCIES = [
        env.Glob('${EMSCRIPTEN_HOME}/src/*.js'),
        env.Glob('${EMSCRIPTEN_HOME}/src/embind/*.js'),
        env.Glob('${EMSCRIPTEN_HOME}/tools/*.py'),
        '${EMSCRIPTEN_HOME}/emscripten.py',
    ]
    if env.subst('$EMSCRIPTEN_SHELL'):
        EMSCRIPTEN_DEPENDENCIES.append('$EMSCRIPTEN_SHELL')

    def touch_file(target, source, env):
        m = hashlib.md5()
        for s in source:
            m.update(file(s.abspath, 'rb').read())
        for t in target:
            file(t.abspath, 'wb').write(m.hexdigest())

    [emscripten_version_file] = env.Command('$EMSCRIPTEN_VERSION_FILE',
                                            EMSCRIPTEN_DEPENDENCIES,
                                            touch_file)

    env.AddPostAction(emscripten_version_file,
                      Delete(env.Dir('$EMSCRIPTEN_TEMP_DIR').abspath))

    return emscripten_version_file
Пример #2
0
def _ExecuteNamecheck(env, files, plugin, conf, includes):
    reg = '(/%s/).*(\[namecheck\])' % env['PROJECT_NAME']
    for x in files.split(SPACE):
        if x.endswith('cpp') or x.endswith('cc'):
            cmd = 'g++'
        elif x.endswith('c'):
            cmd = 'gcc'
        env.Cprint('\nAnalyzing %s...\n' % os.path.basename(x), 'yellow')
        cmd += ' %s %s -c %s %s' % (plugin, conf, x, includes)
        if env.GetOption('verbose'):
            env.Cprint('>>>%s' % cmd, 'end')
        pipe = subprocess.Popen(cmd, stderr=subprocess.PIPE, shell=True)
        for line in pipe.stderr:
            # Check if the project name is into the path of the warning.
            is_there = re.search(reg, line)
            if is_there:
                env.Cprint('%s' % line.strip(), 'end')
        pipe.wait()
        if x.endswith('cpp'):
            try:
                Delete(x.replace('cpp', 'o'))
            except:
                pass
        elif x.endswith('.cc'):
            try:
                os.remove(x.replace('cc', 'o'))
            except:
                pass
        elif x.endswith('.c'):
            try:
                os.remove(x.replace('c', 'o'))
            except:
                pass
Пример #3
0
def virtual_target_command(env, marker, condition, source, action):
    if not isinstance(marker, File):
        raise UserError("`marker` must be a File")

    if not condition(env) and os.path.exists(marker.abspath):
        # Condition has changed in our back, force rebuild
        env.Execute(Delete(marker))

    return env.Command(
        marker,
        source,
        [
            *(action if is_List(action) else [action]),
            Action(
                lambda target, source, env: install_marker(target[0]),
                "Write $TARGET to mark task complete",
            ),
        ],
    )
Пример #4
0
    target_base = os.path.splitext(str(target[0]))[0]
    target += [target_base + '.h', target_base + '.db_']
    return target, source

_gattdbgenBuilder = SCons.Builder.Builder(
        action=['$cprecom',
                '$gattdbgen ${TARGET.base}.db_'],
        suffix='.c',
        src_suffix='.db',
        emitter=_DbEmitter,
        source_scanner=SCons.Scanner.C.CScanner())

_gattdbigenBuilder = SCons.Builder.Builder(
        action=['$cprecom',
                '$gattdbgen -i ${TARGET.base}.db_',
                Delete('${TARGET.base}.db_')],
        suffix='.h',
        src_suffix='.dbi',
        source_scanner=SCons.Scanner.C.CScanner())

def generate(env):
    """Add Builders and construction variables to the Environment.
    """
    kas.generate(env)

    # Set up standard folder locations
    env.SetDefault(SDK_TOOLS = env['TOOLS_ROOT'] + '/tools')

    env['gattdbgen'] = _detect(env)
    # we use KAS as the kalcc pre-processor mangles 128-bit uuids
    env['cpre'] = '$KAS --preprocess-only'