8157348: Build fails with certain source configurations
authorerikj
Fri, 20 May 2016 10:25:40 +0200
changeset 37978 2614022b9fa5
parent 37977 2d1762634bf1
child 37979 42ee4e537363
8157348: Build fails with certain source configurations Reviewed-by: tbell
common/autoconf/configure.ac
common/autoconf/generated-configure.sh
common/autoconf/hotspot.m4
common/autoconf/spec.gmk.in
make/GensrcModuleInfo.gmk
make/Images.gmk
--- a/common/autoconf/configure.ac	Thu May 19 19:45:47 2016 +0000
+++ b/common/autoconf/configure.ac	Fri May 20 10:25:40 2016 +0200
@@ -207,6 +207,7 @@
 # Need toolchain to setup dtrace
 HOTSPOT_SETUP_DTRACE
 HOTSPOT_SETUP_JVM_FEATURES
+HOTSPOT_ENABLE_DISABLE_GTEST
 
 ###############################################################################
 #
--- a/common/autoconf/generated-configure.sh	Thu May 19 19:45:47 2016 +0000
+++ b/common/autoconf/generated-configure.sh	Fri May 20 10:25:40 2016 +0200
@@ -688,6 +688,7 @@
 STATIC_CXX_SETTING
 FIXPATH_DETACH_FLAG
 FIXPATH
+BUILD_GTEST
 VALID_JVM_FEATURES
 JVM_FEATURES_custom
 JVM_FEATURES_zeroshark
@@ -1198,6 +1199,7 @@
 enable_dtrace
 with_jvm_features
 with_jvm_interpreter
+enable_hotspot_gtest
 with_stdc__lib
 with_msvcr_dll
 with_msvcp_dll
@@ -1992,6 +1994,7 @@
   --enable-dtrace[=yes/no/auto]
                           enable dtrace. Default is auto, where dtrace is
                           enabled if all dependencies are present.
+  --disable-hotspot-gtest Disables building of the Hotspot unit tests
   --disable-freetype-bundling
                           disable bundling of the freetype library with the
                           build result [enabled on Windows or when using
@@ -4298,6 +4301,11 @@
 #
 
 
+################################################################################
+# Check if gtest should be built
+#
+
+
 #
 # Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -5072,7 +5080,7 @@
 #CUSTOM_AUTOCONF_INCLUDE
 
 # Do not change or remove the following line, it is needed for consistency checks:
-DATE_WHEN_GENERATED=1463500649
+DATE_WHEN_GENERATED=1463732692
 
 ###############################################################################
 #
@@ -53409,6 +53417,49 @@
 
 
 
+  # Check whether --enable-hotspot-gtest was given.
+if test "${enable_hotspot_gtest+set}" = set; then :
+  enableval=$enable_hotspot_gtest;
+fi
+
+
+  if test -e "$HOTSPOT_TOPDIR/test/native"; then
+    GTEST_DIR_EXISTS="true"
+  else
+    GTEST_DIR_EXISTS="false"
+  fi
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if Hotspot gtest unit tests should be built" >&5
+$as_echo_n "checking if Hotspot gtest unit tests should be built... " >&6; }
+  if test "x$enable_hotspot_gtest" = "xyes"; then
+    if test "x$GTEST_DIR_EXISTS" = "xtrue"; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, forced" >&5
+$as_echo "yes, forced" >&6; }
+      BUILD_GTEST="true"
+    else
+      as_fn_error $? "Cannot build gtest without the test source" "$LINENO" 5
+    fi
+  elif test "x$enable_hotspot_gtest" = "xno"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, forced" >&5
+$as_echo "no, forced" >&6; }
+    BUILD_GTEST="false"
+  elif test "x$enable_hotspot_gtest" = "x"; then
+    if test "x$GTEST_DIR_EXISTS" = "xtrue"; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+      BUILD_GTEST="true"
+    else
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+      BUILD_GTEST="false"
+    fi
+  else
+    as_fn_error $? "--enable-gtest must be either yes or no" "$LINENO" 5
+  fi
+
+
+
+
 ###############################################################################
 #
 # Check dependencies for external and internal libraries.
--- a/common/autoconf/hotspot.m4	Thu May 19 19:45:47 2016 +0000
+++ b/common/autoconf/hotspot.m4	Fri May 20 10:25:40 2016 +0200
@@ -306,3 +306,43 @@
     fi
   done
 ])
