Mercurial > hg > graal-compiler
annotate mx/mx_graal_makefile.py @ 21679:824fe31b25c6
Make sure every invoke is in a different block in the BCI block map to improve local liveness analysis.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Wed, 03 Jun 2015 01:11:28 +0200 |
parents | 93d486d51ab4 |
children | a3315bce5192 |
rev | line source |
---|---|
21488
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
1 import mx, os, sys |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
2 # |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
3 # ---------------------------------------------------------------------------------------------------- |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
4 # |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
5 # Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
6 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
7 # |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
8 # This code is free software; you can redistribute it and/or modify it |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
9 # under the terms of the GNU General Public License version 2 only, as |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
10 # published by the Free Software Foundation. |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
11 # |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
12 # This code is distributed in the hope that it will be useful, but WITHOUT |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
13 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
14 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
15 # version 2 for more details (a copy is included in the LICENSE file that |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
16 # accompanied this code). |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
17 # |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
18 # You should have received a copy of the GNU General Public License version |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
19 # 2 along with this work; if not, write to the Free Software Foundation, |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
20 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
21 # |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
22 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
23 # or visit www.oracle.com if you need additional information or have any |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
24 # questions. |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
25 # |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
26 # ---------------------------------------------------------------------------------------------------- |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
27 # |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
28 |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
29 |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
30 def build_makefile(args): |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
31 """Build a Makefile from the suitte.py to build graa.jar without python""" |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
32 if len(args) == 0 or args[0] == "-": |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
33 do_build_makefile(lambda l: sys.stdout.write(l + os.linesep)) |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
34 elif args[0] == "-o": |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
35 with open(args[1], "w") as f: |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
36 do_build_makefile(lambda l: f.write(l + os.linesep)) |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
37 |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
38 def relative_dep_path(d): |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
39 if isinstance(d, str): d = mx.dependency(d) |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
40 return os.path.basename(d.get_path(False)) |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
41 |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
42 def createMakeRule(p, bootClasspath): |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
43 def filterDeps(deps, t): |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
44 def typeFilter(project): # filters |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
45 if isinstance(project, str): |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
46 project = mx.dependency(project, True) |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
47 return isinstance(project, t) |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
48 return [d for d in deps if typeFilter(d)] |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
49 |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
50 |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
51 canonicalDeps = p.canonical_deps() |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
52 canonicalProjectDep = filterDeps(canonicalDeps, mx.Project) |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
53 canonicalProjectDepDirs = ['$(TARGET)/' +i for i in canonicalProjectDep] |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
54 canonicalLibDep = filterDeps(canonicalDeps, mx.Library) |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
55 canonicalLibDepJars = ["$(LIB)/" + relative_dep_path(d) for d in canonicalLibDep] |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
56 |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
57 allDep = p.all_deps([], True, False, includeAnnotationProcessors=True) |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
58 allProcessorDistNames = [x.definedAnnotationProcessorsDist.name for x in filterDeps(allDep, mx.Project) if x.definedAnnotationProcessors != None] |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
59 allProjectDep = filterDeps(allDep, mx.Project) |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
60 allProjectDepDir = ['$(TARGET)/' +i.name for i in allProjectDep] |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
61 allLibDep = filterDeps(allDep, mx.Library) |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
62 allLibDepJar = ["$(LIB)/" + relative_dep_path(d) for d in allLibDep] |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
63 |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
64 processor = p.annotation_processors_path() |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
65 if processor != None: processor = processor.replace(p.suite.dir, "$(TARGET)") |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
66 |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
67 cp = allLibDepJar +allProjectDepDir |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
68 props = { |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
69 'name': p.name, |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
70 'project_deps': ' '.join(canonicalProjectDepDirs + canonicalLibDepJars + allProcessorDistNames), |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
71 'cp_deps': ('-cp ' + ':'.join(cp)) if len(cp) > 0 else '', |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
72 'cp_boot': ('-bootclasspath ' + bootClasspath) if len(bootClasspath) > 0 else '', |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
73 'processor': ('-processorpath ' + processor) if processor != None else '' |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
74 } |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
75 return """$(TARGET)/{name}: $(shell find graal/{name}/src/ -type f -name *.java) {project_deps} |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
76 \t$(eval TMP := $(shell mktemp -d)) |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
77 \ttest ! -d $(TARGET)/{name} || cp -Rp $(TARGET)/{name} $(TMP) |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
78 \t$(JAVAC) -d $(TMP) {cp_boot} {processor} {cp_deps} $(shell find graal/{name}/src/ -type f -name *.java) |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
79 \ttest ! -d graal/{name}/src/META-INF || (mkdir -p $(TARGET)/{name}/META-INF/ && cp -r graal/{name}/src/META-INF/ $(TARGET)/{name}/) |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
80 \tmkdir -p $(TARGET)/{name} |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
81 \tcp -r $(TMP)/* $(TARGET)/{name} |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
82 \ttouch $(TARGET)/{name} |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
83 \trm -r $(TMP) |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
84 """.format(**props) |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
85 |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
86 def createDistributionRule(dist): |
21504
93d486d51ab4
Remove duplicate directories in distrule
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
21488
diff
changeset
|
87 sorted_deps = set(dist.sorted_deps(False, True)) |
93d486d51ab4
Remove duplicate directories in distrule
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
21488
diff
changeset
|
88 depDirs = ' '.join(['$(TARGET)/' + i.name for i in sorted_deps]) |
93d486d51ab4
Remove duplicate directories in distrule
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
21488
diff
changeset
|
89 depDirsStar = ' '.join(['$(TARGET)/' + i.name + '/*' for i in sorted_deps]) |
21488
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
90 jarPath = os.path.relpath(dist.path, dist.suite.dir) |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
91 jarDir = os.path.dirname(jarPath) |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
92 props = { |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
93 'dist_name': dist.name, |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
94 'depDirs': depDirs, |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
95 'depDirsStar': depDirsStar, |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
96 'jar_path': jarPath, |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
97 'jar_dir': jarDir, |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
98 'providers_dir': '$(TMP)/META-INF/providers/ ', |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
99 'services_dir': '$(TMP)/META-INF/services/' |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
100 } |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
101 return """{dist_name}: {depDirs} |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
102 \t$(eval TMP := $(shell mktemp -d)) |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
103 \tmkdir -p $(TARGET){jar_dir} |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
104 \ttouch $(TARGET)/{jar_path} |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
105 \tcp -r {depDirsStar} $(TMP) |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
106 \ttest -d {services_dir} || mkdir -p {services_dir} |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
107 \ttest ! -d {providers_dir} || (cd {providers_dir} && for i in $$(ls); do c=$$(cat $$i); echo $$i >> {services_dir}$$c; done) |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
108 \ttest ! -d {providers_dir} || rm -r {providers_dir} |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
109 \t$(JAR) cvf $(TARGET){jar_path} -C $(TMP) . |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
110 \trm -r $(TMP) |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
111 """.format(**props) |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
112 |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
113 def createDownloadRule(lib): |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
114 http_urls = [u for u in lib.urls if u.startswith("http")] |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
115 if len(http_urls) == 0: http_urls = [u for u in lib.urls if u.startswith("jar")] |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
116 if len(http_urls) == 0: raise BaseException("No http url specified for downloading library %s: available urls: %s" % (lib.name, lib.urls)) |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
117 url = http_urls[0] |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
118 tofile = '$(LIB)/' + relative_dep_path(lib) |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
119 if url.startswith("jar"): |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
120 props = { |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
121 'url': url[url.find(":")+1:url.rfind("!")], |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
122 'archive_file': url[url.rfind("!")+1:], |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
123 'dest': tofile |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
124 } |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
125 dl = """\t$(eval TMP := $(shell mktemp -d)) |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
126 \tcd $(TMP) && $(WGET) -O dl.zip {url} && $(JAR) xf dl.zip |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
127 \tmv $(TMP)/{archive_file} {dest} |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
128 \trm -rf $(TMP)""".format(**props) |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
129 else: |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
130 dl = "\t$(WGET) -O {} {}".format(tofile, url) |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
131 return """{}:\n{}""".format(tofile, dl) |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
132 |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
133 |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
134 def create_suite_build(suite, out): |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
135 for p in suite.projects: |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
136 java = mx.java(p.javaCompliance) |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
137 bootClassPath = java.bootclasspath() |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
138 bootClassPath = bootClassPath.replace(java.jdk, "$(JDK)") |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
139 out(createMakeRule(p, bootClassPath)) |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
140 for l in suite.libs: |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
141 out(createDownloadRule(l)) |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
142 |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
143 distributionNames = [] |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
144 for d in suite.dists: |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
145 distributionNames.append(d.name) |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
146 out(createDistributionRule(d)) |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
147 out("{0}: {1}\n.PHONY: {1}".format(suite.name, " ".join(distributionNames))) |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
148 |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
149 |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
150 def do_build_makefile(out): |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
151 out("""VERBOSE= |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
152 TARGET=build/ |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
153 LIB=$(TARGET)/lib |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
154 JDK= |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
155 |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
156 WGET=wget |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
157 JAVAC=$(JDK)/bin/javac |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
158 JAR=$(JDK)/bin/jar |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
159 |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
160 |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
161 ifeq ($(JDK),) |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
162 $(error Variable JDK must be set to a JDK installation.) |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
163 endif |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
164 ifneq ($(VERBOSE),) |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
165 SHELL=sh -x |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
166 endif |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
167 |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
168 all: default |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
169 |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
170 $(TARGET): |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
171 \tmkdir -p $(TARGET) |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
172 |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
173 $(LIB): |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
174 \tmkdir -p $(LIB) |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
175 """) |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
176 suiteNames = [] |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
177 for s in mx.suites(): |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
178 suiteNames.append(s.name) |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
179 create_suite_build(s, out) |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
180 |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
181 out("""default: $(TARGET) $(LIB) {0} |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
182 .PHONY: {0} |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
183 """.format(" ".join(suiteNames))) |
6420ac0cbe3c
Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff
changeset
|
184 |