@@ -44,7 +44,7 @@ STANDALONE_LIBS += $(MODULEDIR)/rtaudio.a | |||
STANDALONE_LIBS += $(MODULEDIR)/rtmidi.a | |||
UTILS_LIBS += $(MODULEDIR)/lilv.a | |||
UTILS_LIBS += $(MODULEDIR)/water.a | |||
UTILS_LIBS += $(MODULEDIR)/water.files.a | |||
# ---------------------------------------------------------------------------------------------------------------------------- | |||
@@ -130,7 +130,7 @@ ui_lv2-windows: $(BINDIR)/$(MODULENAME)-lv2-windows.exe | |||
LIBS = \ | |||
$(MODULEDIR)/lilv.a \ | |||
$(MODULEDIR)/water.a | |||
$(MODULEDIR)/water.files.a | |||
# ---------------------------------------------------------------------------------------------------------------------------- | |||
# Common objects | |||
@@ -16,10 +16,12 @@ BUILD_CXX_FLAGS += -I.. | |||
ifeq ($(MACOS),true) | |||
OBJS = $(OBJDIR)/$(MODULENAME).mm.o | |||
OBJS_files = $(OBJDIR)/$(MODULENAME).mm.files.o | |||
OBJS_posix32 = $(OBJDIR)/$(MODULENAME).mm.posix32.o | |||
OBJS_posix64 = $(OBJDIR)/$(MODULENAME).mm.posix64.o | |||
else | |||
OBJS = $(OBJDIR)/$(MODULENAME).cpp.o | |||
OBJS_files = $(OBJDIR)/$(MODULENAME).cpp.files.o | |||
OBJS_posix32 = $(OBJDIR)/$(MODULENAME).cpp.posix32.o | |||
OBJS_posix64 = $(OBJDIR)/$(MODULENAME).cpp.posix64.o | |||
endif | |||
@@ -28,7 +30,7 @@ OBJS_win64 = $(OBJDIR)/$(MODULENAME).cpp.win64.o | |||
# ---------------------------------------------------------------------------------------------------------------------------- | |||
all: $(MODULEDIR)/$(MODULENAME).a | |||
all: $(MODULEDIR)/$(MODULENAME).a $(MODULEDIR)/$(MODULENAME).files.a | |||
posix32: $(MODULEDIR)/$(MODULENAME).posix32.a | |||
posix64: $(MODULEDIR)/$(MODULENAME).posix64.a | |||
win32: $(MODULEDIR)/$(MODULENAME).win32.a | |||
@@ -42,9 +44,6 @@ clean: | |||
debug: | |||
$(MAKE) DEBUG=true | |||
test: main.cpp $(MODULEDIR)/$(MODULENAME).a | |||
@$(CXX) $< $(MODULEDIR)/$(MODULENAME).a $(BUILD_CXX_FLAGS) $(LINK_FLAGS) -lpthread -o $@ | |||
# ---------------------------------------------------------------------------------------------------------------------------- | |||
$(MODULEDIR)/$(MODULENAME).a: $(OBJS) | |||
@@ -53,6 +52,12 @@ $(MODULEDIR)/$(MODULENAME).a: $(OBJS) | |||
@rm -f $@ | |||
@$(AR) crs $@ $^ | |||
$(MODULEDIR)/$(MODULENAME).files.a: $(OBJS_files) | |||
-@mkdir -p $(MODULEDIR) | |||
@echo "Creating $(MODULENAME).files.a" | |||
@rm -f $@ | |||
@$(AR) crs $@ $^ | |||
$(MODULEDIR)/$(MODULENAME).posix32.a: $(OBJS_posix32) | |||
-@mkdir -p $(MODULEDIR) | |||
@echo "Creating $(MODULENAME).posix32.a" | |||
@@ -84,6 +89,11 @@ $(OBJDIR)/$(MODULENAME).cpp.o: $(MODULENAME).cpp | |||
@echo "Compiling $<" | |||
@$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ | |||
$(OBJDIR)/$(MODULENAME).cpp.files.o: $(MODULENAME).files.cpp | |||
-@mkdir -p $(OBJDIR) | |||
@echo "Compiling $<" | |||
@$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ | |||
$(OBJDIR)/$(MODULENAME).cpp.%32.o: $(MODULENAME).cpp | |||
-@mkdir -p $(OBJDIR) | |||
@echo "Compiling $< (32bit)" | |||
@@ -101,6 +111,11 @@ $(OBJDIR)/$(MODULENAME).mm.o: $(MODULENAME).cpp | |||
@echo "Compiling $<" | |||
@$(CXX) $< $(BUILD_CXX_FLAGS) -ObjC++ -c -o $@ | |||
$(OBJDIR)/$(MODULENAME).mm.files.o: $(MODULENAME).files.cpp | |||
-@mkdir -p $(OBJDIR) | |||
@echo "Compiling $<" | |||
@$(CXX) $< $(BUILD_CXX_FLAGS) -ObjC++ -c -o $@ | |||
$(OBJDIR)/$(MODULENAME).mm.%32.o: $(MODULENAME).cpp | |||
-@mkdir -p $(OBJDIR) | |||
@echo "Compiling $< (32bit)" | |||
@@ -0,0 +1,70 @@ | |||
/* | |||
* Cross-platform C++ library for Carla, based on Juce v4 | |||
* Copyright (C) 2015 ROLI Ltd. | |||
* Copyright (C) 2017 Filipe Coelho <falktx@falktx.com> | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU General Public License as | |||
* published by the Free Software Foundation; either version 2 of | |||
* the License, or any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | |||
* | |||
* For a full copy of the GNU General Public License see the doc/GPL.txt file. | |||
*/ | |||
#include "maths/MathsFunctions.h" | |||
#include "misc/Result.h" | |||
//============================================================================== | |||
namespace water | |||
{ | |||
#ifdef CARLA_OS_WIN | |||
static inline | |||
Result getResultForLastError() | |||
{ | |||
TCHAR messageBuffer [256] = { 0 }; | |||
FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, | |||
nullptr, GetLastError(), MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), | |||
messageBuffer, (DWORD) numElementsInArray (messageBuffer) - 1, nullptr); | |||
return Result::fail (String (messageBuffer)); | |||
} | |||
static inline | |||
int64 water_fileSetPosition (void* handle, int64 pos) | |||
{ | |||
LARGE_INTEGER li; | |||
li.QuadPart = pos; | |||
li.LowPart = SetFilePointer ((HANDLE) handle, (LONG) li.LowPart, &li.HighPart, FILE_BEGIN); // (returns -1 if it fails) | |||
return li.QuadPart; | |||
} | |||
#else | |||
static inline | |||
Result getResultForErrno() | |||
{ | |||
return Result::fail (String (strerror (errno))); | |||
} | |||
static inline | |||
int getFD (void* handle) noexcept { return (int) (pointer_sized_int) handle; } | |||
static inline | |||
void* fdToVoidPointer (int fd) noexcept { return (void*) (pointer_sized_int) fd; } | |||
static inline | |||
int64 water_fileSetPosition (void* handle, int64 pos) | |||
{ | |||
if (handle != nullptr && lseek (getFD (handle), pos, SEEK_SET) == pos) | |||
return pos; | |||
return -1; | |||
} | |||
#endif | |||
} |
@@ -16,33 +16,13 @@ | |||
* For a full copy of the GNU General Public License see the doc/GPL.txt file. | |||
*/ | |||
#include "maths/MathsFunctions.h" | |||
#include "misc/Result.h" | |||
#include "common.hpp" | |||
//============================================================================== | |||
namespace water | |||
{ | |||
#ifdef CARLA_OS_WIN | |||
static Result getResultForLastError() | |||
{ | |||
TCHAR messageBuffer [256] = { 0 }; | |||
FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, | |||
nullptr, GetLastError(), MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), | |||
messageBuffer, (DWORD) numElementsInArray (messageBuffer) - 1, nullptr); | |||
return Result::fail (String (messageBuffer)); | |||
} | |||
static int64 water_fileSetPosition (void* handle, int64 pos) | |||
{ | |||
LARGE_INTEGER li; | |||
li.QuadPart = pos; | |||
li.LowPart = SetFilePointer ((HANDLE) handle, (LONG) li.LowPart, &li.HighPart, FILE_BEGIN); // (returns -1 if it fails) | |||
return li.QuadPart; | |||
} | |||
static HINSTANCE currentModuleHandle = nullptr; | |||
HINSTANCE water_getCurrentModuleInstanceHandle() noexcept | |||
@@ -52,22 +32,6 @@ HINSTANCE water_getCurrentModuleInstanceHandle() noexcept | |||
return currentModuleHandle; | |||
} | |||
#else | |||
static Result getResultForErrno() | |||
{ | |||
return Result::fail (String (strerror (errno))); | |||
} | |||
static int getFD (void* handle) noexcept { return (int) (pointer_sized_int) handle; } | |||
static void* fdToVoidPointer (int fd) noexcept { return (void*) (pointer_sized_int) fd; } | |||
static int64 water_fileSetPosition (void* handle, int64 pos) | |||
{ | |||
if (handle != nullptr && lseek (getFD (handle), pos, SEEK_SET) == pos) | |||
return pos; | |||
return -1; | |||
} | |||
#endif | |||
} | |||
@@ -0,0 +1,43 @@ | |||
/* | |||
* Cross-platform C++ library for Carla, based on Juce v4 | |||
* Copyright (C) 2015 ROLI Ltd. | |||
* Copyright (C) 2017 Filipe Coelho <falktx@falktx.com> | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU General Public License as | |||
* published by the Free Software Foundation; either version 2 of | |||
* the License, or any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | |||
* | |||
* For a full copy of the GNU General Public License see the doc/GPL.txt file. | |||
*/ | |||
#include "common.hpp" | |||
//============================================================================== | |||
namespace water | |||
{ | |||
#ifdef CARLA_OS_WIN | |||
static HINSTANCE currentModuleHandle = nullptr; | |||
HINSTANCE water_getCurrentModuleInstanceHandle() noexcept | |||
{ | |||
if (currentModuleHandle == nullptr) | |||
currentModuleHandle = GetModuleHandleA (nullptr); | |||
return currentModuleHandle; | |||
} | |||
#endif | |||
} | |||
#include "files/File.cpp" | |||
#include "misc/Result.cpp" | |||
#include "text/CharacterFunctions.cpp" | |||
#include "text/StringArray.cpp" | |||
#include "text/String.cpp" |