+
+################################################################################
+# Check if gtest should be built
+#
+AC_DEFUN_ONCE([HOTSPOT_ENABLE_DISABLE_GTEST],
+[
+  AC_ARG_ENABLE([hotspot-gtest], [AS_HELP_STRING([--disable-hotspot-gtest],
+      [Disables building of the Hotspot unit tests])])
+
+  if test -e "$HOTSPOT_TOPDIR/test/native"; then
+    GTEST_DIR_EXISTS="true"
+  else
+    GTEST_DIR_EXISTS="false"
+  fi
+
+  AC_MSG_CHECKING([if Hotspot gtest unit tests should be built])
+  if test "x$enable_hotspot_gtest" = "xyes"; then
+    if test "x$GTEST_DIR_EXISTS" = "xtrue"; then
+      AC_MSG_RESULT([yes, forced])
+      BUILD_GTEST="true"
+    else
+      AC_MSG_ERROR([Cannot build gtest without the test source])
+    fi
+  elif test "x$enable_hotspot_gtest" = "xno"; then
+    AC_MSG_RESULT([no, forced])
+    BUILD_GTEST="false"
+  elif test "x$enable_hotspot_gtest" = "x"; then
+    if test "x$GTEST_DIR_EXISTS" = "xtrue"; then
+      AC_MSG_RESULT([yes])
+      BUILD_GTEST="true"
+    else
+      AC_MSG_RESULT([no])
+      BUILD_GTEST="false"
+    fi
+  else
+    AC_MSG_ERROR([--enable-gtest must be either yes or no])
+  fi
+
+  AC_SUBST(BUILD_GTEST)
+])
--- a/common/autoconf/spec.gmk.in	Thu May 19 19:45:47 2016 +0000
+++ b/common/autoconf/spec.gmk.in	Fri May 20 10:25:40 2016 +0200
@@ -237,7 +237,7 @@
 VALID_JVM_VARIANTS := @VALID_JVM_VARIANTS@
 
 # Control wether Hotspot builds gtest tests
-BUILD_GTEST := true
+BUILD_GTEST := @BUILD_GTEST@
 
 # Control use of precompiled header in hotspot libjvm build
 USE_PRECOMPILED_HEADER := @USE_PRECOMPILED_HEADER@
--- a/make/GensrcModuleInfo.gmk	Thu May 19 19:45:47 2016 +0000
+++ b/make/GensrcModuleInfo.gmk	Fri May 20 10:25:40 2016 +0200
@@ -85,21 +85,29 @@
   MODS_REST := $(filter-out $(MODS_QUALIFIED_EXPORTS), $(MOD_FILE_CONTENTS))
 
   # Filter the contents for modules that are actually being built
-  MODULES_FILTER := $(addprefix %/, $(addsuffix ;, $(ALL_MODULES)))
-  MODIFICATIONS := $(filter $(MODULES_FILTER), $(MODS_QUALIFIED_EXPORTS)) \
+  ALL_MODULES_FILTER := $(addprefix %/, $(addsuffix ;, $(ALL_MODULES)))
+  MODIFICATIONS := $(filter $(ALL_MODULES_FILTER), $(MODS_QUALIFIED_EXPORTS)) \
       $(MODS_REST)
 
+  # Returns non empty if the package exists in the current module
+  # Param 1 - Name of package with dots
+  PackageExists = \
+      $(strip $(wildcard $(addsuffix $(subst .,/,/$(strip $1)), \
+          $(MODULE_CLASSES_DIRS))))
+
   # Convert the modification lines into arguments for the modification tool.
   # Filter out modifications for non existing to-modules.
   $(foreach line, $(MODIFICATIONS), \
     $(eval split_line := $(subst /,$(SPACE),$(line))) \
     $(eval command := $(word 1, $(split_line))) \
     $(eval package := $(patsubst %;,%,$(word 2, $(split_line)))) \
-    $(eval to_module := $(patsubst %;,%,$(word 4, $(split_line)))) \
-    $(if $(to_module), \
-      $(eval ARGS += -$(command) $(package)/$(to_module)) \
-    , \
-      $(eval ARGS += -$(command) $(package)) \
+    $(if $(call PackageExists, $(package)), \
+      $(eval to_module := $(patsubst %;,%,$(word 4, $(split_line)))) \
+      $(if $(to_module), \
+        $(eval ARGS += -$(command) $(package)/$(to_module)) \
+      , \
+        $(eval ARGS += -$(command) $(package)) \
+      ) \
     ) \
   )
 
--- a/make/Images.gmk	Thu May 19 19:45:47 2016 +0000
+++ b/make/Images.gmk	Fri May 20 10:25:40 2016 +0200
@@ -43,8 +43,9 @@
 
 $(eval $(call ReadImportMetaData))
 
-JRE_MODULES += $(filter-out $(MODULES_FILTER), $(BOOT_MODULES) $(PLATFORM_MODULES) $(JRE_TOOL_MODULES))
-JDK_MODULES += $(filter-out $(MODULES_FILTER), $(ALL_MODULES))
+JRE_MODULES += $(filter $(ALL_MODULES), $(BOOT_MODULES) \
+    $(PLATFORM_MODULES) $(JRE_TOOL_MODULES))
+JDK_MODULES += $(ALL_MODULES)
 
 # Compact builds have additional modules
 COMPACT1_EXTRA_MODULES := jdk.localedata jdk.crypto.pkcs11 jdk.crypto.ec