3

from command-line i can get a alias list of the function renaming from compiler.jar

Help says:

java -jar compiler.jar --help
[...]
--create_name_map_files                : If true, variable renaming and
                                         property renaming map files will be
                                         produced as {binary name}_vars_map.out
                                         and {binary name}_props_map.out. Note
                                         that this flag cannot be used in
                                         conjunction with either variableMapOut
                                         putFile or property_map_output_file
--create_source_map VAL                : If specified, a source map file
                                         mapping the generated source files
                                         back to the original source file will
                                         be output to the specified path. The
                                         %outname% placeholder will expand to
                                         the name of the output file that the
                                         source map corresponds to.
[...]

so, how can i get "create_name_map_files" from inline java? i took a look into the AbstractCommandLineRunner.java but all classes/methods which relate to this command line option are private and not reachable from my code..

My Code:

CompilerOptions opt = new CompilerOptions();

// decide mode
compilationLevel.ADVANCED_OPTIMIZATIONS.setOptionsForCompilationLevel(opt);
opt.prettyPrint = false;

Compiler.setLoggingLevel(Level.OFF);

Compiler compressor = new Compiler();
compressor.disableThreads();

List<SourceFile> inputs = ...;
List<SourceFile> externs = ...;

compressor.compile(externs, inputs, opt); 
Alex Tape
  • 2,291
  • 4
  • 26
  • 36

3 Answers3

1

you can just use the option : variable_map_output_file filename , similarly for props.

Note that: The flags variable_map_output_file and create_name_map_files cannot both be used simultaniously.

sbr
  • 4,735
  • 5
  • 43
  • 49
0

From CommandLineRunner.java, I would say

opt.setCreateNameMapFiles(true)
rds
  • 26,253
  • 19
  • 107
  • 134
0

The "compile" function returns a Result object that contains the variable (variableMap) and property (propertyMap) renaming maps. These properties contain VariableMap objects that can be serialized:

Result result = compiler.compiler(...);
result.variableMap.save(varmapPath);
result.propertyMap.save(propmapPath);
John
  • 5,443
  • 15
  • 21