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]

[patch] Packager files


Hi,

Attached patch puts files aot-compile-rm, aot-compile, and rebuild-gcj-db into libjava/contrib. These files are taken from java-gcj-compat and are intended to be available for packagers. This is the second part of merging java-gcj-compat into libgcj (also see sdk styled directory patch).

Josh
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 136724)
+++ ChangeLog	(working copy)
@@ -1,3 +1,10 @@
+2008-06-12  Joshua Sumali  <jsumali@redhat.com>
+
+	* contrib/aot-compile-rpm: New file. This file is meant to be available
+	for packagers (originally from java-gcj-compat).
+	* contrib/aot-compile: Likewise.
+	* contrib/rebuild-gcj-db: Likewise.
+
 2008-06-07  Joseph Myers  <joseph@codesourcery.com>
 
 	* configure.host (strongarm*-elf, xscale*-elf): Remove.
Index: contrib/aot-compile-rpm
===================================================================
--- contrib/aot-compile-rpm	(revision 0)
+++ contrib/aot-compile-rpm	(revision 0)
@@ -0,0 +1,96 @@
+#!/usr/bin/env python
+
+## Copyright (C) 2005, 2006, 2007 Red Hat, Inc.
+## Written by Gary Benson <gbenson@redhat.com>
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+
+import aotcompile
+import os
+import sys
+
+def libdir():
+    cmd = "%s -p" % aotcompile.PATHS["dbtool"]
+    dir = os.path.abspath(os.popen(cmd, "r").readline().rstrip())
+    dir, base = os.path.split(dir)
+    if base != "classmap.db":
+        raise aotcompile.Error, "%s: unexpected output" % cmd
+    dir, base = os.path.split(dir)
+    if not base.startswith("gcj-"):
+        raise aotcompile.Error, "%s: unexpected output" % cmd
+    return dir
+
+def writeSourceList(srcdir, dstpath):
+    def visit(fp, dir, items):
+        for item in items:
+            path = os.path.join(dir, item)
+            if os.path.isfile(path):
+                print >>fp, path
+    dstdir = os.path.dirname(dstpath)
+    if not os.path.isdir(dstdir):
+        os.makedirs(dstdir)
+    os.path.walk(srcdir, visit, open(dstpath, "w"))
+
+def copy(srcdir, dstdir, suffix):
+    srcdir = os.path.join(srcdir, suffix.lstrip(os.sep))
+    dstdir = os.path.join(dstdir, suffix.lstrip(os.sep))
+    os.makedirs(os.path.dirname(dstdir))
+    aotcompile.system(("/bin/cp", "-a", srcdir, dstdir))
+
+try:
+    name = os.environ.get("RPM_PACKAGE_NAME")
+    if name is None:
+        raise aotcompile.Error, "not for use outside rpm specfiles"
+    arch = os.environ.get("RPM_ARCH")
+    if arch == "noarch":
+        raise aotcompile.Error, "cannot be used on noarch packages"
+    srcdir = os.environ.get("RPM_BUILD_ROOT")
+    if srcdir in (None, "/"):
+        raise aotcompile.Error, "bad $RPM_BUILD_ROOT"
+    tmpdir = os.path.join(os.getcwd(), "aot-compile-rpm")
+    if os.path.exists(tmpdir):
+        raise aotcompile.Error, "%s exists" % tmpdir
+    dstdir = os.path.join(libdir(), "gcj", name)
+
+    compiler = aotcompile.Compiler(srcdir, dstdir, tmpdir)
+    compiler.gcjflags[0:0] = os.environ.get("RPM_OPT_FLAGS", "").split() 
+
+    # XXX: This script should not accept options, because having
+    # them it cannot be integrated into rpm.  But, gcj cannot
+    # build each and every jarfile yet, so we must be able to
+    # exclude until it can.
+    # XXX --exclude is also used in the jonas rpm to stop
+    # everything being made a subset of the mammoth client
+    # jarfile. Should adjust the subset checker's bias to
+    # favour many small jarfiles over one big one.
+    try:
+        options, exclusions = sys.argv[1:], []
+        while options:
+            if options.pop(0) != "--exclude":
+                raise ValueError
+            compiler.exclusions.append(
+                os.path.join(srcdir, options.pop(0).lstrip(os.sep)))
+    except:
+        print >>sys.stderr, "usage: %s [--exclude PATH]..." % (
+            os.path.basename(sys.argv[0]))
+        sys.exit(1)
+
+    sourcelist = os.path.join(tmpdir, "sources.list")
+    writeSourceList(os.getcwd(), sourcelist)
+    compiler.gcjflags.append("-fsource-filename=" + sourcelist)
+
+    compiler.compile()
+    copy(tmpdir, srcdir, dstdir)
+
+except aotcompile.Error, e:
+    print >>sys.stderr, "%s: error: %s" % (
+        os.path.basename(sys.argv[0]), e)
+    sys.exit(1)

