Ignore:
Timestamp:
05/19/11 12:02:07 (9 years ago)
Author:
hinerm
Message:

Added support for custom core class lists in Jar2Lib

Jar2Lib can now accept a
-core [core.txt]
argument, where core.txt is a file containing one
Java class per line, in a java.lang.class standard format.
Each line is converted to a:
#include jace/proxy/java/lang/class
statement in a new java.h file. The vm template for includes
was modified such that each proxy now includes java.h (in the same
fashion as jace.h is included).

This allows users to specify core Java classes they would like
to ensure are proxied, as Jace is capable of pruning methods if
the required core classes aren't proxied by default.

Location:
trunk/projects/jar2lib/src/main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/projects/jar2lib/src/main/java/loci/jar2lib/Jar2Lib.java

    r7705 r7707  
    8383  private String sourcePath; 
    8484  private String extrasPath; 
     85  private String corePath; 
    8586  private String outputPath; 
    8687 
     
    147148  public void setOutputPath(String outputPath) { 
    148149    this.outputPath = outputPath; 
     150  } 
     151  public String getExtrasPath() { 
     152            return extrasPath; 
     153  } 
     154  public void setExtrasPath(String extrasPath) { 
     155        this.extrasPath = extrasPath; 
     156  } 
     157  public String getCorePath() { 
     158        return corePath; 
     159  } 
     160  public void setCorePath(String corePath) { 
     161        this.corePath = corePath; 
    149162  } 
    150163 
     
    180193          extrasPath = args[++i]; 
    181194      } 
     195      else if (arg.equals("-core")) { 
     196          if (i == args.length - 1) die("Error: no core classes path given."); 
     197          corePath = args[++i]; 
     198      } 
    182199      else if (arg.startsWith("-")) die("Unknown flag: " + arg); 
    183200      else libraryJars.add(arg); 
     
    187204        "  library.jar [library2.jar ...]\n" + 
    188205        "  [-conflicts conflicts.txt] [-header header.txt]\n" + 
    189         "  [-extras cmake_extras.txt] [-output /path/to/output-project]"); 
     206        "  [-extras cmake_extras.txt] [-output /path/to/output-project]\n +" + 
     207        "  [-core java_core_classes.txt"); 
    190208    } 
    191209    if (outputPath == null) outputPath = projectId; 
     
    250268    outputSourceDir = new File(outputDir, "source"); 
    251269    if (!outputSourceDir.exists()) outputSourceDir.mkdirs(); 
    252  
     270     
    253271    proxiesDir = new File(outputPath, "proxies"); 
    254272    proxiesIncludeDir = new File(proxiesDir, "include"); 
     
    256274    proxiesSourceDir = new File(proxiesDir, "source"); 
    257275    if (!proxiesSourceDir.exists()) proxiesSourceDir.mkdirs(); 
     276     
     277    // create java.h 
     278    try { 
     279        BufferedWriter fout = new BufferedWriter(new FileWriter(outputIncludeDir + File.separator + "java.h")); 
     280        fout.write("//\n// java.h\n//\n\n"); 
     281        fout.write("// additional core java files to include\n\n"); 
     282        if(corePath != null) 
     283        { 
     284                BufferedReader fin = new BufferedReader(new FileReader(new File(corePath))); 
     285                while(fin.ready()) 
     286                { 
     287                        fout.write("#include \"jace/proxy/" + fin.readLine().replace('.', '/') + ".h\"\n"); 
     288                } 
     289                fin.close(); 
     290        } 
     291        fout.flush(); 
     292        fout.close(); 
     293    } 
     294    catch (IOException e) 
     295    { 
     296        System.out.println("Error creating java.h"); 
     297    } 
    258298  } 
    259299 
     
    383423    if (path == null) return new File[0]; // no sources 
    384424    final File sourceDir = new File(path); 
     425     
    385426    if (!sourceDir.exists()) return new File[0]; // no sources 
    386427    return sourceDir.listFiles(new FileFilter() { 
  • trunk/projects/jar2lib/src/main/resources/jace-header.vm

    r7626 r7707  
    1515 
    1616\#include "jace.h" 
     17\#include "java.h" 
    1718 
    1819#set ($last = "") 
Note: See TracChangeset for help on using the changeset viewer.