def _link(self, platform): status = 0 cc = platform.flags('CXX') ar = platform.flags('AR') ldflags = platform.flags('LDFLAGS').split() obj_files = [] for (dirpath, dirnames, filenames) in os.walk(self.__obj_path): for filename in filenames: if (filename.startswith(self.name())): obj_files.append(os.path.join(dirpath, filename)) if self.__package_type == CPackage.STATIC_LIB: print(('\t%-15s\t' % (self.name() + ':')) + 'Preparing Static Library') output = os.path.join(self.__lib_path, self.__lib_prefix + self.name() + ".a") if not older(output, obj_files): return call_str = ar + " -r " + output + " " + (' '.join(obj_files)) if amigo_config.VERBOSE: print(call_str) status = call([call_str], env=platform.var_env(), shell=True) elif self.__package_type == CPackage.SHARED_LIB: print(('\t%-15s\t' % (self.name() + ':')) + 'Preparing Shared Library') self.__add_dep_lib(self.name(), self.__lib_path, True) output = os.path.join(self.__lib_path, self.__lib_prefix + self.name() + ".so") if not older(output, obj_files): return call_str = (cc + " -shared -o " + output + " " + (' '.join(obj_files)) + " " + (' '.join(ldflags))) if amigo_config.VERBOSE: print(call_str) status = call([call_str], env=platform.var_env(), shell=True) elif self.__package_type == CPackage.EXECUTABLE: print(('\t%-15s\t' % (self.name() + ':')) + 'Preparing Executable') output = os.path.join(self.__bin_path, self.name()) if not older(output, obj_files): return call_str = (cc + " -o " + output + " " + (' '.join(obj_files)) + " " + (' '.join(ldflags))) if amigo_config.VERBOSE: print(call_str) status = call([call_str], env=platform.var_env(), shell=True) if status != 0: print(('\t%-15s\t' % (self.name() + ':')) + error_str('ERROR') + ': Linking Failed!') sys.exit(1)
def _link(self, platform): status = 0 cc = platform.flags('CXX') ar = platform.flags('AR') ldflags = platform.flags('LDFLAGS').split() obj_files = [] for (dirpath, dirnames, filenames) in os.walk(self.__obj_path): for filename in filenames: if(filename.startswith(self.name())): obj_files.append(os.path.join(dirpath, filename)) if self.__package_type == CPackage.STATIC_LIB: print (('\t%-15s\t' % (self.name() + ':')) + 'Preparing Static Library') output = os.path.join(self.__lib_path, self.__lib_prefix + self.name() + ".a") if not older(output, obj_files): return call_str = ar + " -r " + output + " " + (' '.join(obj_files)) if amigo_config.VERBOSE: print (call_str) status = call([call_str], env=platform.var_env(), shell=True) elif self.__package_type == CPackage.SHARED_LIB: print (('\t%-15s\t' % (self.name() + ':')) + 'Preparing Shared Library') self.__add_dep_lib(self.name(), self.__lib_path, True) output = os.path.join(self.__lib_path, self.__lib_prefix + self.name() + ".so") if not older(output, obj_files): return call_str = (cc + " -shared -o " + output + " " + (' '.join(obj_files)) + " " + (' '.join(ldflags))) if amigo_config.VERBOSE: print (call_str) status = call([call_str], env=platform.var_env(), shell=True) elif self.__package_type == CPackage.EXECUTABLE: print (('\t%-15s\t' % (self.name() + ':')) + 'Preparing Executable') output = os.path.join(self.__bin_path, self.name()) if not older(output, obj_files): return call_str = (cc + " -o " + output + " " + (' '.join(obj_files)) + " " + (' '.join(ldflags))) if amigo_config.VERBOSE: print (call_str) status = call([call_str], env=platform.var_env(), shell=True) if status != 0: print (('\t%-15s\t' % (self.name() + ':')) + error_str('ERROR') + ': Linking Failed!') sys.exit(1)
def __needs_recompile(self): sources_to_recompile = set() for source_file in self._sources: if not (source_file in self.__src_to_header_map and self.__src_to_header_map[source_file]): obj_file = self.__output_name(source_file) obj_path = os.path.join(self.__obj_path, obj_file) if (not os.path.isfile(obj_path) or older(obj_path, [source_file])): sources_to_recompile.add(source_file) for header_file in self._headers: if header_file in self.__header_to_src_map: sources = self.__header_to_src_map[header_file] for source_file in sources: obj_file = self.__output_name(source_file) obj_path = os.path.join(self.__obj_path, obj_file) if (not os.path.isfile(obj_path) or older(obj_path, [header_file, source_file])): sources_to_recompile.add(source_file) return sources_to_recompile
def compile_file(self, file_path, platform, cc, cflags): output_name = self.__output_name(file_path) output = os.path.join(self.__obj_path, output_name) if (file_path not in self.__outdated_sources and not older(output, [file_path])): return if file_path in self.__src_to_header_map: self.__add_include_flags(file_path, cflags) call_str = cc + " -c " + file_path + " " + " -o " + output + " " + (' '.join(cflags)) status = call([call_str], env=platform.var_env(), shell=True) if check_extensions(file_path, ['.cpp', '.cc', '.mm']): print ('\t CXX\t' + file_path) else: print ('\t CC\t' + file_path) if amigo_config.VERBOSE: print (call_str) if status != 0: failed_files.append(file_path)
def compile_file(self, file_path, platform, cc, cflags): output_name = self.__output_name(file_path) output = os.path.join(self.__obj_path, output_name) if (file_path not in self.__outdated_sources and not older(output, [file_path])): return if file_path in self.__src_to_header_map: self.__add_include_flags(file_path, cflags) call_str = cc + " -c " + file_path + " " + " -o " + output + " " + ( ' '.join(cflags)) status = call([call_str], env=platform.var_env(), shell=True) if check_extensions(file_path, ['.cpp', '.cc', '.mm']): print('\t CXX\t' + file_path) else: print('\t CC\t' + file_path) if amigo_config.VERBOSE: print(call_str) if status != 0: failed_files.append(file_path)