From ad3016e12262917f474f0f511c8ac1a1c3e91935 Mon Sep 17 00:00:00 2001
From: "thomasvl@chromium.org"
 <thomasvl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>
Date: Fri, 8 May 2009 20:24:08 +0000
Subject: [PATCH] Add a simple dmg script to the mac build dir to build a dmg
 out of the app. Add a target to build a dmg out of the app. Add a target to
 all that will build everything and the dmg (since we don't include the dmg in
 all since developers really don't need to wait for that). Review URL:
 http://codereview.chromium.org/113152

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15672 0039d316-1c4b-4281-b951-d872f2087c98
---
 build/all.gyp           | 14 ++++++++++++--
 build/mac/build_app_dmg | 40 ++++++++++++++++++++++++++++++++++++++++
 chrome/chrome.gyp       | 29 +++++++++++++++++++++++++++++
 3 files changed, 81 insertions(+), 2 deletions(-)
 create mode 100755 build/mac/build_app_dmg

diff --git a/build/all.gyp b/build/all.gyp
index 2aad4a377c75c..a2ef584b86045 100644
--- a/build/all.gyp
+++ b/build/all.gyp
@@ -79,10 +79,10 @@
   ],
   'conditions': [
     ['OS=="mac"', {
-      # Target to build everything needed for layout tests to cut down
-      # on what the layout test bots have to build.
       'targets': [
         {
+          # Target to build everything needed for layout tests to cut down
+          # on what the layout test bots have to build.
           'target_name': 'build_for_layout_tests',
           'type': 'none',
           'dependencies': [
@@ -91,6 +91,16 @@
             '../webkit/tools/test_shell/test_shell.gyp:test_shell_tests',
           ],
         },
+        {
+          # Target to build everything plus the dmg.  We don't put the dmg
+          # in the All target because developer really don't need it.
+          'target_name': 'all_and_dmg',
+          'type': 'none',
+          'dependencies': [
+            'All',
+            '../chrome/chrome.gyp:build_app_dmg',
+          ],
+        },
       ],
     }],
   ],
diff --git a/build/mac/build_app_dmg b/build/mac/build_app_dmg
new file mode 100755
index 0000000000000..ec124189461b6
--- /dev/null
+++ b/build/mac/build_app_dmg
@@ -0,0 +1,40 @@
+#!/bin/sh
+
+# Copyright (c) 2009 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Normally you don't want to build a dmg out of a debug build.
+if [ "${CONFIGURATION}" != "Release" ] ; then
+  echo "warning: building dmg in non-release mode" >&2
+fi
+
+# Make sure we got the branding passed to us
+if [ $# -ne 1 ]; then
+  echo "error: missing branding as an argument" >&2
+  exit 1
+fi
+
+# fail on anything from here out
+set -e
+
+TOP="${SRCROOT}/.."
+PKG_DMG="${TOP}/build/mac/pkg-dmg"
+
+APP_NAME=$1
+SRC_APP_PATH="${BUILT_PRODUCTS_DIR}/${APP_NAME}.app"
+VOL_NAME="${APP_NAME}"
+# Do we want a svn version in the DMG name?
+DMG_NAME="${APP_NAME}.dmg"
+DST_DMG_PATH="${BUILT_PRODUCTS_DIR}/${DMG_NAME}"
+
+# show things as we run them
+set -x
+
+# Call the real working
+"${PKG_DMG}" --source /var/empty \
+             --target "${DST_DMG_PATH}" \
+             --format UDBZ \
+             --volname "${VOL_NAME}" \
+             --tempdir "${TEMP_DIR}" \
+             --copy "${SRC_APP_PATH}/:/${APP_NAME}.app/"
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index 0d1d680f3afba..95cdc1a3fcaf1 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -2771,6 +2771,9 @@
     ['OS=="mac"',
       # On Mac only, add a project target called "package_app" that only
       # runs a shell script (package_chrome.sh).
+      # On Mac only, add a project target called "build_app_dmg" that only
+      # builds a DMG out of the App (eventually will completely replace
+      # "package_app").
       { 'targets': [
         {
           'target_name': 'package_app',
@@ -2792,6 +2795,32 @@
             },
           ],  # 'actions'
         },
+        {
+          'target_name': 'build_app_dmg',
+          # do NOT place this in the 'all' list; most won't want it.
+          # In gyp, booleans are 0/1 not True/False.
+          'suppress_wildcard': 1,
+          'type': 'none',
+          'dependencies': [
+            'app',
+          ],
+          'variables': {
+            'build_app_dmg_script_path': '<(DEPTH)/build/mac/build_app_dmg',
+          },
+          'actions': [
+            {
+              'inputs': [
+                '<(build_app_dmg_script_path)',
+                '<(PRODUCT_DIR)/<(branding).app',
+              ],
+              'outputs': [
+                '<(PRODUCT_DIR)/<(branding).dmg',
+              ],
+              'action_name': 'build_app_dmg',
+              'action': ['<(build_app_dmg_script_path)', '<@(branding)'],
+            },
+          ],  # 'actions'
+        },
       ]
     }, { # else: OS != "mac"
       'targets': [
-- 
GitLab