Property changes on: contrib/aot-compile-rpm
___________________________________________________________________
Name: svn:executable
   + *

Index: contrib/aot-compile
===================================================================
--- contrib/aot-compile	(revision 0)
+++ contrib/aot-compile	(revision 0)
@@ -0,0 +1,87 @@
+#!/usr/bin/env python
+
+## Copyright (C) 2006 Red Hat, Inc.
+## Written by Gary Benson <gbenson@redhat.com>
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+
+import aotcompile
+import getopt
+import os
+import sys
+
+usage = """\
+Usage: %s [OPTION...] SRCDIR DSTDIR
+AOT-compile all Java bytecode in SRCDIR into DSTDIR.
+
+Options:
+  -M, --make=PATH        make executable to use (%s)
+  -C, --gcj=PATH         gcj executable to use (%s)
+  -D, --dbtool=PATH      gcj-dbtool executable to use (%s)
+  -m, --makeflags=FLAGS  flags to pass to make during build
+  -c, --gcjflags=FLAGS   flags to pass to gcj during compilation
+                           in addition to %s
+  -l, --ldflags=FLAGS    flags to pass to gcj during linking
+                           in addition to %s
+  -e, --exclude=PATH     do not compile PATH
+
+Extra flags may also be passed using the AOT_MAKEFLAGS, AOT_GCJFLAGS
+and AOT_LDFLAGS environment variables.""" % (
+    os.path.basename(sys.argv[0]),
+    aotcompile.PATHS["make"],
+    aotcompile.PATHS["gcj"],
+    aotcompile.PATHS["dbtool"],
+    repr(" ".join(aotcompile.GCJFLAGS)),
+    repr(" ".join(aotcompile.LDFLAGS)))
+
+try:
+    if os.environ.has_key("RPM_PACKAGE_NAME"):
+        raise aotcompile.Error, "not for use within rpm specfiles"
+
+    try:
+        opts, args = getopt.getopt(
+            sys.argv[1:],
+            "M:C:D:m:c:l:e:",
+            ["make=", "gcj=", "dbtool=",
+             "makeflags=" "gcjflags=", "ldflags=",
+             "exclude="])
+        srcdir, dstdir = args
+    except:
+        print >>sys.stderr, usage
+        sys.exit(1)
+
+    compiler = aotcompile.Compiler(srcdir, dstdir)
+    for o, a in opts:
+        if o in ("-M", "--make"):
+            aotcompile.PATHS["make"] = a
+        if o in ("-C", "--gcj"):
+            aotcompile.PATHS["gcj"] = a
+        if o in ("-D", "--dbtool"):
+            aotcompile.PATHS["dbtool"] = a
+        if o in ("-m", "--makeflags"):
+            compiler.makeflags[0:0] = a.split()
+        if o in ("-c", "--gcjflags"):
+            compiler.gcjflags[0:0] = a.split()
+        if o in ("-l", "--ldflags"):
+            compiler.ldflags[0:0] = a.split()
+        if o in ("-e", "--exclude"):
+            compiler.exclusions.append(a)
+    
+    compiler.makeflags[0:0] = os.environ.get("AOT_MAKEFLAGS", "").split() 
+    compiler.gcjflags[0:0] = os.environ.get("AOT_GCJFLAGS", "").split() 
+    compiler.ldflags[0:0] = os.environ.get("AOT_LDFLAGS", "").split() 
+
+    compiler.compile()
+
+except aotcompile.Error, e:
+    print >>sys.stderr, "%s: error: %s" % (
+        os.path.basename(sys.argv[0]), e)
+    sys.exit(1)

Property changes on: contrib/aot-compile
___________________________________________________________________
Name: svn:executable
   + *

Index: contrib/rebuild-gcj-db
===================================================================
--- contrib/rebuild-gcj-db	(revision 0)
+++ contrib/rebuild-gcj-db	(revision 0)
@@ -0,0 +1,16 @@
+#!/bin/bash
+# rebuild-gcj-db
+
+# Rebuild all the standard databases.
+for base in /usr/lib*; do
+   dbLocation=`/usr/bin/gcj-dbtool -p $base`
+   libdir=$base/gcj
+   if ! test -d $libdir; then
+      # No shared libraries here.
+      continue
+   fi
+   dirname $dbLocation | xargs mkdir -p
+   /usr/bin/gcj-dbtool -n $dbLocation 64
+   find $libdir -follow -name '*.db' -print0 | \
+      xargs -0 /usr/bin/gcj-dbtool -m $dbLocation $dbLocation
+done

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