Ejemplo n.º 1
0
def check_deps(info):
    for dep_name in info.dependency_map().iterkeys():
        if dep_name != info.name:
            dep_info = packageinfo.get(dep_name)
            if not path.exists(dep_info.stamp_file):
                log(info, "error: dependency '%s' is not built" % dep_name)
                return False
    return True
Ejemplo n.º 2
0
def _build_configure_env(user_libs, user_cflags):
    paths = []
    libs = []
    cflags = []
    pkg_config_paths = []

    for dep_name in _info.dependency_map().iterkeys():
        if dep_name == _info.name:
            continue
        p = packageinfo.get(dep_name).install_dir
        bin_dir = path.join(p, 'bin')
        lib_dir = path.join(p, 'lib')
        include_dir = path.join(p, 'include')
        pkg_config_dir = path.join(p, 'lib', 'pkgconfig')

        if path.exists(bin_dir):
            paths.append(bin_dir)
        if path.exists(lib_dir):
            libs.append('-L' + cmdutil.to_unix_path(lib_dir))
        if path.exists(include_dir):
            cflags.append('-I' + cmdutil.to_unix_path(include_dir))
        if path.exists(pkg_config_dir):
            pkg_config_paths.append(cmdutil.to_unix_path(pkg_config_dir))

    env_libs = config.get_list('libs') + config.get_list(_info.name + '-libs')
    env_cflags = config.get_list('cflags') + config.get_list(_info.name + '-cflags')

    result_path = os.pathsep.join(paths)
    result_libs = ' '.join(libs + user_libs + env_libs)
    result_cflags = ' '.join(cflags + user_cflags + env_cflags)
    result_pkg_config_path = ':'.join(pkg_config_paths)

    result = {
        'PATH'            : result_path,
        'LIBS'            : result_libs,
        'CFLAGS'          : result_cflags,
        'CXXFLAGS'        : result_cflags,
        'PKG_CONFIG_PATH' : result_pkg_config_path,
    }

    if toolchain.crossbuild:
        pkg_config_libdir = path.join(toolchain.sysroot, 'lib', 'pkgconfig')
        result.update({
            'AR'      : toolchain.tool_name('ar'),
            'AS'      : toolchain.tool_name('as'),
            'CC'      : toolchain.tool_name('gcc'),
            'CXX'     : toolchain.tool_name('g++'),
            'LD'      : toolchain.tool_name('ld'),
            'NM'      : toolchain.tool_name('nm'),
            'DLLTOOL' : toolchain.tool_name('dlltool'),
            'OBJDUMP' : toolchain.tool_name('objdump'),
            'RANLIB'  : toolchain.tool_name('ranlib'),
            'STRIP'   : toolchain.tool_name('strip'),
            'WINRC'   : toolchain.tool_name('windres'),
            'PKG_CONFIG_LIBDIR' : cmdutil.to_unix_path(pkg_config_libdir)
        })

    return result
Ejemplo n.º 3
0
def run(action, targets):
    action_func = get_action_func(action)

    if inspect.getargspec(action_func).args:
        if not targets:
            raise ValueError('No target specified')
        for t in targets:
            action_func(packageinfo.get(t))
    else:
        action_func()
Ejemplo n.º 4
0
def check_stamp(info):
    if not path.exists(info.stamp_file):
        return False
    max_mtime = 0
    dep_stamps = [info.package_file, info.build_file]
    for dep_name in info.dependency_map().iterkeys():
        if dep_name != info.name:
            dep_stamps.append(packageinfo.get(dep_name).stamp_file)
    for dep_stamp in dep_stamps:
        if path.exists(dep_stamp):
            max_mtime = max(max_mtime, path.getmtime(dep_stamp))
        else:
            return False
    return path.getmtime(info.stamp_file) >= max_mtime
Ejemplo n.º 5
0
def do_generate_makefile():
    dependency_map = {}
    for name in packageinfo.get_packages():
        info = packageinfo.get(name)
        if info.enabled:
            dependency_map.update(info.dependency_map())
    names = sorted(dependency_map.iterkeys())
    build_targets = add_prefix('build-', names)
    clean_targets = add_prefix('clean-', names)

    target_file = path.join(packageinfo.get_work_dir(), 'Makefile')
    with open(target_file, 'w') as f:
        f.write('export BUILDTOOL_PROFILE  := %s\n' % _config_profile)
        f.write('export BUILDTOOL_BASE_DIR := %s\n\n' % _base_dir)

        f.write('buildtool := %s %s\n\n' % (sys.executable, path.abspath(__file__)))

        f.write('build := $(buildtool) build\n')
        f.write('clean := $(buildtool) clean\n\n')

        f.write('_default:\n')
        f.write('\t@echo No defaults. Please, specify target to build.\n\n')

        f.write('refresh:\n')
        f.write('\t@$(buildtool) generate-makefile\n\n')

        f.write('clean: %s\n\n' % wrap_for_make(clean_targets))

        for name, target in zip(names, build_targets):
            deps = add_prefix('build-', dependency_map[name])
            f.write('%s: %s\n' % (target, wrap_for_make(deps)))
            f.write('\t@$(build) %s\n\n' % name)

        for name, target in zip(names, clean_targets):
            f.write('%s:\n' % target)
            f.write('\t@$(clean) %s\n\n' % name)

        f.write('.PHONY: _default refresh clean\n')
        f.write('.PHONY: %s\n' % wrap_for_make(build_targets))
        f.write('.PHONY: %s\n' % wrap_for_make(clean_targets))