Browse Source

Setup Script in Mac App Bundle

Thomas Buck 10 years ago
parent
commit
154d59cd4c
6 changed files with 60 additions and 10 deletions
  1. 17
    5
      CMakeLists.txt
  2. 0
    0
      cmake/AppIcon.icns
  3. 32
    0
      cmake/setup_mac.sh
  4. 1
    2
      data/OpenRaider.init
  5. 9
    2
      src/CMakeLists.txt
  6. 1
    1
      src/OpenRaider.cpp

+ 17
- 5
CMakeLists.txt View File

25
 
25
 
26
 #################################################################
26
 #################################################################
27
 
27
 
28
-# Preparing the bundle on install
29
-# http://www.cmake.org/Wiki/BundleUtilitiesExample
30
-# Why does it even work? O.o
31
 if (APPLE)
28
 if (APPLE)
29
+    # Preparing the bundle on install
30
+    # http://www.cmake.org/Wiki/BundleUtilitiesExample
32
     set (plugin_dest_dir OpenRaider.app/Contents/MacOS)
31
     set (plugin_dest_dir OpenRaider.app/Contents/MacOS)
33
     set (APPS "${PROJECT_BINARY_DIR}/src/OpenRaider.app")
32
     set (APPS "${PROJECT_BINARY_DIR}/src/OpenRaider.app")
