diff options
Diffstat (limited to 'debian/aot-compile')
-rw-r--r-- | debian/aot-compile | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/debian/aot-compile b/debian/aot-compile new file mode 100644 index 0000000..93e1c60 --- /dev/null +++ b/debian/aot-compile @@ -0,0 +1,98 @@ +#!/usr/bin/python + +## Copyright (C) 2006, 2008 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 sys +sys.path.append("/usr/lib/gcc") +import aotcompile +import getopt +import os + +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 + -L, --libdir=DIR overwrite destination directory + +Extra flags may also be passed using the AOT_MAKEFLAGS, AOT_GCJFLAGS +and AOT_LDFLAGS environment variables. + +The parallel=<n> option in DEB_BUILD_OPTIONS is passed to make unless +-j<n> is passed with -m, --makeflags""" % ( + os.path.basename(sys.argv[0]), + aotcompile.PATHS["make"], + aotcompile.PATHS["gcj"], + aotcompile.PATHS["dbtool"], + repr(" ".join(aotcompile.GCJFLAGS)), + repr(" ".join(aotcompile.LDFLAGS))) + +try: + try: + opts, args = getopt.getopt( + sys.argv[1:], + "M:C:D:m:c:l:e:L:", + ["make=", "gcj=", "dbtool=", + "makeflags=" "gcjflags=", "ldflags=", + "exclude=", "libdir="]) + 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) + if o in ("-L", "--libdir"): + compiler.libdir = 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() + + try: + n = [int(o.replace('parallel=', '')) for o in os.environ.get("DEB_BUILD_OPTIONS", "").replace(',',' ').split() if o.startswith('parallel=')][-1] + except (ValueError, IndexError): + n=1 + if not [o for o in compiler.makeflags if o.startswith('-j')] and n > 1: + compiler.makeflags.append('-j%d' % n) + + compiler.compile() + +except aotcompile.Error, e: + print >>sys.stderr, "%s: error: %s" % ( + os.path.basename(sys.argv[0]), e) + sys.exit(1) |