annotate mx.graal/mx_graal_makefile.py @ 22044:5de4a002d097

Schedule: Allow floating reads to be scheduled after loops
author Gilles Duboscq <gilles.m.duboscq@oracle.com>
date Sun, 21 Jun 2015 18:53:42 +0200
parents 66dd063eb6a0
children 0e095e2c24e2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
21488
6420ac0cbe3c Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff changeset
1 #
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 # 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
5 # 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
6 #
6420ac0cbe3c Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff changeset
7 # 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
8 # 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
9 # published by the Free Software Foundation.
6420ac0cbe3c Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff changeset
10 #
6420ac0cbe3c Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff changeset
11 # 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
12 # 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
13 # 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
14 # 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
15 # accompanied this code).
6420ac0cbe3c Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff changeset
16 #
6420ac0cbe3c Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff changeset
17 # 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
18 # 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
19 # 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
20 #
6420ac0cbe3c Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff changeset
21 # 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
22 # 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
23 # questions.
6420ac0cbe3c Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff changeset
24 #
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 #
21718
b5bbf03bc17a Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21717
diff changeset
27 import mx, mx_graal, os
21717
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
28 from argparse import ArgumentParser, REMAINDER
21488
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
21717
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
31 class Makefile:
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
32 def __init__(self):
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
33 self.rules = []
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
34 self.definitions = []
21718
b5bbf03bc17a Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21717
diff changeset
35
21717
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
36 def add_rule(self, s):
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
37 self.rules.append(s)
21718
b5bbf03bc17a Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21717
diff changeset
38
21717
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
39 def add_definition(self, s):
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
40 self.definitions.append(s)
21718
b5bbf03bc17a Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21717
diff changeset
41
21717
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
42 def generate(self):
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
43 return "\n\n".join(self.definitions + self.rules)
21718
b5bbf03bc17a Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21717
diff changeset
44
21717
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
45
21488
6420ac0cbe3c Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff changeset
46 def build_makefile(args):
21936
11f241f26c61 mx: add check to gate the jvmci.make and suite.py are in sync
Doug Simon <doug.simon@oracle.com>
parents: 21919
diff changeset
47 """Creates a Makefile which is able to build distributions without mx
11f241f26c61 mx: add check to gate the jvmci.make and suite.py are in sync
Doug Simon <doug.simon@oracle.com>
parents: 21919
diff changeset
48
11f241f26c61 mx: add check to gate the jvmci.make and suite.py are in sync
Doug Simon <doug.simon@oracle.com>
parents: 21919
diff changeset
49 The return value indicates how many files were modified"""
21717
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
50 parser = ArgumentParser(prog='mx makefile')
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
51 parser.add_argument('-o', action='store', dest='output', help='Write contents to this file.')
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
52 parser.add_argument('selectedDists', help="Selected distribution names which are going to be built with make.", nargs=REMAINDER)
21790
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21740
diff changeset
53 opts = parser.parse_args(args)
21718
b5bbf03bc17a Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21717
diff changeset
54
21790
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21740
diff changeset
55 if opts.selectedDists == None or len(opts.selectedDists) == 0:
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21740
diff changeset
56 opts.selectedDists = [d.name for d in mx_graal._jdkDeployedDists if d.partOfHotSpot]
21717
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
57 mf = Makefile()
21790
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21740
diff changeset
58 commandline = " ".join(["mx.sh", "makefile"] + args)
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21740
diff changeset
59 if do_build_makefile(mf, opts.selectedDists, commandline):
21717
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
60 contents = mf.generate()
21790
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21740
diff changeset
61 if opts.output == None:
21717
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
62 print contents
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
63 else:
21957
555f788b964b show diff if jvmci.make generation modifies an existing file
Doug Simon <doug.simon@oracle.com>
parents: 21955
diff changeset
64 if mx.update_file(opts.output, contents, showDiff=True):
21936
11f241f26c61 mx: add check to gate the jvmci.make and suite.py are in sync
Doug Simon <doug.simon@oracle.com>
parents: 21919
diff changeset
65 return 1
11f241f26c61 mx: add check to gate the jvmci.make and suite.py are in sync
Doug Simon <doug.simon@oracle.com>
parents: 21919
diff changeset
66 return 0
21488
6420ac0cbe3c Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff changeset
67
21955
3ce35131bff2 Introduce clean target in jvmci.make
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21949
diff changeset
68 def short_dist_name(name):
3ce35131bff2 Introduce clean target in jvmci.make
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21949
diff changeset
69 return name.replace("COM_ORACLE_", "")
3ce35131bff2 Introduce clean target in jvmci.make
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21949
diff changeset
70
21717
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
71 def filter_projects(deps, t):
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
72 def typeFilter(project): # filters
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
73 if isinstance(project, str):
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
74 project = mx.dependency(project, True)
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
75 return isinstance(project, t)
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
76 return [d for d in deps if typeFilter(d)]
21488
6420ac0cbe3c Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff changeset
77
21718
b5bbf03bc17a Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21717
diff changeset
78 def get_jdk_deployed_dists():
b5bbf03bc17a Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21717
diff changeset
79 return [d.name for d in mx_graal._jdkDeployedDists]
21488
6420ac0cbe3c Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff changeset
80
21790
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21740
diff changeset
81 def update_list(li, elements):
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21740
diff changeset
82 for e in elements:
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21740
diff changeset
83 if e not in li:
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21740
diff changeset
84 li.append(e)
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21740
diff changeset
85
21917
0df6a0cb4b5f Cleanup code in mx_graal_makefile.py, add comments
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21916
diff changeset
86 def make_dist_rule(dist, mf):
21717
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
87 def path_dist_relative(p):
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
88 return os.path.relpath(p, dist.suite.dir)
21790
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21740
diff changeset
89 shortName = short_dist_name(dist.name)
21718
b5bbf03bc17a Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21717
diff changeset
90 jdkDeployedDists = get_jdk_deployed_dists()
21717
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
91 jarPath = path_dist_relative(dist.path)
21790
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21740
diff changeset
92 sourcesVariableName = shortName + "_SRC"
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21740
diff changeset
93 depJarVariableName = shortName + "_DEP_JARS"
21717
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
94 sources = []
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
95 resources = []
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
96 sortedDeps = dist.sorted_deps(True, transitive=False, includeAnnotationProcessors=True)
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
97 projects = filter_projects(sortedDeps, mx.Project)
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
98 targetPathPrefix = "$(TARGET)" + os.path.sep
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
99 libraryDeps = [path_dist_relative(l.get_path(False)) for l in filter_projects(sortedDeps, mx.Library)]
21718
b5bbf03bc17a Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21717
diff changeset
100
21790
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21740
diff changeset
101 annotationProcessorDeps = []
21717
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
102 distDeps = dist.get_dist_deps(includeSelf=False, transitive=True)
21790
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21740
diff changeset
103 distDepProjects = []
21718
b5bbf03bc17a Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21717
diff changeset
104 for d in distDeps:
21790
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21740
diff changeset
105 update_list(distDepProjects, d.sorted_deps(includeLibs=False, transitive=True))
21718
b5bbf03bc17a Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21717
diff changeset
106
b5bbf03bc17a Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21717
diff changeset
107 classPath = [targetPathPrefix + path_dist_relative(d.path) for d in distDeps] + libraryDeps \
b5bbf03bc17a Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21717
diff changeset
108 + [path_dist_relative(mx.dependency(name).path) for name in dist.excludedDependencies]
21717
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
109 for p in projects:
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
110 if p.definedAnnotationProcessors != None and p.definedAnnotationProcessorsDist != dist:
21790
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21740
diff changeset
111 update_list(annotationProcessorDeps, [p])
21717
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
112 for p in projects:
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
113 projectDir = path_dist_relative(p.dir)
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
114 if p not in distDepProjects and p not in annotationProcessorDeps:
21916
3df76a0300f3 jvmci.make remove generated source from search path; export compilers into a different directory when jvmci is disabled: jre/lib/<arch>/(server|client)-nojvmci/
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21912
diff changeset
115 for src in [projectDir + os.path.sep + d for d in p.srcDirs]:
21911
899d7cadd0a1 Make jvmci.make quiet and use recipe for build and jar
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21888
diff changeset
116 sources.append("$(shell find {} -type f 2> /dev/null)".format(src))
21718
b5bbf03bc17a Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21717
diff changeset
117 metaInf = src + os.path.sep + "META-INF"
21717
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
118 if os.path.exists(metaInf):
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
119 resources.append(metaInf)
21718
b5bbf03bc17a Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21717
diff changeset
120
b5bbf03bc17a Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21717
diff changeset
121
21717
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
122 sourceLines = sourcesVariableName + " = " + ("\n" + sourcesVariableName + " += ").join(sources)
21718
b5bbf03bc17a Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21717
diff changeset
123 apPaths = []
b5bbf03bc17a Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21717
diff changeset
124 apDistNames = []
b5bbf03bc17a Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21717
diff changeset
125 apDistVariableNames = []
21717
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
126 for p in annotationProcessorDeps:
21718
b5bbf03bc17a Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21717
diff changeset
127 apPaths.append(path_dist_relative(p.definedAnnotationProcessorsDist.path))
21790
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21740
diff changeset
128 name = short_dist_name(p.definedAnnotationProcessorsDist.name)
21718
b5bbf03bc17a Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21717
diff changeset
129 apDistNames.append(name)
b5bbf03bc17a Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21717
diff changeset
130 apDistVariableNames.append("$(" + name + "_JAR)")
b5bbf03bc17a Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21717
diff changeset
131 shouldExport = dist.name in jdkDeployedDists
21488
6420ac0cbe3c Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff changeset
132 props = {
21790
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21740
diff changeset
133 "name": shortName,
21717
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
134 "jarPath": targetPathPrefix + jarPath,
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
135 "depJarsVariableAccess": "$(" + depJarVariableName + ")" if len(classPath) > 0 else "",
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
136 "depJarsVariable": depJarVariableName,
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
137 "sourceLines": sourceLines,
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
138 "sourcesVariableName": sourcesVariableName,
21718
b5bbf03bc17a Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21717
diff changeset
139 "annotationProcessors": " ".join(apDistVariableNames),
21917
0df6a0cb4b5f Cleanup code in mx_graal_makefile.py, add comments
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21916
diff changeset
140 "cpAnnotationProcessors": ":".join(apDistVariableNames),
21717
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
141 "jarDeps": " ".join(classPath),
21917
0df6a0cb4b5f Cleanup code in mx_graal_makefile.py, add comments
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21916
diff changeset
142 "copyResources": " ".join(resources)
21717
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
143 }
21718
b5bbf03bc17a Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21717
diff changeset
144
21717
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
145 mf.add_definition(sourceLines)
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
146 mf.add_definition("{name}_JAR = {jarPath}".format(**props))
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
147 if len(classPath) > 0: mf.add_definition("{depJarsVariable} = {jarDeps}".format(**props))
21718
b5bbf03bc17a Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21717
diff changeset
148 if shouldExport: mf.add_definition("EXPORTED_FILES += $({name}_JAR)".format(**props))
b5bbf03bc17a Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21717
diff changeset
149 mf.add_rule("""$({name}_JAR): $({sourcesVariableName}) {annotationProcessors} {depJarsVariableAccess}
21919
62da3906ab7f Do not make builds in jvmci.make
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21917
diff changeset
150 \t$(call build_and_jar,{cpAnnotationProcessors},$(subst $(space),:,{depJarsVariableAccess}),{copyResources},$({name}_JAR))
21911
899d7cadd0a1 Make jvmci.make quiet and use recipe for build and jar
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21888
diff changeset
151 """.format(**props))
21717
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
152 return
21488
6420ac0cbe3c Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff changeset
153
6420ac0cbe3c Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff changeset
154
21718
b5bbf03bc17a Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21717
diff changeset
155
21790
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21740
diff changeset
156 def do_build_makefile(mf, selectedDists, commandline):
21717
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
157 java = mx.java()
21971
28debbb6496d Don't apply os.path.realpath to the boot classpath
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21969
diff changeset
158 bootClassPath = java.bootclasspath()
21969
eef888fdb8b1 Use real path (canonicalized) when create relative paths for bootclasspath
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21957
diff changeset
159 bootClassPath = bootClassPath.replace(os.path.realpath(java.jdk), "$(ABS_BOOTDIR)")
21717
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
160 jdkBootClassPathVariableName = "JDK_BOOTCLASSPATH"
21718
b5bbf03bc17a Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21717
diff changeset
161
21790
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21740
diff changeset
162 mf.add_definition("""# This Makefile is generated automatically, do not edit
21488
6420ac0cbe3c Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff changeset
163
21790
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21740
diff changeset
164 TARGET=.
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21740
diff changeset
165 # Bootstrap JDK to be used (for javac and jar)
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21740
diff changeset
166 ABS_BOOTDIR=
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21740
diff changeset
167
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21740
diff changeset
168 JAVAC=$(ABS_BOOTDIR)/bin/javac -g -target """ + str(java.javaCompliance) + """
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21740
diff changeset
169 JAR=$(ABS_BOOTDIR)/bin/jar
21488
6420ac0cbe3c Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff changeset
170
21718
b5bbf03bc17a Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21717
diff changeset
171 HS_COMMON_SRC=.
21790
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21740
diff changeset
172
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21740
diff changeset
173 # Directories, where the generated property-files reside within the JAR files
21937
3a292e8b9e51 replaced Service marker interface with non-standard META-INF directory names to differentiate JVMCI providers from standard service providers
Doug Simon <doug.simon@oracle.com>
parents: 21936
diff changeset
174 PROVIDERS_INF=/META-INF/jvmci.providers
3a292e8b9e51 replaced Service marker interface with non-standard META-INF directory names to differentiate JVMCI providers from standard service providers
Doug Simon <doug.simon@oracle.com>
parents: 21936
diff changeset
175 SERVICES_INF=/META-INF/jvmci.services
3a292e8b9e51 replaced Service marker interface with non-standard META-INF directory names to differentiate JVMCI providers from standard service providers
Doug Simon <doug.simon@oracle.com>
parents: 21936
diff changeset
176 OPTIONS_INF=/META-INF/jvmci.options
21488
6420ac0cbe3c Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff changeset
177
21955
3ce35131bff2 Introduce clean target in jvmci.make
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21949
diff changeset
178 JARS = $(foreach dist,$(DISTRIBUTIONS),$($(dist)_JAR))
3ce35131bff2 Introduce clean target in jvmci.make
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21949
diff changeset
179
21790
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21740
diff changeset
180 ifeq ($(ABS_BOOTDIR),)
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21740
diff changeset
181 $(error Variable ABS_BOOTDIR must be set to a JDK installation.)
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21740
diff changeset
182 endif
21911
899d7cadd0a1 Make jvmci.make quiet and use recipe for build and jar
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21888
diff changeset
183 ifeq ($(MAKE_VERBOSE),)
899d7cadd0a1 Make jvmci.make quiet and use recipe for build and jar
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21888
diff changeset
184 QUIETLY=@
21488
6420ac0cbe3c Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff changeset
185 endif
6420ac0cbe3c Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff changeset
186
21919
62da3906ab7f Do not make builds in jvmci.make
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21917
diff changeset
187 # Required to construct a whitespace for use with subst
62da3906ab7f Do not make builds in jvmci.make
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21917
diff changeset
188 space :=
62da3906ab7f Do not make builds in jvmci.make
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21917
diff changeset
189 space +=
62da3906ab7f Do not make builds in jvmci.make
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21917
diff changeset
190
21937
3a292e8b9e51 replaced Service marker interface with non-standard META-INF directory names to differentiate JVMCI providers from standard service providers
Doug Simon <doug.simon@oracle.com>
parents: 21936
diff changeset
191 # Takes the provider files created by ServiceProviderProcessor (the processor
3a292e8b9e51 replaced Service marker interface with non-standard META-INF directory names to differentiate JVMCI providers from standard service providers
Doug Simon <doug.simon@oracle.com>
parents: 21936
diff changeset
192 # for the @ServiceProvider annotation) and merges them into a single file.
21917
0df6a0cb4b5f Cleanup code in mx_graal_makefile.py, add comments
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21916
diff changeset
193 # Arguments:
0df6a0cb4b5f Cleanup code in mx_graal_makefile.py, add comments
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21916
diff changeset
194 # 1: directory with contents of the JAR file
21937
3a292e8b9e51 replaced Service marker interface with non-standard META-INF directory names to differentiate JVMCI providers from standard service providers
Doug Simon <doug.simon@oracle.com>
parents: 21936
diff changeset
195 define process_providers
21943
31be1c8f4905 switched to use of simple makefile assignment in jvmci.make and removed unnecessary semicolons
Doug Simon <doug.simon@oracle.com>
parents: 21939
diff changeset
196 $(eval providers := $(1)/$(PROVIDERS_INF))
31be1c8f4905 switched to use of simple makefile assignment in jvmci.make and removed unnecessary semicolons
Doug Simon <doug.simon@oracle.com>
parents: 21939
diff changeset
197 $(eval services := $(1)/$(SERVICES_INF))
21911
899d7cadd0a1 Make jvmci.make quiet and use recipe for build and jar
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21888
diff changeset
198 $(QUIETLY) test -d $(services) || mkdir -p $(services)
899d7cadd0a1 Make jvmci.make quiet and use recipe for build and jar
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21888
diff changeset
199 $(QUIETLY) test ! -d $(providers) || (cd $(providers) && for i in $$(ls); do c=$$(cat $$i); echo $$i >> $(abspath $(services))/$$c; rm $$i; done)
21718
b5bbf03bc17a Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21717
diff changeset
200
21911
899d7cadd0a1 Make jvmci.make quiet and use recipe for build and jar
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21888
diff changeset
201 @# Since all projects are built together with one javac call we cannot determine
899d7cadd0a1 Make jvmci.make quiet and use recipe for build and jar
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21888
diff changeset
202 @# which project contains HotSpotVMConfig.inline.hpp so we hardcode it.
21943
31be1c8f4905 switched to use of simple makefile assignment in jvmci.make and removed unnecessary semicolons
Doug Simon <doug.simon@oracle.com>
parents: 21939
diff changeset
203 $(eval vmconfig := $(1)/hotspot/HotSpotVMConfig.inline.hpp)
31be1c8f4905 switched to use of simple makefile assignment in jvmci.make and removed unnecessary semicolons
Doug Simon <doug.simon@oracle.com>
parents: 21939
diff changeset
204 $(eval vmconfigDest := $(HS_COMMON_SRC)/../jvmci/com.oracle.jvmci.hotspot/src_gen/hotspot)
21911
899d7cadd0a1 Make jvmci.make quiet and use recipe for build and jar
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21888
diff changeset
205 $(QUIETLY) test ! -f $(vmconfig) || (mkdir -p $(vmconfigDest) && cp $(vmconfig) $(vmconfigDest))
21717
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
206 endef
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
207
21937
3a292e8b9e51 replaced Service marker interface with non-standard META-INF directory names to differentiate JVMCI providers from standard service providers
Doug Simon <doug.simon@oracle.com>
parents: 21936
diff changeset
208 # Reads the files in jvmci.options/ created by OptionProcessor (the processor for the @Option annotation)
3a292e8b9e51 replaced Service marker interface with non-standard META-INF directory names to differentiate JVMCI providers from standard service providers
Doug Simon <doug.simon@oracle.com>
parents: 21936
diff changeset
209 # and appends to services/com.oracle.jvmci.options.Options entries for the providers
3a292e8b9e51 replaced Service marker interface with non-standard META-INF directory names to differentiate JVMCI providers from standard service providers
Doug Simon <doug.simon@oracle.com>
parents: 21936
diff changeset
210 # also created by the same processor.
3a292e8b9e51 replaced Service marker interface with non-standard META-INF directory names to differentiate JVMCI providers from standard service providers
Doug Simon <doug.simon@oracle.com>
parents: 21936
diff changeset
211 # Arguments:
3a292e8b9e51 replaced Service marker interface with non-standard META-INF directory names to differentiate JVMCI providers from standard service providers
Doug Simon <doug.simon@oracle.com>
parents: 21936
diff changeset
212 # 1: directory with contents of the JAR file
3a292e8b9e51 replaced Service marker interface with non-standard META-INF directory names to differentiate JVMCI providers from standard service providers
Doug Simon <doug.simon@oracle.com>
parents: 21936
diff changeset
213 define process_options
21943
31be1c8f4905 switched to use of simple makefile assignment in jvmci.make and removed unnecessary semicolons
Doug Simon <doug.simon@oracle.com>
parents: 21939
diff changeset
214 $(eval options := $(1)/$(OPTIONS_INF))
31be1c8f4905 switched to use of simple makefile assignment in jvmci.make and removed unnecessary semicolons
Doug Simon <doug.simon@oracle.com>
parents: 21939
diff changeset
215 $(eval services := $(1)/META-INF/services)
21937
3a292e8b9e51 replaced Service marker interface with non-standard META-INF directory names to differentiate JVMCI providers from standard service providers
Doug Simon <doug.simon@oracle.com>
parents: 21936
diff changeset
216 $(QUIETLY) test -d $(services) || mkdir -p $(services)
3a292e8b9e51 replaced Service marker interface with non-standard META-INF directory names to differentiate JVMCI providers from standard service providers
Doug Simon <doug.simon@oracle.com>
parents: 21936
diff changeset
217 $(QUIETLY) test ! -d $(options) || (cd $(options) && for i in $$(ls); do echo $${i}_Options >> $(abspath $(services))/com.oracle.jvmci.options.Options; done)
3a292e8b9e51 replaced Service marker interface with non-standard META-INF directory names to differentiate JVMCI providers from standard service providers
Doug Simon <doug.simon@oracle.com>
parents: 21936
diff changeset
218 endef
3a292e8b9e51 replaced Service marker interface with non-standard META-INF directory names to differentiate JVMCI providers from standard service providers
Doug Simon <doug.simon@oracle.com>
parents: 21936
diff changeset
219
3a292e8b9e51 replaced Service marker interface with non-standard META-INF directory names to differentiate JVMCI providers from standard service providers
Doug Simon <doug.simon@oracle.com>
parents: 21936
diff changeset
220 # Extracts META-INF/jvmci.services and META-INF/jvmci.options of a JAR file into a given directory
21917
0df6a0cb4b5f Cleanup code in mx_graal_makefile.py, add comments
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21916
diff changeset
221 # Arguments:
0df6a0cb4b5f Cleanup code in mx_graal_makefile.py, add comments
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21916
diff changeset
222 # 1: JAR file to extract
21943
31be1c8f4905 switched to use of simple makefile assignment in jvmci.make and removed unnecessary semicolons
Doug Simon <doug.simon@oracle.com>
parents: 21939
diff changeset
223 # 2: target directory (which already exists)
21793
44bad469bec2 Create DEST_SUBDIR when doing install_jvm (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21790
diff changeset
224 define extract
21912
1a6a520af3b5 jvmci.make put temp dirs into the target directory
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21911
diff changeset
225 $(eval TMP := $(shell mktemp -d $(TARGET)/tmp_XXXXX))
21911
899d7cadd0a1 Make jvmci.make quiet and use recipe for build and jar
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21888
diff changeset
226 $(QUIETLY) cd $(TMP) && $(JAR) xf $(abspath $(1)) && \\
21937
3a292e8b9e51 replaced Service marker interface with non-standard META-INF directory names to differentiate JVMCI providers from standard service providers
Doug Simon <doug.simon@oracle.com>
parents: 21936
diff changeset
227 ((test ! -d .$(SERVICES_INF) || cp -r .$(SERVICES_INF) $(abspath $(2))) && \\
21943
31be1c8f4905 switched to use of simple makefile assignment in jvmci.make and removed unnecessary semicolons
Doug Simon <doug.simon@oracle.com>
parents: 21939
diff changeset
228 (test ! -d .$(OPTIONS_INF) || cp -r .$(OPTIONS_INF) $(abspath $(2))));
21911
899d7cadd0a1 Make jvmci.make quiet and use recipe for build and jar
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21888
diff changeset
229 $(QUIETLY) rm -r $(TMP);
21937
3a292e8b9e51 replaced Service marker interface with non-standard META-INF directory names to differentiate JVMCI providers from standard service providers
Doug Simon <doug.simon@oracle.com>
parents: 21936
diff changeset
230 $(QUIETLY) cp $(1) $(2)
21718
b5bbf03bc17a Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21717
diff changeset
231 endef
b5bbf03bc17a Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21717
diff changeset
232
21937
3a292e8b9e51 replaced Service marker interface with non-standard META-INF directory names to differentiate JVMCI providers from standard service providers
Doug Simon <doug.simon@oracle.com>
parents: 21936
diff changeset
233 # Calls $(JAVAC) with the boot class path $(JDK_BOOTCLASSPATH) and sources taken from the automatic variable $^
21917
0df6a0cb4b5f Cleanup code in mx_graal_makefile.py, add comments
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21916
diff changeset
234 # Arguments:
0df6a0cb4b5f Cleanup code in mx_graal_makefile.py, add comments
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21916
diff changeset
235 # 1: processorpath
0df6a0cb4b5f Cleanup code in mx_graal_makefile.py, add comments
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21916
diff changeset
236 # 2: classpath
0df6a0cb4b5f Cleanup code in mx_graal_makefile.py, add comments
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21916
diff changeset
237 # 3: resources to copy
0df6a0cb4b5f Cleanup code in mx_graal_makefile.py, add comments
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21916
diff changeset
238 # 4: target JAR file
21911
899d7cadd0a1 Make jvmci.make quiet and use recipe for build and jar
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21888
diff changeset
239 define build_and_jar
899d7cadd0a1 Make jvmci.make quiet and use recipe for build and jar
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21888
diff changeset
240 $(info Building $(4))
21912
1a6a520af3b5 jvmci.make put temp dirs into the target directory
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21911
diff changeset
241 $(eval TMP := $(shell mkdir -p $(TARGET) && mktemp -d $(TARGET)/tmp_XXXXX))
21937
3a292e8b9e51 replaced Service marker interface with non-standard META-INF directory names to differentiate JVMCI providers from standard service providers
Doug Simon <doug.simon@oracle.com>
parents: 21936
diff changeset
242 $(QUIETLY) $(JAVAC) -d $(TMP) -processorpath :$(1) -bootclasspath $(JDK_BOOTCLASSPATH) -cp :$(2) $(filter %.java,$^)
3a292e8b9e51 replaced Service marker interface with non-standard META-INF directory names to differentiate JVMCI providers from standard service providers
Doug Simon <doug.simon@oracle.com>
parents: 21936
diff changeset
243 $(QUIETLY) test "$(3)" = "" || cp -r $(3) $(TMP)
3a292e8b9e51 replaced Service marker interface with non-standard META-INF directory names to differentiate JVMCI providers from standard service providers
Doug Simon <doug.simon@oracle.com>
parents: 21936
diff changeset
244 $(QUIETLY) $(call process_options,$(TMP))
3a292e8b9e51 replaced Service marker interface with non-standard META-INF directory names to differentiate JVMCI providers from standard service providers
Doug Simon <doug.simon@oracle.com>
parents: 21936
diff changeset
245 $(QUIETLY) $(call process_providers,$(TMP))
21911
899d7cadd0a1 Make jvmci.make quiet and use recipe for build and jar
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21888
diff changeset
246 $(QUIETLY) mkdir -p $(shell dirname $(4))
21992
72129dd49bc0 jvmci.make do not compress jars
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21985
diff changeset
247 $(QUIETLY) $(JAR) -0cf $(4) -C $(TMP) .
21937
3a292e8b9e51 replaced Service marker interface with non-standard META-INF directory names to differentiate JVMCI providers from standard service providers
Doug Simon <doug.simon@oracle.com>
parents: 21936
diff changeset
248 $(QUIETLY) rm -r $(TMP)
21911
899d7cadd0a1 Make jvmci.make quiet and use recipe for build and jar
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21888
diff changeset
249 endef
21718
b5bbf03bc17a Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21717
diff changeset
250
21939
eac31af360db verify that only existing JVMCI services and options are exported in make/defs.make
Doug Simon <doug.simon@oracle.com>
parents: 21938
diff changeset
251 # Verifies that make/defs.make contains an appropriate line for each JVMCI service or option
eac31af360db verify that only existing JVMCI services and options are exported in make/defs.make
Doug Simon <doug.simon@oracle.com>
parents: 21938
diff changeset
252 # and that only existing JVMCI services and options are exported.
21947
e701664f4168 Add parameter description to jvmci.make
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21919
diff changeset
253 # Arguments:
21939
eac31af360db verify that only existing JVMCI services and options are exported in make/defs.make
Doug Simon <doug.simon@oracle.com>
parents: 21938
diff changeset
254 # 1: list of service or option files
21978
f0a982a28944 relax verify_defs_make in jvmci.make for conditional exports
Doug Simon <doug.simon@oracle.com>
parents: 21971
diff changeset
255 # 2: variable name for directory of service or option files
21937
3a292e8b9e51 replaced Service marker interface with non-standard META-INF directory names to differentiate JVMCI providers from standard service providers
Doug Simon <doug.simon@oracle.com>
parents: 21936
diff changeset
256 define verify_defs_make
21943
31be1c8f4905 switched to use of simple makefile assignment in jvmci.make and removed unnecessary semicolons
Doug Simon <doug.simon@oracle.com>
parents: 21939
diff changeset
257 $(eval defs := make/defs.make)
21978
f0a982a28944 relax verify_defs_make in jvmci.make for conditional exports
Doug Simon <doug.simon@oracle.com>
parents: 21971
diff changeset
258 $(eval uncondPattern := EXPORT_LIST += $$$$($(2))/)
f0a982a28944 relax verify_defs_make in jvmci.make for conditional exports
Doug Simon <doug.simon@oracle.com>
parents: 21971
diff changeset
259 $(eval condPattern := CONDITIONAL_EXPORT_LIST += $$$$($(2))/)
f0a982a28944 relax verify_defs_make in jvmci.make for conditional exports
Doug Simon <doug.simon@oracle.com>
parents: 21971
diff changeset
260 $(eval unconditionalExports := $(shell grep '^EXPORT_LIST += $$($2)' make/defs.make | sed 's:.*($(2))/::g'))
f0a982a28944 relax verify_defs_make in jvmci.make for conditional exports
Doug Simon <doug.simon@oracle.com>
parents: 21971
diff changeset
261 $(eval conditionalExports := $(shell grep '^CONDITIONAL_EXPORT_LIST += $$($2)' make/defs.make | sed 's:.*($(2))/::g'))
f0a982a28944 relax verify_defs_make in jvmci.make for conditional exports
Doug Simon <doug.simon@oracle.com>
parents: 21971
diff changeset
262 $(eval allExports := $(unconditionalExports) $(conditionalExports))
f0a982a28944 relax verify_defs_make in jvmci.make for conditional exports
Doug Simon <doug.simon@oracle.com>
parents: 21971
diff changeset
263 $(foreach file,$(1),$(if $(findstring $(file),$(allExports)), ,$(error "Line matching '$(uncondPattern)$(file)' or '$(condPattern)$(file)' not found in $(defs)")))
f0a982a28944 relax verify_defs_make in jvmci.make for conditional exports
Doug Simon <doug.simon@oracle.com>
parents: 21971
diff changeset
264 $(foreach export,$(unconditionalExports),$(if $(findstring $(export),$(1)), ,$(error "The line '$(uncondPattern)$(export)' should not be in $(defs)")))
21919
62da3906ab7f Do not make builds in jvmci.make
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21917
diff changeset
265 endef
62da3906ab7f Do not make builds in jvmci.make
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21917
diff changeset
266
21488
6420ac0cbe3c Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff changeset
267 all: default
21944
b121c00d3c4c fixed subtle makefile evaluation order issue in the verification that only existing JVMCI services and options are exported in make/defs.make
Doug Simon <doug.simon@oracle.com>
parents: 21943
diff changeset
268 \t$(info Put $(EXPORTED_FILES) into SHARED_DIR $(SHARED_DIR))
21985
ba769b2ee8fa jvmci.make $(shell ...) is always quiet
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21978
diff changeset
269 \t$(shell mkdir -p $(SHARED_DIR))
21944
b121c00d3c4c fixed subtle makefile evaluation order issue in the verification that only existing JVMCI services and options are exported in make/defs.make
Doug Simon <doug.simon@oracle.com>
parents: 21943
diff changeset
270 \t$(foreach export,$(EXPORTED_FILES),$(call extract,$(export),$(SHARED_DIR)))
21488
6420ac0cbe3c Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff changeset
271
21718
b5bbf03bc17a Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21717
diff changeset
272 export: all
21978
f0a982a28944 relax verify_defs_make in jvmci.make for conditional exports
Doug Simon <doug.simon@oracle.com>
parents: 21971
diff changeset
273 \t$(call verify_defs_make,$(notdir $(wildcard $(SHARED_DIR)/jvmci.services/*)),EXPORT_JRE_LIB_JVMCI_SERVICES_DIR)
f0a982a28944 relax verify_defs_make in jvmci.make for conditional exports
Doug Simon <doug.simon@oracle.com>
parents: 21971
diff changeset
274 \t$(call verify_defs_make,$(notdir $(wildcard $(SHARED_DIR)/jvmci.options/*)),EXPORT_JRE_LIB_JVMCI_OPTIONS_DIR)
21718
b5bbf03bc17a Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21717
diff changeset
275 .PHONY: export
21488
6420ac0cbe3c Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff changeset
276
21955
3ce35131bff2 Introduce clean target in jvmci.make
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21949
diff changeset
277 clean:
3ce35131bff2 Introduce clean target in jvmci.make
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21949
diff changeset
278 \t$(QUIETLY) rm $(JARS) 2> /dev/null || true
3ce35131bff2 Introduce clean target in jvmci.make
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21949
diff changeset
279 \t$(QUIETLY) rmdir -p $(dir $(JARS)) 2> /dev/null || true
3ce35131bff2 Introduce clean target in jvmci.make
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21949
diff changeset
280 .PHONY: export clean
3ce35131bff2 Introduce clean target in jvmci.make
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21949
diff changeset
281
21488
6420ac0cbe3c Add Makefile generator for building graal without mx
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
diff changeset
282 """)
21717
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
283 s = mx.suite("graal")
21790
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21740
diff changeset
284 dists = []
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21740
diff changeset
285 ap = []
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21740
diff changeset
286 projects = []
21717
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
287 for d in s.dists:
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
288 if d.name in selectedDists:
21790
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21740
diff changeset
289 update_list(dists, d.get_dist_deps(True, True))
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21740
diff changeset
290 update_list(projects, d.sorted_deps(includeLibs=False, transitive=True))
21740
6c3c21d9b5ef Add -m switch to mx build, which builds/exports JVMCI with the make/jvmci.make file
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21739
diff changeset
291
21717
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
292 for p in projects:
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
293 deps = p.all_deps([], False, includeSelf=True, includeJreLibs=False, includeAnnotationProcessors=True)
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
294 for d in deps:
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
295 if d.definedAnnotationProcessorsDist != None:
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
296 apd = d.definedAnnotationProcessorsDist
21790
6db6070d30b9 Make jvmci.make stable; add header for building the jvmci.make; default to use the jvmci.make file when running mx.build
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21740
diff changeset
297 update_list(ap, [apd])
21718
b5bbf03bc17a Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21717
diff changeset
298
21717
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
299 if len(dists) > 0:
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
300 mf.add_definition(jdkBootClassPathVariableName + " = " + bootClassPath)
21917
0df6a0cb4b5f Cleanup code in mx_graal_makefile.py, add comments
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21916
diff changeset
301 for d in ap: make_dist_rule(d, mf)
0df6a0cb4b5f Cleanup code in mx_graal_makefile.py, add comments
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21916
diff changeset
302 for d in dists: make_dist_rule(d, mf)
21955
3ce35131bff2 Introduce clean target in jvmci.make
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21949
diff changeset
303 mf.add_definition("DISTRIBUTIONS = " + " ".join([short_dist_name(d.name) for d in dists+ap]))
3ce35131bff2 Introduce clean target in jvmci.make
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21949
diff changeset
304 mf.add_rule("default: $({}_JAR)\n.PHONY: default\n".format("_JAR) $(".join([short_dist_name(d.name) for d in dists])))
21717
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
305 return True
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
306 else:
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
307 for d in dists:
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
308 selectedDists.remove(d.name)
a3315bce5192 Change makefile generator to produce human readable code (JBS:GRAAL-52)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21504
diff changeset
309 print "Distribution(s) '" + "', '".join(selectedDists) + "' does not exist."