From 5dea0f41d183a89cbce8cdfed62cc80c4335566f Mon Sep 17 00:00:00 2001 From: Mateusz Adamczyk Date: Sun, 6 Nov 2016 14:55:26 +0100 Subject: [PATCH] Added dynamic linking for windows --- ports/box2d/dll.patch | 410 +++++++++++++++++++++++++++++++++++++ ports/box2d/portfile.cmake | 42 +++- 2 files changed, 442 insertions(+), 10 deletions(-) create mode 100644 ports/box2d/dll.patch diff --git a/ports/box2d/dll.patch b/ports/box2d/dll.patch new file mode 100644 index 0000000000..dd538ae08b --- /dev/null +++ b/ports/box2d/dll.patch @@ -0,0 +1,410 @@ +From 05e359c59228183562d636d8c4559730d3674fc7 Mon Sep 17 00:00:00 2001 +From: Mateusz Adamczyk +Date: Sun, 6 Nov 2016 00:27:18 +0100 +Subject: [PATCH] Auto-create dll + +--- + Box2D/Build/vs2015/Box2D.sln | 12 +- + Box2D/Build/vs2015/Box2D.vcxproj | 24 +++ + Box2D/Build/vs2015/Box2D_dll.vcxproj | 216 +++++++++++++++++++++++++++ + Box2D/Build/vs2015/Box2D_dll.vcxproj.filters | 27 ++++ + Box2D/Build/vs2015/createDef.ps1 | 18 +++ + Box2D/Build/vs2015/main.cpp | 8 + + 6 files changed, 304 insertions(+), 1 deletion(-) + create mode 100644 Box2D/Build/vs2015/Box2D_dll.vcxproj + create mode 100644 Box2D/Build/vs2015/Box2D_dll.vcxproj.filters + create mode 100644 Box2D/Build/vs2015/createDef.ps1 + create mode 100644 Box2D/Build/vs2015/main.cpp + +diff --git a/Box2D/Build/vs2015/Box2D.sln b/Box2D/Build/vs2015/Box2D.sln +index 68a6bac..cfdd4c3 100644 +--- a/Box2D/Build/vs2015/Box2D.sln ++++ b/Box2D/Build/vs2015/Box2D.sln +@@ -1,7 +1,7 @@ +  + Microsoft Visual Studio Solution File, Format Version 12.00 + # Visual Studio 14 +-VisualStudioVersion = 14.0.25123.0 ++VisualStudioVersion = 14.0.25420.1 + MinimumVisualStudioVersion = 10.0.40219.1 + Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Box2D", "Box2D.vcxproj", "{98400D17-43A5-1A40-95BE-C53AC78E7694}" + EndProject +@@ -22,6 +22,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "glew", "glew.vcxproj", "{CD + EndProject + Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "imgui", "imgui.vcxproj", "{542D8CF8-03FC-43BB-9586-D95E98150A56}" + EndProject ++Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Box2D_dll", "Box2D_dll.vcxproj", "{6CF7BCAA-8E3A-42B2-8763-5E4B63A41D84}" ++EndProject + Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 +@@ -78,6 +80,14 @@ Global + {542D8CF8-03FC-43BB-9586-D95E98150A56}.Release|Win32.Build.0 = Release|Win32 + {542D8CF8-03FC-43BB-9586-D95E98150A56}.Release|x64.ActiveCfg = Release|x64 + {542D8CF8-03FC-43BB-9586-D95E98150A56}.Release|x64.Build.0 = Release|x64 ++ {6CF7BCAA-8E3A-42B2-8763-5E4B63A41D84}.Debug|Win32.ActiveCfg = Debug|Win32 ++ {6CF7BCAA-8E3A-42B2-8763-5E4B63A41D84}.Debug|Win32.Build.0 = Debug|Win32 ++ {6CF7BCAA-8E3A-42B2-8763-5E4B63A41D84}.Debug|x64.ActiveCfg = Debug|x64 ++ {6CF7BCAA-8E3A-42B2-8763-5E4B63A41D84}.Debug|x64.Build.0 = Debug|x64 ++ {6CF7BCAA-8E3A-42B2-8763-5E4B63A41D84}.Release|Win32.ActiveCfg = Release|Win32 ++ {6CF7BCAA-8E3A-42B2-8763-5E4B63A41D84}.Release|Win32.Build.0 = Release|Win32 ++ {6CF7BCAA-8E3A-42B2-8763-5E4B63A41D84}.Release|x64.ActiveCfg = Release|x64 ++ {6CF7BCAA-8E3A-42B2-8763-5E4B63A41D84}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE +diff --git a/Box2D/Build/vs2015/Box2D.vcxproj b/Box2D/Build/vs2015/Box2D.vcxproj +index 830803c..3d86e39 100644 +--- a/Box2D/Build/vs2015/Box2D.vcxproj ++++ b/Box2D/Build/vs2015/Box2D.vcxproj +@@ -107,6 +107,12 @@ + Windows + true + ++ ++ dumpbin /LINKERMEMBER:1 $(TargetPath) > $(TargetDir)\symbols.symb ++ ++ ++ Dumping symbols ++ + + + +@@ -137,6 +143,12 @@ + Windows + true + ++ ++ dumpbin /LINKERMEMBER:1 $(TargetPath) > $(TargetDir)\symbols.symb ++ ++ ++ Dumping symbols ++ + + + +@@ -168,6 +180,12 @@ + true + true + ++ ++ dumpbin /LINKERMEMBER:1 $(TargetPath) > $(TargetDir)\symbols.symb ++ ++ ++ Dumping symbols ++ + + + +@@ -202,6 +220,12 @@ + true + true + ++ ++ dumpbin /LINKERMEMBER:1 $(TargetPath) > $(TargetDir)\symbols.symb ++ ++ ++ Dumping symbols ++ + + + +diff --git a/Box2D/Build/vs2015/Box2D_dll.vcxproj b/Box2D/Build/vs2015/Box2D_dll.vcxproj +new file mode 100644 +index 0000000..5c438f6 +--- /dev/null ++++ b/Box2D/Build/vs2015/Box2D_dll.vcxproj +@@ -0,0 +1,216 @@ ++ ++ ++ ++ ++ Debug ++ Win32 ++ ++ ++ Release ++ Win32 ++ ++ ++ Debug ++ x64 ++ ++ ++ Release ++ x64 ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ {98400d17-43a5-1a40-95be-c53ac78e7694} ++ ++ ++ ++ {6CF7BCAA-8E3A-42B2-8763-5E4B63A41D84} ++ Win32Proj ++ Box2D_dll ++ 8.1 ++ ++ ++ ++ DynamicLibrary ++ true ++ v140 ++ Unicode ++ ++ ++ DynamicLibrary ++ false ++ v140 ++ true ++ Unicode ++ ++ ++ DynamicLibrary ++ true ++ v140 ++ Unicode ++ ++ ++ DynamicLibrary ++ false ++ v140 ++ true ++ Unicode ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ true ++ bin\dll\x$(PlatformArchitecture)\$(Configuration)\ ++ obj\x$(PlatformArchitecture)\$(Configuration)\Box2D\dll\ ++ Box2D ++ ++ ++ true ++ ++ ++ bin\dll\x$(PlatformArchitecture)\$(Configuration)\ ++ obj\x$(PlatformArchitecture)\$(Configuration)\Box2D\dll\ ++ Box2D ++ ++ ++ false ++ bin\dll\x$(PlatformArchitecture)\$(Configuration)\ ++ obj\x$(PlatformArchitecture)\$(Configuration)\Box2D\dll\ ++ Box2D ++ ++ ++ false ++ bin\dll\x$(PlatformArchitecture)\$(Configuration)\ ++ obj\x$(PlatformArchitecture)\$(Configuration)\Box2D\dll\ ++ Box2D ++ ++ ++ ++ ++ ++ Level3 ++ Disabled ++ WIN32;_DEBUG;_WINDOWS;_USRDLL;BOX2D_DLL_EXPORTS;%(PreprocessorDefinitions) ++ ++ ++ Windows ++ true ++ $(TargetDir)symbols.def ++ $(OutDir)Box2D$(TargetExt) ++ ++ ++ powershell -exec bypass $(SolutionDir)createDef.ps1 -symbols $(SolutionDir)\bin\x$(PlatformArchitecture)\$(Configuration)\symbols.symb -output $(TargetDir)symbols.def ++ ++ ++ Create def file ++ ++ ++ ++ ++ ++ ++ Level3 ++ Disabled ++ _DEBUG;_WINDOWS;_USRDLL;BOX2D_DLL_EXPORTS;%(PreprocessorDefinitions) ++ ++ ++ Windows ++ true ++ $(TargetDir)symbols.def ++ $(OutDir)Box2D$(TargetExt) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ powershell -exec bypass $(SolutionDir)createDef.ps1 -symbols $(SolutionDir)\bin\x$(PlatformArchitecture)\$(Configuration)\symbols.symb -output $(TargetDir)symbols.def ++ ++ ++ Create def file ++ ++ ++ ++ ++ Level3 ++ ++ ++ MaxSpeed ++ true ++ true ++ WIN32;NDEBUG;_WINDOWS;_USRDLL;BOX2D_DLL_EXPORTS;%(PreprocessorDefinitions) ++ ++ ++ Windows ++ true ++ true ++ true ++ $(TargetDir)symbols.def ++ $(OutDir)Box2D$(TargetExt) ++ ++ ++ powershell -exec bypass $(SolutionDir)createDef.ps1 -symbols $(SolutionDir)\bin\x$(PlatformArchitecture)\$(Configuration)\symbols.symb -output $(TargetDir)symbols.def ++ ++ ++ Create def file ++ ++ ++ ++ ++ Level3 ++ ++ ++ MaxSpeed ++ true ++ true ++ NDEBUG;_WINDOWS;_USRDLL;BOX2D_DLL_EXPORTS;%(PreprocessorDefinitions) ++ ++ ++ Windows ++ true ++ true ++ true ++ $(TargetDir)symbols.def ++ $(OutDir)Box2D$(TargetExt) ++ ++ ++ powershell -exec bypass $(SolutionDir)createDef.ps1 -symbols $(SolutionDir)\bin\x$(PlatformArchitecture)\$(Configuration)\symbols.symb -output $(TargetDir)symbols.def ++ ++ ++ Create def file ++ ++ ++ ++ ++ ++ +\ No newline at end of file +diff --git a/Box2D/Build/vs2015/Box2D_dll.vcxproj.filters b/Box2D/Build/vs2015/Box2D_dll.vcxproj.filters +new file mode 100644 +index 0000000..6e1dfcb +--- /dev/null ++++ b/Box2D/Build/vs2015/Box2D_dll.vcxproj.filters +@@ -0,0 +1,27 @@ ++ ++ ++ ++ ++ {4FC737F1-C7A5-4376-A066-2A32D752A2FF} ++ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx ++ ++ ++ {93995380-89BD-4b04-88EB-625FBE52EBFB} ++ h;hh;hpp;hxx;hm;inl;inc;xsd ++ ++ ++ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} ++ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms ++ ++ ++ ++ ++ Source Files ++ ++ ++ ++ ++ Source Files ++ ++ ++ +\ No newline at end of file +diff --git a/Box2D/Build/vs2015/createDef.ps1 b/Box2D/Build/vs2015/createDef.ps1 +new file mode 100644 +index 0000000..4939723 +--- /dev/null ++++ b/Box2D/Build/vs2015/createDef.ps1 +@@ -0,0 +1,18 @@ ++param( ++ [String] $symbols, ++ [String] $output ++) ++ ++Write-Output "LIBRARY Box2D" > $output ++Write-Output 'DESCRIPTION "Box2D dynamic link library"' >> $output ++Write-Output "EXPORTS" >> $output ++ ++$from = (Select-String $symbols -pattern "public symbols" | Select-Object LineNumber).LineNumber + 1 ++$to = (Select-String $symbols -pattern "Summary" | Select-Object LineNumber).LineNumber - 2 ++$no = 1 ++Get-Content $symbols -head $to ` ++ | Select-Object -Last ($to - $from) ` ++ | ForEach-Object { Write-Output $_.split()[-1] } ` ++ | Select-String -Pattern '^\?' ` ++ | ForEach-Object { Write-Output ("`t" + $_ + " @" + $no++) } ` ++ >> $output +\ No newline at end of file +diff --git a/Box2D/Build/vs2015/main.cpp b/Box2D/Build/vs2015/main.cpp +new file mode 100644 +index 0000000..72216f9 +--- /dev/null ++++ b/Box2D/Build/vs2015/main.cpp +@@ -0,0 +1,8 @@ ++#define WIN32_LEAN_AND_MEAN ++#include ++ ++BOOL APIENTRY DllMain(HANDLE hModule, ++ DWORD ul_reason_for_call, ++ LPVOID lpReserved) { ++ return TRUE; ++} +-- +2.10.2.windows.1 + diff --git a/ports/box2d/portfile.cmake b/ports/box2d/portfile.cmake index e70c373eb6..59d7c119ed 100644 --- a/ports/box2d/portfile.cmake +++ b/ports/box2d/portfile.cmake @@ -1,12 +1,11 @@ include(${CMAKE_TRIPLET_FILE}) -if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) - message(FATAL_ERROR "Dynamic building not supported") -endif() # Get architecture params set(PROJECT_ARCH "x64") +set(PROJECT_ARCH_BITS "${PROJECT_ARCH}") if(TRIPLET_SYSTEM_ARCH MATCHES "x86") set(PROJECT_ARCH "Win32") + set(PROJECT_ARCH_BITS "x32") endif(TRIPLET_SYSTEM_ARCH MATCHES "x86") include(vcpkg_common_functions) @@ -38,6 +37,11 @@ message(STATUS "Adding worktree done") set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/) +vcpkg_apply_patches( + SOURCE_PATH ${SOURCE_PATH} + PATCHES "${CMAKE_CURRENT_LIST_DIR}/dll.patch" +) + # Put the licence and readme files where vcpkg expects it message(STATUS "Packaging license") file(COPY ${SOURCE_PATH}/README.md DESTINATION ${CURRENT_PACKAGES_DIR}/share/box2d) @@ -46,32 +50,50 @@ file(RENAME ${CURRENT_PACKAGES_DIR}/share/box2d/License.txt ${CURRENT_PACKAGES_D message(STATUS "Packaging license done") # Building: +set(PROJECT "./Box2D/Build/vs2015/Box2D.vcxproj") +set(OUTPUTS_PATH "${SOURCE_PATH}/Box2D/Build/vs2015/bin/${PROJECT_ARCH_BITS}") +if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) + set(PROJECT "./Box2D/Build/vs2015/Box2D_dll.vcxproj") + set(OUTPUTS_PATH "${SOURCE_PATH}/Box2D/Build/vs2015/bin/dll/${PROJECT_ARCH_BITS}") +endif(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) + foreach(TYPE "Release" "Debug") message(STATUS "Building ${TARGET_TRIPLET}-${TYPE}") vcpkg_execute_required_process( COMMAND "devenv.exe" "./Box2D/Build/vs2015/Box2D.sln" /Build "${TYPE}|${PROJECT_ARCH}" - /Project "./Box2D/Build/vs2015/Box2D.vcxproj" + /Project "${PROJECT}" /Projectconfig "${TYPE}|${PROJECT_ARCH}" WORKING_DIRECTORY ${SOURCE_PATH} LOGNAME build-${TARGET_TRIPLET}-${TYPE} ) message(STATUS "Building ${TARGET_TRIPLET}-${TYPE} done") - message(STATUS "Packaging ${TARGET_TRIPLET}-${TYPE} lib") - set(TARGET_PATH "${CURRENT_PACKAGES_DIR}/lib") + set(TARGET_PATH "${CURRENT_PACKAGES_DIR}") if(TYPE STREQUAL Debug) - set(TARGET_PATH "${CURRENT_PACKAGES_DIR}/debug/lib") + set(TARGET_PATH "${CURRENT_PACKAGES_DIR}/debug") endif(TYPE STREQUAL Debug) + message(STATUS "Packaging ${TARGET_TRIPLET}-${TYPE} lib") file( - INSTALL ${SOURCE_PATH}/Box2D/Build/vs2015/bin/${PROJECT_ARCH}/${TYPE}/ - DESTINATION ${TARGET_PATH} + INSTALL ${OUTPUTS_PATH}/${TYPE}/ + DESTINATION ${TARGET_PATH}/lib FILES_MATCHING PATTERN "*.lib" ) - file(RENAME ${TARGET_PATH}/Box2D.lib ${TARGET_PATH}/box2d.lib) + file(RENAME ${TARGET_PATH}/lib/Box2D.lib ${TARGET_PATH}/lib/box2d.lib) message(STATUS "Packaging ${TARGET_TRIPLET}-${TYPE} lib done") + + if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) + message(STATUS "Packaging ${TARGET_TRIPLET}-${TYPE} dll") + file( + INSTALL ${OUTPUTS_PATH}/${TYPE}/ + DESTINATION ${TARGET_PATH}/bin + FILES_MATCHING PATTERN "*.dll" + ) + file(RENAME ${TARGET_PATH}/bin/Box2D.dll ${TARGET_PATH}/bin/box2d.dll) + message(STATUS "Packaging ${TARGET_TRIPLET}-${TYPE} dll done") + endif(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) endforeach() message(STATUS "Packaging headers")