Browse Source

Other fixes to enable msvc builds

pull/278/head
Jean Pierre Cimalando 4 years ago
parent
commit
8cc6eb8f2f
8 changed files with 110 additions and 50 deletions
  1. +2
    -0
      .gitignore
  2. +37
    -21
      cmake/DPF-plugin.cmake
  3. +8
    -1
      distrho/extra/String.hpp
  4. +1
    -1
      distrho/src/DistrhoDefines.h
  5. +2
    -2
      distrho/src/DistrhoUI.cpp
  6. +1
    -1
      distrho/src/DistrhoUILV2.cpp
  7. +9
    -1
      distrho/src/ladspa/ladspa.h
  8. +50
    -23
      utils/lv2-ttl-generator/lv2_ttl_generator.c

+ 2
- 0
.gitignore View File

@@ -10,6 +10,8 @@
.kdev_include_paths .kdev_include_paths
.kdev4/ .kdev4/
.DS_Store .DS_Store
.vs/
CMakeSettings.json


bin/ bin/
build/ build/


+ 37
- 21
cmake/DPF-plugin.cmake View File

@@ -293,7 +293,8 @@ function(dpf__build_lv2 NAME DGL_LIBRARY MONOLITHIC)
COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR}
"$<TARGET_FILE:lv2_ttl_generator>" "$<TARGET_FILE:lv2_ttl_generator>"
"$<TARGET_FILE:${NAME}-lv2>" "$<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() endfunction()


# dpf__build_vst2 # dpf__build_vst2
@@ -488,6 +489,22 @@ function(dpf__add_dgl_system_libs)
# target_compile_definitions(dgl-system-libs-definitions INTERFACE "HAVE_XCURSOR") # target_compile_definitions(dgl-system-libs-definitions INTERFACE "HAVE_XCURSOR")
#endif() #endif()
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) target_link_libraries(dgl-system-libs INTERFACE dgl-system-libs-definitions)
endfunction() endfunction()


@@ -498,14 +515,7 @@ endfunction()
# #
function(dpf__add_executable NAME) function(dpf__add_executable NAME)
add_executable("${NAME}" ${ARGN}) 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() endfunction()


# dpf__add_module # dpf__add_module
@@ -515,17 +525,7 @@ endfunction()
# #
function(dpf__add_module NAME) function(dpf__add_module NAME)
add_library("${NAME}" MODULE ${ARGN}) 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() endfunction()


# dpf__add_static_library # dpf__add_static_library
@@ -535,14 +535,30 @@ endfunction()
# #
function(dpf__add_static_library NAME) function(dpf__add_static_library NAME)
add_library("${NAME}" STATIC ${ARGN}) 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 set_target_properties("${NAME}" PROPERTIES
POSITION_INDEPENDENT_CODE TRUE POSITION_INDEPENDENT_CODE TRUE
C_VISIBILITY_PRESET "hidden" C_VISIBILITY_PRESET "hidden"
CXX_VISIBILITY_PRESET "hidden" CXX_VISIBILITY_PRESET "hidden"
VISIBILITY_INLINES_HIDDEN TRUE) VISIBILITY_INLINES_HIDDEN TRUE)
if(WIN32)
target_compile_definitions("${NAME}" PUBLIC "NOMINMAX")
endif()
if (MINGW) if (MINGW)
target_compile_options("${NAME}" PUBLIC "-mstackrealign") target_compile_options("${NAME}" PUBLIC "-mstackrealign")
endif() endif()
if (MSVC)
target_compile_options("${NAME}" PUBLIC "/UTF-8")
target_compile_definitions("${NAME}" PUBLIC "_CRT_SECURE_NO_WARNINGS")
endif()
endfunction() endfunction()


# dpf__add_plugin_main # dpf__add_plugin_main
@@ -597,7 +613,7 @@ function(dpf__add_lv2_ttl_generator)
return() return()
endif() endif()
add_executable(lv2_ttl_generator "${DPF_ROOT_DIR}/utils/lv2-ttl-generator/lv2_ttl_generator.c") 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") target_link_libraries(lv2_ttl_generator "dl")
endif() endif()
endfunction() endfunction()


+ 8
- 1
distrho/extra/String.hpp View File

@@ -22,6 +22,11 @@


#include <algorithm> #include <algorithm>


#if defined(_MSC_VER)
#include <basetsd.h>
typedef SSIZE_T ssize_t;
#endif

START_NAMESPACE_DISTRHO START_NAMESPACE_DISTRHO


// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@@ -658,7 +663,7 @@ public:
uint i=0, j=0; uint i=0, j=0;
uint charArray3[3], charArray4[4]; uint charArray3[3], charArray4[4];


