Skip to content

Commit

Permalink
Merge pull request surge-synthesizer#25 from kzantow/build-on-osx
Browse files Browse the repository at this point in the history
[WiP] Build on OSX (surge-synthesizer#3)
  • Loading branch information
kurasu authored Oct 7, 2018
2 parents 09a22e4 + 43e6ae5 commit cd44922
Show file tree
Hide file tree
Showing 9 changed files with 201 additions and 3 deletions.
5 changes: 4 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "vst3sdk"]
path = vst3sdk
url = https://github.com/steinbergmedia/vst3sdk.git
url = https://github.com/steinbergmedia/vst3sdk.git
[submodule "VST_SDK_2.4"]
path = VST_SDK_2.4
url = https://github.com/R-Tur/VST_SDK_2.4
2 changes: 1 addition & 1 deletion build-osx.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
premake5 xcode4
xcodebuild build -configuration Release -project surge-vst2.xcodeproj
xcodebuild build -configuration Release -project surge-vst3.xcodeproj
xcodebuild build -configuration Release -project surge-au.xcodeproj
xcodebuild build -configuration Release -project surge-au.xcodeproj
114 changes: 114 additions & 0 deletions libs/filesystem/filesystem.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
//
// filesystem.cpp
// surge-vst2
//
// Created by Keith Zantow on 10/2/18.
//

#ifdef __APPLE__
#include "TargetConditionals.h"
#ifdef TARGET_OS_MAC

#include "filesystem.h"

namespace std::experimental::filesystem {
path::path():
path("")
{}

path::path(std::string filePath):
p(filePath)
{}

path::operator std::string() {
return p;
}

void path::append(std::string s) {
p.append("/");
p.append(s);
}

const char* path::c_str() {
return p.c_str();
}

std::string path::generic_string() {
return p;
}

path path::filename() {
auto idx = this->p.find_last_of("/");
path p(this->p.substr(idx+1));
return p;
}

std::string path::extension() {
auto idx = this->p.find_last_of(".");
return p.substr(idx);
}

file::file(std::string filePath):
p(filePath)
{}

file::operator class path() {
return p;
}

path file::path() {
return p;
}

bool exists(path p) {
FILE *file;
if ((file = fopen(p.p.c_str(), "r")))
{
fclose(file);
return true;
}
return false;
}

void create_directories(path p) {
mode_t nMode = 0733; // UNIX style permissions
int nError = 0;
#if defined(_WIN32)
nError = _mkdir(p.c_str()); // can be used on Windows
#else
nError = mkdir(p.c_str(), nMode); // can be used on non-Windows
#endif
if (nError != 0) {
// handle your error here
}
}

bool is_directory(path p) {
DIR *dp;
bool isDir = false;
if((dp = opendir(p.c_str())) != NULL && readdir(dp) != NULL) {
isDir = true;
}
closedir(dp);
return isDir;
}

std::vector<file> directory_iterator(path p) {
std::vector<file> files;
DIR *dp;
struct dirent *dirp;
if((dp = opendir(p.c_str())) == NULL) {
// std::cout << "Error(" << errno << ") opening " << p.generic_string() << std::endl;
}

while ((dirp = readdir(dp)) != NULL) {
files.push_back(file(string(dirp->d_name)));
}
closedir(dp);

return files;
}
}

#endif
#endif
68 changes: 68 additions & 0 deletions libs/filesystem/filesystem.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
//
// Filesystem.h
// surge-vst2
//
// Created by Keith Zantow on 10/2/18.
//

#ifndef Filesystem_h
#define Filesystem_h

#ifdef __APPLE__
#include "TargetConditionals.h"
#ifdef TARGET_OS_MAC

#include <string>
#include <vector>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>

namespace std::experimental::filesystem {
class path {
public:
std::string p;

path();

path(std::string filePath);

operator std::string();

void append(std::string s);

const char* c_str();

std::string generic_string();

path filename();

std::string extension();
};

class file {
public:
path p;

file(std::string filePath);

operator path();

path path();
};

bool exists(path p);

void create_directories(path p);

bool is_directory(path p);

std::vector<file> directory_iterator(path p);
}

#endif
#else
#include <filesystem>
#endif

#endif /* Filesystem_h */
Empty file modified package-vst.sh
100644 → 100755
Empty file.
9 changes: 9 additions & 0 deletions premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ function plugincommon()
"libs/xml/tinyxml.cpp",
"libs/xml/tinyxmlerror.cpp",
"libs/xml/tinyxmlparser.cpp",
"libs/filesystem/filesystem.cpp",
"src/common/vt_dsp/*.cpp",
"src/common/thread/*.cpp",
"vst3sdk/pluginterfaces/base/*.cpp",
Expand All @@ -162,6 +163,12 @@ function plugincommon()
"-Wno-unused-variable"
}

sysincludedirs {
"src/**",
"libs/**",
"vst3sdk/vstgui4",
}

files
{
"src/mac/**.mm",
Expand Down Expand Up @@ -293,6 +300,7 @@ plugincommon()
files {
"src/vst2/**.cpp",
"src/vst2/**.h",
"VST_SDK_2.4/public.sdk/source/vst2.x/**.cpp",
"vst3sdk/public.sdk/source/vst2.x/**.cpp",
VSTGUI .. "plugin-bindings/aeffguieditor.cpp",
}
Expand All @@ -303,6 +311,7 @@ excludes {

includedirs {
"src/vst2",
"VST_SDK_2.4",
"vst3sdk"
}

Expand Down
2 changes: 2 additions & 0 deletions src/common/SurgeStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ using namespace std;

#if __linux
#include <experimental/filesystem>
#elif __APPLE__
#include <filesystem.h>
#else
#include <filesystem>
#endif
Expand Down
2 changes: 2 additions & 0 deletions src/common/SurgeSynthesizerIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include <vt_dsp/vt_dsp_endian.h>
#ifdef __linux__
#include <experimental/filesystem>
#elif __APPLE__
#include <filesystem.h>
#else
#include <filesystem>
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/vst2/Vst2PluginInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "SurgeGUIEditor.h"
//#include "sub3_editor2.h"
#include <float.h>
#include <public.sdk/source/vst2.x/aeffeditor.h>
#include "public.sdk/source/vst2.x/aeffeditor.h"

#if PPC
// For Carbon, use CoreServices.h instead
Expand Down

0 comments on commit cd44922

Please sign in to comment.