def _setup_compile(self, sources, macros, include_dirs, extra, depends): """Process arguments and decide which source files to compile.""" if macros is None: macros = self.macros elif typecheck.is_list(macros): macros = macros + (self.macros or []) else: raise TypeError("'macros' (if supplied) must be a list of tuples") if include_dirs is None: include_dirs = self._include_dirs elif typecheck.is_sequence(include_dirs): include_dirs = list(include_dirs) + (self._include_dirs or []) else: raise TypeError("'include_dirs' (if supplied) must be a list of strings") if extra is None: extra = [] # List of expected output files objects = self.get_object_filenames(sources) assert len(objects) == len(sources) pp_options = self._gen_preprocess_options(macros, include_dirs) build = {} for i in range(len(sources)): src = sources[i] obj = objects[i] ext = path_utils.splitext(src)[1] path_utils.mkpath(path_utils.dirname(obj), 0777) build[obj] = (src, ext) return macros, objects, extra, pp_options, build
def _link(self, objects, output_dir=None, libraries=None, library_dirs=None, debug=False, extra_preargs=None, extra_postargs=None, target_lang=None): """Linking.""" objects, output_dir, libraries, library_dirs = \ self._setup_link(objects, output_dir, libraries, library_dirs) lib_options = self._gen_lib_options(library_dirs, libraries) # Finalize linker options ld_options = self._gen_ld_options(debug, extra_preargs) if extra_postargs: ld_options.extend(extra_postargs) ld_options += (objects + lib_options + ['-o', self.get_output_filename()]) path_utils.mkpath(path_utils.dirname(self.get_output_filename())) try: linker = self.get_executable() # skip over environment variable settings if /usr/bin/env is used to set # up the linker's environment. This is needed on OSX. Note: this # assumes that the normal and C++ compiler have the same environment # settings. i = 0 if path_utils.basename(linker[0]) == "env": i = 1 while "=" in linker[i]: i = i + 1 # TODO: resolve this #linker[i] = self.get_executable('compiler_cxx')[i] spawn.spawn([linker] + ld_options, debug=self.get_verbosity_level(), dry_run=self.is_dry_run_mode_enabled()) except Exception, e: raise Exception, e
def init_home_dir(cls, home_dir): """Initializes passed home directory if such wasn't already initialized. :returns: Path to home directory. """ if not path_utils.exists(home_dir): raise IOError("'%s' doesn't exist" % home_dir) settings_dir = path_utils.join(home_dir, SETTINGS_DIR) path_utils.mkpath(settings_dir) return home_dir
def set_build_dir(self, path, make=False): """Sets path to the build directory. The build directory will be used to store temporary/autogenerated and compiled build-files. :param path: Build-directory name. :param make: Whether or not the path needs to be created. """ if not path_utils.exists(path): if not make: raise IOError("`%s' doesn't exist" % path) path_utils.mkpath(path) self._build_dir = path