From 01f983f6788a2722a08897d7613c9caab3b933a1 Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Sat, 21 May 2011 01:45:29 -0500 Subject: Ported Mac packaging system from Kokua. Build the "package" target in Xcode to create a DMG. --- linden/indra/develop.py | 6 +- linden/indra/newview/CMakeLists.txt | 89 ++++++----------- .../indra/newview/packaging/mac/ConfigureDMG.scpt | 110 +++++++++++++++++++++ .../newview/packaging/mac/GenerateInfoPlist.cmake | 39 ++++++++ linden/indra/newview/packaging/mac/Info.plist.in | 30 +++--- linden/indra/newview/packaging/mac/background.png | Bin 0 -> 19029 bytes linden/indra/newview/viewer_manifest.py | 41 ++++---- linden/scripts/package.py | 6 +- 8 files changed, 222 insertions(+), 99 deletions(-) create mode 100644 linden/indra/newview/packaging/mac/ConfigureDMG.scpt create mode 100644 linden/indra/newview/packaging/mac/GenerateInfoPlist.cmake create mode 100644 linden/indra/newview/packaging/mac/background.png diff --git a/linden/indra/develop.py b/linden/indra/develop.py index e804374..094ce3b 100755 --- a/linden/indra/develop.py +++ b/linden/indra/develop.py @@ -121,7 +121,7 @@ class PlatformSetup(object): opts=quote(opts), standalone=self.standalone, unattended=self.unattended, - type=self.build_type.upper(), + type=self.build_type, ) #if simple: # return 'cmake %(opts)s %(dir)r' % args @@ -287,7 +287,7 @@ class LinuxSetup(UnixSetup): opts=quote(opts), standalone=self.standalone, unattended=self.unattended, - type=self.build_type.upper(), + type=self.build_type, project_name=self.project_name ) if not self.is_internal_tree(): @@ -419,7 +419,7 @@ class DarwinSetup(UnixSetup): unattended=self.unattended, project_name=self.project_name, universal=self.universal, - type=self.build_type.upper() + type=self.build_type ) if self.universal == 'ON': args['universal'] = '-DCMAKE_OSX_ARCHITECTURES:STRING=\'i386\'' diff --git a/linden/indra/newview/CMakeLists.txt b/linden/indra/newview/CMakeLists.txt index 313227c..65eacaa 100644 --- a/linden/indra/newview/CMakeLists.txt +++ b/linden/indra/newview/CMakeLists.txt @@ -1480,83 +1480,58 @@ endif (LINUX) if (DARWIN) - set(product "Imprudence") + set(product "${viewer_NAME}") + set_target_properties( ${VIEWER_BINARY_NAME} PROPERTIES OUTPUT_NAME "${product}" - MACOSX_BUNDLE_INFO_STRING "info string - localize me" - MACOSX_BUNDLE_ICON_FILE "viewer.icns" - MACOSX_BUNDLE_GUI_IDENTIFIER "Imprudence" - MACOSX_BUNDLE_LONG_VERSION_STRING "ververver" - MACOSX_BUNDLE_BUNDLE_NAME "Imprudence" - MACOSX_BUNDLE_SHORT_VERSION_STRING "asdf" - MACOSX_BUNDLE_BUNDLE_VERSION "asdf" - MACOSX_BUNDLE_COPYRIGHT "copyright linden lab 2007 - localize me and run me through a legal wringer" ) + + # Generate Info.plist from the template. + add_custom_target( + GenerateInfoPlist + ALL + COMMENT "Generating Info.plist..." + VERBATIM + DEPENDS + ${CMAKE_CURRENT_SOURCE_DIR}/packaging/mac/GenerateInfoPlist.cmake + ${CMAKE_CURRENT_SOURCE_DIR}/packaging/mac/Info.plist.in + ${CMAKE_CURRENT_SOURCE_DIR}/viewerinfo.cpp + COMMAND + ${CMAKE_COMMAND} + -DSOURCE_DIR=${CMAKE_SOURCE_DIR} + -DBINARY_DIR=${CMAKE_BINARY_DIR} + -P ${CMAKE_CURRENT_SOURCE_DIR}/packaging/mac/GenerateInfoPlist.cmake + ) + + # Ensure that it's generated before the binary is built, so + # that it will definitely be ready when viewer_manifest.py runs. + add_dependencies(${VIEWER_BINARY_NAME} GenerateInfoPlist) + add_custom_command( TARGET ${VIEWER_BINARY_NAME} POST_BUILD COMMAND ${PYTHON_EXECUTABLE} ARGS ${CMAKE_CURRENT_SOURCE_DIR}/viewer_manifest.py - --grid=${GRID} --actions=copy - --configuration=${CMAKE_CFG_INTDIR} - --source=${CMAKE_CURRENT_SOURCE_DIR} --artwork=${ARTWORK_DIR} --build=${CMAKE_CURRENT_BINARY_DIR} + --buildtype=${CMAKE_BUILD_TYPE} + --configuration=${CMAKE_CFG_INTDIR} --dest=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${product}.app + --grid=${GRID} + --source=${CMAKE_CURRENT_SOURCE_DIR} + --standalone=${STANDALONE} DEPENDS ${VIEWER_BINARY_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/viewer_manifest.py ) - - add_dependencies(${VIEWER_BINARY_NAME} SLPlugin media_plugin_quicktime media_plugin_webkit media_plugin_gstreamer010) - - if (PACKAGE) - add_custom_target(package ALL DEPENDS ${VIEWER_BINARY_NAME}) - add_dependencies(package mac-updater mac-crash-logger) - - add_custom_command( - TARGET package POST_BUILD - COMMAND ${PYTHON_EXECUTABLE} - ARGS - ${CMAKE_CURRENT_SOURCE_DIR}/viewer_manifest.py - --standalone=${STANDALONE} - --buildtype=${CMAKE_BUILD_TYPE} - --grid=${GRID} - --configuration=${CMAKE_CFG_INTDIR} - --channel=${VIEWER_CHANNEL} - --login_channel=${VIEWER_LOGIN_CHANNEL} - --source=${CMAKE_CURRENT_SOURCE_DIR} - --artwork=${ARTWORK_DIR} - --build=${CMAKE_CURRENT_BINARY_DIR} - --dest=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${product}.app - --touch=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/.${product}.touched - DEPENDS - ${CMAKE_CURRENT_SOURCE_DIR}/viewer_manifest.py - ) + add_dependencies(${VIEWER_BINARY_NAME} SLPlugin media_plugin_quicktime media_plugin_webkit media_plugin_gstreamer010 mac-updater mac-crash-logger) - add_dependencies(${VIEWER_BINARY_NAME} SLPlugin media_plugin_quicktime media_plugin_webkit media_plugin_gstreamer010) - add_custom_command( - TARGET package POST_BUILD - COMMAND ${PYTHON_EXECUTABLE} - ARGS - ${CMAKE_CURRENT_SOURCE_DIR}/viewer_manifest.py - --grid=${GRID} - --configuration=${CMAKE_CFG_INTDIR} - --channel=${VIEWER_CHANNEL} - --login_channel=${VIEWER_LOGIN_CHANNEL} - --source=${CMAKE_CURRENT_SOURCE_DIR} - --artwork=${ARTWORK_DIR} - --build=${CMAKE_CURRENT_BINARY_DIR} - --dest=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${product}.app - --touch=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/.${product}.touched - DEPENDS - ${CMAKE_CURRENT_SOURCE_DIR}/viewer_manifest.py - ) + add_package_target() + add_dependencies(package ${VIEWER_BINARY_NAME}) - endif (PACKAGE) endif (DARWIN) if (INSTALL) diff --git a/linden/indra/newview/packaging/mac/ConfigureDMG.scpt b/linden/indra/newview/packaging/mac/ConfigureDMG.scpt new file mode 100644 index 0000000..198ab9e --- /dev/null +++ b/linden/indra/newview/packaging/mac/ConfigureDMG.scpt @@ -0,0 +1,110 @@ +(* + +@file ConfigureDMG.scpt +@author Jacek Antonelli +@brief Script for configuring the Mac installer disk image. + +Copyright (c) 2011, Jacek Antonelli + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation files +(the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of the Software, +and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +----- + +This AppleScript script configures the view options and icon layout of +the Mac installer disk image (DMG) as part of the packaging process. +See also scripts/package.py, which executes this script. + +This script takes two required positional command line arguments: + + 1: the name of the mounted volume (e.g. for "/Volumes/Imprudence Installer", + the volume name is "Imprudence Installer"). + 2: the name of the application file (e.g. "Imprudence.app"). + +Example usage: + + osascript ConfigureDMG.scpt "Imprudence Installer" "Imprudence.app" + +Some preparation is necessary before running this script: + + * The target disk image must be currently attached as a volume, with + the volume name specified by the first command line argument. + * The volume must contain the application file, with the file + name specified by the second command line argument. + * The volume must contain the "background.png" image file. + * The volume must not contain a file or folder named "Applications". + * It might be necessary to "Enable access for assistive devices" + in System Preferences > Universal Access. + +*) + +on run argv + + -- Read the first positional argument, the volume name. + set volumeName to item 1 of argv + + -- Read the second positional argument, the app name. + set appName to item 2 of argv + + tell application "Finder" to tell disk volumeName + -- Open the volume in a Finder window. + open + set theWindow to the container window + + -- Tweak some options. + set current view of theWindow to icon view + set toolbar visible of theWindow to false + set statusbar visible of theWindow to false + + -- Set window to position {150,150}, size {+600,+420}. + set bounds of theWindow to {150, 150, 750, 570} + + -- Tweak some more options. + set viewOptions to the icon view options of theWindow + set arrangement of viewOptions to not arranged + set icon size of viewOptions to 128 + + -- Make sure background.png is visible, so Finder can see it. + set bgPicPath to the quoted form of (the POSIX path of (it as alias) & "background.png") + do shell script ("SetFile -a v " & bgPicPath) + update without registering applications + + -- Use background.png as the background picture. + set background picture of viewOptions to file "background.png" + + -- Now set background.png to invisible, so the end user won't see it. + do shell script ("SetFile -a V " & bgPicPath) + + -- Position the application file. + set position of item appName of theWindow to {138, 260} + + -- Create and position an alias to the Applications folder. + set appAlias to make new alias file at theWindow to POSIX file "/Applications" + set name of appAlias to "Applications" + set position of appAlias to {470, 260} + + -- Visually update the window so all the changes take effect. + update without registering applications + + -- Pause briefly so we can admire the results. + delay 2 + end tell + +end run diff --git a/linden/indra/newview/packaging/mac/GenerateInfoPlist.cmake b/linden/indra/newview/packaging/mac/GenerateInfoPlist.cmake new file mode 100644 index 0000000..ecbec34 --- /dev/null +++ b/linden/indra/newview/packaging/mac/GenerateInfoPlist.cmake @@ -0,0 +1,39 @@ +# +# Generate the Info.plist file from the template. +# Only @-style "@VARIABLES@" are substituted in the template (not "${VARIABLES}"). +# +# This script is needed because CMake has no other way to perform +# configure_file() as a build-time custom command. :( +# +# When running this script, you must define (-D) SOURCE_DIR and +# BINARY_DIR to refer to indra and the build directory respectively. +# (Equivalent to CMAKE_SOURCE_DIR and CMAKE_BINARY_DIR in +# CMakeLists.txt ) +# + +if (NOT SOURCE_DIR) + message( FATAL_ERROR "You forgot to define SOURCE_DIR!" ) +endif (NOT SOURCE_DIR) + +if (NOT BINARY_DIR) + message( FATAL_ERROR "You forgot to define BINARY_DIR!" ) +endif (NOT BINARY_DIR) + +set(SCRIPTS_DIR "${SOURCE_DIR}/../scripts") +set(CMAKE_MODULE_PATH "${SOURCE_DIR}/cmake/" "${CMAKE_ROOT/Modules}") + +include(BuildVersion) +build_version(viewer) + +SET( BUNDLE_NAME "${viewer_NAME}" ) +SET( EXECUTABLE "${viewer_NAME}" ) +set( BUNDLE_VERSION "${viewer_VERSION}" ) +set( SHORT_VERSION_STRING "${viewer_NAME} ${viewer_VERSION}" ) +set( ICON_FILE "viewer.icns" ) +set( IDENTIFIER "${viewer_BUNDLE_ID}" ) +set( SIGNATURE "impr" ) + +configure_file( + ${SOURCE_DIR}/newview/packaging/mac/Info.plist.in + ${BINARY_DIR}/newview/packaging/mac/Info.plist + @ONLY) diff --git a/linden/indra/newview/packaging/mac/Info.plist.in b/linden/indra/newview/packaging/mac/Info.plist.in index b3045c9..78cc6b7 100644 --- a/linden/indra/newview/packaging/mac/Info.plist.in +++ b/linden/indra/newview/packaging/mac/Info.plist.in @@ -2,22 +2,20 @@ - CFBundleDevelopmentRegion - English + CFBundleName + @BUNDLE_NAME@ CFBundleExecutable - Imprudence + @EXECUTABLE@ + CFBundleVersion + @BUNDLE_VERSION@ + CFBundleShortVersionString + @SHORT_VERSION_STRING@ CFBundleIconFile - viewer.icns + @ICON_FILE@ CFBundleIdentifier - org.imprudenceviewer.viewer - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - Imprudence - CFBundlePackageType - APPL + @IDENTIFIER@ CFBundleSignature - ???? + @SIGNATURE@ CFBundleURLTypes @@ -31,8 +29,12 @@ - CFBundleVersion - 1.4.0 beta 1 + CFBundleDevelopmentRegion + English + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + APPL CSResourcesFileMapped diff --git a/linden/indra/newview/packaging/mac/background.png b/linden/indra/newview/packaging/mac/background.png new file mode 100644 index 0000000..9b0b0b2 Binary files /dev/null and b/linden/indra/newview/packaging/mac/background.png differ diff --git a/linden/indra/newview/viewer_manifest.py b/linden/indra/newview/viewer_manifest.py index 0f129dd..5e1e816 100755 --- a/linden/indra/newview/viewer_manifest.py +++ b/linden/indra/newview/viewer_manifest.py @@ -585,7 +585,8 @@ class DarwinManifest(ViewerManifest): if self.prefix(src="", dst="Contents"): # everything goes in Contents - self.path("Info-Imprudence.plist", dst="Info.plist") + # Info.plist goes directly in Contents + self.path("packaging/mac/Info.plist", dst="Info.plist") # copy additional libs in /Contents/MacOS/ if (not self.standalone()) and self.prefix(src="../../libraries/universal-darwin/lib_release", dst="MacOS/"): @@ -653,27 +654,27 @@ class DarwinManifest(ViewerManifest): self.gather_documents() self.path("featuretable_mac.txt") - self.path("SecondLife.nib") - self.path("viewer.icns") - # Translations - self.path("English.lproj") - self.path("German.lproj") - self.path("Japanese.lproj") - self.path("Korean.lproj") - self.path("da.lproj") - self.path("es.lproj") - self.path("fr.lproj") - self.path("hu.lproj") - self.path("it.lproj") - self.path("nl.lproj") - self.path("pl.lproj") - self.path("pt.lproj") - self.path("ru.lproj") - self.path("tr.lproj") - self.path("uk.lproj") - self.path("zh-Hans.lproj") + if self.prefix(src="packaging/mac", dst=""): + self.path("SecondLife.nib") + self.path("English.lproj") + self.path("German.lproj") + self.path("Japanese.lproj") + self.path("Korean.lproj") + self.path("da.lproj") + self.path("es.lproj") + self.path("fr.lproj") + self.path("hu.lproj") + self.path("it.lproj") + self.path("nl.lproj") + self.path("pl.lproj") + self.path("pt.lproj") + self.path("ru.lproj") + self.path("tr.lproj") + self.path("uk.lproj") + self.path("zh-Hans.lproj") + self.end_prefix("packaging/mac") # if (not self.standalone()) and self.prefix(src="../../libraries/universal-darwin/lib_release/gstreamer-plugins", dst="lib/gstreamer-plugins"): diff --git a/linden/scripts/package.py b/linden/scripts/package.py index 59aef79..e02a9cc 100755 --- a/linden/scripts/package.py +++ b/linden/scripts/package.py @@ -196,17 +196,13 @@ true""" % {'d': packaged_dir}) os.path.join(dmg_dst, 'background.png')) config_script = os.path.join(self.source_dir, 'newview', - 'packaging', 'mac', 'ConfigureDMG.scpt') + 'packaging', 'mac', 'ConfigureDMG.scpt') self.__run_command( "Configuring temp disk image's view options...", 'osascript %(script)r %(volname)r %(app_name)r' % {'script': config_script, 'volname': volname, 'app_name': app_name}) - # self.__run_command( - # 'Hiding background.png...', - # 'SetFile -a V %r' % os.path.join(dmg_dst, 'background.png')) - self.__run_command( 'Unmounting temp disk image...', 'hdiutil detach %r' % dmg_dst) -- cgit v1.1