def execute(self, args, cwd): # Initial build if len(args.targets): (result, all_target_outputs) = commandutil.run_build(cwd, args) print all_target_outputs self._launch_http_server(args.http_port, cwd) return 0
def execute(self, args, cwd): # Handle --rebuild if args.rebuild: if not commandutil.clean_output(cwd): return False (result, all_target_outputs) = commandutil.run_build(cwd, args) print 'result %s, %s outputs' % (result, len(all_target_outputs)) #print all_target_outputs return 0 if result else 1
def execute(self, args, cwd): # Build everything first (result, all_target_outputs) = commandutil.run_build(cwd, args) if not result: # Failed - don't copy anything return False # Delete output, if desired if args.clean: try: shutil.rmtree(args.output) except: pass # Ensure output exists if not os.path.isdir(args.output): os.makedirs(args.output) # Sort all outputs by path, as it makes things prettier all_target_outputs = list(all_target_outputs) all_target_outputs.sort() # Copy results print '' print 'Copying results to %s:' % (args.output) for target_output in all_target_outputs: # Get path relative to root # This will contain the build-out/ etc rel_path = os.path.relpath(target_output, cwd) # Strip the build-*/ # TODO(benvanik): a more reliable strip rel_path_parts = rel_path.split(os.sep) if rel_path_parts[0].startswith('build-'): rel_path = os.path.join(*(rel_path_parts[1:])) # Make output path deploy_path = os.path.normpath(os.path.join(args.output, rel_path)) # Ensure directory exists # TODO(benvanik): cache whether we have checked yet to reduce OS cost deploy_dir = os.path.dirname(deploy_path) if not os.path.isdir(deploy_dir): os.makedirs(deploy_dir) # Copy! print '%s -> %s' % (rel_path, deploy_path) shutil.copy(target_output, deploy_path) return 0 if result else 1
def execute(self, args, cwd): # Build everything first (result, all_target_outputs) = commandutil.run_build(cwd, args) if not result: # Failed - don't copy anything return False # Delete output, if desired if args.clean: try: shutil.rmtree(args.output) except: pass # Ensure output exists if not os.path.isdir(args.output): os.makedirs(args.output) # Sort all outputs by path, as it makes things prettier all_target_outputs = list(all_target_outputs) all_target_outputs.sort() # Tracks all exists checks on link parent paths checked_dirs = {} # Copy results print '' print 'Symlinking results to %s:' % (args.output) skipped_links = 0 for target_output in all_target_outputs: # Get path relative to root # This will contain the build-out/ etc rel_path = os.path.relpath(target_output, cwd) # Strip the build-*/ # TODO(benvanik): a more reliable strip rel_path_parts = rel_path.split(os.sep) if rel_path_parts[0].startswith('build-'): rel_path = os.path.join(*(rel_path_parts[1:])) # Make output path deploy_path = os.path.normpath(os.path.join(args.output, rel_path)) # Ensure directory exists # Ensure parent of link path exists deploy_dir = os.path.dirname(deploy_path) if not checked_dirs.get(deploy_dir, False): if not os.path.exists(deploy_dir): os.makedirs(deploy_dir) checked_dirs[deploy_dir] = True # Link! if not os.path.exists(deploy_path): print '%s -> %s' % (rel_path, deploy_path) os.symlink(target_output, deploy_path) else: skipped_links += 1 if skipped_links: print '(%s skipped)' % (skipped_links) return 0 if result else 1
def execute(self, args, cwd): (result, all_target_outputs) = commandutil.run_build(cwd, args) print all_target_outputs return 0 if result else 1