make/GensrcModuleInfo.gmk
author dcubed
Thu, 07 Apr 2016 12:57:15 -0700
changeset 37524 76baeda6e93a
parent 36506 17612cee3530
child 37030 e047c2f3f510
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36506
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
     1
#
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
     2
# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
     3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
     4
#
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
     5
# This code is free software; you can redistribute it and/or modify it
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
     6
# under the terms of the GNU General Public License version 2 only, as
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
     7
# published by the Free Software Foundation.  Oracle designates this
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
     8
# particular file as subject to the "Classpath" exception as provided
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
     9
# by Oracle in the LICENSE file that accompanied this code.
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    10
#
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    11
# This code is distributed in the hope that it will be useful, but WITHOUT
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    13
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    14
# version 2 for more details (a copy is included in the LICENSE file that
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    15
# accompanied this code).
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    16
#
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    17
# You should have received a copy of the GNU General Public License version
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    18
# 2 along with this work; if not, write to the Free Software Foundation,
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    20
#
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    22
# or visit www.oracle.com if you need additional information or have any
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    23
# questions.
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    24
#
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    25
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    26
################################################################################
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    27
# This file makes modifications to module-info.java files based on the build
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    28
# configuration.
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    29
#
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    30
# Depending on build platform, imported modules and optional parts of the build
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    31
# being active, some modules need to have extra exports, provides or uses
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    32
# declarations added to them. These optional extras are defined in .extra files:
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    33
#
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    34
# src/<module>/<share,platform>/classes/module-info.java.extra
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    35
#
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    36
# The contents of the .extra files are simply extra lines that could fit into
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    37
# the module-info file.
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    38
#
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    39
# This makefile is called once for each from-module with the variable
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    40
# MODULE naming the from-module.
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    41
#
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    42
# The modified module-info.java files are put in the gensrc directory where
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    43
# they will automatically override the static versions in the src tree.
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    44
#
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    45
################################################################################
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    46
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    47
default: all
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    48
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    49
include $(SPEC)
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    50
include MakeBase.gmk
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    51
include Modules.gmk
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    52
#include TextFileProcessing.gmk
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    53
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    54
################################################################################
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    55
# Define this here since jdk/make/Tools.gmk cannot be included from the top
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    56
# make directory. Should probably move some tools away from the jdk repo.
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    57
TOOL_GENMODULEINFOSOURCE = $(JAVA_SMALL) \
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    58
    $(INTERIM_LANGTOOLS_ARGS) \
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    59
    -cp "$(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes" \
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    60
    build.tools.module.GenModuleInfoSource
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    61
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    62
################################################################################
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    63
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    64
# Name of data file. Keep module-info.java.ext until javafx has changed.
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    65
MOD_FILENAME := module-info.java.extra module-info.java.ext
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    66
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    67
# List all the possible sub directories inside a module source directory where
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    68
# data might be stored.
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    69
CLASSES_SUBDIRS += $(OPENJDK_TARGET_OS)/classes
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    70
ifneq ($(OPENJDK_TARGET_OS), $(OPENJDK_TARGET_OS_TYPE))
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    71
  CLASSES_SUBDIRS += $(OPENJDK_TARGET_OS_TYPE)/classes
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    72
endif
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    73
CLASSES_SUBDIRS += share/classes
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    74
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    75
# TODO: When the deploy build is better integrated, this will get added globally
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    76
# but for now need to add it here.
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    77
ifeq ($(BUILD_DEPLOY), true)
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    78
  ALL_TOP_SRC_DIRS += $(DEPLOY_TOPDIR)/src
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    79
endif
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    80
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    81
# Construct all possible src directories for the module.
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    82
MODULE_CLASSES_DIRS := $(strip \
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    83
    $(foreach sub, $(CLASSES_SUBDIRS), \
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    84
        $(addsuffix /$(MODULE)/$(sub), $(ALL_TOP_SRC_DIRS))) \
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    85
    $(addsuffix /$(MODULE), $(IMPORT_MODULES_SRC)))
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    86
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    87
# Find all the .extra files in the src dirs.
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    88
MOD_FILES := $(wildcard $(foreach f, $(MOD_FILENAME), $(addsuffix /$(f), \
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    89
    $(MODULE_CLASSES_DIRS))))
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    90
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    91
ifneq ($(MOD_FILES), )
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    92
  # Only make this call if modification files are found for this module
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    93
  ALL_MODULES := $(call FindAllModules)
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    94
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    95
  # Read the contents of all the files into a variable. Replace space with / to
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    96
  # let space represent new lines in the variable as $(shell) normalizes all
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    97
  # whitespace.
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    98
  $(foreach f, $(MOD_FILES), \
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
    99
    $(eval MOD_FILE_CONTENTS += $(shell $(GREP) -v ".\*" $f | $(TR) ' ' '/')))
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   100
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   101
  # Filter the contents for modules that are actually being built
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   102
  MODULES_FILTER := $(addprefix %/, $(addsuffix ;, $(ALL_MODULES)))
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   103
  MODULES_FILTER += provides%
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   104
  MODIFICATIONS := $(filter $(MODULES_FILTER), $(MOD_FILE_CONTENTS))
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   105
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   106
  # Convert the modification lines into arguments for the modification tool.
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   107
  # Filter out modifications for non existing to-modules.
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   108
  $(foreach line, $(MODIFICATIONS), \
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   109
    $(eval split_line := $(subst /,$(SPACE),$(line))) \
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   110
    $(eval command := $(word 1, $(split_line))) \
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   111
    $(eval package := $(word 2, $(split_line))) \
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   112
    $(eval to_module := $(patsubst %;,%,$(word 4, $(split_line)))) \
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   113
    $(eval ARGS += -$(command) $(package)/$(to_module)))
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   114
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   115
  ifneq ($(ARGS), )
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   116
    $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/module-info.java: \
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   117
        $(firstword $(call FindAllModuleInfos, $(MODULE))) \
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   118
        $(BUILD_TOOLS_JDK) \
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   119
        $(call DependOnVariable, ARGS)
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   120
		$(MKDIR) -p $(@D)
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   121
		$(RM) $@ $@.tmp
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   122
		$(TOOL_GENMODULEINFOSOURCE) $(ARGS) -o $@.tmp $<
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   123
		$(MV) $@.tmp $@
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   124
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   125
    TARGETS += $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/module-info.java
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   126
  endif
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   127
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   128
# This doesn't work because javac only accepts one single exports line per
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   129
# exported package.
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   130
  # Restore the modifications to separate lines with spaces
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   131
#  MODIFICATIONS := $(subst /,$(SPACE),$(MODIFICATIONS))
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   132
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   133
#  ifneq ($(MODIFICATIONS), )
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   134
#    $(eval $(call SetupTextFileProcessing, PROCESS_MODULE_INFO, \
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   135
#        SOURCE_FILES := $(firstword $(call FindAllModuleInfos, $(MODULE))), \
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   136
#        OUTPUT_FILE := $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/module-info.java, \
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   137
#        REPLACEMENTS := } => $(MODIFICATIONS) }, \
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   138
#    ))
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   139
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   140
#    TARGETS += $(PROCESS_MODULE_INFO)
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   141
#  endif
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   142
endif
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   143
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   144
# If no modifications are found for this module, remove any module-info.java
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   145
# created by a previous build since that is no longer valid.
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   146
ifeq ($(MODIFICATIONS), )
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   147
  ifneq ($(wildcard $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/module-info.java), )
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   148
    $(shell $(RM) $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/module-info.java)
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   149
  endif
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   150
endif
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   151
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   152
################################################################################
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   153
17612cee3530 8142968: Module System implementation
alanb
parents:
diff changeset
   154
all: $(TARGETS)