OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [contrib/] [aot-compile-rpm.in] - Blame information for rev 867

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 754 jeremybenn
#!/usr/bin/env python
2
 
3
## Copyright (C) 2005, 2006, 2007, 2011 Free Software Foundation
4
## Written by Gary Benson 
5
##
6
## This program is free software; you can redistribute it and/or modify
7
## it under the terms of the GNU General Public License as published by
8
## the Free Software Foundation; either version 2 of the License, or
9
## (at your option) any later version.
10
##
11
## This program is distributed in the hope that it will be useful,
12
## but WITHOUT ANY WARRANTY; without even the implied warranty of
13
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
## GNU General Public License for more details.
15
 
16
import sys
17
sys.path.insert(0, "@python_mod_dir_expanded@")
18
import aotcompile
19
import os
20
 
21
def libdir():
22
    cmd = "%s -p" % aotcompile.PATHS["dbtool"]
23
    dir = os.path.abspath(os.popen(cmd, "r").readline().rstrip())
24
    dir, base = os.path.split(dir)
25
    if base != "classmap.db":
26
        raise aotcompile.Error, "%s: unexpected output" % cmd
27
    dir, base = os.path.split(dir)
28
    if not base.startswith("gcj-"):
29
        raise aotcompile.Error, "%s: unexpected output" % cmd
30
    return dir
31
 
32
def writeSourceList(srcdir, dstpath):
33
    def visit(fp, dir, items):
34
        for item in items:
35
            path = os.path.join(dir, item)
36
            if os.path.isfile(path):
37
                print >>fp, path
38
    dstdir = os.path.dirname(dstpath)
39
    if not os.path.isdir(dstdir):
40
        os.makedirs(dstdir)
41
    os.path.walk(srcdir, visit, open(dstpath, "w"))
42
 
43
def copy(srcdir, dstdir, suffix):
44
    srcdir = os.path.join(srcdir, suffix.lstrip(os.sep))
45
    dstdir = os.path.join(dstdir, suffix.lstrip(os.sep))
46
    os.makedirs(os.path.dirname(dstdir))
47
    aotcompile.system(("/bin/cp", "-a", srcdir, dstdir))
48
 
49
try:
50
    name = os.environ.get("RPM_PACKAGE_NAME")
51
    if name is None:
52
        raise aotcompile.Error, "not for use outside rpm specfiles"
53
    arch = os.environ.get("RPM_ARCH")
54
    if arch == "noarch":
55
        raise aotcompile.Error, "cannot be used on noarch packages"
56
    srcdir = os.environ.get("RPM_BUILD_ROOT")
57
    if srcdir in (None, "/"):
58
        raise aotcompile.Error, "bad $RPM_BUILD_ROOT"
59
    tmpdir = os.path.join(os.getcwd(), "aot-compile-rpm")
60
    if os.path.exists(tmpdir):
61
        raise aotcompile.Error, "%s exists" % tmpdir
62
    dstdir = os.path.join(libdir(), "gcj", name)
63
 
64
    compiler = aotcompile.Compiler(srcdir, dstdir, tmpdir)
65
    compiler.gcjflags[0:0] = os.environ.get("RPM_OPT_FLAGS", "").split()
66
 
67
    # XXX: This script should not accept options, because having
68
    # them it cannot be integrated into rpm.  But, gcj cannot
69
    # build each and every jarfile yet, so we must be able to
70
    # exclude until it can.
71
    # XXX --exclude is also used in the jonas rpm to stop
72
    # everything being made a subset of the mammoth client
73
    # jarfile. Should adjust the subset checker's bias to
74
    # favour many small jarfiles over one big one.
75
    try:
76
        options, exclusions = sys.argv[1:], []
77
        while options:
78
            if options.pop(0) != "--exclude":
79
                raise ValueError
80
            compiler.exclusions.append(
81
                os.path.join(srcdir, options.pop(0).lstrip(os.sep)))
82
    except:
83
        print >>sys.stderr, "usage: %s [--exclude PATH]..." % (
84
            os.path.basename(sys.argv[0]))
85
        sys.exit(1)
86
 
87
    sourcelist = os.path.join(tmpdir, "sources.list")
88
    writeSourceList(os.getcwd(), sourcelist)
89
    compiler.gcjflags.append("-fsource-filename=" + sourcelist)
90
 
91
    compiler.compile()
92
    copy(tmpdir, srcdir, dstdir)
93
 
94
except aotcompile.Error, e:
95
    print >>sys.stderr, "%s: error: %s" % (
96
        os.path.basename(sys.argv[0]), e)
97
    sys.exit(1)

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.