From 3eba4b755e353a3b35480b431a727ae45461abcd Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Sat, 26 Aug 2017 22:48:43 -0400 Subject: [PATCH] Switch from noc to osdialog, add arch-detecting Makefile, added dep Makefile --- Makefile | 10 ++--- Makefile-arch.inc | 15 +++++++ Makefile.inc | 3 ++ dep/Makefile | 99 +++++++++++++++++++++++++++++++++++++++++++++ include/gui.hpp | 2 - src/app.cpp | 2 +- src/app/Toolbar.cpp | 7 +++- src/gui.cpp | 12 ------ 8 files changed, 127 insertions(+), 23 deletions(-) create mode 100644 Makefile-arch.inc create mode 100755 dep/Makefile diff --git a/Makefile b/Makefile index ac81318b..ccf6cdff 100644 --- a/Makefile +++ b/Makefile @@ -8,8 +8,8 @@ SOURCES = $(wildcard src/*.cpp src/*/*.cpp) \ ifeq ($(ARCH), lin) -SOURCES += ext/noc/noc_file_dialog.c -CFLAGS += -DNOC_FILE_DIALOG_GTK $(shell pkg-config --cflags gtk+-2.0) +SOURCES += ext/osdialog/osdialog_gtk2.c +CFLAGS += $(shell pkg-config --cflags gtk+-2.0) LDFLAGS += -rdynamic \ -lpthread -lGL -ldl \ -lportaudio -lportmidi \ @@ -19,16 +19,14 @@ TARGET = Rack endif ifeq ($(ARCH), mac) -SOURCES += ext/noc/noc_file_dialog.m -CFLAGS += -DNOC_FILE_DIALOG_OSX +SOURCES += ext/osdialog/osdialog_mac.m CXXFLAGS += -DAPPLE -stdlib=libc++ -I$(HOME)/local/include -I/usr/local/lib/libzip/include LDFLAGS += -stdlib=libc++ -L$(HOME)/local/lib -lpthread -lglew -lglfw3 -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo -ldl -ljansson -lportaudio -lportmidi -lsamplerate -lcurl -lzip TARGET = Rack endif ifeq ($(ARCH), win) -SOURCES += ext/noc/noc_file_dialog.c -CFLAGS += -DNOC_FILE_DIALOG_WIN32 +SOURCES += ext/osdialog/osdialog_win.c CXXFLAGS += -DGLEW_STATIC \ -I$(HOME)/pkg/portaudio-r1891-build/include -I/mingw64/lib/libzip/include -I$(HOME)/local/include LDFLAGS += \ diff --git a/Makefile-arch.inc b/Makefile-arch.inc new file mode 100644 index 00000000..25d7f4c3 --- /dev/null +++ b/Makefile-arch.inc @@ -0,0 +1,15 @@ +# Detect architecture if ARCH is not defined + +MACHINE = $(shell gcc -dumpmachine) +ifneq (,$(findstring linux,$(MACHINE))) + # Linux + ARCH = lin +else ifneq (,$(findstring apple,$(MACHINE))) + # Mac + ARCH = mac +else ifneq (,$(findstring mingw,$(MACHINE))) + # Windows + ARCH = win +else + $(error Could not determine machine type. Try hacking around in Makefile-arch.inc) +endif diff --git a/Makefile.inc b/Makefile.inc index b20c24b0..21a56c6e 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -1,3 +1,6 @@ +VERSION ?= dev +FLAGS += -DVERSION=$(VERSION) + # Generate dependency files build/*.d FLAGS += -MMD # Optimization diff --git a/dep/Makefile b/dep/Makefile new file mode 100755 index 00000000..b3388665 --- /dev/null +++ b/dep/Makefile @@ -0,0 +1,99 @@ + +LOCAL = $(PWD) + +# Arch-specifics +include ../Makefile-arch.inc +ifeq ($(ARCH),mac) + export CFLAGS = -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk \ + -mmacosx-version-min=10.7 + export CXXFLAGS = $(CFLAGS) + export LDFLAGS = $(CFLAGS) +endif + +# Commands +WGET = wget -nc +UNTAR = tar xf +UNZIP = unzip + +# Packages +glew = glew-2.1.0 +glfw = glfw-3.2.1 +jansson = jansson-2.10 +libsamplerate = libsamplerate-0.1.9 +libcurl = curl-7.54.1 +libzip = libzip-1.2.0 +portmidi = portmidi +portaudio = portaudio + + +.NOTPARALLEL: + +all: $(glew) $(glfw) $(jansson) $(libsamplerate) $(libcurl) $(libzip) $(portmidi) $(portaudio) + +$(glew): + $(WGET) https://downloads.sourceforge.net/project/glew/glew/$(patsubst glew-%,%,$@)/$@.tgz + $(UNTAR) $@.tgz + $(MAKE) -C $@ + ln -s lib lib64 + $(MAKE) -C $@ GLEW_DEST="$(LOCAL)" install + rm lib64 + +$(glfw): + $(WGET) https://github.com/glfw/glfw/releases/download/$(patsubst glfw-%,%,$@)/$@.zip + $(UNZIP) $@.zip + cd $@ && cmake . \ + -DCMAKE_INSTALL_PREFIX="$(LOCAL)" -DBUILD_SHARED_LIBS=ON \ + -DGLFW_USE_CHDIR=ON -DGLFW_USE_MENUBAR=ON -DGLFW_USE_RETINA=ON + $(MAKE) -C $@ + $(MAKE) -C $@ install + +$(jansson): + $(WGET) http://www.digip.org/jansson/releases/$@.tar.gz + $(UNTAR) $@.tar.gz + cd $@ && ./configure --prefix="$(LOCAL)" + $(MAKE) -C $@ + $(MAKE) -C $@ install + +$(libsamplerate): + $(WGET) http://www.mega-nerd.com/SRC/$@.tar.gz + $(UNTAR) $@.tar.gz + cd $@ && ./configure --prefix="$(LOCAL)" + $(MAKE) -C $@ + $(MAKE) -C $@ install + +$(libcurl): + $(WGET) https://curl.haxx.se/download/$@.tar.gz + $(UNTAR) $@.tar.gz + cd $@ && ./configure --prefix="$(LOCAL)" \ + --disable-ftp --disable-file --disable-ldap --disable-ldaps --disable-rtsp --disable-proxy --disable-dict --disable-telnet --disable-tftp --disable-pop3 --disable-imap --disable-smb --disable-smtp --disable-gopher --disable-manual \ + --without-zlib --without-ssl --without-ca-bundle --without-ca-path --without-ca-fallback --without-libpsl --without-libmetalink --without-libssh2 --without-librtmp --without-winidn --without-libidn2 --without-nghttp2 + $(MAKE) -C $@ + $(MAKE) -C $@ install + +$(libzip): + $(WGET) https://nih.at/libzip/$@.tar.gz + $(UNTAR) $@.tar.gz + cd $@ && ./configure --prefix="$(LOCAL)" + $(MAKE) -C $@ + $(MAKE) -C $@ install + +$(portmidi): + git clone https://github.com/aoeu/portmidi.git $@ + # TODO Does not yet work + cd $@ && cmake . -DCMAKE_INSTALL_PREFIX="$(LOCAL)" \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=$(PWD)/$@/Release \ + -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=$(PWD)/$@/Release \ + -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=$(PWD)/$@/Release + $(MAKE) -C $@ + $(MAKE) -C $@ install + +$(portaudio): + $(WGET) http://www.portaudio.com/archives/pa_stable_v190600_20161030.tgz + $(UNTAR) pa_stable_v190600_20161030.tgz + cd $@ && ./configure --prefix="$(LOCAL)" + $(MAKE) -C $@ + $(MAKE) -C $@ install + +clean: + git clean -fdxi diff --git a/include/gui.hpp b/include/gui.hpp index 0d31c3a5..380b344f 100644 --- a/include/gui.hpp +++ b/include/gui.hpp @@ -11,8 +11,6 @@ void guiRun(); bool guiIsKeyPressed(int key); void guiCursorLock(); void guiCursorUnlock(); -const char *guiSaveDialog(const char *filters, const char *filename); -const char *guiOpenDialog(const char *filters, const char *filename); extern NVGcontext *gVg; extern std::shared_ptr gGuiFont; diff --git a/src/app.cpp b/src/app.cpp index e9bca662..e626205c 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -4,7 +4,7 @@ namespace rack { std::string gApplicationName = "VCV Rack"; -std::string gApplicationVersion = "v0.2.1 alpha"; +std::string gApplicationVersion = TOSTRING(VERSION); RackWidget *gRackWidget = NULL; diff --git a/src/app/Toolbar.cpp b/src/app/Toolbar.cpp index 67a491f0..8e4f0123 100644 --- a/src/app/Toolbar.cpp +++ b/src/app/Toolbar.cpp @@ -1,6 +1,7 @@ #include "app.hpp" #include "gui.hpp" #include "engine.hpp" +#include "../ext/osdialog/osdialog.h" namespace rack { @@ -16,18 +17,20 @@ struct NewItem : MenuItem { struct SaveItem : MenuItem { void onAction() { - const char *path = guiSaveDialog(filters, "Untitled.json"); + char *path = osdialog_file(OSDIALOG_SAVE, "./patches", "Untitled.json", NULL); if (path) { gRackWidget->savePatch(path); + free(path); } } }; struct OpenItem : MenuItem { void onAction() { - const char *path = guiOpenDialog(filters, NULL); + char *path = osdialog_file(OSDIALOG_OPEN, "./patches", NULL, NULL); if (path) { gRackWidget->loadPatch(path); + free(path); } } }; diff --git a/src/gui.cpp b/src/gui.cpp index 74822456..1bfa4355 100644 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -17,10 +17,6 @@ #define NANOSVG_IMPLEMENTATION #include "../ext/nanosvg/src/nanosvg.h" -extern "C" { - #include "../ext/noc/noc_file_dialog.h" -} - namespace rack { @@ -284,14 +280,6 @@ void guiCursorUnlock() { glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL); } -const char *guiSaveDialog(const char *filters, const char *filename) { - return noc_file_dialog_open(NOC_FILE_DIALOG_SAVE, filters, NULL, filename); -} - -const char *guiOpenDialog(const char *filters, const char *filename) { - return noc_file_dialog_open(NOC_FILE_DIALOG_OPEN, filters, NULL, filename); -} - //////////////////// // resources