8154841: Let different Jib profiles have different default make targets
authorerikj
Wed, 27 Apr 2016 14:30:32 +0200
changeset 37649 3809534d4531
parent 37646 84aba7335005
child 37650 ef6c24163cb2
8154841: Let different Jib profiles have different default make targets Reviewed-by: dholmes, tbell
common/conf/jib-profiles.js
make/Init.gmk
make/Jprt.gmk
make/Main.gmk
--- a/common/conf/jib-profiles.js	Wed Jul 05 21:38:12 2017 +0200
+++ b/common/conf/jib-profiles.js	Wed Apr 27 14:30:32 2016 +0200
@@ -212,14 +212,17 @@
  * @returns Common values
  */
 var getJibProfilesCommon = function (input) {
-    var common = {
-        dependencies: ["boot_jdk", "gnumake", "jtreg"],
-        configure_args: ["--with-default-make-target=all", "--enable-jtreg-failure-handler"],
-        configure_args_32bit: ["--with-target-bits=32", "--with-jvm-variants=client,server"],
-        configure_args_debug: ["--enable-debug"],
-        configure_args_slowdebug: ["--with-debug-level=slowdebug"],
-        organization: "jpg.infra.builddeps"
-    };
+    var common = {};
+
+    common.dependencies = ["boot_jdk", "gnumake", "jtreg"],
+    common.default_make_targets = ["product-images", "test-image"],
+    common.default_make_targets_debug = common.default_make_targets;
+    common.default_make_targets_slowdebug = common.default_make_targets;
+    common.configure_args = ["--enable-jtreg-failure-handler"],
+    common.configure_args_32bit = ["--with-target-bits=32", "--with-jvm-variants=client,server"],
+    common.configure_args_debug = ["--enable-debug"],
+    common.configure_args_slowdebug = ["--with-debug-level=slowdebug"],
+    common.organization = "jpg.infra.builddeps"
 
     return common;
 };
@@ -241,8 +244,8 @@
             target_os: "linux",
             target_cpu: "x64",
             dependencies: concat(common.dependencies, "devkit"),
-	    configure_args: concat(common.configure_args, "--with-zlib=system"),
-            make_args: common.make_args
+            configure_args: concat(common.configure_args, "--with-zlib=system"),
+            default_make_targets: concat(common.default_make_targets, "docs-image")
         },
 
         "linux-x86": {
@@ -252,39 +255,39 @@
             dependencies: concat(common.dependencies, "devkit"),
             configure_args: concat(common.configure_args, common.configure_args_32bit,
                 "--with-zlib=system"),
-            make_args: common.make_args
+            default_make_targets: common.default_make_targets
         },
 
         "macosx-x64": {
             target_os: "macosx",
             target_cpu: "x64",
             dependencies: concat(common.dependencies, "devkit"),
-	    configure_args: concat(common.configure_args, "--with-zlib=system"),
-            make_args: common.make_args
+            configure_args: concat(common.configure_args, "--with-zlib=system"),
+            default_make_targets: common.default_make_targets
         },
 
         "solaris-x64": {
             target_os: "solaris",
             target_cpu: "x64",
             dependencies: concat(common.dependencies, "devkit", "cups"),
-	    configure_args: concat(common.configure_args, "--with-zlib=system"),
-            make_args: common.make_args
+            configure_args: concat(common.configure_args, "--with-zlib=system"),
+            default_make_targets: common.default_make_targets
         },
 
         "solaris-sparcv9": {
             target_os: "solaris",
             target_cpu: "sparcv9",
             dependencies: concat(common.dependencies, "devkit", "cups"),
-	    configure_args: concat(common.configure_args, "--with-zlib=system"),
-            make_args: common.make_args
+            configure_args: concat(common.configure_args, "--with-zlib=system"),
+            default_make_targets: common.default_make_targets
         },
 
         "windows-x64": {
             target_os: "windows",
             target_cpu: "x64",
             dependencies: concat(common.dependencies, "devkit", "freetype"),
-            configure_args: common.configure_args,
-            make_args: common.make_args
+            configure_args: concat(common.configure_args),
+            default_make_targets: common.default_make_targets
         },
 
         "windows-x86": {
@@ -293,7 +296,7 @@
             build_cpu: "x64",
             dependencies: concat(common.dependencies, "devkit", "freetype"),
             configure_args: concat(common.configure_args, common.configure_args_32bit),
-            make_args: common.make_args
+            default_make_targets: common.default_make_targets
         }
     };
     profiles = concatObjects(profiles, mainProfiles);
@@ -306,14 +309,15 @@
     // implementation builds.
     var openOnlyProfiles = generateOpenOnlyProfiles(common, mainProfiles);
     // The open only profiles on linux are used for reference builds and should
-    // produce the compact profile images by default.
+    // produce the compact profile images by default. This adds "profiles" as an
+    // extra default target.
     var openOnlyProfilesExtra = {
         "linux-x64-open": {
-            configure_args: ["--with-default-make-target=all profiles"],
+            default_make_targets: "profiles"
         },
 
         "linux-x86-open": {
-            configure_args: ["--with-default-make-target=all profiles"],
+            default_make_targets: "profiles"
         }
     };
     var openOnlyProfiles = concatObjects(openOnlyProfiles, openOnlyProfilesExtra);
@@ -336,6 +340,7 @@
 
     // Generate the missing platform attributes
     profiles = generatePlatformAttributes(profiles);
+    profiles = generateDefaultMakeTargetsConfigureArg(common, profiles);
     return profiles;
 };
 
