async def build(self, mc, _, f_in): pymake.makedirs(os.path.dirname(self.req.fn)) args = ['-g','-pg','-std=c++11'] + self.p.args.args print(crayons.red("Build executable " + self.library_project.name, bold = True)) print(" args: {}".format(" ".join(args))) args_link = self.get_args_link() args_library_dir = ['-L' + d.build_dir for d in self.library_project.deps] cmd = ['g++'] + args + ['-o', self.req.fn] cmd += list(self.library_project.files_object()) + args_library_dir cmd += args_link + args_link + self.p.args.args #print(" ".join(cmd)) r = subprocess.call(cmd) print('ret:', r) if r != 0: print(crayons.red(" ".join(cmd))) raise Exception(crayons.red(" ".join(cmd), bold = True)) return r
async def build(self, mc, _, f_in): #libhello.so: hello.cpp hello.h #g++ hello.cpp -shared -o libhello.so -fPIC -std=c++0x ${inc_paths} ${libs} f_out = self.req.fn pymake.makedirs(os.path.dirname(f_out)) #inc_paths = -I/usr/include/python3.5 libs = ['-lboost_python-py36', '-lpython3.6m'] #libs = ['-lboost_python-py27','-lpython2.7'] args_library_dir = ['-L' + d.build_dir for d in self.p.deps] args_link = self.get_args_link() # whole archive args_link_whole = ["-Wl,-whole-archive" ] + args_link + libs + ["-Wl,-no-whole-archive"] objs = list(self.p.files_object()) cmd = ['g++'] + objs + ['-shared', '-o', f_out, '-fPIC', '-std=c++0x'] cmd += args_library_dir + args_link_whole + libs + libs logger.info(" ".join(cmd)) return subprocess.call(cmd)
async def build(self, mc, _, f_in): print('build CStaticLibrary', self.library_project.name) pymake.makedirs(os.path.dirname(self.req.fn)) cmd = ['ar', 'rcs', self.req.fn] + list(self.library_project.files_object()) #print(" ".join(cmd)) return subprocess.call(cmd)
def write_binary(self, b): # it appears that this functionality is actually not useful as currently # implemented. revisit later #if check_existing_binary_data(filename, b): if True: pymake.makedirs(os.path.dirname(self.req.fn)) with open(self.req.fn, 'wb') as f: f.write(b) else: logging.info('binary data unchanged. do not write.')
async def build(self, makecall, _, f_in): for f in f_in: logger.info(crayons.yellow(f' {f!r}')) pymake.makedirs(os.path.dirname(self.f_out)) assert f_in[0].fn[-3:] == ".py" av = [f_in[0].fn, self.f_out] + [a for a in f_in[1:]] s = f_in[0].fn[:-3].replace('/', '.') m = __import__(s, fromlist=['main']) c = await m.main(makecall, av)
async def new_class(args): f = args.file d = os.path.dirname(f) pymake.makedirs(d) src = os.path.join(pbs.BASE_DIR, "templates2", "CHeader.hpp_in") dst = f if os.path.exists(dst): print('file exists') return shutil.copyfile(src, dst)
async def build(self, mc, _, f_in): print( crayons.yellow('CSourceFileDeps {}'.format(self.file_deps), bold=True)) include_args = ['-I' + d for d in self.library_project.include_dirs()] args = ['-std=c++11'] cmd = ['g++'] + args + [ '-MM', '-MF', self.file_deps, self.file_source ] + include_args pymake.makedirs(os.path.dirname(self.file_deps)) ret = subprocess.call(cmd) #print(' '.join(cmd)) #self.read_file() return ret
async def build(self, makecall, _, f_in): pymake.makedirs(os.path.dirname(self.f_out)) if not f_in: raise Exception(f'{self.__class__} f_in is empty') if f_in[0].fn[-3:] == ".py": cmd = [sys.executable, f_in[0].fn, self.f_out ] + [a.fn for a in f_in[1:]] else: prog = f_in[0].fn out = os.path.abspath(self.f_out) cmd = [prog, out] + [os.path.abspath(a.fn) for a in f_in[1:]] logging.info( crayons.yellow("cmd = {}".format(' '.join(cmd)), 'yellow', bold=True)) subprocess.run(cmd, check=True)
async def build(self, mc, _, f_in): pymake.makedirs(os.path.dirname(self.req.fn)) include_args = ['-I' + d for d in self.library_project.include_dirs()] define_args = ['-D' + d for d in self.library_project.defines()] args = ['-g', '-pg', '-c', '-std=c++11'] + list( a for a in self.library_project.get_c_source_args() if a is not None) cmd = ['g++'] + args + [self.file_source, '-o', self.file_object ] + include_args + define_args print( crayons.yellow("CSourceFile {}".format(self.file_object), bold=True)) print(crayons.yellow(" args: {}".format(" ".join(args)), bold=True)) #print(" ".join(cmd)) ret = subprocess.call(cmd) if ret != 0: print('ret:', ret) print('include args:') for s in include_args: print(s) print('files header processed') for f in self.library_project.files_header_processed(): print(f) raise pbs.exception.CompileError(" ".join(cmd)) return ret
def write_object(self, file_out, o): pymake.makedirs(os.path.dirname(file_out)) with open(file_out, 'wb') as f: pickle.dump(o, f)
def write_binary(self, b): pymake.makedirs(os.path.dirname(self.fn)) with open(self.fn, 'wb') as f: f.write(b)
def write_object(self, o): pymake.makedirs(os.path.dirname(self.fn)) with open(self.fn, 'wb') as f: pickle.dump(o, f)
def write_json(self, d): pymake.makedirs(os.path.dirname(self.fn)) with open(self.fn, 'w') as f: f.write(json.dumps(d, indent=8, sort_keys=True))
async def build(self, mc, f_out, f_in): #print("HeaderProcessedFile", self.f_out, self.file_in) #ith open(self.file_in, 'r') as f: # temp = jinja2.Template(f.read()) env = jinja2.environment.Environment() template_dirs = [os.path.join(BASE_DIR,'templates'), self.library_project.config_dir, '/', '.'] #print('template_dirs',template_dirs) env.loader = jinja2.FileSystemLoader(template_dirs) temp = env.get_template(self.file_in) # making special macros r = os.path.relpath(self.file_in, self.library_project.include_dir) c = self.get_context() # ns and class names h,filename = os.path.split(r) lst = filename_to_list(r) ns_name = "::".join(lst) filename2,_ = os.path.splitext(filename) class_name,_ = os.path.splitext(filename2) full_name = ns_name + "::" + class_name typedef_verb = "typedef gal::verb::Verbosity<{}> VERB;".format(full_name) c['type_this'] = full_name c['typedef_verb'] = typedef_verb c['setup_verb'] = "\n".join([ typedef_verb, "using VERB::init_verb;", "using VERB::printv;"]) # render and write preamble = "/*\n * DO NOT EDIT THIS FILE\n *\n * {}\n */\n".format(self.file_in) out = preamble + "\n" + temp.render(c) try: os.chmod(self.req.fn, stat.S_IRUSR | stat.S_IWUSR ) except Exception as e: print("error in chmod", e) pymake.makedirs(os.path.dirname(self.req.fn)) try: with open(self.req.fn, 'w') as f: f.write(out) except Exception as e: print("error in write", e) raise try: os.chmod(self.req.fn, stat.S_IRUSR) except Exception as e: print("error in chmod", e) raise st = os.stat(self.req.fn)