@@ -10,6 +10,8 @@ | |||
.kdev_include_paths | |||
.kdev4/ | |||
.DS_Store | |||
.vs/ | |||
CMakeSettings.json | |||
bin/ | |||
build/ | |||
@@ -293,7 +293,8 @@ function(dpf__build_lv2 NAME DGL_LIBRARY MONOLITHIC) | |||
COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} | |||
"$<TARGET_FILE:lv2_ttl_generator>" | |||
"$<TARGET_FILE:${NAME}-lv2>" | |||
WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/bin/${NAME}.lv2") | |||
WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/bin/${NAME}.lv2" | |||
DEPENDS lv2_ttl_generator) | |||
endfunction() | |||
# dpf__build_vst2 | |||
@@ -488,6 +489,22 @@ function(dpf__add_dgl_system_libs) | |||
# target_compile_definitions(dgl-system-libs-definitions INTERFACE "HAVE_XCURSOR") | |||
#endif() | |||
endif() | |||
if(MSVC) | |||
file(MAKE_DIRECTORY "${DPF_ROOT_DIR}/khronos/GL") | |||
foreach(_gl_header "glext.h") | |||
if(NOT EXISTS "${DPF_ROOT_DIR}/khronos/GL/${_gl_header}") | |||
file(DOWNLOAD "https://www.khronos.org/registry/OpenGL/api/GL/${_gl_header}" "${DPF_ROOT_DIR}/khronos/GL/${_gl_header}" SHOW_PROGRESS) | |||
endif() | |||
endforeach() | |||
foreach(_khr_header "khrplatform.h") | |||
if(NOT EXISTS "${DPF_ROOT_DIR}/khronos/KHR/${_khr_header}") | |||
file(DOWNLOAD "https://www.khronos.org/registry/EGL/api/KHR/${_khr_header}" "${DPF_ROOT_DIR}/khronos/KHR/${_khr_header}" SHOW_PROGRESS) | |||
endif() | |||
endforeach() | |||
target_include_directories(dgl-system-libs-definitions INTERFACE "${DPF_ROOT_DIR}/khronos") | |||
endif() | |||
target_link_libraries(dgl-system-libs INTERFACE dgl-system-libs-definitions) | |||
endfunction() | |||
@@ -498,14 +515,7 @@ endfunction() | |||
# | |||
function(dpf__add_executable NAME) | |||
add_executable("${NAME}" ${ARGN}) | |||
set_target_properties("${NAME}" PROPERTIES | |||
POSITION_INDEPENDENT_CODE TRUE | |||
C_VISIBILITY_PRESET "hidden" | |||
CXX_VISIBILITY_PRESET "hidden" | |||
VISIBILITY_INLINES_HIDDEN TRUE) | |||
if (MINGW) | |||
target_compile_options("${NAME}" PUBLIC "-mstackrealign") | |||
endif() | |||
dpf__set_target_defaults("${NAME}") | |||
endfunction() | |||
# dpf__add_module | |||
@@ -515,17 +525,7 @@ endfunction() | |||
# | |||
function(dpf__add_module NAME) | |||
add_library("${NAME}" MODULE ${ARGN}) | |||
set_target_properties("${NAME}" PROPERTIES | |||
POSITION_INDEPENDENT_CODE TRUE | |||
C_VISIBILITY_PRESET "hidden" | |||
CXX_VISIBILITY_PRESET "hidden" | |||
VISIBILITY_INLINES_HIDDEN TRUE) | |||
if ((NOT WIN32 AND NOT APPLE) OR MINGW) | |||
target_link_libraries("${NAME}" PRIVATE "-Wl,--no-undefined") | |||
endif() | |||
if (MINGW) | |||
target_compile_options("${NAME}" PUBLIC "-mstackrealign") | |||
endif() | |||
dpf__set_target_defaults("${NAME}") | |||
endfunction() | |||
# dpf__add_static_library | |||
@@ -535,14 +535,30 @@ endfunction() | |||
# | |||
function(dpf__add_static_library NAME) | |||
add_library("${NAME}" STATIC ${ARGN}) | |||
dpf__set_target_defaults("${NAME}") | |||
endfunction() | |||
# dpf__set_target_defaults | |||
# ------------------------------------------------------------------------------ | |||
# | |||
# Set default properties which must apply to all DPF-defined targets. | |||
# | |||
function(dpf__set_target_defaults NAME) | |||
set_target_properties("${NAME}" PROPERTIES | |||
POSITION_INDEPENDENT_CODE TRUE | |||
C_VISIBILITY_PRESET "hidden" | |||
CXX_VISIBILITY_PRESET "hidden" | |||
VISIBILITY_INLINES_HIDDEN TRUE) | |||
if(WIN32) | |||
target_compile_definitions("${NAME}" PUBLIC "NOMINMAX") | |||
endif() | |||
if (MINGW) | |||
target_compile_options("${NAME}" PUBLIC "-mstackrealign") | |||
endif() | |||
if (MSVC) | |||
target_compile_options("${NAME}" PUBLIC "/UTF-8") | |||
target_compile_definitions("${NAME}" PUBLIC "_CRT_SECURE_NO_WARNINGS") | |||
endif() | |||
endfunction() | |||
# dpf__add_plugin_main | |||
@@ -597,7 +613,7 @@ function(dpf__add_lv2_ttl_generator) | |||
return() | |||
endif() | |||
add_executable(lv2_ttl_generator "${DPF_ROOT_DIR}/utils/lv2-ttl-generator/lv2_ttl_generator.c") | |||
if(NOT WINDOWS AND NOT APPLE AND NOT HAIKU) | |||
if((NOT WIN32) AND (NOT APPLE) AND (NOT HAIKU)) | |||
target_link_libraries(lv2_ttl_generator "dl") | |||
endif() | |||
endfunction() | |||
@@ -22,6 +22,11 @@ | |||
#include <algorithm> | |||
#if defined(_MSC_VER) | |||
#include <basetsd.h> | |||
typedef SSIZE_T ssize_t; | |||
#endif | |||
START_NAMESPACE_DISTRHO | |||
// ----------------------------------------------------------------------- | |||
@@ -658,7 +663,7 @@ public: | |||
uint i=0, j=0; | |||
uint charArray3[3], charArray4[4]; | |||
char strBuf[kTmpBufSize+1]; | |||
char* strBuf = (char*)malloc(kTmpBufSize + 1); | |||
strBuf[kTmpBufSize] = '\0'; | |||
std::size_t strBufIndex = 0; | |||
@@ -712,6 +717,8 @@ public: | |||
ret += strBuf; | |||
} | |||
free(strBuf); | |||
return ret; | |||
} | |||
@@ -74,7 +74,7 @@ | |||
#if defined(__GNUC__) | |||
# define DISTRHO_DEPRECATED __attribute__((deprecated)) | |||
#elif defined(_MSC_VER) | |||
# define DISTRHO_DEPRECATED __declspec(deprecated) | |||
# define DISTRHO_DEPRECATED [[deprecated]] // Note: __declspec(deprecated) it not applicable to enum members | |||
#else | |||
# define DISTRHO_DEPRECATED | |||
#endif | |||
@@ -40,7 +40,7 @@ Window* d_lastUiWindow = nullptr; | |||
// ----------------------------------------------------------------------------------------------------------- | |||
#if DISTRHO_PLUGIN_HAS_EXTERNAL_UI | |||
UI* createUiWrapper(void* const dspPtr, const uintptr_t winId, const double scaleFactor, const char* const bundlePath) | |||
UI* createUiWrapper(void* dspPtr, uintptr_t winId, double scaleFactor, const char* bundlePath) | |||
{ | |||
d_lastUiDspPtr = dspPtr; | |||
g_nextWindowId = winId; | |||
@@ -54,7 +54,7 @@ UI* createUiWrapper(void* const dspPtr, const uintptr_t winId, const double scal | |||
return ret; | |||
} | |||
#else | |||
UI* createUiWrapper(void* const dspPtr, Window* const window) | |||
UI* createUiWrapper(void* dspPtr, Window* window) | |||
{ | |||
d_lastUiDspPtr = dspPtr; | |||
d_lastUiWindow = window; | |||
@@ -289,7 +289,7 @@ protected: | |||
// reserve atom space | |||
const size_t atomSize = sizeof(LV2_Atom) + msgSize; | |||
char atomBuf[atomSize]; | |||
char* atomBuf = (char*)alloca(atomSize); | |||
std::memset(atomBuf, 0, atomSize); | |||
// set atom info | |||
@@ -30,6 +30,14 @@ | |||
extern "C" { | |||
#endif | |||
#ifndef LADSPA_PLUGIN_EXPORT | |||
# ifdef _WIN32 | |||
# define LADSPA_PLUGIN_EXPORT __declspec(dllexport) | |||
# else | |||
# define LADSPA_PLUGIN_EXPORT __attribute__((visibility("default"))) | |||
# endif | |||
#endif | |||
/*****************************************************************************/ | |||
/* Overview: | |||
@@ -586,7 +594,7 @@ typedef struct _LADSPA_Descriptor { | |||
returning NULL, so the plugin count can be determined by checking | |||
for the least index that results in NULL being returned. */ | |||
const LADSPA_Descriptor * ladspa_descriptor(unsigned long Index); | |||
LADSPA_PLUGIN_EXPORT const LADSPA_Descriptor * ladspa_descriptor(unsigned long Index); | |||
/* Datatype corresponding to the ladspa_descriptor() function. */ | |||
typedef const LADSPA_Descriptor * | |||
@@ -31,6 +31,9 @@ | |||
typedef void (*TTL_Generator_Function)(const char* basename); | |||
static int isPathSeparator(char c); | |||
static char* makeNormalPath(const char* path); | |||
int main(int argc, char* argv[]) | |||
{ | |||
if (argc != 2) | |||
@@ -39,10 +42,12 @@ int main(int argc, char* argv[]) | |||
return 1; | |||
} | |||
const char* path = argv[1]; | |||
#ifdef TTL_GENERATOR_WINDOWS | |||
const HMODULE handle = LoadLibraryA(argv[1]); | |||
const HMODULE handle = LoadLibraryA(path); | |||
#else | |||
void* const handle = dlopen(argv[1], RTLD_LAZY); | |||
void* const handle = dlopen(path, RTLD_LAZY); | |||
#endif | |||
if (! handle) | |||
@@ -63,33 +68,27 @@ int main(int argc, char* argv[]) | |||
if (ttlFn != NULL) | |||
{ | |||
char* basename = malloc(strlen(argv[1])+1); | |||
char* normalPath = makeNormalPath(path); | |||
#ifdef TTL_GENERATOR_WINDOWS | |||
char* base2 = strrchr(argv[1], '\\'); | |||
#else | |||
char* base2 = strrchr(argv[1], '/'); | |||
#endif | |||
if (base2 != NULL) | |||
{ | |||
strcpy(basename, base2+1); | |||
basename[strrchr(base2, '.')-base2-1] = '\0'; | |||
} | |||
else if (argv[1][0] == '.' && argv[1][1] == '/') | |||
{ | |||
strcpy(basename, argv[1]+2); | |||
basename[strrchr(basename, '.')-basename] = '\0'; | |||
} | |||
path = normalPath; | |||
while (path[0] == '.' && path[1] == '/') | |||
path += 2; | |||
char* basename = strrchr(path, '/'); | |||
if (basename != NULL) | |||
basename += 1; | |||
else | |||
{ | |||
strcpy(basename, argv[1]); | |||
} | |||
basename = (char*)path; | |||
char* dotPos = strrchr(basename, '.'); | |||
if (dotPos) | |||
*dotPos = '\0'; | |||
printf("Generate ttl data for '%s', basename: '%s'\n", argv[1], basename); | |||
printf("Generate ttl data for '%s', basename: '%s'\n", path, basename); | |||
ttlFn(basename); | |||
free(basename); | |||
free(normalPath); | |||
} | |||
else | |||
printf("Failed to find 'lv2_generate_ttl' function\n"); | |||
@@ -102,3 +101,31 @@ int main(int argc, char* argv[]) | |||
return 0; | |||
} | |||
static int isPathSeparator(char c) | |||
{ | |||
#ifdef TTL_GENERATOR_WINDOWS | |||
return c == '/' || c == '\\'; | |||
#else | |||
return c == '/'; | |||
#endif | |||
} | |||
static char* makeNormalPath(const char* path) | |||
{ | |||
size_t i, j; | |||
size_t len = strlen(path); | |||
char* result = (char*)malloc(len + 1); | |||
int isSep, wasSep = 0; | |||
for (i = 0, j = 0; i < len; ++i) | |||
{ | |||
isSep = isPathSeparator(path[i]); | |||
if (!isSep) | |||
result[j++] = path[i]; | |||
else if (!wasSep) | |||
result[j++] = '/'; | |||
wasSep = isSep; | |||
} | |||
result[j] = '\0'; | |||
return result; | |||
} |