Skip to content

Commit

Permalink
solvespace: New Package
Browse files Browse the repository at this point in the history
  • Loading branch information
Kreijstal committed Dec 7, 2024
1 parent 49b3cb3 commit b03a93e
Show file tree
Hide file tree
Showing 3 changed files with 340 additions and 0 deletions.
25 changes: 25 additions & 0 deletions mingw-w64-solvespace/002-not-in-msys2-temp.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f46b37d..7376873 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -34,9 +34,9 @@ endif()
# NOTE TO PACKAGERS: The embedded git commit hash is critical for rapid bug triage when the builds
# can come from a variety of sources. If you are mirroring the sources or otherwise build when
# the .git directory is not present, please comment the following line:
-include(GetGitCommitHash)
+#include(GetGitCommitHash)
# and instead uncomment the following, adding the complete git hash of the checkout you are using:
-# set(GIT_COMMIT_HASH 0000000000000000000000000000000000000000)
+set(GIT_COMMIT_HASH 70bde63cb32a7f049fa56cbdf924e2695fcb2916)

string(SUBSTRING "${GIT_COMMIT_HASH}" 0 8 solvespace_GIT_HASH)
project(solvespace
@@ -219,7 +219,7 @@ if(NOT EXISTS "${EIGEN3_INCLUDE_DIRS}")
endif()


-if(WIN32 OR APPLE)
+if(APPLE)
# On Win32 and macOS we use vendored packages, since there is little to no benefit
# to trying to find system versions. In particular, trying to link to libraries from
# Homebrew or macOS system libraries into the .app file is highly likely to result
249 changes: 249 additions & 0 deletions mingw-w64-solvespace/1487.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,249 @@
From f160eadf2f2542dd6587f95bbe2b98c1dfed91a5 Mon Sep 17 00:00:00 2001
From: kreijstal <[email protected]>
Date: Sat, 28 Sep 2024 02:52:34 +0200
Subject: [PATCH 1/2] Compiling on msys2

---
CMakeLists.txt | 159 ++++++++++++++++++++++++++++++++++------
src/platform/guiwin.cpp | 3 +
2 files changed, 138 insertions(+), 24 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5a012553f..c94b9a47a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -94,7 +94,10 @@ if(MINGW)
# Link 32 bit SolveSpace with --large-address-aware which allows it to access
# up to 3GB on a properly configured 32 bit Windows and up to 4GB on 64 bit.
# See https://msdn.microsoft.com/en-us/library/aa366778
- set(CMAKE_EXE_LINKER_FLAGS "-Wl,--large-address-aware")
+ if(CMAKE_SIZEOF_VOID_P EQUAL 4)
+ # Set large address aware flag for 32-bit targets
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--large-address-aware")
+ endif()
endif()

# Ensure that all platforms use 64-bit IEEE floating point operations for consistency;
@@ -193,13 +196,24 @@ endif()
message(STATUS "Using in-tree libdxfrw")
add_subdirectory(extlib/libdxfrw)

-message(STATUS "Using in-tree mimalloc")
-set(MI_OVERRIDE OFF CACHE BOOL "")
-set(MI_BUILD_SHARED OFF CACHE BOOL "")
-set(MI_BUILD_OBJECT OFF CACHE BOOL "")
-set(MI_BUILD_TESTS OFF CACHE BOOL "")
-add_subdirectory(extlib/mimalloc EXCLUDE_FROM_ALL)
-set(MIMALLOC_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/extlib/mimalloc/include)
+find_package(PkgConfig QUIET)
+
+if(PkgConfig_FOUND)
+ pkg_check_modules(MIMALLOC mimalloc)
+endif()
+
+if(MIMALLOC_FOUND)
+ message(STATUS "Using system mimalloc: ${MIMALLOC_LIBRARIES}")
+else()
+ message(STATUS "System mimalloc not found. Using in-tree mimalloc")
+ set(MI_OVERRIDE OFF CACHE BOOL "")
+ set(MI_BUILD_SHARED OFF CACHE BOOL "")
+ set(MI_BUILD_OBJECT OFF CACHE BOOL "")
+ set(MI_BUILD_TESTS OFF CACHE BOOL "")
+ add_subdirectory(extlib/mimalloc EXCLUDE_FROM_ALL)
+ set(MIMALLOC_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/extlib/mimalloc/include)
+ set(MIMALLOC_LIBRARIES mimalloc)
+endif()

if(NOT FORCE_VENDORED_Eigen3)
find_package(Eigen3 CONFIG)
@@ -215,9 +229,90 @@ if(NOT EXISTS "${EIGEN3_INCLUDE_DIRS}")
message(FATAL_ERROR "Eigen 3 not found on system or in-tree")
endif()

+if(WIN32)
+ include(FindVendoredPackage)
+ include(AddVendoredSubdirectory)
+
+ # For Windows, we prefer system libraries when available,
+ # but fall back to vendored versions if not found
+
+ # Check for system libbacktrace
+ if(PKG_CONFIG_FOUND)
+ pkg_check_modules(BACKTRACE libbacktrace)
+ if(BACKTRACE_FOUND)
+ message(STATUS "Using system libbacktrace: ${BACKTRACE_LIBRARIES}")
+ endif()
+ pkg_check_modules(ZLIB zlib)
+ find_package(PNG)
+ find_package(Freetype)
+ pkg_check_modules(PIXMAN pixman-1)
+ pkg_check_modules(CAIRO cairo)
+ endif()
+
+ # If system libraries are not found, use vendored versions
+ if(NOT ZLIB_FOUND)
+ message(STATUS "System ZLIB not found. Using vendored version.")
+ find_vendored_package(ZLIB zlib
+ ZLIB_LIBRARY zlibstatic
+ ZLIB_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/extlib/zlib)
+ list(APPEND ZLIB_INCLUDE_DIR ${CMAKE_BINARY_DIR}/extlib/zlib)
+ endif()
+
+ if(NOT PNG_FOUND)
+ message(STATUS "System PNG not found. Using vendored version.")
+ find_vendored_package(PNG libpng
+ SKIP_INSTALL_ALL ON
+ PNG_LIBRARY png_static
+ PNG_ARM_NEON "off"
+ PNG_SHARED OFF
+ PNG_STATIC ON
+ PNG_EXECUTABLES OFF
+ PNG_TESTS OFF
+ PNG_FRAMEWORK OFF
+ PNG_PNG_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/extlib/libpng)
+ list(APPEND PNG_PNG_INCLUDE_DIR ${CMAKE_BINARY_DIR}/extlib/libpng)
+ endif()
+
+ if(NOT FREETYPE_FOUND)
+ message(STATUS "System Freetype not found. Using vendored version.")
+ find_vendored_package(Freetype freetype
+ WITH_ZLIB OFF
+ WITH_BZip2 OFF
+ WITH_PNG OFF
+ WITH_HarfBuzz OFF
+ FREETYPE_LIBRARY freetype
+ FREETYPE_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/extlib/freetype/include)
+ endif()
+
+ if(PIXMAN_FOUND)
+ message(STATUS "Using system pixman: ${PIXMAN_LIBRARIES}")
+ else()
+ message(STATUS "Using in-tree pixman")
+ set(PIXMAN_FOUND YES)
+ set(PIXMAN_LIBRARY pixman)
+ set(PIXMAN_BUILD_TESTS OFF CACHE BOOL "")
+ set(PIXMAN_BUILD_DEMOS OFF CACHE BOOL "")
+
+ set(PIXMAN_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/extlib/pixman/pixman)
+ list(APPEND PIXMAN_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/extlib/pixman/pixman)
+ add_vendored_subdirectory(extlib/pixman)
+ endif()
+
+ if(CAIRO_FOUND)
+ message(STATUS "Using system cairo: ${CAIRO_LIBRARIES}")
+ else()
+ message(STATUS "Using in-tree cairo")
+ add_vendored_subdirectory(extlib/cairo)
+ set(CAIRO_FOUND YES)
+ set(CAIRO_LIBRARIES cairo)
+ set(CAIRO_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/extlib/cairo/src)
+ list(APPEND CAIRO_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/extlib/cairo/src)
+
+ endif()
+

-if(WIN32 OR APPLE OR EMSCRIPTEN)
- # On Win32 and macOS we use vendored packages, since there is little to no benefit
+elseif(APPLE OR EMSCRIPTEN)
+ # On macOS and Emscripten, we use vendored packages to ensure compatibility, since there is little to no benefit
# to trying to find system versions. In particular, trying to link to libraries from
# Homebrew or macOS system libraries into the .app file is highly likely to result
# in incompatibilities after upgrades.
@@ -270,6 +365,7 @@ if(WIN32 OR APPLE OR EMSCRIPTEN)
set(CAIRO_LIBRARIES cairo)
set(CAIRO_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/extlib/cairo/src)
list(APPEND CAIRO_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/extlib/cairo/src)
+
else()
# On Linux and BSDs we're a good citizen and link to system libraries.
find_package(Backtrace)
@@ -284,21 +380,36 @@ endif()

if(ENABLE_GUI)
if(WIN32)
- if(OPENGL STREQUAL "3")
- message(STATUS "Using in-tree ANGLE")
- set(ANGLE_STATIC ON CACHE INTERNAL "")
- set(ANGLE_ENABLE_D3D9 ON CACHE INTERNAL "")
- set(ANGLE_ENABLE_D3D11 ON CACHE INTERNAL "")
- set(ANGLE_ENABLE_OPENGL ON CACHE INTERNAL "")
- set(ANGLE_ENABLE_ESSL ON CACHE INTERNAL "")
- set(ANGLE_ENABLE_GLSL ON CACHE INTERNAL "")
- set(ANGLE_ENABLE_HLSL ON CACHE INTERNAL "")
- add_vendored_subdirectory(extlib/angle)
- set(OPENGL_LIBRARIES EGL GLESv2)
- set(OPENGL_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/extlib/angle/include)
- else()
+ if(OPENGL STREQUAL "3")
+ # Check for system-installed ANGLE
+ find_path(ANGLE_INCLUDE_DIR NAMES GLES2/gl2.h GLES3/gl3.h EGL/egl.h
+ PATHS $ENV{MINGW_PREFIX}/include)
+ find_library(ANGLE_EGL_LIBRARY NAMES libEGL EGL
+ PATHS $ENV{MINGW_PREFIX}/lib)
+ find_library(ANGLE_GLESV2_LIBRARY NAMES libGLESv2 GLESv2
+ PATHS $ENV{MINGW_PREFIX}/lib)
+
+ if(ANGLE_INCLUDE_DIR AND ANGLE_EGL_LIBRARY AND ANGLE_GLESV2_LIBRARY)
+ message(STATUS "Using system-installed ANGLE")
+ set(ANGLE_FOUND TRUE)
+ set(OPENGL_LIBRARIES ${ANGLE_EGL_LIBRARY} ${ANGLE_GLESV2_LIBRARY})
+ set(OPENGL_INCLUDE_DIR ${ANGLE_INCLUDE_DIR})
+ else()
+ message(STATUS "System-installed ANGLE not found. Using in-tree ANGLE")
+ set(ANGLE_STATIC ON CACHE INTERNAL "")
+ set(ANGLE_ENABLE_D3D9 ON CACHE INTERNAL "")
+ set(ANGLE_ENABLE_D3D11 ON CACHE INTERNAL "")
+ set(ANGLE_ENABLE_OPENGL ON CACHE INTERNAL "")
+ set(ANGLE_ENABLE_ESSL ON CACHE INTERNAL "")
+ set(ANGLE_ENABLE_GLSL ON CACHE INTERNAL "")
+ set(ANGLE_ENABLE_HLSL ON CACHE INTERNAL "")
+ add_vendored_subdirectory(extlib/angle)
+ set(OPENGL_LIBRARIES EGL GLESv2)
+ set(OPENGL_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/extlib/angle/include)
+ endif()
+ else()
find_package(OpenGL REQUIRED)
- endif()
+ endif()

if(MSVC AND ${CMAKE_SIZEOF_VOID_P} EQUAL 4)
message(STATUS "Using prebuilt SpaceWare")
diff --git a/src/platform/guiwin.cpp b/src/platform/guiwin.cpp
index 39189e3ef..d01c1df3b 100644
--- a/src/platform/guiwin.cpp
+++ b/src/platform/guiwin.cpp
@@ -43,6 +43,9 @@
# define EGL_EGLEXT_PROTOTYPES
# include <EGL/egl.h>
# include <EGL/eglext.h>
+#if defined(__MINGW32__)
+# include <EGL/eglext_angle.h>
+#endif
#endif

#if defined(HAVE_SPACEWARE)

From 404e1dbdb1da54148d9d87daf6331d6839ba0716 Mon Sep 17 00:00:00 2001
From: Kreijstal <[email protected]>
Date: Mon, 30 Sep 2024 23:27:35 +0200
Subject: [PATCH 2/2] Fix whitespace

---
CMakeLists.txt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c94b9a47a..9e8196fd6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -94,8 +94,8 @@ if(MINGW)
# Link 32 bit SolveSpace with --large-address-aware which allows it to access
# up to 3GB on a properly configured 32 bit Windows and up to 4GB on 64 bit.
# See https://msdn.microsoft.com/en-us/library/aa366778
- if(CMAKE_SIZEOF_VOID_P EQUAL 4)
- # Set large address aware flag for 32-bit targets
+ if(CMAKE_SIZEOF_VOID_P EQUAL 4)
+ # Set large address aware flag for 32-bit targets
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--large-address-aware")
endif()
endif()
66 changes: 66 additions & 0 deletions mingw-w64-solvespace/PKGBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Maintainer: Kreijstal <[email protected]>

_realname=solvespace
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=3.1
pkgrel=1
pkgdesc="Parametric 2d/3d CAD (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://solvespace.com"
license=('GPL3')
depends=("${MINGW_PACKAGE_PREFIX}-mimalloc"
"${MINGW_PACKAGE_PREFIX}-angleproject"
"${MINGW_PACKAGE_PREFIX}-pixman"
"${MINGW_PACKAGE_PREFIX}-cairo"
"${MINGW_PACKAGE_PREFIX}-libpng"
"${MINGW_PACKAGE_PREFIX}-freetype"
"${MINGW_PACKAGE_PREFIX}-eigen3"
"${MINGW_PACKAGE_PREFIX}-zlib")
makedepends=("${MINGW_PACKAGE_PREFIX}-cmake"
"${MINGW_PACKAGE_PREFIX}-ninja"
"${MINGW_PACKAGE_PREFIX}-libbacktrace"
"${MINGW_PACKAGE_PREFIX}-cc")
source=("https://github.com/solvespace/solvespace/releases/download/v${pkgver}/${_realname}-${pkgver}.tar.xz"
"1487.patch"
"002-not-in-msys2-temp.patch")
sha256sums=('34a273ce642d0c77b8f101463730ed4eade7d90cfabfe486f3e7cbf494ff132a'
'76b7711320430440e646d3a93c4128ae86db797c4089cc08bbfb813aac70527e'
'519cda45a5e5c76d1c5a3904b9ff35fcb058a8f12a72ec06d703576290092a54')

prepare() {
cd "${srcdir}/${_realname}-${pkgver}"
patch -N -p1 -i "${srcdir}/1487.patch" || true
patch -N -p1 -i "${srcdir}/002-not-in-msys2-temp.patch" || true
}

build() {
declare -a extra_config
if check_option "debug" "n"; then
extra_config+=("-DCMAKE_BUILD_TYPE=Release")
else
extra_config+=("-DCMAKE_BUILD_TYPE=Debug")
fi

mkdir -p "${srcdir}/build-${MSYSTEM}" && cd "${srcdir}/build-${MSYSTEM}"

MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
cmake \
-GNinja \
-DCMAKE_INSTALL_PREFIX="${MINGW_PREFIX}" \
"${extra_config[@]}" \
-DENABLE_TESTS=OFF \
-DENABLE_COVERAGE=OFF \
../${_realname}-${pkgver}

cmake --build .
}

package() {
cd "${srcdir}/build-${MSYSTEM}"
DESTDIR="${pkgdir}" cmake --install .

install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING.txt" \
"${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING.txt"
}

0 comments on commit b03a93e

Please sign in to comment.