Browse Source

Change build system to create standalone app bundle with resources inside, use ~/Documents/Rack as local directory

tags/v0.4.0
Andrew Belt 7 years ago
parent
commit
ba49dd6cb4
3 changed files with 58 additions and 37 deletions
  1. +25
    -21
      Makefile
  2. +28
    -16
      src/asset.cpp
  3. +5
    -0
      src/main.cpp

+ 25
- 21
Makefile View File

@@ -74,29 +74,15 @@ include compile.mk


dist: all
ifndef VERSION
$(error VERSION is not set.)
endif
mkdir -p dist/Rack
mkdir -p dist/Rack/plugins
cp -R LICENSE* res dist/Rack/
ifeq ($(ARCH), lin)
cp Rack Rack.sh dist/Rack/
cp dep/lib/libsamplerate.so.0 dist/Rack/
cp dep/lib/libjansson.so.4 dist/Rack/
cp dep/lib/libGLEW.so.2.1 dist/Rack/
cp dep/lib/libglfw.so.3 dist/Rack/
cp dep/lib/libcurl.so.4 dist/Rack/
cp dep/lib/libzip.so.5 dist/Rack/
cp dep/lib/libportaudio.so.2 dist/Rack/
cp dep/lib/libportmidi.so dist/Rack/
endif
$(MAKE) -C plugins/Fundamental dist

ifeq ($(ARCH), mac)
$(eval BUNDLE := dist/Rack/$(TARGET).app)
$(eval BUNDLE := dist/$(TARGET).app)
mkdir -p $(BUNDLE)
mkdir -p $(BUNDLE)/Contents
mkdir -p $(BUNDLE)/Contents/Resources
cp Info.plist $(BUNDLE)/Contents/
cp -R LICENSE* res $(BUNDLE)/Contents/Resources

mkdir -p $(BUNDLE)/Contents/MacOS
cp Rack $(BUNDLE)/Contents/MacOS/
@@ -123,8 +109,13 @@ ifeq ($(ARCH), mac)
install_name_tool -change @rpath/libportmidi.dylib @executable_path/libportmidi.dylib $(BUNDLE)/Contents/MacOS/Rack

otool -L $(BUNDLE)/Contents/MacOS/Rack

mkdir -p $(BUNDLE)/Contents/Resources/plugins
cp -R plugins/Fundamental/dist/Fundamental $(BUNDLE)/Contents/Resources/plugins
endif
ifeq ($(ARCH), win)
mkdir -p dist/Rack
cp -R LICENSE* res dist/Rack/
cp Rack.exe dist/Rack/
cp /mingw64/bin/libwinpthread-1.dll dist/Rack/
cp /mingw64/bin/zlib1.dll dist/Rack/
@@ -138,11 +129,24 @@ ifeq ($(ARCH), win)
cp dep/bin/libsamplerate-0.dll dist/Rack/
cp dep/bin/libzip-5.dll dist/Rack/
cp dep/bin/portaudio_x64.dll dist/Rack/
mkdir -p dist/Rack/plugins
cp -R plugins/Fundamental/dist/Fundamental dist/Rack/plugins/
endif

# Fundamental
$(MAKE) -C plugins/Fundamental dist
ifeq ($(ARCH), lin)
mkdir -p dist/Rack
cp -R LICENSE* res dist/Rack/
cp Rack Rack.sh dist/Rack/
cp dep/lib/libsamplerate.so.0 dist/Rack/
cp dep/lib/libjansson.so.4 dist/Rack/
cp dep/lib/libGLEW.so.2.1 dist/Rack/
cp dep/lib/libglfw.so.3 dist/Rack/
cp dep/lib/libcurl.so.4 dist/Rack/
cp dep/lib/libzip.so.5 dist/Rack/
cp dep/lib/libportaudio.so.2 dist/Rack/
cp dep/lib/libportmidi.so dist/Rack/
mkdir -p dist/Rack/plugins
cp -R plugins/Fundamental/dist/Fundamental dist/Rack/plugins/
endif

ifeq ($(ARCH), mac)
cd dist && ln -s /Applications Applications


+ 28
- 16
src/asset.cpp View File

@@ -1,25 +1,28 @@
#include "asset.hpp"
#include <stdlib.h> // for realpath
#include <assert.h>
#include <sys/stat.h> // for mkdir

#if ARCH_MAC
#include <CoreFoundation/CoreFoundation.h>
#include <pwd.h>
#endif

namespace rack {

namespace rack {

static std::string fileRealPath(std::string path) {
char *rpath = realpath(path.c_str(), NULL);
if (!rpath)
return "";

std::string rrpath = path;
free(rpath);
return rrpath;
}

std::string assetGlobal(std::string filename) {
std::string path;
#if ARCH_MAC
// TODO
CFBundleRef bundle = CFBundleGetMainBundle();
CFURLRef resourcesUrl = CFBundleCopyResourcesDirectoryURL(bundle);
char buf[PATH_MAX];
Boolean success = CFURLGetFileSystemRepresentation(resourcesUrl, TRUE, (UInt8 *)buf, sizeof(buf));
assert(success);
CFRelease(resourcesUrl);
path = buf;
path += "/";
path += filename;
#endif
#if ARCH_WIN
path = "./" + filename;
@@ -27,13 +30,20 @@ std::string assetGlobal(std::string filename) {
#if ARCH_LIN
path = "./" + filename;
#endif
return fileRealPath(path);
return path;
}

std::string assetLocal(std::string filename) {
std::string path;
#if ARCH_MAC
// TODO
// Get home directory
struct passwd *pw = getpwuid(getuid());
assert(pw);
path = pw->pw_dir;
path += "/Documents/Rack";
mkdir(path.c_str(), 0755);
path += "/";
path += filename;
#endif
#if ARCH_WIN
// TODO
@@ -43,12 +53,14 @@ std::string assetLocal(std::string filename) {
// If Rack is "installed" (however that may be defined), look in ~/.Rack or something instead
path = "./" + filename;
#endif
return fileRealPath(path);
return path;
}

std::string assetPlugin(Plugin *plugin, std::string filename) {
assert(plugin);
return fileRealPath(plugin->path + "/" + filename);
std::string path;
path = plugin->path + "/" + filename;
return path;
}




+ 5
- 0
src/main.cpp View File

@@ -4,11 +4,16 @@
#include "plugin.hpp"
#include "settings.hpp"
#include "asset.hpp"
#include <unistd.h>


using namespace rack;

int main(int argc, char* argv[]) {
char *cwd = getcwd(NULL, 0);
printf("Current working directory is %s\n", cwd);
free(cwd);

pluginInit();
engineInit();
guiInit();


Loading…
Cancel
Save