char strBuf[kTmpBufSize+1];
char* strBuf = (char*)malloc(kTmpBufSize + 1);
strBuf[kTmpBufSize] = '\0'; strBuf[kTmpBufSize] = '\0';
std::size_t strBufIndex = 0; std::size_t strBufIndex = 0;


@@ -712,6 +717,8 @@ public:
ret += strBuf; ret += strBuf;
} }


free(strBuf);

return ret; return ret;
} }




+ 1
- 1
distrho/src/DistrhoDefines.h View File

@@ -74,7 +74,7 @@
#if defined(__GNUC__) #if defined(__GNUC__)
# define DISTRHO_DEPRECATED __attribute__((deprecated)) # define DISTRHO_DEPRECATED __attribute__((deprecated))
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
# define DISTRHO_DEPRECATED __declspec(deprecated)
# define DISTRHO_DEPRECATED [[deprecated]] // Note: __declspec(deprecated) it not applicable to enum members
#else #else
# define DISTRHO_DEPRECATED # define DISTRHO_DEPRECATED
#endif #endif


+ 2
- 2
distrho/src/DistrhoUI.cpp View File

@@ -40,7 +40,7 @@ Window* d_lastUiWindow = nullptr;
// ----------------------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------------------


#if DISTRHO_PLUGIN_HAS_EXTERNAL_UI #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; d_lastUiDspPtr = dspPtr;
g_nextWindowId = winId; g_nextWindowId = winId;
@@ -54,7 +54,7 @@ UI* createUiWrapper(void* const dspPtr, const uintptr_t winId, const double scal
return ret; return ret;
} }
#else #else
UI* createUiWrapper(void* const dspPtr, Window* const window)
UI* createUiWrapper(void* dspPtr, Window* window)
{ {
d_lastUiDspPtr = dspPtr; d_lastUiDspPtr = dspPtr;
d_lastUiWindow = window; d_lastUiWindow = window;


+ 1
- 1
distrho/src/DistrhoUILV2.cpp View File

@@ -289,7 +289,7 @@ protected:


// reserve atom space // reserve atom space
const size_t atomSize = sizeof(LV2_Atom) + msgSize; const size_t atomSize = sizeof(LV2_Atom) + msgSize;
char atomBuf[atomSize];
char* atomBuf = (char*)alloca(atomSize);
std::memset(atomBuf, 0, atomSize); std::memset(atomBuf, 0, atomSize);


// set atom info // set atom info


+ 9
- 1
distrho/src/ladspa/ladspa.h View File

@@ -30,6 +30,14 @@
extern "C" { extern "C" {
#endif #endif


#ifndef LADSPA_PLUGIN_EXPORT
# ifdef _WIN32
# define LADSPA_PLUGIN_EXPORT __declspec(dllexport)
# else
# define LADSPA_PLUGIN_EXPORT __attribute__((visibility("default")))
# endif
#endif

/*****************************************************************************/ /*****************************************************************************/


/* Overview: /* Overview:
@@ -586,7 +594,7 @@ typedef struct _LADSPA_Descriptor {
returning NULL, so the plugin count can be determined by checking returning NULL, so the plugin count can be determined by checking
for the least index that results in NULL being returned. */ 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. */ /* Datatype corresponding to the ladspa_descriptor() function. */
typedef const LADSPA_Descriptor * typedef const LADSPA_Descriptor *


+ 50
- 23
utils/lv2-ttl-generator/lv2_ttl_generator.c View File

@@ -31,6 +31,9 @@


typedef void (*TTL_Generator_Function)(const char* basename); 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[]) int main(int argc, char* argv[])
{ {
if (argc != 2) if (argc != 2)
@@ -39,10 +42,12 @@ int main(int argc, char* argv[])
return 1; return 1;
} }


const char* path = argv[1];

#ifdef TTL_GENERATOR_WINDOWS #ifdef TTL_GENERATOR_WINDOWS
const HMODULE handle = LoadLibraryA(argv[1]);
const HMODULE handle = LoadLibraryA(path);
#else #else
void* const handle = dlopen(argv[1], RTLD_LAZY);
void* const handle = dlopen(path, RTLD_LAZY);
#endif #endif


if (! handle) if (! handle)
@@ -63,33 +68,27 @@ int main(int argc, char* argv[])


if (ttlFn != NULL) 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 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); ttlFn(basename);


free(basename);
free(normalPath);
} }
else else
printf("Failed to find 'lv2_generate_ttl' function\n"); printf("Failed to find 'lv2_generate_ttl' function\n");
@@ -102,3 +101,31 @@ int main(int argc, char* argv[])


return 0; 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;
}

Loading…
Cancel
Save