Преглед изворни кода

Setup Script in Mac App Bundle

Thomas Buck пре 10 година
родитељ
комит
154d59cd4c
6 измењених фајлова са 60 додато и 10 уклоњено
  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 Прегледај датотеку

@@ -25,20 +25,32 @@ add_subdirectory (test)
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 28
 if (APPLE)
29
+    # Preparing the bundle on install
30
+    # http://www.cmake.org/Wiki/BundleUtilitiesExample
32 31
     set (plugin_dest_dir OpenRaider.app/Contents/MacOS)
33 32
     set (APPS "${PROJECT_BINARY_DIR}/src/OpenRaider.app")
34
-    set (DIRS ${QT_LIBRARY_DIRS})
35 33
     install (CODE "
36 34
         file(GLOB_RECURSE PLUGINS
37 35
             \"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/plugins/*${CMAKE_SHARED_LIBRARY_SUFFIX}\")
38 36
         include(BundleUtilities)
39
-        fixup_bundle(\"${APPS}\" \"\${PLUGINS}\" \"${DIRS}\")
37
+        fixup_bundle(\"${APPS}\" \"\${PLUGINS}\" \"\")
40 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 54
 endif (APPLE)
43 55
 
44 56
 #################################################################

data/AppIcon.icns → cmake/AppIcon.icns Прегледај датотеку


+ 32
- 0
cmake/setup_mac.sh Прегледај датотеку

@@ -0,0 +1,32 @@
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 Прегледај датотеку

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

+ 9
- 2
src/CMakeLists.txt Прегледај датотеку

@@ -34,9 +34,16 @@ if (APPLE)
34 34
     set (MACOSX_BUNDLE_COPYRIGHT "2001 - 2014")
35 35
 
36 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 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 47
 endif (APPLE)
41 48
 
42 49
 # Add Executable

+ 1
- 1
src/OpenRaider.cpp Прегледај датотеку

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

Loading…
Откажи
Сачувај