This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RFC: add override path to gcj-dbtool


Hi,
I am writing a maven plugin which does among other things, native compilation
(BC ABI) with gcj and got into trouble when creating the classmap file for the
just compiled .so.

gcj-dbtool inserts the absolute location of the .so into the classmap which is
bad for me, because after installation the .so will lie at a completely
different location (/usr/share/java instead of /home/foo/baz/devel/..../).

Looking at the tool's source code I saw no immediate need that the location must
be taken from the .so file itself and so I wrote a patch which allows me to
provide an override path.

Please comment.

ChangeLog would be:

2006-09-11  Robert Schuster  <robertschuster@fsfe.org>

        * gnu/gcj/tools/gcj_dbtool/Main.java:
        (main): Allow 5 arguments for -f and -a command.
        (addJar): Added another argument, construct path from overridePath
        variable if set.
        (usage): Updated usage information.

Best Regards
Robert
--- libjava/gnu/gcj/tools/gcj_dbtool/Main.java.orig	2006-02-06 23:41:34.000000000 +0100
+++ libjava/gnu/gcj/tools/gcj_dbtool/Main.java		2006-09-10 15:57:30.000000000 +0200
@@ -97,10 +97,11 @@
 	// then renames the new database over the old.
 	try
 	  {
-	    insist (s.length == 4);
+	    insist (s.length == 4 || s.length == 5);
 	    File database = new File(s[1]);
 	    database = database.getAbsoluteFile();
 	    File jar = new File(s[2]);	
+	    String overridePath = null;
 	    PersistentByteMap map; 
 	    if (database.isFile())
 	      map = new PersistentByteMap(database, 
@@ -109,9 +110,18 @@
 	      map = PersistentByteMap.emptyPersistentByteMap(database, 
 							     100, 100*32);
 	    File soFile = new File(s[3]);
-	    if (! s[0].equals("-f") && ! soFile.isFile())
+	    
+	    // If we have 5 arguments the 5th is supposed to be an override path
+	    // for the .so file.
+	    if (s.length == 5)
+	      {
+	        if (verbose)
+		  System.err.println("Override path set to: " + s[4]);
+	        overridePath = s[4];
+              }
+	    else if (! s[0].equals("-f") && ! soFile.isFile())
 	      throw new IllegalArgumentException(s[3] + " is not a file");
- 	    map = addJar(jar, map, soFile);
+ 	    map = addJar(jar, map, soFile, overridePath);
 	  }
 	catch (Exception e)
 	  {
@@ -319,10 +329,13 @@
        + "\n"
        + "  Usage: \n"
        + "    gcj-dbtool -n file.gcjdb [size]     - Create a new gcj map database\n"
-       + "    gcj-dbtool -a file.gcjdb file.jar file.so\n"
+       + "    gcj-dbtool -a file.gcjdb file.jar file.so [path]\n"
        + "            - Add the contents of file.jar to a gcj map database\n"
+       + "              If [path] is set it will be prepended to the file \n"
+       + "              name of the shared object and disables existance  \n"
+       + "              checks\n"
        + "    gcj-dbtool -f file.gcjdb file.jar file.so\n"
-       + "            - Add the contents of file.jar to a gcj map database\n"
+       + "            - Synonymous with -a\n"
        + "    gcj-dbtool -t file.gcjdb            - Test a gcj map database\n"
        + "    gcj-dbtool -l file.gcjdb            - List a gcj map database\n"
        + "    gcj-dbtool [-][-0] -m dest.gcjdb [source.gcjdb]...\n"
@@ -340,7 +353,7 @@
   // closed.
 
   private static PersistentByteMap 
-  addJar(File f, PersistentByteMap b, File soFile)
+  addJar(File f, PersistentByteMap b, File soFile, String overridePath)
     throws Exception
   {
     MessageDigest md = MessageDigest.getInstance("MD5");
@@ -368,7 +381,9 @@
 
     Enumeration entries = jar.entries();
 
-    byte[] soFileName = soFile.getCanonicalPath().getBytes("UTF-8");
+    byte[] soFileName = (overridePath != null)
+			? (overridePath + "/" + soFile.getName()).getBytes("UTF-8")
+			: soFile.getCanonicalPath().getBytes("UTF-8");
     while (entries.hasMoreElements())
       {
 	JarEntry classfile = (JarEntry)entries.nextElement();

Attachment: signature.asc
Description: OpenPGP digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]