def get_fingerprint_strategy(cls): return JavaThriftLibraryFingerprintStrategy( ThriftDefaults.global_instance())
def create_strategy(self, option_values): self.context(for_subsystems=[ThriftDefaults], options={ThriftDefaults.options_scope: option_values}) return JavaThriftLibraryFingerprintStrategy( ThriftDefaults.global_instance())
def gen(self, partial_cmd, targets): fp_strategy = JavaThriftLibraryFingerprintStrategy( self._thrift_defaults) with self.invalidated( targets, fingerprint_strategy=fp_strategy, invalidate_dependents=True) as invalidation_check: invalid_targets = [] for vt in invalidation_check.invalid_vts: invalid_targets.extend(vt.targets) import_paths, changed_srcs = calculate_compile_sources( invalid_targets, self.is_scroogetarget) outdir = self._outdir(partial_cmd) if changed_srcs: args = [] for import_path in import_paths: args.extend(['--import-path', import_path]) args.extend(['--language', partial_cmd.language]) for lhs, rhs in partial_cmd.namespace_map: args.extend(['--namespace-map', '%s=%s' % (lhs, rhs)]) if partial_cmd.rpc_style == 'ostrich': args.append('--finagle') args.append('--ostrich') elif partial_cmd.rpc_style == 'finagle': args.append('--finagle') args.extend(['--dest', outdir]) safe_mkdir(outdir) if not self.get_options().strict: args.append('--disable-strict') if self.get_options().verbose: args.append('--verbose') gen_file_map_path = os.path.relpath(self._tempname()) args.extend(['--gen-file-map', gen_file_map_path]) args.extend(changed_srcs) classpath = self.tool_classpath('scrooge-gen') jvm_options = list(self.get_options().jvm_options) jvm_options.append('-Dfile.encoding=UTF-8') returncode = self.runjava(classpath=classpath, main='com.twitter.scrooge.Main', jvm_options=jvm_options, args=args, workunit_name='scrooge-gen') try: if 0 == returncode: gen_files_for_source = self.parse_gen_file_map( gen_file_map_path, outdir) else: gen_files_for_source = None finally: os.remove(gen_file_map_path) if 0 != returncode: raise TaskError( 'Scrooge compiler exited non-zero ({0})'.format( returncode)) self.write_gen_file_map(gen_files_for_source, invalid_targets, outdir) return self.gen_file_map(targets, outdir)