def compile_object( src_filename, fn_name = None, src_extension = None, declarations = [], extra_objects = [], extra_compile_flags = [], print_commands = None, compiler = None, compiler_flag_prefix = None): if print_commands is None: print_commands = config.print_commands if src_extension is None: src_extension = get_source_extension() if compiler is None: compiler = get_compiler() object_name = src_filename.replace(src_extension, object_extension) compiler_flags = get_compiler_flags(extra_compile_flags, compiler_flag_prefix) if isinstance(compiler, (list,tuple)): compiler_cmd = list(compiler) else: compiler_cmd = [compiler] compiler_cmd += compiler_flags compiler_cmd += ['-c', src_filename, '-o', object_name] run_cmd(compiler_cmd, label = "Compile source") return CompiledObject(src_filename = src_filename, object_filename = object_name, fn_name = fn_name)
def link_module(compiler, object_name, shared_name, extra_objects = [], extra_link_flags = [], linker_flag_prefix = None): linker_flags = get_linker_flags(extra_link_flags, linker_flag_prefix) if isinstance(compiler, (list,tuple)): linker_cmd = list(compiler) else: linker_cmd = [compiler] linker_cmd += [object_name] linker_cmd += linker_flags linker_cmd += list(extra_objects) linker_cmd += ['-o', shared_name] env = os.environ.copy() if not windows: env["LD_LIBRARY_PATH"] = python_lib_dir run_cmd(linker_cmd, env = env, label = "Linking")
def link_module( compiler, object_name, shared_name, extra_objects = [], extra_link_flags = [], linker_flag_prefix = None): linker_flags = get_linker_flags(extra_link_flags, linker_flag_prefix) if isinstance(compiler, (list,tuple)): linker_cmd = list(compiler) else: linker_cmd = [compiler] linker_cmd += [object_name] linker_cmd += linker_flags linker_cmd += list(extra_objects) linker_cmd += ['-o', shared_name] env = os.environ.copy() if not windows: env["LD_LIBRARY_PATH"] = python_lib_dir run_cmd(linker_cmd, env = env, label = "Linking")