1 #
   2 # Copyright (c) 2014, 2017, 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 # This must be the first rule
  27 default: all
  28 
  29 include $(SPEC)
  30 include MakeBase.gmk
  31 include JavaCompilation.gmk
  32 include SetupJavaCompilers.gmk
  33 include Modules.gmk
  34 
  35 ################################################################################
  36 # Generate interim versions of the module-info.java files for the interim
  37 # langtools modules. Each interim module has ".interim" added as suffix to the
  38 # original module name.
  39 
  40 INTERIM_MODULEINFO_PATTERN := \
  41     $(foreach m, $(INTERIM_LANGTOOLS_BASE_MODULES), -e 's/$m\([,; ]\)/$m.interim\1/g')
  42 
  43 $(BUILDTOOLS_OUTPUTDIR)/gensrc/%.interim/module-info.java: \
  44     $(TOPDIR)/src/%/share/classes/module-info.java
  45         $(call LogInfo, Generating module-info.java for $*.interim)
  46         $(call MakeDir, $(@D))
  47         $(SED) $(INTERIM_MODULEINFO_PATTERN) $< > $@
  48 
  49 TARGETS += $(patsubst %, $(BUILDTOOLS_OUTPUTDIR)/gensrc/%/module-info.java, \
  50     $(INTERIM_LANGTOOLS_MODULES))
  51 
  52 $(eval $(call SetupCopyFiles, COPY_PREVIEW_FEATURES, \
  53     FILES := $(TOPDIR)/src/java.base/share/classes/jdk/internal/PreviewFeature.java, \
  54     DEST := $(BUILDTOOLS_OUTPUTDIR)/gensrc/java.base.interim/jdk/internal/, \
  55 ))
  56 
  57 TARGETS += $(COPY_PREVIEW_FEATURES)
  58 
  59 ################################################################################
  60 # Setup the rules to build interim langtools, which is compiled by the boot
  61 # javac and can be run on the boot jdk. This will be used to compile the rest of
  62 # the product. Each module is compiled separately because a multi module setup
  63 # would require the source files to be copied into directories named after the
  64 # actual interim modules.
  65 
  66 # Param 1 - Name of module to compile
  67 define SetupInterimModule
  68   $$(eval $$(call SetupJavaCompilation, BUILD_$1.interim, \
  69       SETUP := BOOT_JAVAC, \
  70       DISABLE_SJAVAC := true, \
  71       SRC := $(BUILDTOOLS_OUTPUTDIR)/gensrc/$1.interim \
  72           $$(wildcard $(SUPPORT_OUTPUTDIR)/gensrc/$1) \
  73           $(TOPDIR)/src/$1/share/classes, \
  74       EXCLUDES := sun, \
  75       EXCLUDE_FILES := $(TOPDIR)/src/$1/share/classes/module-info.java \
  76           Standard.java, \
  77       EXTRA_FILES := $(BUILDTOOLS_OUTPUTDIR)/gensrc/$1.interim/module-info.java, \
  78       COPY := .gif .png .xml .css .js javax.tools.JavaCompilerTool, \
  79       BIN := $(BUILDTOOLS_OUTPUTDIR)/interim_langtools_modules/$1.interim, \
  80       ADD_JAVAC_FLAGS := --module-path $(BUILDTOOLS_OUTPUTDIR)/interim_langtools_modules \
  81           $$(INTERIM_LANGTOOLS_ADD_EXPORTS) \
  82           --patch-module java.base=$(BUILDTOOLS_OUTPUTDIR)/gensrc/java.base.interim \
  83           --add-exports java.base/jdk.internal=java.compiler.interim \
  84           --add-exports java.base/jdk.internal=jdk.compiler.interim \
  85           -Xlint:-module, \
  86   ))
  87 
  88   $1_DEPS_INTERIM := $$(addsuffix .interim, $$(filter \
  89       $$(INTERIM_LANGTOOLS_BASE_MODULES), $$(call FindTransitiveDepsForModule, $1)))
  90 
  91   $$(BUILD_$1.interim): $$(foreach d, $$($1_DEPS_INTERIM), $$(BUILD_$$d)) $(COPY_PREVIEW_FEATURES)
  92 
  93   TARGETS += $$(BUILD_$1.interim)
  94 endef
  95 
  96 $(foreach m, $(INTERIM_LANGTOOLS_BASE_MODULES), \
  97   $(eval $(call SetupInterimModule,$m)) \
  98 )
  99 
 100 ################################################################################
 101 
 102 all: $(TARGETS)