1 #
   2 # Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
   3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4 #
   5 # This code is free software; you can redistribute it and/or modify it
   6 # under the terms of the GNU General Public License version 2 only, as
   7 # published by the Free Software Foundation.  Oracle designates this
   8 # particular file as subject to the "Classpath" exception as provided
   9 # by Oracle in the LICENSE file that accompanied this code.
  10 #
  11 # This code is distributed in the hope that it will be useful, but WITHOUT
  12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14 # version 2 for more details (a copy is included in the LICENSE file that
  15 # accompanied this code).
  16 #
  17 # You should have received a copy of the GNU General Public License version
  18 # 2 along with this work; if not, write to the Free Software Foundation,
  19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20 #
  21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22 # or visit www.oracle.com if you need additional information or have any
  23 # questions.
  24 #
  25 
  26 GENSRC_DIR := $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)
  27 SRC_DIR := $(TOPDIR)/src/$(MODULE)/share/classes
  28 
  29 ################################################################################
  30 
  31 PROC_SRC_SUBDIRS := \
  32     org.graalvm.compiler.asm.amd64 \
  33     org.graalvm.compiler.code \
  34     org.graalvm.compiler.core \
  35     org.graalvm.compiler.core.aarch64 \
  36     org.graalvm.compiler.core.amd64 \
  37     org.graalvm.compiler.core.common \
  38     org.graalvm.compiler.debug \
  39     org.graalvm.compiler.hotspot \
  40     org.graalvm.compiler.hotspot.aarch64 \
  41     org.graalvm.compiler.hotspot.amd64 \
  42     org.graalvm.compiler.graph \
  43     org.graalvm.compiler.java \
  44     org.graalvm.compiler.lir \
  45     org.graalvm.compiler.lir.amd64 \
  46     org.graalvm.compiler.loop \
  47     org.graalvm.compiler.loop.phases \
  48     org.graalvm.compiler.nodes \
  49     org.graalvm.compiler.replacements \
  50     org.graalvm.compiler.replacements.aarch64 \
  51     org.graalvm.compiler.replacements.amd64 \
  52     org.graalvm.compiler.phases \
  53     org.graalvm.compiler.phases.common \
  54     org.graalvm.compiler.printer \
  55     org.graalvm.compiler.virtual \
  56     #
  57 
  58 PROC_SRC_DIRS := $(patsubst %, $(SRC_DIR)/%/src, $(PROC_SRC_SUBDIRS))
  59 
  60 PROC_SRCS := $(filter %.java, $(call FindFiles, $(PROC_SRC_DIRS)))
  61 
  62 ALL_SRC_DIRS := $(SRC_DIR) $(wildcard $(SRC_DIR)/*/src)
  63 SOURCEPATH := $(call PathList, $(ALL_SRC_DIRS))
  64 
  65 PROCESSOR_JARS := \
  66     $(BUILDTOOLS_OUTPUTDIR)/jdk.vm.compiler.match.processor.jar \
  67     $(BUILDTOOLS_OUTPUTDIR)/jdk.vm.compiler.nodeinfo.processor.jar \
  68     $(BUILDTOOLS_OUTPUTDIR)/jdk.vm.compiler.options.processor.jar \
  69     $(BUILDTOOLS_OUTPUTDIR)/jdk.vm.compiler.replacements.verifier.jar \
  70     $(BUILDTOOLS_OUTPUTDIR)/jdk.vm.compiler.serviceprovider.processor.jar \
  71     #
  72 PROCESSOR_PATH := $(call PathList, $(PROCESSOR_JARS))
  73 
  74 ADD_EXPORTS := \
  75     --add-modules jdk.internal.vm.ci \
  76     --add-exports jdk.internal.vm.ci/jdk.vm.ci.aarch64=jdk.internal.vm.compiler \
  77     --add-exports jdk.internal.vm.ci/jdk.vm.ci.amd64=jdk.internal.vm.compiler \
  78     --add-exports jdk.internal.vm.ci/jdk.vm.ci.code=jdk.internal.vm.compiler \
  79     --add-exports jdk.internal.vm.ci/jdk.vm.ci.code.site=jdk.internal.vm.compiler \
  80     --add-exports jdk.internal.vm.ci/jdk.vm.ci.code.stack=jdk.internal.vm.compiler \
  81     --add-exports jdk.internal.vm.ci/jdk.vm.ci.common=jdk.internal.vm.compiler \
  82     --add-exports jdk.internal.vm.ci/jdk.vm.ci.hotspot=jdk.internal.vm.compiler \
  83     --add-exports jdk.internal.vm.ci/jdk.vm.ci.hotspot.aarch64=jdk.internal.vm.compiler \
  84     --add-exports jdk.internal.vm.ci/jdk.vm.ci.hotspot.amd64=jdk.internal.vm.compiler \
  85     --add-exports jdk.internal.vm.ci/jdk.vm.ci.hotspot.events=jdk.internal.vm.compiler \
  86     --add-exports jdk.internal.vm.ci/jdk.vm.ci.hotspotvmconfig=jdk.internal.vm.compiler \
  87     --add-exports jdk.internal.vm.ci/jdk.vm.ci.inittimer=jdk.internal.vm.compiler \
  88     --add-exports jdk.internal.vm.ci/jdk.vm.ci.meta=jdk.internal.vm.compiler \
  89     --add-exports jdk.internal.vm.ci/jdk.vm.ci.runtime=jdk.internal.vm.compiler \
  90     --add-exports jdk.internal.vm.ci/jdk.vm.ci.services=jdk.internal.vm.compiler \
  91     #
  92 
  93 $(GENSRC_DIR)/_gensrc_proc_done: $(PROC_SRCS) $(PROCESSOR_JARS)
  94         $(call MakeDir, $(@D))
  95         $(eval $(call ListPathsSafely,PROC_SRCS,$(@D)/_gensrc_proc_files))
  96         $(JAVA) $(NEW_JAVAC) \
  97             -XDignore.symbol.file \
  98             --upgrade-module-path $(JDK_OUTPUTDIR)/modules --system none \
  99             $(ADD_EXPORTS) \
 100             -sourcepath $(SOURCEPATH) \
 101             -implicit:none \
 102             -proc:only \
 103             -processorpath $(PROCESSOR_PATH) \
 104             -d $(GENSRC_DIR) \
 105             -s $(GENSRC_DIR) \
 106             @$(@D)/_gensrc_proc_files
 107         $(TOUCH) $@
 108 
 109 TARGETS += $(GENSRC_DIR)/_gensrc_proc_done
 110 
 111 ################################################################################
 112 
 113 $(GENSRC_DIR)/module-info.java.extra: $(GENSRC_DIR)/_gensrc_proc_done
 114         $(ECHO) "" > $@;
 115         ($(CD) $(GENSRC_DIR)/META-INF/providers && \
 116             p=""; \
 117             impl=""; \
 118             for i in $$($(GREP) '^' * | $(SORT) -t ':' -k 2 | $(SED) 's/:.*//'); do \
 119               c=$$($(CAT) $$i | $(TR) -d '\n\r'); \
 120               if test x$$p != x$$c; then \
 121                 if test x$$p != x; then \
 122                   $(ECHO) "    ;" >> $@; \
 123                 fi; \
 124                 $(ECHO) "provides $$c with" >> $@; \
 125                 p=$$c; \
 126                 impl=""; \
 127               fi; \
 128               if test x$$impl != x; then \
 129                 $(ECHO) "  , $$i" >> $@; \
 130               else \
 131                 $(ECHO) "    $$i" >> $@; \
 132               fi; \
 133               impl=$$i; \
 134             done); \
 135             $(ECHO) "    ;" >> $@; \
 136         $(ECHO) "uses org.graalvm.compiler.options.OptionDescriptors;" >> $@; \
 137         $(ECHO) "provides org.graalvm.compiler.options.OptionDescriptors with" >> $@; \
 138         impl=""; \
 139         for i in $$($(FIND) $(GENSRC_DIR) -name '*_OptionDescriptors.java' | $(SORT)); do \
 140             c=$$($(ECHO) $$i | $(SED) 's:.*/jdk\.internal\.vm\.compiler/\(.*\)\.java:\1:' | $(TR) '/' '.'); \
 141             if test x$$impl != x; then \
 142               $(ECHO) "  , $$c" >> $@; \
 143             else \
 144               $(ECHO) "    $$c" >> $@; \
 145             fi; \
 146             impl=$$c; \
 147         done; \
 148         $(ECHO) "    ;" >> $@;
 149 
 150 TARGETS += $(GENSRC_DIR)/module-info.java.extra