def calculate_sources(cls, targets): sources = set() for target in targets: sources.update( source for source in target.sources_relative_to_buildroot() if GoLocalSource.is_go_source(source)) return sources
def _list_deps(self, gopath, local_address): # TODO(John Sirois): Lift out a local go sources target chroot util - GoWorkspaceTask and # GoTargetGenerator both create these chroot symlink trees now. import_path = GoLocalSource.local_import_path(self._local_source_root, local_address) src_path = os.path.join(gopath, 'src', import_path) safe_mkdir(src_path) package_src_root = os.path.join(get_buildroot(), local_address.spec_path) for source_file in os.listdir(package_src_root): source_path = os.path.join(package_src_root, source_file) if GoLocalSource.is_go_source(source_path): dest_path = os.path.join(src_path, source_file) os.symlink(source_path, dest_path) # TODO(John Sirois): Lift up a small `go list utility` - GoFetch and GoTargetGenerator both use # this go command now as well as a version of the stdlib gathering done above in _go_stdlib. go_cmd = self._go_distribution.create_go_cmd('list', args=['-json', import_path], gopath=gopath) with self._workunit_factory(local_address.reference(), cmd=str(go_cmd), labels=[WorkUnitLabel.TOOL]) as workunit: # TODO(John Sirois): It would be nice to be able to tee the stdout to the workunit to we have # a capture of the json available for inspection in the server console. process = go_cmd.spawn(stdout=subprocess.PIPE, stderr=workunit.output('stderr')) out, _ = process.communicate() returncode = process.returncode workunit.set_outcome(WorkUnit.SUCCESS if returncode == 0 else WorkUnit.FAILURE) if returncode != 0: raise self.GenerationError('Problem listing imports for {}: {} failed with exit code {}' .format(local_address, go_cmd, returncode)) data = json.loads(out) return data.get('Name'), data.get('Imports', []) + data.get('TestImports', [])
def source_iter(): remote_lib_source_dir = self.context.products.get_data( 'go_remote_lib_src')[go_remote_lib] for path in os.listdir(remote_lib_source_dir): remote_src = os.path.join(remote_lib_source_dir, path) if GoLocalSource.is_go_source(remote_src): yield remote_src
def _list_deps(self, gopath, local_address): # TODO(John Sirois): Lift out a local go sources target chroot util - GoWorkspaceTask and # GoTargetGenerator both create these chroot symlink trees now. import_path = GoLocalSource.local_import_path(self._local_source_root, local_address) src_path = os.path.join(gopath, "src", import_path) safe_mkdir(src_path) package_src_root = os.path.join(get_buildroot(), local_address.spec_path) for source_file in os.listdir(package_src_root): source_path = os.path.join(package_src_root, source_file) if GoLocalSource.is_go_source(source_path): dest_path = os.path.join(src_path, source_file) os.symlink(source_path, dest_path) return self._import_oracle.list_imports(import_path, gopath=gopath)
def _list_deps(self, gopath, local_address): # TODO(John Sirois): Lift out a local go sources target chroot util - GoWorkspaceTask and # GoTargetGenerator both create these chroot symlink trees now. import_path = GoLocalSource.local_import_path(self._local_source_root, local_address) src_path = os.path.join(gopath, 'src', import_path) safe_mkdir(src_path) package_src_root = os.path.join(get_buildroot(), local_address.spec_path) for source_file in os.listdir(package_src_root): source_path = os.path.join(package_src_root, source_file) if GoLocalSource.is_go_source(source_path): dest_path = os.path.join(src_path, source_file) os.symlink(source_path, dest_path) return self._import_oracle.list_imports(import_path, gopath=gopath)
def _list_deps(self, gopath, local_address): # TODO(John Sirois): Lift out a local go sources target chroot util - GoWorkspaceTask and # GoTargetGenerator both create these chroot symlink trees now. import_path = GoLocalSource.local_import_path(self._local_source_root, local_address) src_path = os.path.join(gopath, 'src', import_path) safe_mkdir(src_path) package_src_root = os.path.join(get_buildroot(), local_address.spec_path) for source_file in os.listdir(package_src_root): source_path = os.path.join(package_src_root, source_file) if GoLocalSource.is_go_source(source_path): dest_path = os.path.join(src_path, source_file) os.symlink(source_path, dest_path) # TODO(John Sirois): Lift up a small `go list utility` - GoFetch and GoTargetGenerator both use # this go command now as well as a version of the stdlib gathering done above in _go_stdlib. go_cmd = self._go_distribution.create_go_cmd( 'list', args=['-json', import_path], gopath=gopath) with self._workunit_factory(local_address.reference(), cmd=str(go_cmd), labels=[WorkUnitLabel.TOOL]) as workunit: # TODO(John Sirois): It would be nice to be able to tee the stdout to the workunit to we have # a capture of the json available for inspection in the server console. process = go_cmd.spawn(stdout=subprocess.PIPE, stderr=workunit.output('stderr')) out, _ = process.communicate() returncode = process.returncode workunit.set_outcome(WorkUnit.SUCCESS if returncode == 0 else WorkUnit.FAILURE) if returncode != 0: raise self.GenerationError( 'Problem listing imports for {}: {} failed with exit code {}' .format(local_address, go_cmd, returncode)) data = json.loads(out) return data.get('Name'), data.get('Imports', []) + data.get( 'TestImports', [])
def source_iter(): remote_lib_source_dir = self.context.products.get_data('go_remote_lib_src')[go_remote_lib] for path in os.listdir(remote_lib_source_dir): remote_src = os.path.join(remote_lib_source_dir, path) if GoLocalSource.is_go_source(remote_src): yield remote_src
def calculate_sources(cls, targets): sources = set() for target in targets: sources.update(source for source in target.sources_relative_to_buildroot() if GoLocalSource.is_go_source(source)) return sources