34
-    set (DIRS ${QT_LIBRARY_DIRS})
35
     install (CODE "
33
     install (CODE "
36
         file(GLOB_RECURSE PLUGINS
34
         file(GLOB_RECURSE PLUGINS
37
             \"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/plugins/*${CMAKE_SHARED_LIBRARY_SUFFIX}\")
35
             \"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/plugins/*${CMAKE_SHARED_LIBRARY_SUFFIX}\")
38
         include(BundleUtilities)
36
         include(BundleUtilities)
39
-        fixup_bundle(\"${APPS}\" \"\${PLUGINS}\" \"${DIRS}\")
37
+        fixup_bundle(\"${APPS}\" \"\${PLUGINS}\" \"\")
40
         " COMPONENT Runtime
38
         " COMPONENT Runtime
41
     )
39
     )
40
+
41
+    # Copy setup script
42
+    install (PROGRAMS ${PROJECT_SOURCE_DIR}/cmake/setup_mac.sh
43
+        DESTINATION ${PROJECT_BINARY_DIR}/src/OpenRaider.app/Contents/MacOS
44
+        RENAME OpenRaider.sh
45
+    )
46
+
47
+    # Fix executable name, so setup script will be called
48
+    install (CODE "
49
+        execute_process (
50
+            COMMAND /usr/libexec/PlistBuddy -c \"Set :CFBundleExecutable OpenRaider.sh\" Info.plist
51
+            WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/src/OpenRaider.app/Contents
52
+        )
53
+    " COMPONENT Runtime)
42
 endif (APPLE)
54
 endif (APPLE)
43
 
55
 
44
 #################################################################
56
 #################################################################

data/AppIcon.icns → cmake/AppIcon.icns View File


+ 32
- 0
cmake/setup_mac.sh View File

1
+#!/bin/sh
2
+cd `dirname $0`
3
+if [ ! -d "${HOME}/.OpenRaider" ]; then
4
+    echo "Setting up OpenRaider for user $USER..."
5
+    mkdir -p ~/.OpenRaider
6
+    cp ../Resources/defaults/OpenRaider.init ~/.OpenRaider/
7
+    cp ../Resources/defaults/custom.cfg ~/.OpenRaider/
8
+    mkdir -p ~/.OpenRaider/paks
9
+    mkdir -p ~/.OpenRaider/music
10
+    mkdir -p ~/.OpenRaider/data
11
+    mkdir -p ~/.OpenRaider/sshots
12
+    cp ../Resources/defaults/*.tga ~/.OpenRaider/data
13
+    cp ../Resources/defaults/*.wav ~/.OpenRaider/data
14
+    cp ../Resources/defaults/*.ttf ~/.OpenRaider/data
15
+    echo "DONE"
16
+    osascript -e 'tell app "System Events" to display alert "Initial Configuration stored in ~/.OpenRaider\n\nView and edit OpenRaider.init to your needs..."'
17
+fi
18
+if [[ ! -n `find "${HOME}/.OpenRaider/paks" -type f -exec echo Found {} \;` ]]; then
19
+    echo "Missing level files!"
20
+    osascript -e 'tell app "System Events" to display alert "No level files stored in ~/.OpenRaider/paks\n\nPlace level files there and edit ~/.OpenRaider/OpenRaider.init"'
21
+else
22
+    if [[ ! `diff "${HOME}/.OpenRaider/OpenRaider.init" "../Resources/defaults/OpenRaider.init"` ]]; then
23
+        if [[ ! `diff "${HOME}/.OpenRaider/custom.cfg" "../Resources/defaults/custom.cfg"` ]]; then
24
+            echo "Unconfigured user!"
25
+            osascript -e 'tell app "System Events" to display alert "Please edit ~/.OpenRaider/OpenRaider.init or ~/.OpenRaider/custom.cfg"'
26
+        else
27
+            ./OpenRaider
28
+        fi
29
+    else
30
+        ./OpenRaider
31
+    fi
32
+fi

+ 1
- 2
data/OpenRaider.init View File

1
-# This is the Open Raider RC file
1
+# This is the OpenRaider RC file
2
 #####################################
2
 #####################################
3
 
3
 
4
 [Video.OpenGL]
4
 [Video.OpenGL]
5
 Driver=/usr/lib/libGL.so.1
5
 Driver=/usr/lib/libGL.so.1
6
 Width=1280
6
 Width=1280
7
 Height=720
7
 Height=720
8
-FastCard=true
9
 FullScreen=false
8
 FullScreen=false
10
 Font=~/.OpenRaider/data/test.ttf
9
 Font=~/.OpenRaider/data/test.ttf
11
 
10
 

+ 9
- 2
src/CMakeLists.txt View File

34
     set (MACOSX_BUNDLE_COPYRIGHT "2001 - 2014")
34
     set (MACOSX_BUNDLE_COPYRIGHT "2001 - 2014")
35
 
35
 
36
     # Copy Icon
36
     # Copy Icon
37
-    set (MAC_ICON "../data/AppIcon.icns")
38
-    set_source_files_properties(${MAC_ICON} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
37
+    set (MAC_ICON "../cmake/AppIcon.icns")
38
+    set_source_files_properties (${MAC_ICON} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
39
     set (SRCS ${SRCS} ${MAC_ICON})
39
     set (SRCS ${SRCS} ${MAC_ICON})
40
+
41
+    # Copy Data
42
+    set (MAC_DATA "../data/custom.cfg" "../data/OpenRaider.init" "../data/particle.tga" "../data/sample.wav")
43
+    set (MAC_DATA ${MAC_DATA} "../data/snow.tga" "../data/snow2.tga" "../data/splash.tga" "../data/test.ttf")
44
+    set (MAC_DATA ${MAC_DATA} "../data/white.tga")
45
+    set_source_files_properties (${MAC_DATA} PROPERTIES MACOSX_PACKAGE_LOCATION Resources/defaults)
46
+    set (SRCS ${SRCS} ${MAC_DATA})
40
 endif (APPLE)
47
 endif (APPLE)
41
 
48
 
42
 # Add Executable
49
 # Add Executable

+ 1
- 1
src/OpenRaider.cpp View File

3358
                 char *fullPathMap = bufferString("%s%s", dir, ep->d_name);
3358
                 char *fullPathMap = bufferString("%s%s", dir, ep->d_name);
3359
 
3359
 
3360
                 if (m_tombraider.checkMime(fullPathMap) == 0) {
3360
                 if (m_tombraider.checkMime(fullPathMap) == 0) {
3361
-                    printf("Validated pak: '%s'\n", fullPathMap);
3361
+                    // printf("Validated pak: '%s'\n", fullPathMap);
3362
                     delete [] fullPathMap;
3362
                     delete [] fullPathMap;
3363
 
3363
 
3364
                     // Just load relative filename
3364
                     // Just load relative filename

Loading…
Cancel
Save