Hi,

Could you check the attached patch for possible mistakes or things you'd like to see implemented differently?

About the directory functions (opendir,...), I'm currently also porting zynaddsubfx to msvc and have a partial implementation ready. As soon as it's complete, tested and approved, I'll copy the code into libgig and send you a patch.

diff --git CMakeLists.txt CMakeLists.txt
new file mode 100644
index 0000000..5c239b8
--- /dev/null
+++ CMakeLists.txt
@@ -0,0 +1,63 @@
+cmake_minimum_required(VERSION 3.0)
+project(libgig)
+
+if(NOT MSVC)
+       message(FATAL_ERROR "Please use configure and make, this cmake file is 
only to generate msvc solution files")
+endif()
+
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
+
+find_path(CPPUNIT_INCLUDE_DIRS cppunit/TestFixture.h)
+find_library(CPPUNIT_LIBRARIES_DEBUG cppunitd_dll)
+find_library(CPPUNIT_LIBRARIES_RELEASE cppunit_dll)
+set(CPPUNIT_LIBRARIES
+       $<$<CONFIG:Debug>:${CPPUNIT_LIBRARIES_DEBUG}>
+       $<$<CONFIG:RelWithDebInfo>:${CPPUNIT_LIBRARIES_RELEASE}>
+       $<$<CONFIG:Release>:${CPPUNIT_LIBRARIES_RELEASE}>
+       $<$<CONFIG:MinSizeRel>:${CPPUNIT_LIBRARIES_RELEASE}>)
+
+find_package(LibSndFile)
+
+if(CPPUNIT_LIBRARIES AND CPPUNIT_INCLUDE_DIRS)
+       set(CPPUNIT_FOUND TRUE)
+else()
+       message("cppunit not found. Testcases will not be built.")
+endif()
+
+#get version from configure.ac
+file(STRINGS configure.ac VERSION_STRINGS REGEX 
"^m4_define\\(libgig_release.*\\)$")
+
+string(REGEX MATCH "libgig_release_major, ([^)]*)\\)" TEMP ${VERSION_STRINGS})
+set(VERSION_MAJOR ${CMAKE_MATCH_1})
+string(REGEX MATCH "libgig_release_minor, ([^)]*)\\)" TEMP ${VERSION_STRINGS})
+set(VERSION_MINOR ${CMAKE_MATCH_1})
+string(REGEX MATCH "libgig_release_build, ([^)]*)\\)" TEMP ${VERSION_STRINGS})
+set(VERSION_BUILD ${CMAKE_MATCH_1})
+
+set(PACKAGE_NAME "libgig")
+
+set(SOURCES 
+       src/Akai.cpp
+       src/DLS.cpp
+       src/gig.cpp
+       src/helper.cpp
+       src/Korg.cpp
+       src/RIFF.cpp
+       src/Serialization.cpp
+       src/SF.cpp
+       src/typeinfo.cpp
+       win32/dllmain.cpp)
+
+add_library(libgig SHARED ${SOURCES})
+target_compile_definitions(libgig PRIVATE NOMINMAX)
+target_compile_definitions(libgig PRIVATE PACKAGE="${PACKAGE_NAME}" 
VERSION="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_BUILD}")
+
+target_link_libraries(libgig Rpcrt4.lib dbghelp.lib)
+set_target_properties(libgig PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
+if(CPPUNIT_FOUND)
+       add_subdirectory(src/testcases)
+endif(CPPUNIT_FOUND)
+
+add_subdirectory(src/tools)
diff --git README README
index 433c35e..fb37e25 100644
--- README
+++ README
@@ -149,8 +149,30 @@ Compiling for Linux
   On success, the resulting rpm(s) can usually be found under the proper
   "/usr/src/<rpmdir>/RPMS/<arch>" directory.
 
-Compiling for Windows
-=====================
+Compiling for Windows using CMake
+=================================
+The easiest way is to compile is to use vcpkg 
(https://github.com/Microsoft/vcpkg)
+to install libsndfile (required) and cppunit (optional). In the vcpkg install 
dir
+type:
+.\vcpkg.exe install libsndfile cppunit [--triplet x64-windows]
+
+This should install the libraries in vcpkg, add the triplet option if you wish 
to
+get the 64bit libraries.
+
+In an empty directory type:
+cmake <libgig source dir> -DCMAKE_TOOLCHAIN_FILE=<vcpkg 
dir>\scripts\buildsystems\vcpkg.cmake
+[-G"Visual Studio 15 2017 Win64"]
+
+Use the -G option to select the visual studio version and whether to compile 
for
+64bits.
+
+This will create libgig.sln file which you can open in visual studio or you 
can use
+the following command line to compile:
+
+cmake --build . --config <Release|Debug|MinRelSize|RelWithDebInfo>
+
+Compiling for Windows using Dev-C++
+===================================
 
   libgig and its tools can be compiled for Windows using Bloodshed Dev-C++,
   which is a free (GPL) C++ integrated development environment for Windows.
diff --git src/Akai.cpp src/Akai.cpp
index fc4558d..3f4ae7d 100644
--- src/Akai.cpp
+++ src/Akai.cpp
@@ -24,8 +24,10 @@
 
 #include <stdio.h>
 #include <string.h>
+#ifndef _MSC_VER
 #include <unistd.h>
 #include <fcntl.h>
+#endif
 #if defined(_CARBON_) || defined(__APPLE__)
 # if defined (__GNUC__) && (__GNUC__ >= 4)
 #  include <sys/disk.h>
diff --git src/Akai.h src/Akai.h
index 759648f..6815029 100644
--- src/Akai.h
+++ src/Akai.h
@@ -43,8 +43,9 @@
 #include <fstream>
 #include <sys/types.h>
 #include <sys/stat.h>
+#ifndef _MSC_VER
 #include <sys/fcntl.h>
-
+#endif
 #if defined(_CARBON_) || defined(__APPLE__) || LINUX
 # include <sys/ioctl.h>
 # include <unistd.h>
diff --git src/RIFF.h src/RIFF.h
index 558935c..fba7444 100644
--- src/RIFF.h
+++ src/RIFF.h
@@ -54,7 +54,7 @@
 # include <unistd.h>
 #endif // POSIX
 
-#ifdef _MSC_VER
+#if _MSC_VER < 1600
 // Visual C++ 2008 doesn't have stdint.h
 typedef __int8 int8_t;
 typedef __int16 int16_t;
diff --git src/Serialization.cpp src/Serialization.cpp
index b586691..2581a54 100644
--- src/Serialization.cpp
+++ src/Serialization.cpp
@@ -31,8 +31,12 @@
 #include <assert.h>
 #include <string.h> // for memcpy()
 #include <stdlib.h> // for atof()
+#ifdef _MSC_VER
+#include <windows.h>
+#include <dbghelp.h>
+#else
 #include <cxxabi.h>
-
+#endif
 #include "helper.h"
 
 #define LIBGIG_EPOCH_TIME ((time_t)0)
@@ -403,10 +407,23 @@ namespace Serialization {
      */
     String DataType::customTypeName(bool demangle) const {
         if (!demangle) return m_customTypeName;
+#ifdef _MSC_VER
+        const size_t MAXLENGTH = 1024;
+        char result[MAXLENGTH];
+
+        //Skip the first char
+        size_t size = UnDecorateSymbolName(m_customTypeName.c_str() +1, 
result, MAXLENGTH, UNDNAME_32_BIT_DECODE | UNDNAME_NO_ARGUMENTS);
+        if (size)
+        {
+            return result;
+        }
+        return m_customTypeName;
+#else
         int status;
         const char* result =
             abi::__cxa_demangle(m_customTypeName.c_str(), 0, 0, &status);
         return (status == 0) ? result : m_customTypeName;
+#endif
     }
 
     // *************** Member ***************
diff --git src/Serialization.h src/Serialization.h
index f96df0e..98af4ac 100644
--- src/Serialization.h
+++ src/Serialization.h
@@ -441,8 +441,7 @@ namespace Serialization {
         template<typename T>
         static String rawCppTypeNameOf(const T& data) {
             #if defined _MSC_VER // Microsoft compiler ...
-            # warning type_info::raw_name() demangling has not been tested yet 
with Microsoft compiler! Feedback appreciated!
-            String name = typeid(data).raw_name(); //NOTE: I haven't checked 
yet what MSC actually outputs here exactly
+            String name = typeid(data).raw_name();
             #else // i.e. especially GCC and clang ...
             String name = typeid(data).name();
             #endif
diff --git src/helper.h src/helper.h
index 65a481e..3e64f0d 100644
--- src/helper.h
+++ src/helper.h
@@ -29,17 +29,26 @@
 #include <sstream>
 #include <algorithm>
 
-#if defined(WIN32) && !HAVE_CONFIG_H
+#if defined(WIN32) && !HAVE_CONFIG_H && !defined(_MSC_VER)
 # include "../win32/libgig_private.h" // like config.h, automatically 
generated by Dev-C++
 # define PACKAGE "libgig"
 # define VERSION VER_STRING // VER_STRING defined in libgig_private.h
 #endif // WIN32
 
-#if HAVE_CONFIG_H /*&& !HAVE_VASPRINTF*/ && defined(WIN32)
+#if (HAVE_CONFIG_H /*&& !HAVE_VASPRINTF*/ && defined(WIN32)) || 
defined(_MSC_VER)
 # include <stdarg.h>
 int vasprintf(char** ret, const char* format, va_list arg);
 #endif
 
+#if defined(_MSC_VER)
+#if _MSC_VER < 1900
+#error versions prior to msvc 2015 haven't been tested
+#else
+#include <BaseTsd.h>
+typedef SSIZE_T ssize_t;
+#endif
+#endif
+
 #include "RIFF.h"
 
 // *************** Helper Functions **************
diff --git src/testcases/CMakeLists.txt src/testcases/CMakeLists.txt
new file mode 100644
index 0000000..4b276ac
--- /dev/null
+++ src/testcases/CMakeLists.txt
@@ -0,0 +1,9 @@
+set(TEST_SOURCES 
+    main.cpp
+    GigWriteTest.cpp)
+
+
+add_executable(gigwritetest ${TEST_SOURCES})
+target_link_libraries(gigwritetest PRIVATE libgig ${CPPUNIT_LIBRARIES})
+
+target_include_directories(gigwritetest PRIVATE ${CPPUNIT_INCLUDE_DIRS})
diff --git src/testcases/GigWriteTest.cpp src/testcases/GigWriteTest.cpp
index 2ca5c87..97f5da0 100644
--- src/testcases/GigWriteTest.cpp
+++ src/testcases/GigWriteTest.cpp
@@ -207,7 +207,9 @@ void GigWriteTest::testArticulationsOfCreatedGigFile() {
             CPPUNIT_ASSERT(pRegion->VelocityRange.low  == iInstrument - 1);
             CPPUNIT_ASSERT(pRegion->VelocityRange.high == iInstrument);
             CPPUNIT_ASSERT(pRegion->KeyGroup  == iInstrument - 1);
-            gig::DimensionRegion* pDimensionRegion = 
pRegion->GetDimensionRegionByValue((uint[8]){0,0,0,0,0,0,0,0});
+            //gig::DimensionRegion* pDimensionRegion = 
pRegion->GetDimensionRegionByValue((uint[8]){0,0,0,0,0,0,0,0});
+            const uint dimensionRegion[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
+            gig::DimensionRegion* pDimensionRegion = 
pRegion->GetDimensionRegionByValue(dimensionRegion);
             CPPUNIT_ASSERT(pDimensionRegion);
             CPPUNIT_ASSERT(pDimensionRegion->pSample->pInfo->Name == 
sOughtToBe);
             iInstrument++;
diff --git src/tools/CMakeLists.txt src/tools/CMakeLists.txt
new file mode 100644
index 0000000..2953a2b
--- /dev/null
+++ src/tools/CMakeLists.txt
@@ -0,0 +1,22 @@
+
+macro(add_tool NAME)
+    add_executable(${NAME} ${NAME}.cpp)
+    target_link_libraries(${NAME} PRIVATE libgig)
+endmacro(add_tool)
+
+add_tool(akaidump)
+#add_tool(akaiextract)
+add_tool(dlsdump)
+#add_tool(gig2mono)
+#add_tool(gig2stereo)
+add_tool(gigdump)
+add_tool(gigextract)
+target_link_libraries(gigextract PRIVATE sndfile-shared)
+add_tool(gigmerge)
+add_tool(korg2gig)
+add_tool(korgdump)
+add_tool(rifftree)
+add_tool(sf2dump)
+add_tool(sf2extract)
+target_link_libraries(sf2extract PRIVATE sndfile-shared)
+
_______________________________________________
Linuxsampler-devel mailing list
Linuxsampler-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxsampler-devel

Reply via email to