def _setup_compiler(ctx, cc_type): old_env = ctx.env ctx.env = Environment() cc_env = None sys.path.insert(0, os.path.dirname(yaku.tools.__file__)) try: try: mod = __import__(cc_type) mod.setup(ctx) except ImportError: raise RuntimeError("No tool %s is available (import failed)" \ % cc_type) # XXX: this is ugly - find a way to have tool-specific env... cc_env = ctx.env finally: sys.path.pop(0) ctx.env = old_env copied_values = [ "CC", "CPPPATH_FMT", "LIBDIR_FMT", "LIB_FMT", "CC_OBJECT_FMT", "CC_TGT_F", "CC_SRC_F", "LINK_TGT_F", "LINK_SRC_F", "SHLINK" ] for k in copied_values: ctx.env["PYEXT_%s" % k] = cc_env[k] ctx.env.prextend("PYEXT_CPPPATH", cc_env["CPPPATH"]) ctx.env.prextend("PYEXT_LIBDIR", cc_env["LIBDIR"])
def __init__(self, name, bld, sources, target): self.bld = bld self.name = name self.sources = sources self.target = target self.env = Environment()
def setup_pyext_env(ctx, cc_type="default", use_distutils=True): pyenv = Environment() if use_distutils: if cc_type == "default": dist_env = get_configuration() else: dist_env = get_configuration(cc_type) print(dist_env) for name, value in list(dist_env.items()): pyenv["PYEXT_%s" % name] = value pyenv["PYEXT_CFLAGS"].extend(dist_env.get("SHARED", [])) pyenv["PYEXT_FMT"] = "%%s%s" % dist_env["SO"] pyenv["PYEXT_SHLINKFLAGS"] = dist_env["LDFLAGS"] else: old_env = ctx.env ctx.env = Environment() cc_env = None sys.path.insert(0, os.path.dirname(yaku.tools.__file__)) try: try: mod = __import__(cc_type) mod.setup(ctx) except ImportError: raise RuntimeError("No tool %s is available (import failed)" \ % cc_type) cc_env = ctx.env finally: sys.path.pop(0) ctx.env = old_env pyenv["PYEXT_CC"] = cc_env["CC"] pyenv["PYEXT_CFLAGS"] = cc_env["CFLAGS"] pyenv["PYEXT_LIBDIR"] = cc_env["LIBDIR"] pyenv["PYEXT_LIBS"] = cc_env["LIBS"] pyenv["PYEXT_FMT"] = "%s.so" pyenv["PYEXT_SHLINK"] = cc_env["MODLINK"] pyenv["PYEXT_SHLINKFLAGS"] = cc_env["MODLINKFLAGS"] pyenv["PYEXT_CPPPATH"] = cc_env["CPPPATH"] pyenv.append("PYEXT_CPPPATH", distutils.sysconfig.get_python_inc(), create=True) if sys.platform == "win32": pyenv.append("PYEXT_LIBDIR", os.path.join(sys.exec_prefix, "libs")) return pyenv
def load(self, src_path=None, build_path="build"): if src_path is None: src_path = os.getcwd() src_path = os.path.abspath(src_path) build_path = os.path.abspath(os.path.join(os.getcwd(), build_path)) if not os.path.exists(build_path): raise IOError("%s not found (did you use different build_path for configure and build contexts ?)" \ % build_path) srcnode, bldnode = create_top_nodes(src_path, build_path) self.src_root = srcnode self.bld_root = bldnode self.path = srcnode self.env = Environment() default_env = bldnode.find_node(DEFAULT_ENV) if default_env: self.env.load(default_env.abspath()) if not os.path.abspath(self.env["BLDDIR"]) == bldnode.abspath(): raise ValueError("Gne ?") build_config = bldnode.find_node(BUILD_CONFIG) if build_config is None: raise IOError("Did not find %r in %r" % (BUILD_CONFIG, bldnode.abspath())) else: f = open(build_config.abspath()) try: load_tools(self, f) finally: f.close() build_cache = bldnode.find_node(BUILD_CACHE) if build_cache is not None: fid = open(build_cache.abspath(), "rb") try: self.cache = load(fid) finally: fid.close() else: self.cache = {} hook_dump = bldnode.find_node(HOOK_DUMP) fid = open(hook_dump.abspath(), "rb") try: data = load(fid) yaku.task_manager.RULES_REGISTRY = data["extensions"] yaku.task_manager.FILES_REGISTRY = _hook_path_to_hook_id( srcnode, data["files"]) finally: fid.close()
def __init__(self): self.env = Environment() self.tools = [] self._tool_modules = {} self.builders = {} self.cache = {} self.conf_results = [] self._configured = {} self._stdout_cache = {} self._cmd_cache = {} self.src_root = None self.bld_root = None self.path = None
def _setup_cxxcompiler(ctx, cxx_type): old_env = ctx.env ctx.env = Environment() sys.path.insert(0, os.path.dirname(yaku.tools.__file__)) try: mod = __import__(cxx_type) mod.setup(ctx) cxx_env = ctx.env finally: sys.path.pop(0) ctx.env = old_env for k in ["CXX", "CXXFLAGS", "CXX_TGT_F", "CXX_SRC_F", "CXXSHLINK"]: ctx.env["PYEXT_%s" % k] = cxx_env[k]
def get_cfg(src_path=None, build_path="build"): ctx = ConfigureContext() config_cache = os.path.join(build_path, CONFIG_CACHE) if os.path.exists(config_cache): fid = open(config_cache, "rb") try: ctx.cache = load(fid) ctx._stdout_cache = load(fid) ctx._cmd_cache = load(fid) finally: fid.close() # XXX: how to reload existing environment ? env = Environment() if not "BLDDIR" in env: env["BLDDIR"] = build_path # FIXME: nothing to do here env["VERBOSE"] = False if "-v" in sys.argv: env["VERBOSE"] = True # Keep this as is - we do want a dictionary for 'serialization', and python # 3 os.environ is an object instead of a dict env["ENV"] = dict([(k, v) for k, v in list(os.environ.items())]) if src_path is None: src_path = os.getcwd() srcnode, bldnode = create_top_nodes(os.path.abspath(src_path), os.path.abspath(env["BLDDIR"])) ctx.src_root = srcnode ctx.bld_root = bldnode # src_root and bld_root never change, but path may. All source nodes are # created relatively to path (kinda 'virtual' cwd) ctx.path = srcnode ctx.env = env ctx.log = myopen(os.path.join(env["BLDDIR"], "config.log"), "w") return ctx
def __init__(self): self.env = Environment() self.tools = [] self.cache = {} self.builders = {} self.tasks = []