From 57ea251d39b4a4623ce0d41918eebac2ed705fff Mon Sep 17 00:00:00 2001 From: w1z7ard Date: Thu, 22 May 2008 23:15:01 +0000 Subject: [PATCH] mac bundle support for the config file and its path references git-svn-id: https://projectm.svn.sourceforge.net/svnroot/projectm/trunk@1019 6778bc44-b910-0410-a7a0-be141de4315d --- src/projectM-engine/CMakeLists.txt | 4 ++- src/projectM-engine/config.inp.in | 8 ++--- src/projectM-engine/libprojectM.pc.in | 4 +-- src/projectM-engine/projectM.cpp | 1 + src/projectM-jack/CMakeLists.txt | 6 ++++ src/projectM-jack/make_bundle-no-qt.sh | 45 +++++++------------------- src/projectM-jack/make_bundle.sh | 14 ++++---- src/projectM-jack/qprojectM-jack.cpp | 13 +++++--- 8 files changed, 43 insertions(+), 52 deletions(-) diff --git a/src/projectM-engine/CMakeLists.txt b/src/projectM-engine/CMakeLists.txt index ff4a10840..7d2fe828c 100644 --- a/src/projectM-engine/CMakeLists.txt +++ b/src/projectM-engine/CMakeLists.txt @@ -12,7 +12,6 @@ OPTION (USE_NATIVE_GLEW "Use projectM's native implemention of GLEW." OFF) #OPTION (FTGL_STATIC "Build the projectM target library in the platform's native static (NOT shared) format." OFF) OPTION (BUILD_PROJECTM_STATIC "Build the projectM target library in the platform's native static (NOT shared) format." OFF) - SET(SOIL_SOURCES image_DXT.c image_helper.c SOIL.c stb_image_aug.c) if (USE_NATIVE_GLEW) @@ -58,10 +57,13 @@ SET_TARGET_PROPERTIES(projectM PROPERTIES VERSION 2.00 SOVERSION 2) if (APPLE) ADD_DEFINITIONS(-DMACOS -DSTBI_NO_DDS -DUSE_THREADS) +set(RESOURCE_PREFIX "Resources") else (APPLE) if (WIN32) +set (RESOURCE_PREFIX "Resources") ADD_DEFINITIONS(-DWIN32 -DSTBI_NO_DDS -DUSE_THREADS) else(WIN32) +set (RESOURCE_PREFIX "share/projectM") ADD_DEFINITIONS(-DLINUX -DSTBI_NO_DDS -DUSE_THREADS) endif(WIN32) endif(APPLE) diff --git a/src/projectM-engine/config.inp.in b/src/projectM-engine/config.inp.in index f2296f2b8..b27b193d2 100644 --- a/src/projectM-engine/config.inp.in +++ b/src/projectM-engine/config.inp.in @@ -16,7 +16,7 @@ Easter Egg Parameter = 1 Hard Cut Sensitivity = 10 # Lower to make hard cuts more frequent Aspect Correction = true # Custom Shape Aspect Correction -Preset Path = @CMAKE_INSTALL_PREFIX@/share/projectM/presets #preset location -Title Font = @CMAKE_INSTALL_PREFIX@/share/projectM/fonts/Vera.ttf -Menu Font = @CMAKE_INSTALL_PREFIX@/share/projectM/fonts/VeraMono.ttf - \ No newline at end of file +Preset Path = @CMAKE_INSTALL_PREFIX@/@RESOURCE_PREFIX@/presets # preset location +Title Font = @CMAKE_INSTALL_PREFIX@/@RESOURCE_PREFIX@/fonts/Vera.ttf +Menu Font = @CMAKE_INSTALL_PREFIX@/@RESOURCE_PREFIX@/fonts/VeraMono.ttf + diff --git a/src/projectM-engine/libprojectM.pc.in b/src/projectM-engine/libprojectM.pc.in index c416b4e67..218323dd0 100644 --- a/src/projectM-engine/libprojectM.pc.in +++ b/src/projectM-engine/libprojectM.pc.in @@ -2,8 +2,8 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=@CMAKE_INSTALL_PREFIX@ libdir=@CMAKE_INSTALL_PREFIX@/lib includedir=@CMAKE_INSTALL_PREFIX@/include -pkgdatadir=@CMAKE_INSTALL_PREFIX@/share/projectM -sysconfdir=@CMAKE_INSTALL_PREFIX@/share/projectM +pkgdatadir=@CMAKE_INSTALL_PREFIX@/@RESOURCE_PREFIX@ +sysconfdir=@CMAKE_INSTALL_PREFIX@/@RESOURCE_PREFIX@ Name: libprojectM Version: 1.10 diff --git a/src/projectM-engine/projectM.cpp b/src/projectM-engine/projectM.cpp index 2e8b2c533..4d5a14d60 100755 --- a/src/projectM-engine/projectM.cpp +++ b/src/projectM-engine/projectM.cpp @@ -163,6 +163,7 @@ bool projectM::writeConfig(const std::string & configFile, const Settings & sett void projectM::readConfig (const std::string & configFile ) { std::cout << "configFile: " << configFile << std::endl; + ConfigFile config ( configFile ); _settings.meshX = config.read ( "Mesh X", 32 ); _settings.meshY = config.read ( "Mesh Y", 24 ); diff --git a/src/projectM-jack/CMakeLists.txt b/src/projectM-jack/CMakeLists.txt index ff72a52d8..ce9908c53 100644 --- a/src/projectM-jack/CMakeLists.txt +++ b/src/projectM-jack/CMakeLists.txt @@ -19,6 +19,12 @@ else(${CMAKE_PROJECT_NAME} MATCHES ${PROJECT_NAME}) ADD_DEFINITIONS(-DLINUX -DPROJECTM_PREFIX='"${CMAKE_INSTALL_PREFIX}"') endif(${CMAKE_PROJECT_NAME} MATCHES ${PROJECT_NAME}) +if (APPLE) +ADD_DEFINITIONS(-DRESOURCE_PREFIX='"Resources"') +else (APPLE) +ADD_DEFINITIONS(-DRESOURCE_PREFIX='"share/projectM"') +endif (APPLE) + FIND_PACKAGE(OpenGL) FIND_PACKAGE(Qt4 REQUIRED) diff --git a/src/projectM-jack/make_bundle-no-qt.sh b/src/projectM-jack/make_bundle-no-qt.sh index 05c3b322a..ce4451bac 100755 --- a/src/projectM-jack/make_bundle-no-qt.sh +++ b/src/projectM-jack/make_bundle-no-qt.sh @@ -1,6 +1,7 @@ #!/bin/sh -### make_bund.sh A simple script to create a mac bundle #### -### Author: Carmelo Piccione (carmelo.piccione+projectM@gmail.com) ### +### make_bundle-no-qt.sh A simple script to create a mac bundle without qt +### included in the bundle (depends on standard framework paths instead) +### Author: Carmelo Piccione (carmelo.piccione+projectM@gmail.com) # Path to installed qt framework on your machine PATH_TO_QT=/Developer/SDKs/MacOSX10.4u.sdk/Library/Frameworks/ @@ -22,44 +23,20 @@ mkdir ${APP}/Contents mkdir ${APP}/Contents/Frameworks mkdir ${APP}/Contents/Plugins mkdir ${APP}/Contents/MacOs +mkdir ${APP}/Contents/Resources +mkdir ${APP}/Contents/Resources/fonts +mkdir ${APP}/Contents/Resources/presets -cp projectM-jack ${APP}/Contents/MAcOs/ +cp projectM-jack ${APP}/Contents/MacOs/ cp -f ${PROJECTM_QT_BUILD_PATH} ${APP}/Contents/Plugins/libprojectM-qt.dylib - -## [2] Copy each qt framework into the bundle -#cp -Rf ${PATH_TO_QT}/QtCore.framework ${APP}/Contents/Frameworks -#cp -Rf ${PATH_TO_QT}/QtGui.framework ${APP}/Contents/Frameworks -#cp -Rf ${PATH_TO_QT}/QtXml.framework ${APP}/Contents/Frameworks -#cp -Rf ${PATH_TO_QT}/QtOpenGL.framework ${APP}/Contents/Frameworks - +cp -Rf ../../fonts/*.ttf ${APP}/Contents/Resources/fonts +cp -Rf ../../presets_projectM/*.prjm ${APP}/Contents/Resources/presets +cp -Rf ../../presets_projectM/*.milk ${APP}/Contents/Resources/presets +cp -f ${BUILD_PATH}/projectM-engine/config.inp ${APP}/Contents/Resources ## [3] Change id of each qt framework to specialized one for this bundle -#install_name_tool -id @executable_path/../Frameworks/QtCore.framework/Versions/${QT_VERSION}/QtCore ${APP}/Contents/Frameworks/QtCore.framework/Versions/${QT_VERSION}/QtCore -#install_name_tool -id @executable_path/../Frameworks/QtGui.framework/Versions/${QT_VERSION}/QtGui ${APP}/Contents/Frameworks/QtGui.framework/Versions/${QT_VERSION}/QtGui -#install_name_tool -id @executable_path/../Frameworks/QtXml.framework/Versions/${QT_VERSION}/QtXml ${APP}/Contents/Frameworks/QtXml.framework/Versions/${QT_VERSION}/QtXml -#install_name_tool -id @executable_path/../Frameworks/QtOpenGL.framework/Versions/${QT_VERSION}/QtOpenGL ${APP}/Contents/Frameworks/QtOpenGL.framework/Versions/${QT_VERSION}/QtOpenGL install_name_tool -id @executable_path/../Plugins/libprojectM-qt.dylib ${APP}/Contents/Plugins/libprojectM-qt.dylib - -## [4] Change reference ids in projectM-jack to the local referred to id's -#install_name_tool -change QtCore.framework/Versions/${QT_VERSION}/QtCore @executable_path/../Frameworks/QtCore.framework/Versions/${QT_VERSION}/QtCore ${APP}/Contents/MacOs/projectM-jack -#install_name_tool -change QtGui.framework/Versions/${QT_VERSION}/QtGui @executable_path/../Frameworks/QtGui.framework/Versions/${QT_VERSION}/QtGui ${APP}/Contents/MacOs/projectM-jack -#install_name_tool -change QtXml.framework/Versions/${QT_VERSION}/QtXml @executable_path/../Frameworks/QtXml.framework/Versions/${QT_VERSION}/QtXml ${APP}/Contents/MacOs/projectM-jack -#install_name_tool -change QtOpenGL.framework/Versions/${QT_VERSION}/QtOpenGL @executable_path/../Frameworks/QtOpenGL.framework/Versions/${QT_VERSION}/QtOpenGL ${APP}/Contents/MacOs/projectM-jack - install_name_tool -change ${PROJECTM_QT_BUILD_PATH} @executable_path/../Plugins/libprojectM-qt.dylib ${APP}/Contents/MacOs/projectM-jack -# [4b] Change projectM-qt library reference to bundle version - -## [5] Change references from one qt lib to another qt lib from system to local -#install_name_tool -change QtCore.framework/Versions/${QT_VERSION}/QtCore @executable_path/../Frameworks/QtCore.framework/Versions/${QT_VERSION}/QtCore ${APP}/Contents/Frameworks/QtGui.framework/Versions/${QT_VERSION}/QtGui -#install_name_tool -change QtCore.framework/Versions/${QT_VERSION}/QtCore @executable_path/../Frameworks/QtCore.framework/Versions/${QT_VERSION}/QtCore ${APP}/Contents/Frameworks/QtXml.framework/Versions/${QT_VERSION}/QtXml - -#install_name_tool -change QtCore.framework/Versions/${QT_VERSION}/QtCore @executable_path/../Frameworks/QtCore.framework/Versions/${QT_VERSION}/QtCore ${APP}/Contents/Frameworks/QtOpenGL.framework/Versions/${QT_VERSION}/QtOpenGL -#install_name_tool -change QtGui.framework/Versions/${QT_VERSION}/QtGui @executable_path/../Frameworks/QtGui.framework/Versions/${QT_VERSION}/QtGui ${APP}/Contents/Frameworks/QtOpenGL.framework/Versions/${QT_VERSION}/QtOpenGL - -#install_name_tool -change QtCore.framework/Versions/${QT_VERSION}/QtCore @executable_path/../Frameworks/QtCore.framework/Versions/${QT_VERSION}/QtCore ${APP}/Contents/Plugins/libprojectM-qt.dylib -#install_name_tool -change QtGui.framework/Versions/${QT_VERSION}/QtGui @executable_path/../Frameworks/QtGui.framework/Versions/${QT_VERSION}/QtGui ${APP}/Contents/Plugins/libprojectM-qt.dylib -#install_name_tool -change QtXml.framework/Versions/${QT_VERSION}/QtXml @executable_path/../Frameworks/QtXml.framework/Versions/${QT_VERSION}/QtXml ${APP}/Contents/Plugins/libprojectM-qt.dylib -#install_name_tool -change QtOpenGL.framework/Versions/${QT_VERSION}/QtOpenGL @executable_path/../Frameworks/QtOpenGL.framework/Versions/${QT_VERSION}/QtOpenGL ${APP}/Contents/Plugins/libprojectM-qt.dylib diff --git a/src/projectM-jack/make_bundle.sh b/src/projectM-jack/make_bundle.sh index 156efab67..d3e88d991 100644 --- a/src/projectM-jack/make_bundle.sh +++ b/src/projectM-jack/make_bundle.sh @@ -24,7 +24,7 @@ mkdir ${APP}/Contents/Plugins mkdir ${APP}/Contents/MacOs cp projectM-jack ${APP}/Contents/MAcOs/ -cp -f ${PROJECTM_QT_BUILD_PATH} ${APP}/Contents/Plugins/projectM-qt +cp -f ${PROJECTM_QT_BUILD_PATH} ${APP}/Contents/Plugins/libprojectM-qt.dylib ## [2] Copy each qt framework into the bundle cp -Rf ${PATH_TO_QT}/QtCore.framework ${APP}/Contents/Frameworks @@ -41,7 +41,7 @@ install_name_tool -id @executable_path/../Frameworks/QtGui.framework/Versions/${ install_name_tool -id @executable_path/../Frameworks/QtXml.framework/Versions/${QT_VERSION}/QtXml ${APP}/Contents/Frameworks/QtXml.framework/Versions/${QT_VERSION}/QtXml install_name_tool -id @executable_path/../Frameworks/QtOpenGL.framework/Versions/${QT_VERSION}/QtOpenGL ${APP}/Contents/Frameworks/QtOpenGL.framework/Versions/${QT_VERSION}/QtOpenGL -install_name_tool -id @executable_path/../Plugins/projectM-qt ${APP}/Contents/Plugins/projectM-qt +install_name_tool -id @executable_path/../Plugins/libprojectM-qt.dylib ${APP}/Contents/Plugins/libprojectM-qt.dylib ## [4] Change reference ids in projectM-jack to the local referred to id's @@ -53,7 +53,7 @@ install_name_tool -change QtXml.framework/Versions/${QT_VERSION}/QtXml @executab install_name_tool -change QtOpenGL.framework/Versions/${QT_VERSION}/QtOpenGL @executable_path/../Frameworks/QtOpenGL.framework/Versions/${QT_VERSION}/QtOpenGL ${APP}/Contents/MacOs/projectM-jack -install_name_tool -change ${PROJECTM_QT_BUILD_PATH} @executable_path/../Plugins/projectM-qt ${APP}/Contents/MacOs/projectM-jack +install_name_tool -change ${PROJECTM_QT_BUILD_PATH} @executable_path/../Plugins/libprojectM-qt.dylib ${APP}/Contents/MacOs/projectM-jack # [4b] Change projectM-qt library reference to bundle version @@ -64,7 +64,7 @@ install_name_tool -change QtCore.framework/Versions/${QT_VERSION}/QtCore @execut install_name_tool -change QtCore.framework/Versions/${QT_VERSION}/QtCore @executable_path/../Frameworks/QtCore.framework/Versions/${QT_VERSION}/QtCore ${APP}/Contents/Frameworks/QtOpenGL.framework/Versions/${QT_VERSION}/QtOpenGL install_name_tool -change QtGui.framework/Versions/${QT_VERSION}/QtGui @executable_path/../Frameworks/QtGui.framework/Versions/${QT_VERSION}/QtGui ${APP}/Contents/Frameworks/QtOpenGL.framework/Versions/${QT_VERSION}/QtOpenGL -install_name_tool -change QtCore.framework/Versions/${QT_VERSION}/QtCore @executable_path/../Frameworks/QtCore.framework/Versions/${QT_VERSION}/QtCore ${APP}/Contents/Plugins/projectM-qt -install_name_tool -change QtGui.framework/Versions/${QT_VERSION}/QtGui @executable_path/../Frameworks/QtGui.framework/Versions/${QT_VERSION}/QtGui ${APP}/Contents/Plugins/projectM-qt -install_name_tool -change QtXml.framework/Versions/${QT_VERSION}/QtXml @executable_path/../Frameworks/QtXml.framework/Versions/${QT_VERSION}/QtXml ${APP}/Contents/Plugins/projectM-qt -install_name_tool -change QtOpenGL.framework/Versions/${QT_VERSION}/QtOpenGL @executable_path/../Frameworks/QtOpenGL.framework/Versions/${QT_VERSION}/QtOpenGL ${APP}/Contents/Plugins/projectM-qt +install_name_tool -change QtCore.framework/Versions/${QT_VERSION}/QtCore @executable_path/../Frameworks/QtCore.framework/Versions/${QT_VERSION}/QtCore ${APP}/Contents/Plugins/libprojectM-qt.dylib +install_name_tool -change QtGui.framework/Versions/${QT_VERSION}/QtGui @executable_path/../Frameworks/QtGui.framework/Versions/${QT_VERSION}/QtGui ${APP}/Contents/Plugins/libprojectM-qt.dylib +install_name_tool -change QtXml.framework/Versions/${QT_VERSION}/QtXml @executable_path/../Frameworks/QtXml.framework/Versions/${QT_VERSION}/QtXml ${APP}/Contents/Plugins/libprojectM-qt.dylib +install_name_tool -change QtOpenGL.framework/Versions/${QT_VERSION}/QtOpenGL @executable_path/../Frameworks/QtOpenGL.framework/Versions/${QT_VERSION}/QtOpenGL ${APP}/Contents/Plugins/libprojectM-qt.dylib diff --git a/src/projectM-jack/qprojectM-jack.cpp b/src/projectM-jack/qprojectM-jack.cpp index 2f7910faa..b517171d6 100644 --- a/src/projectM-jack/qprojectM-jack.cpp +++ b/src/projectM-jack/qprojectM-jack.cpp @@ -33,7 +33,7 @@ #include // for mkdir #include -#define CONFIG_FILE "/share/projectM/config.inp" +#define QPROJECTM_JACK_CONFIG_FILE "/config.inp" std::string read_config(); @@ -67,7 +67,7 @@ std::string read_config() { int n; - + char num[512]; FILE *in; FILE *out; @@ -76,9 +76,14 @@ std::string read_config() char projectM_home[1024]; char projectM_config[1024]; + int len; strcpy(projectM_config, PROJECTM_PREFIX); - strcpy(projectM_config+strlen(PROJECTM_PREFIX), CONFIG_FILE); - projectM_config[strlen(PROJECTM_PREFIX)+strlen(CONFIG_FILE)]='\0'; + strcpy(projectM_config + (len = strlen(PROJECTM_PREFIX)), "/"); + + strcpy(projectM_config+(len += strlen("/")), RESOURCE_PREFIX); + strcpy(projectM_config+(len += strlen(RESOURCE_PREFIX)), QPROJECTM_JACK_CONFIG_FILE); + projectM_config[len += strlen(QPROJECTM_JACK_CONFIG_FILE)]='\0'; + printf("dir:%s \n",projectM_config); home=getenv("HOME"); strcpy(projectM_home, home);