summaryrefslogtreecommitdiff
path: root/libjava/contrib/aot-compile-rpm.in
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /libjava/contrib/aot-compile-rpm.in
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'libjava/contrib/aot-compile-rpm.in')
-rw-r--r--libjava/contrib/aot-compile-rpm.in97
1 files changed, 97 insertions, 0 deletions
diff --git a/libjava/contrib/aot-compile-rpm.in b/libjava/contrib/aot-compile-rpm.in
new file mode 100644
index 000000000..7d9563255
--- /dev/null
+++ b/libjava/contrib/aot-compile-rpm.in
@@ -0,0 +1,97 @@
+#!/usr/bin/env python
+
+## Copyright (C) 2005, 2006, 2007, 2011 Free Software Foundation
+## 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 sys
+sys.path.insert(0, "@python_mod_dir_expanded@")
+import aotcompile
+import os
+
+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)