gcc/libjava/contrib/aot-compile-rpm.in

98 lines
3.6 KiB
Plaintext
Raw Normal View History

configure.ac (java-home): new AC_ARG_ENABLE. 2008-06-30 Joshua Sumali <jsumali@redhat.com> Andrew Haley <aph@redhat.com> * configure.ac (java-home): new AC_ARG_ENABLE. (aot-compile-rpm): Likewise. (CREATE_JAVA_HOME): new AM_CONDITIONAL. (INSTALL_AOT_RPM): Likewise. (gcc-suffix): new AC_ARG_WITH. (arch-directory): Likewise. (os-directory): Likewise. (origin-name): Likewise. (arch-suffix): Likewise. (jvm-root-dir): Likewise. (jvm-jar-dir): Likewise. (python-dir): Likewise. (AC_CONFIG_FILES): Add contrib/aotcompile.py, contrib/aot-compile, contrib/aot-compile-rpm, contrib/rebuild-gcj-db. (gcjsubdir): New AC_SUBST. * Makefile.am (install-data-local): Install Python modules for aot-compile. Also install an sdk style directory if --enable-java-home is passed to configure. (bin_SCRIPTS): Add contrib/rebuild-gcj-db and contrib/aot-compile. (gcjsubdir): Add. (db_pathtail): Redefine in terms of gcjsubdir. * contrib/aot-compile.in: New file. * contrib/aotcompile.py.in: Likewise. * contrib/aot-compile-rpm.in: Likewise. * contrib/classfile.py: Likewise. * contrib/rebuild-gcj-db.in: Likewise. * configure: Regenerate. * Makefile.in: Regenerate. 2008-06-30 Joshua Sumali <jsumali@redhat.com> * doc/install.texi (--enable-java-home): Document. (--enable-aot-compile-rpm): Likewise. (--with-arch-directory): Likewise. (--with-os-directory): Likewise. (--with-origin-name): Likewise. (--with-arch-suffix): Likewise. (--with-jvm-root-dir): Likewise. (--with-jvm-jar-dir): Likewise. (--with-python-dir): Likewise. 2008-06-30 Joshua Sumali <jsumali@redhat.com> * Make-lang.in (JAVA_MANFILES): Add doc/aot-compile.1 and doc/rebuild-gcj-db.1 (java.uninstall): Likewise. (java.maintainer-clean): Likewise. (aot-compile.pod): New rule. (rebuild-gcj-db.pod): New rule. (java.install-man): Install doc/aot-compile.1 and doc/rebuild-gcj-db.1 * gcj.texi: Add new sections for aot-compile and rebuild-gcj-db. Co-Authored-By: Andrew Haley <aph@redhat.com> From-SVN: r137353
2008-07-02 15:17:54 +02:00
#!/usr/bin/env python
## Copyright (C) 2005, 2006, 2007 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.append("@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)