Changeset 7705 for trunk/projects


Ignore:
Timestamp:
04/22/11 10:22:34 (9 years ago)
Author:
hinerm
Message:

Added -extras command to Jar2Lib

Usage: -extras <path to cmake_extras.txt>

The contents of the cmake_extras.txt file will be
appended to the CMakeLists.txt generated by Jar2Lib

File:
1 edited

Legend:

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

    r7668 r7705  
    3737import jace.proxy.AutoProxy; 
    3838 
     39import java.io.BufferedReader; 
     40import java.io.BufferedWriter; 
    3941import java.io.File; 
    4042import java.io.FileFilter; 
    4143import java.io.FileInputStream; 
    4244import java.io.FileOutputStream; 
     45import java.io.FileReader; 
     46import java.io.FileWriter; 
    4347import java.io.IOException; 
    4448import java.io.InputStream; 
     
    4650import java.io.UnsupportedEncodingException; 
    4751import java.net.URLDecoder; 
     52import java.nio.channels.FileChannel; 
    4853import java.util.ArrayList; 
    4954import java.util.Enumeration; 
     
    7782  private String headerPath; 
    7883  private String sourcePath; 
     84  private String extrasPath; 
    7985  private String outputPath; 
    8086 
     
    170176        outputPath = args[++i]; 
    171177      } 
     178      else if (arg.equals("-extras")) { 
     179          if (i == args.length - 1) die("Error: no extras path given."); 
     180          extrasPath = args[++i]; 
     181      } 
    172182      else if (arg.startsWith("-")) die("Unknown flag: " + arg); 
    173183      else libraryJars.add(arg); 
     
    177187        "  library.jar [library2.jar ...]\n" + 
    178188        "  [-conflicts conflicts.txt] [-header header.txt]\n" + 
    179         "  [-output /path/to/output-project]"); 
     189        "  [-extras cmake_extras.txt] [-output /path/to/output-project]"); 
    180190    } 
    181191    if (outputPath == null) outputPath = projectId; 
     
    262272    generator.createCMakeLists(projectId, projectName, 
    263273      sourceFiles, path(outputDir)); 
     274     
     275    if (extrasPath != null) 
     276    {  
     277        String cmakePath = outputPath + "/CMakeLists.txt"; 
     278 
     279        OutputStream fout = new FileOutputStream(new File(cmakePath), true); 
     280        InputStream fin = new FileInputStream(new File(extrasPath)); 
     281 
     282        byte[] buf = new byte[1]; 
     283        int len; 
     284 
     285        while ((len = fin.read(buf)) >= 0) { 
     286                if(len > 0) fout.write(buf, 0, len); 
     287        } 
     288 
     289        fout.flush(); 
     290 
     291        fin.close(); 
     292        fout.close(); 
     293    } 
     294     
    264295  } 
    265296 
Note: See TracChangeset for help on using the changeset viewer.