@@ -469,6 +474,8 @@
         var debugProfile = profile + "-debug";
         newProfiles[debugProfile] = clone(profiles[profile]);
         newProfiles[debugProfile].debug_level = "fastdebug";
+        newProfiles[debugProfile].default_make_targets
+            = common.default_make_targets_debug;
         newProfiles[debugProfile].labels
             = concat(newProfiles[debugProfile].labels || [], "debug"),
             newProfiles[debugProfile].configure_args
@@ -492,6 +499,8 @@
         var debugProfile = profile + "-slowdebug";
         newProfiles[debugProfile] = clone(profiles[profile]);
         newProfiles[debugProfile].debug_level = "slowdebug";
+        newProfiles[debugProfile].default_make_targets
+            = common.default_make_targets_slowdebug;
         newProfiles[debugProfile].labels
             = concat(newProfiles[debugProfile].labels || [], "slowdebug"),
             newProfiles[debugProfile].configure_args
@@ -524,6 +533,39 @@
 };
 
 /**
+ * The default_make_targets attribute on a profile is not a real Jib attribute.
+ * This function rewrites that attribute into the corresponding configure arg.
+ * Calling this function multiple times on the same profiles object is safe.
+ *
+ * @param common Common values
+ * @param profiles Profiles map to rewrite profiles for
+ * @returns {{}} New map of profiles with the make targets converted
+ */
+var generateDefaultMakeTargetsConfigureArg = function (common, profiles) {
+    var ret = concatObjects(profiles, {});
+    for (var profile in ret) {
+        if (ret[profile]["default_make_targets"] != null) {
+            var targetsString = concat(ret[profile].default_make_targets).join(" ");
+            // Iterate over all configure args and see if --with-default-make-target
+            // is already there and change it, otherwise add it.
+            var found = false;
+            for (var arg in ret[profile].configure_args) {
+                if (arg.startsWith("--with-default-make-target")) {
+                    found = true;
+                    arg.replace(/=.*/, "=" + targetsString);
+                }
+            }
+            if (!found) {
+                ret[profile].configure_args = concat(
+                    ret[profile].configure_args,
+                    "--with-default-make-target=" + targetsString);
+            }
+        }
+    }
+    return ret;
+}
+
+/**
  * Deep clones an object tree.
  *
  * @param o Object to clone
--- a/make/Init.gmk	Wed Jul 05 21:38:12 2017 +0200
+++ b/make/Init.gmk	Wed Apr 27 14:30:32 2016 +0200
@@ -268,8 +268,13 @@
   ##############################################################################
 
   MAIN_TARGETS := $(SEQUENTIAL_TARGETS) $(PARALLEL_TARGETS) $(COMPARE_BUILD_MAKE)
+  # If building the default target, add what they are to the description.
+  DESCRIPTION_TARGETS := $(strip $(MAIN_TARGETS))
+  ifeq ($(DESCRIPTION_TARGETS), default)
+    DESCRIPTION_TARGETS += ($(DEFAULT_MAKE_TARGET))
+  endif
   TARGET_DESCRIPTION := target$(if $(word 2, $(MAIN_TARGETS)),s) \
-      '$(strip $(MAIN_TARGETS))' in configuration '$(CONF_NAME)'
+      '$(strip $(DESCRIPTION_TARGETS))' in configuration '$(CONF_NAME)'
 
   # MAKEOVERRIDES is automatically set and propagated by Make to sub-Make calls.
   # We need to clear it of the init-specific variables. The user-specified
--- a/make/Jprt.gmk	Wed Jul 05 21:38:12 2017 +0200
+++ b/make/Jprt.gmk	Wed Apr 27 14:30:32 2016 +0200
@@ -108,8 +108,8 @@
 SRC_JRE_MACOSX_BUNDLE_DIR := $(JRE_MACOSX_BUNDLE_DIR)
 
 # Bundle up the images
-JPRT_TARGET ?= all
-ifeq ($(JPRT_TARGET), all)
+JPRT_TARGET ?= default
+ifeq ($(JPRT_TARGET), default)
   bundles: $(JPRT_TARGET)
 	@$(call TargetEnter)
 	$(MKDIR) -p $(BUILD_OUTPUT)/bundles
--- a/make/Main.gmk	Wed Jul 05 21:38:12 2017 +0200
+++ b/make/Main.gmk	Wed Apr 27 14:30:32 2016 +0200
@@ -340,10 +340,10 @@
 docs-jvmtidoc:
 	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Javadoc.gmk jvmtidocs)
 
-zip-docs: docs-javadoc docs-jvmtidoc
+zip-docs:
 	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Javadoc.gmk zip-docs)
 
-ALL_TARGETS += docs-javadoc docs-jvmtidoc
+ALL_TARGETS += docs-javadoc docs-jvmtidoc zip-docs
 
 ################################################################################
 # Cross compilation support
@@ -602,6 +602,8 @@
 
   docs-jvmtidoc: hotspot
 
+  zip-docs: docs-javadoc docs-jvmtidoc
+
   test: jimages test-image
 
   create-buildjdk-copy: jdk.jlink-java java.base-gendata
@@ -703,7 +705,7 @@
 endif
 
 # This target builds the documentation image
-docs-image: zip-docs
+docs-image: docs-javadoc docs-jvmtidoc
 
 # This target builds the test image
 test-image: prepare-test-image test-image-hotspot-jtreg-native \
@@ -727,7 +729,7 @@
 docs: docs-image
 all: all-images
 
-ALL_TARGETS += default jdk images docs all zip-docs
+ALL_TARGETS += default jdk images docs all
 
 ################################################################################
 ################################################################################