diff --git a/.github/scripts/build-macos.sh b/.github/scripts/build-macos.sh index 3394a8af..103b3186 100755 --- a/.github/scripts/build-macos.sh +++ b/.github/scripts/build-macos.sh @@ -49,4 +49,4 @@ else if [ $(uname -m) = "$2" ]; then make -j$(sysctl -n hw.logicalcpu) test_solvespace fi -fi \ No newline at end of file +fi diff --git a/.github/scripts/sign-macos.sh b/.github/scripts/sign-macos.sh index 8e944d3e..0580f748 100755 --- a/.github/scripts/sign-macos.sh +++ b/.github/scripts/sign-macos.sh @@ -72,12 +72,12 @@ do echo "Checking progress..." progress=$(xcrun altool --notarization-info "${notarize_uuid}" -u "${MACOS_APPSTORE_USERNAME}" -p "${MACOS_APPSTORE_APP_PASSWORD}" 2>&1) # echo "${progress}" - + if [ $? -ne 0 ] || [[ "${progress}" =~ "Invalid" ]] ; then echo "Error with notarization. Exiting" break fi - + if [[ "${progress}" =~ "success" ]]; then success=1 break @@ -88,4 +88,4 @@ do done # staple -xcrun stapler staple "${dmg}" \ No newline at end of file +xcrun stapler staple "${dmg}" diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index abfaba33..85f28aa2 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -69,7 +69,7 @@ jobs: with: name: windows path: build/bin/RelWithDebInfo/solvespace.exe - + build_release_windows_openmp: needs: [test_ubuntu, test_windows, test_macos] name: Build Release Windows (OpenMP) @@ -123,8 +123,8 @@ jobs: - name: Set Up Source run: rsync --filter=":- .gitignore" -r ./ pkg/snap/solvespace-snap-src - name: Build Snap + uses: snapcore/action-build@v1 id: build - uses: diddlesnaps/snapcraft-multiarch-action@v1 with: path: pkg/snap - name: Upload & Release to Edge @@ -142,40 +142,6 @@ jobs: snap: ${{ steps.build.outputs.snap }} release: edge,beta - deploy_snap_arm64: - needs: [test_ubuntu, test_windows, test_macos] - name: Deploy ARM64 Snap - runs-on: ubuntu-latest - steps: - - uses: docker/setup-qemu-action@v1 - with: - image: tonistiigi/binfmt@sha256:df15403e06a03c2f461c1f7938b171fda34a5849eb63a70e2a2109ed5a778bde - - uses: actions/checkout@v2 - - name: Fetch Tags - run: git fetch --force --tags - - name: Set Up Source - run: rsync --filter=":- .gitignore" -r ./ pkg/snap/solvespace-snap-src - - name: Build Snap - id: build - uses: diddlesnaps/snapcraft-multiarch-action@v1 - with: - path: pkg/snap - architecture: arm64 - - name: Upload & Release to Edge - if: github.event_name == 'push' - uses: snapcore/action-publish@v1 - with: - store_login: ${{ secrets.SNAPSTORE_LOGIN }} - snap: ${{ steps.build.outputs.snap }} - release: edge - - name: Upload & Release to Beta + Edge - if: github.event_name == 'release' - uses: snapcore/action-publish@v1 - with: - store_login: ${{ secrets.SNAPSTORE_LOGIN }} - snap: ${{ steps.build.outputs.snap }} - release: edge,beta - upload_release_assets: name: Upload Release Assets needs: [build_release_windows, build_release_windows_openmp, build_release_macos] diff --git a/.github/workflows/source-tarball.yml b/.github/workflows/source-tarball.yml index 8bc06221..cc3c4101 100644 --- a/.github/workflows/source-tarball.yml +++ b/.github/workflows/source-tarball.yml @@ -21,7 +21,12 @@ jobs: dir_name="solvespace-${version}" archive_name="${dir_name}.tar.xz" archive_path="${HOME}/${archive_name}" - + commit_sha="$GITHUB_SHA" + + sed -e 's/^\(include(GetGitCommitHash)\)/#\1/' \ + -e 's/^# \(set(GIT_COMMIT_HASH\).*/\1 '"$commit_sha"')/' \ + -i CMakeLists.txt + echo "::set-output name=archive_name::${archive_name}" echo "::set-output name=archive_path::${archive_path}" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1ca64b3a..9042b8e8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -42,3 +42,20 @@ jobs: run: .github/scripts/install-macos.sh ci - name: Build & Test run: .github/scripts/build-macos.sh debug arm64 && .github/scripts/build-macos.sh debug x86_64 + + test_flatpak: + name: Test Flatpak x86_64 + runs-on: ubuntu-latest + container: + image: bilelmoussaoui/flatpak-github-actions:freedesktop-21.08 + options: --privileged + steps: + - uses: actions/checkout@v3 + with: + submodules: true + fetch-depth: 0 + - uses: bilelmoussaoui/flatpak-github-actions/flatpak-builder@v4 + with: + bundle: "solvespace.flatpak" + manifest-path: "pkg/flatpak/com.solvespace.SolveSpace.json" + cache-key: flatpak-builder-${{ github.sha }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f6a4af0..ce24e593 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ Changelog ========= -3.x - since the 3.0 release, only available in edge builds +3.1 --- Constraints: diff --git a/CMakeLists.txt b/CMakeLists.txt index ecef9c5b..5a012553 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,7 +40,7 @@ include(GetGitCommitHash) string(SUBSTRING "${GIT_COMMIT_HASH}" 0 8 solvespace_GIT_HASH) project(solvespace - VERSION 3.0 + VERSION 3.1 LANGUAGES C CXX ASM) set(ENABLE_GUI ON CACHE BOOL @@ -91,6 +91,10 @@ endif() if(MINGW) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++") + # 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") endif() # Ensure that all platforms use 64-bit IEEE floating point operations for consistency; @@ -182,12 +186,13 @@ if(APPLE) set(CMAKE_FIND_FRAMEWORK LAST) endif() +if(EMSCRIPTEN) + set(M_LIBRARY "" CACHE STRING "libm (not necessary)" FORCE) +endif() + message(STATUS "Using in-tree libdxfrw") add_subdirectory(extlib/libdxfrw) -message(STATUS "Using in-tree eigen") -include_directories(extlib/eigen) - message(STATUS "Using in-tree mimalloc") set(MI_OVERRIDE OFF CACHE BOOL "") set(MI_BUILD_SHARED OFF CACHE BOOL "") @@ -199,16 +204,19 @@ set(MIMALLOC_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/extlib/mimalloc/include) if(NOT FORCE_VENDORED_Eigen3) find_package(Eigen3 CONFIG) endif() -if(FORCE_VENDORED_Eigen3 OR NOT EIGEN3_FOUND) +if(FORCE_VENDORED_Eigen3 OR NOT EIGEN3_INCLUDE_DIRS) message(STATUS "Using in-tree Eigen") set(EIGEN3_FOUND YES) set(EIGEN3_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/extlib/eigen) else() message(STATUS "Using system Eigen: ${EIGEN3_INCLUDE_DIRS}") endif() +if(NOT EXISTS "${EIGEN3_INCLUDE_DIRS}") + message(FATAL_ERROR "Eigen 3 not found on system or in-tree") +endif() -if(WIN32 OR APPLE) +if(WIN32 OR APPLE OR EMSCRIPTEN) # 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 @@ -269,7 +277,7 @@ else() find_package(ZLIB REQUIRED) find_package(PNG REQUIRED) find_package(Freetype REQUIRED) - pkg_check_modules(CAIRO REQUIRED cairo) + find_package(Cairo REQUIRED) endif() # GUI dependencies @@ -303,6 +311,8 @@ if(ENABLE_GUI) elseif(APPLE) find_package(OpenGL REQUIRED) find_library(APPKIT_LIBRARY AppKit REQUIRED) + elseif(EMSCRIPTEN) + # Everything is built in else() find_package(OpenGL REQUIRED) find_package(SpaceWare) @@ -373,9 +383,19 @@ if(MSVC) # Same for the (C99) __func__ special variable; we use it only in C++ code. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D__func__=__FUNCTION__") + # Multi-processor Compilation + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") + # We rely on these /we flags. They correspond to the GNU-style flags below as # follows: /w4062=-Wswitch set(WARNING_FLAGS "${WARNING_FLAGS} /we4062") + + # Link 32 bit SolveSpace with /LARGEADDRESSAWARE 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 "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /LARGEADDRESSAWARE") endif() if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") diff --git a/README.md b/README.md index 14bb49ff..6416b3ad 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,14 @@ automatically built by the SolveSpace maintainers for each stable release. [rel]: https://github.com/solvespace/solvespace/releases +### Via Flathub + +Official releases can be installed as a Flatpak from Flathub. + +[Get SolveSpace from Flathub](https://flathub.org/apps/details/com.solvespace.SolveSpace) + +These should work on any Linux distribution that supports Flatpak. + ### Via Snap Store Official releases can be installed from the `stable` channel. @@ -68,18 +76,18 @@ from the following links: Extract the downloaded archive and install or execute the contained file as is appropriate for your platform. -### Via third-party packages - -_Third-party_ nightly binary packages for Debian and Ubuntu are available via -[notesalexp.org][notesalexp]. These packages are automatically built from -non-released source code. The SolveSpace maintainers do not control the contents -of these packages and cannot guarantee their functionality. - -[notesalexp]: https://notesalexp.org/packages/en/source/solvespace/ - ### Via source code -See below. +Irrespective of the OS used, before building, check out the project and the +necessary submodules: + +```sh +git clone https://github.com/solvespace/solvespace +cd solvespace +git submodule update --init +``` + +You will need `git`. See the platform specific instructions below to install it. ## Building on Linux @@ -106,13 +114,7 @@ sudo dnf install git gcc-c++ cmake zlib-devel libpng-devel \ mesa-libGL-devel mesa-libGLU-devel libspnav-devel ``` -Before building, check out the project and the necessary submodules: - -```sh -git clone https://github.com/solvespace/solvespace -cd solvespace -git submodule update --init extlib/libdxfrw extlib/mimalloc extlib/eigen -``` +Before building, [check out the project and the necessary submodules](#via-source-code). After that, build SolveSpace as following: @@ -146,13 +148,7 @@ Debian derivative (e.g. Ubuntu) these can be installed with: apt-get install git build-essential cmake mingw-w64 ``` -Before building, check out the project and the necessary submodules: - -```sh -git clone https://github.com/solvespace/solvespace -cd solvespace -git submodule update --init -``` +Before building, [check out the project and the necessary submodules](#via-source-code). Build 64-bit SolveSpace with the following: @@ -169,6 +165,45 @@ command-line interface is built as `build/bin/solvespace-cli.exe`. Space Navigator support will not be available. +### Building for web (very experimental) + +**Please note that this port contains many critical bugs and unimplemented core functions.** + +You will need the usual build tools, cmake and [Emscripten][]. On a Debian derivative (e.g. Ubuntu) dependencies other than Emscripten can be installed with: + +```sh +apt-get install git build-essential cmake +``` + +First, install and prepare `emsdk`: + +```sh +git clone https://github.com/emscripten-core/emsdk +cd emsdk +./emsdk install latest +./emsdk activate latest +source ./emsdk_env.sh +cd .. +``` + +Before building, [check out the project and the necessary submodules](#via-source-code). + +After that, build SolveSpace as following: + +```sh +mkdir build +cd build +emcmake cmake .. -DCMAKE_BUILD_TYPE=Release -DENABLE_LTO="ON" -DENABLE_TESTS="OFF" -DENABLE_CLI="OFF" -DENABLE_COVERAGE="OFF" +make +``` + +The graphical interface is built as multiple files in the `build/bin` directory with names +starting with `solvespace`. It can be run locally with `emrun build/bin/solvespace.html`. + +The command-line interface is not available. + +[emscripten]: https://emscripten.org/ + ## Building on macOS You will need git, XCode tools, CMake and libomp. Git, CMake and libomp can be installed @@ -181,13 +216,7 @@ brew install git cmake libomp XCode has to be installed via AppStore or [the Apple website][appledeveloper]; it requires a free Apple ID. -Before building, check out the project and the necessary submodules: - -```sh -git clone https://github.com/solvespace/solvespace -cd solvespace -git submodule update --init -``` +Before building, [check out the project and the necessary submodules](#via-source-code). After that, build SolveSpace as following: @@ -225,13 +254,7 @@ These can be installed from the ports tree: pkg_add -U git cmake libexecinfo png json-c gtk3mm pangomm ``` -Before building, check out the project and the necessary submodules: - -```sh -git clone https://github.com/solvespace/solvespace -cd solvespace -git submodule update --init extlib/libdxfrw extlib/mimalloc extlib/eigen -``` +Before building, [check out the project and the necessary submodules](#via-source-code). After that, build SolveSpace as following: @@ -254,10 +277,14 @@ by passing the `-DENABLE_GUI=OFF` flag to the cmake invocation. You will need [git][gitwin], [cmake][cmakewin] and a C++ compiler (either Visual C++ or MinGW). If using Visual C++, Visual Studio 2015 or later is required. +If gawk is in your path be sure it is a proper Windows port that can handle CL LF line endings. +If not CMake may fail in libpng due to some awk scripts - issue #1228. + +Before building, [check out the project and the necessary submodules](#via-source-code). ### Building with Visual Studio IDE -Check out the git submodules. Create a directory `build` in +Create a directory `build` in the source tree and point cmake-gui to the source tree and that directory. Press "Configure" and "Generate", then open `build\solvespace.sln` with Visual C++ and build it. @@ -269,9 +296,6 @@ First, ensure that `git` and `cl` (the Visual C++ compiler driver) are in your Visual Studio install. Then, run the following in cmd or PowerShell: ```bat -git clone https://github.com/solvespace/solvespace -cd solvespace -git submodule update --init mkdir build cd build cmake .. -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release @@ -287,9 +311,6 @@ First, ensure that git and gcc are in your `$PATH`. Then, run the following in bash: ```sh -git clone https://github.com/solvespace/solvespace -cd solvespace -git submodule update --init mkdir build cd build cmake .. -DCMAKE_BUILD_TYPE=Release diff --git a/cmake/DisableWarnings.cmake b/cmake/DisableWarnings.cmake index b79ef9cd..34925c80 100644 --- a/cmake/DisableWarnings.cmake +++ b/cmake/DisableWarnings.cmake @@ -4,12 +4,12 @@ function(disable_warnings) if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w" PARENT_SCOPE) elseif(CMAKE_C_COMPILER_ID STREQUAL "MSVC") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W0" PARENT_SCOPE) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W0 /MP" PARENT_SCOPE) endif() if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w" PARENT_SCOPE) elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W0" PARENT_SCOPE) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W0 /MP" PARENT_SCOPE) endif() endfunction() diff --git a/cmake/FindCairo.cmake b/cmake/FindCairo.cmake new file mode 100644 index 00000000..d0130ad5 --- /dev/null +++ b/cmake/FindCairo.cmake @@ -0,0 +1,75 @@ +# - Try to find Cairo +# Once done, this will define +# +# CAIRO_FOUND - system has Cairo +# CAIRO_INCLUDE_DIRS - the Cairo include directories +# CAIRO_LIBRARIES - link these to use Cairo +# +# Copyright (C) 2012 Raphael Kubo da Costa +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND ITS CONTRIBUTORS ``AS +# IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ITS +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +find_package(PkgConfig) +pkg_check_modules(PC_CAIRO QUIET cairo) + +find_path(CAIRO_INCLUDE_DIRS + NAMES cairo.h + HINTS ${PC_CAIRO_INCLUDEDIR} + ${PC_CAIRO_INCLUDE_DIRS} + PATH_SUFFIXES cairo +) + +find_library(CAIRO_LIBRARIES + NAMES cairo + HINTS ${PC_CAIRO_LIBDIR} + ${PC_CAIRO_LIBRARY_DIRS} +) + +if (CAIRO_INCLUDE_DIRS) + if (EXISTS "${CAIRO_INCLUDE_DIRS}/cairo-version.h") + file(READ "${CAIRO_INCLUDE_DIRS}/cairo-version.h" CAIRO_VERSION_CONTENT) + + string(REGEX MATCH "#define +CAIRO_VERSION_MAJOR +([0-9]+)" _dummy "${CAIRO_VERSION_CONTENT}") + set(CAIRO_VERSION_MAJOR "${CMAKE_MATCH_1}") + + string(REGEX MATCH "#define +CAIRO_VERSION_MINOR +([0-9]+)" _dummy "${CAIRO_VERSION_CONTENT}") + set(CAIRO_VERSION_MINOR "${CMAKE_MATCH_1}") + + string(REGEX MATCH "#define +CAIRO_VERSION_MICRO +([0-9]+)" _dummy "${CAIRO_VERSION_CONTENT}") + set(CAIRO_VERSION_MICRO "${CMAKE_MATCH_1}") + + set(CAIRO_VERSION "${CAIRO_VERSION_MAJOR}.${CAIRO_VERSION_MINOR}.${CAIRO_VERSION_MICRO}") + endif () +endif () + +if ("${Cairo_FIND_VERSION}" VERSION_GREATER "${CAIRO_VERSION}") + message(FATAL_ERROR "Required version (" ${Cairo_FIND_VERSION} ") is higher than found version (" ${CAIRO_VERSION} ")") +endif () + +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Cairo REQUIRED_VARS CAIRO_INCLUDE_DIRS CAIRO_LIBRARIES + VERSION_VAR CAIRO_VERSION) + +mark_as_advanced( + CAIRO_INCLUDE_DIRS + CAIRO_LIBRARIES +) diff --git a/cmake/Platform/Emscripten.cmake b/cmake/Platform/Emscripten.cmake new file mode 100644 index 00000000..160f2e51 --- /dev/null +++ b/cmake/Platform/Emscripten.cmake @@ -0,0 +1,20 @@ +set(EMSCRIPTEN 1) + +set(CMAKE_C_OUTPUT_EXTENSION ".o") +set(CMAKE_CXX_OUTPUT_EXTENSION ".o") +set(CMAKE_EXECUTABLE_SUFFIX ".html") + +set(CMAKE_SIZEOF_VOID_P 4) + +set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE) + +# FIXME(emscripten): Suppress non-c-typedef-for-linkage warnings in solvespace.h +add_compile_options(-Wno-non-c-typedef-for-linkage) + + +# Enable optimization. Workaround for "too many locals" error when runs on browser. +if(CMAKE_BUILD_TYPE STREQUAL Release) + add_compile_options(-O2) +else() + add_compile_options(-O1) +endif() diff --git a/cmake/Toolchain-emscripten.cmake b/cmake/Toolchain-emscripten.cmake new file mode 100644 index 00000000..ad20ea16 --- /dev/null +++ b/cmake/Toolchain-emscripten.cmake @@ -0,0 +1,8 @@ +set(CMAKE_SYSTEM_NAME Emscripten) + +set(TRIPLE asmjs-unknown-emscripten) + +set(CMAKE_C_COMPILER emcc) +set(CMAKE_CXX_COMPILER em++) + +set(M_LIBRARY m) diff --git a/cmake/c_flag_overrides.cmake b/cmake/c_flag_overrides.cmake index b21f00e3..978b6b65 100644 --- a/cmake/c_flag_overrides.cmake +++ b/cmake/c_flag_overrides.cmake @@ -3,4 +3,8 @@ if(MSVC) set(CMAKE_C_FLAGS_MINSIZEREL_INIT "/MT /O1 /Ob1 /D NDEBUG") set(CMAKE_C_FLAGS_RELEASE_INIT "/MT /O2 /Ob2 /D NDEBUG") set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "/MT /Zi /O2 /Ob1 /D NDEBUG") -endif() \ No newline at end of file +endif() + +if(EMSCRIPTEN) + set(CMAKE_C_FLAGS_DEBUG_INIT "-g4") +endif() diff --git a/cmake/cxx_flag_overrides.cmake b/cmake/cxx_flag_overrides.cmake index 67e00433..9c8d15fe 100644 --- a/cmake/cxx_flag_overrides.cmake +++ b/cmake/cxx_flag_overrides.cmake @@ -4,3 +4,7 @@ if(MSVC) set(CMAKE_CXX_FLAGS_RELEASE_INIT "/MT /O2 /Ob2 /D NDEBUG") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "/MT /Zi /O2 /Ob1 /D NDEBUG") endif() + +if(EMSCRIPTEN) + set(CMAKE_CXX_FLAGS_DEBUG_INIT "-g4") +endif() diff --git a/exposed/CMakeLists.txt b/exposed/CMakeLists.txt index bdc3fc39..db72d4d4 100644 --- a/exposed/CMakeLists.txt +++ b/exposed/CMakeLists.txt @@ -6,3 +6,8 @@ add_executable(CDemo target_link_libraries(CDemo slvs) + +if(EMSCRIPTEN) + set_target_properties(CDemo PROPERTIES + LINK_FLAGS "-s TOTAL_MEMORY=134217728") +endif() diff --git a/extlib/mimalloc b/extlib/mimalloc index 4e643b6d..f819dbb4 160000 --- a/extlib/mimalloc +++ b/extlib/mimalloc @@ -1 +1 @@ -Subproject commit 4e643b6d3178e0ea2a093b7e14fe621631a91e4b +Subproject commit f819dbb4e4813fab464aee16770f39f11476bfea diff --git a/pkg/flatpak/com.solvespace.SolveSpace.json b/pkg/flatpak/com.solvespace.SolveSpace.json index 8f55fa84..1d6a8fa9 100644 --- a/pkg/flatpak/com.solvespace.SolveSpace.json +++ b/pkg/flatpak/com.solvespace.SolveSpace.json @@ -1,69 +1,97 @@ { + "$schema": "https://raw.githubusercontent.com/TingPing/flatpak-manifest-schema/master/flatpak-manifest.schema", "app-id": "com.solvespace.SolveSpace", "runtime": "org.freedesktop.Platform", - "runtime-version": "20.08", + "runtime-version": "21.08", "sdk": "org.freedesktop.Sdk", "finish-args": [ - /* Access to display server and OpenGL */ + "--device=dri", "--share=ipc", "--socket=fallback-x11", - "--socket=wayland", - "--device=dri", - /* Access to save files */ - "--filesystem=home" + "--socket=wayland" ], "cleanup": [ "/include", - "/lib/*/include", - "*.a", - "*.la", - "*.m4", - "/lib/libslvs*.so*", - "/lib/libglibmm_generate_extra_defs*.so*", - "/share/pkgconfig", - "*.pc", - "/share/man", - "/share/doc", + "/lib/cmake", + "/lib/pkgconfig", "/share/aclocal", - /* mm-common junk */ - "/bin/mm-common-prepare", - "/share/mm-common" + "/share/pkgconfig", + "*.la" ], "command": "solvespace", "modules": [ { "name": "mm-common", - "sources": [ - { - "type": "archive", - "url": "https://download.gnome.org/sources/mm-common/1.0/mm-common-1.0.2.tar.xz", - "sha256": "a2a99f3fa943cf662f189163ed39a2cfc19a428d906dd4f92b387d3659d1641d" - } - ] - }, - { - "name": "sigc++", - "config-opts": [ - "--disable-documentation" - ], - "sources": [ - { - "type": "archive", - "url": "https://download.gnome.org/sources/libsigc++/2.10/libsigc%2B%2B-2.10.6.tar.xz", - "sha256": "dda176dc4681bda9d5a2ac1bc55273bdd381662b7a6d49e918267d13e8774e1b" - } - ] - }, - { - "name": "glibmm", - "config-opts": [], "buildsystem": "meson", "sources": [ { "type": "archive", - "url": "https://download.gnome.org/sources/glibmm/2.64/glibmm-2.64.5.tar.xz", - "sha256": "508fc86e2c9141198aa16c225b16fd6b911917c0d3817602652844d0973ea386" + "url": "https://download.gnome.org/sources/mm-common/1.0/mm-common-1.0.4.tar.xz", + "sha256": "e954c09b4309a7ef93e13b69260acdc5738c907477eb381b78bb1e414ee6dbd8", + "x-checker-data": { + "type": "gnome", + "name": "mm-common", + "stable-only": true + } } + ], + "cleanup": [ + "/bin", + "/share/doc", + "/share/man", + "/share/mm-common" + ] + }, + { + "name": "sigc++", + "buildsystem": "meson", + "config-opts": [ + "-Dbuild-examples=false" + ], + "sources": [ + { + "type": "archive", + "url": "https://download.gnome.org/sources/libsigc++/2.10/libsigc++-2.10.8.tar.xz", + "sha256": "235a40bec7346c7b82b6a8caae0456353dc06e71f14bc414bcc858af1838719a", + "x-checker-data": { + "type": "gnome", + "name": "libsigc++", + "stable-only": true, + "versions": { + "<": "3.0.0" + } + } + } + ], + "cleanup": [ + "/lib/sigc++-*" + ] + }, + { + "name": "glibmm", + "buildsystem": "meson", + "config-opts": [ + "-Dbuild-examples=false" + ], + "sources": [ + { + "type": "archive", + "url": "https://download.gnome.org/sources/glibmm/2.66/glibmm-2.66.4.tar.xz", + "sha256": "199ace5682d81b15a1d565480b4a950682f2db6402c8aa5dd7217d71edff81d5", + "x-checker-data": { + "type": "gnome", + "name": "glibmm", + "stable-only": true, + "versions": { + "<": "2.68.0" + } + } + } + ], + "cleanup": [ + "/lib/giomm-*", + "/lib/glibmm-*", + "/lib/libglibmm_generate_extra_defs-*.so*" ] }, { @@ -74,76 +102,152 @@ "sources": [ { "type": "archive", - "url": "http://ftp.gnome.org/pub/GNOME/sources/cairomm/1.12/cairomm-1.12.0.tar.xz", - "sha256": "a54ada8394a86182525c0762e6f50db6b9212a2109280d13ec6a0b29bfd1afe6" + "url": "https://download.gnome.org/sources/cairomm/1.12/cairomm-1.12.0.tar.xz", + "sha256": "a54ada8394a86182525c0762e6f50db6b9212a2109280d13ec6a0b29bfd1afe6", + "x-checker-data": { + "type": "gnome", + "name": "cairomm", + "stable-only": true, + "versions": { + "<": "1.16.0" + } + } } + ], + "cleanup": [ + "/lib/cairomm-*" ] }, { "name": "pangomm", - "config-opts": [ - "--disable-documentation" - ], - "sources": [ - { - "type": "archive", - "url": "http://ftp.gnome.org/pub/GNOME/sources/pangomm/2.40/pangomm-2.40.2.tar.xz", - "sha256": "0a97aa72513db9088ca3034af923484108746dba146e98ed76842cf858322d05" - } - ] - }, - { - "name": "atkmm", - "config-opts": [ - "--disable-documentation" - ], - "sources": [ - { - "type": "archive", - "url": "http://ftp.gnome.org/pub/GNOME/sources/atkmm/2.28/atkmm-2.28.0.tar.xz", - "sha256": "4c4cfc917fd42d3879ce997b463428d6982affa0fb660cafcc0bc2d9afcedd3a" - } - ] - }, - { - "name": "gtkmm", - "config-opts": [], "buildsystem": "meson", "sources": [ { "type": "archive", - "url": "https://download.gnome.org/sources/gtkmm/3.24/gtkmm-3.24.4.tar.xz", - "sha256": "9beb71c3e90cfcfb790396b51e3f5e7169966751efd4f3ef9697114be3be6743" + "url": "https://download.gnome.org/sources/pangomm/2.46/pangomm-2.46.2.tar.xz", + "sha256": "57442ab4dc043877bfe3839915731ab2d693fc6634a71614422fb530c9eaa6f4", + "x-checker-data": { + "type": "gnome", + "name": "pangomm", + "stable-only": true, + "versions": { + "<": "2.48.0" + } + } } + ], + "cleanup": [ + "/lib/pangomm-*" + ] + }, + { + "name": "atkmm", + "buildsystem": "meson", + "sources": [ + { + "type": "archive", + "url": "https://download.gnome.org/sources/atkmm/2.28/atkmm-2.28.2.tar.xz", + "sha256": "a0bb49765ceccc293ab2c6735ba100431807d384ffa14c2ebd30e07993fd2fa4", + "x-checker-data": { + "type": "gnome", + "name": "atkmm", + "stable-only": true, + "versions": { + "<": "2.30.0" + } + } + } + ], + "cleanup": [ + "/lib/atkmm-*" + ] + }, + { + "name": "gtkmm", + "buildsystem": "meson", + "config-opts": [ + "-Dbuild-demos=false", + "-Dbuild-tests=false" + ], + "sources": [ + { + "type": "archive", + "url": "https://download.gnome.org/sources/gtkmm/3.24/gtkmm-3.24.6.tar.xz", + "sha256": "4b3e142e944e1633bba008900605c341a93cfd755a7fa2a00b05d041341f11d6", + "x-checker-data": { + "type": "gnome", + "name": "gtkmm", + "stable-only": true, + "versions": { + "<": "4.0.0" + } + } + } + ], + "cleanup": [ + "/lib/gdkmm-*", + "/lib/gtkmm-*" + ] + }, + { + "name": "eigen", + "buildsystem": "cmake-ninja", + "builddir": true, + "sources": [ + { + "type": "archive", + "url": "https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.gz", + "sha256": "8586084f71f9bde545ee7fa6d00288b264a2b7ac3607b974e54d13e7162c1c72", + "x-checker-data": { + "type": "anitya", + "project-id": 13751, + "stable-only": true, + "url-template": "https://gitlab.com/libeigen/eigen/-/archive/$version/eigen-$version.tar.gz" + } + } + ], + "cleanup": [ + "*" ] }, { "name": "libjson-c", + "buildsystem": "cmake-ninja", + "builddir": true, + "config-opts": [ + "-DBUILD_STATIC_LIBS=OFF", + "-DENABLE_THREADING=ON" + ], "sources": [ { - /* 0.15-nodoc doesn't build */ "type": "archive", - "url": "https://s3.amazonaws.com/json-c_releases/releases/json-c-0.13.1-nodoc.tar.gz", - "sha256": "94a26340c0785fcff4f46ff38609cf84ebcd670df0c8efd75d039cc951d80132" + "url": "https://s3.amazonaws.com/json-c_releases/releases/json-c-0.16.tar.gz", + "sha256": "8e45ac8f96ec7791eaf3bb7ee50e9c2100bbbc87b8d0f1d030c5ba8a0288d96b", + "x-checker-data": { + "type": "anitya", + "project-id": 1477, + "stable-only": true, + "url-template": "https://s3.amazonaws.com/json-c_releases/releases/json-c-$version.tar.gz" + } } - ], - "buildsystem": "cmake", - "builddir": true + ] }, { - "name": "SolveSpace", + "name": "solvespace", + "buildsystem": "cmake-ninja", + "builddir": true, + "config-opts": [ + "-DFLATPAK=ON", + "-DENABLE_TESTS=OFF" + ], "sources": [ { "type": "dir", "path": "../.." } ], - "buildsystem": "cmake", - "builddir": true, - "config-opts": [ - "-DFLATPAK=ON", - "-DENABLE_CLI=OFF", - "-DENABLE_TESTS=OFF" + "cleanup": [ + "/lib/libslvs*.so*" ] } ] diff --git a/pkg/snap/snap/snapcraft.yaml b/pkg/snap/snap/snapcraft.yaml index b01b25cf..79baaadb 100644 --- a/pkg/snap/snap/snapcraft.yaml +++ b/pkg/snap/snap/snapcraft.yaml @@ -1,5 +1,5 @@ name: solvespace -base: core20 +base: core22 summary: Parametric 2d/3d CAD adopt-info: solvespace description: | @@ -15,6 +15,7 @@ description: | confinement: strict license: GPL-3.0 compression: lzo +grade: stable layout: /usr/share/solvespace: @@ -24,11 +25,11 @@ apps: solvespace: command: usr/bin/solvespace desktop: solvespace.desktop - extensions: [gnome-3-38] + extensions: [gnome] plugs: [opengl, unity7, home, removable-media, gsettings, network] cli: command: usr/bin/solvespace-cli - extensions: [gnome-3-38] + extensions: [gnome] plugs: [home, removable-media, network] parts: @@ -37,16 +38,14 @@ parts: source: ./solvespace-snap-src source-type: local override-pull: | - snapcraftctl pull + craftctl default git submodule update --init extlib/libdxfrw extlib/mimalloc extlib/eigen override-build: | - snapcraftctl build + craftctl default project_version=$(grep CMAKE_PROJECT_VERSION:STATIC CMakeCache.txt | cut -d "=" -f2) - cd $SNAPCRAFT_PART_SRC + cd $CRAFT_PART_SRC version="$project_version~$(git rev-parse --short=8 HEAD)" - snapcraftctl set-version "$version" - git describe --exact-match HEAD && grade="stable" || grade="devel" - snapcraftctl set-grade "$grade" + craftctl set version="$version" cmake-parameters: - -DCMAKE_INSTALL_PREFIX=/usr - -DCMAKE_BUILD_TYPE=Release @@ -54,8 +53,6 @@ parts: - -DSNAP=ON - -DENABLE_OPENMP=ON - -DENABLE_LTO=ON - build-snaps: - - gnome-3-38-2004-sdk build-packages: - zlib1g-dev - libpng-dev @@ -67,6 +64,7 @@ parts: - libspnav-dev - git - g++ + - libc6-dev stage-packages: - libspnav0 - libsigc++-2.0-0v5 @@ -74,14 +72,14 @@ parts: cleanup: after: [solvespace] plugin: nil - build-snaps: [gnome-3-38-2004] + build-snaps: [gnome-42-2204] override-prime: | set -eux - for snap in "gnome-3-38-2004"; do # List all content-snaps you're using here - cd "/snap/$snap/current" && find . -type f,l -exec rm -f "$SNAPCRAFT_PRIME/{}" "$SNAPCRAFT_PRIME/usr/{}" \; + for snap in "gnome-42-2204"; do # List all content-snaps you're using here + cd "/snap/$snap/current" && find . -type f,l -exec rm -f "$CRAFT_PRIME/{}" "$CRAFT_PRIME/usr/{}" \; done for cruft in bug lintian man; do - rm -rf $SNAPCRAFT_PRIME/usr/share/$cruft + rm -rf $CRAFT_PRIME/usr/share/$cruft done - find $SNAPCRAFT_PRIME/usr/share/doc/ -type f -not -name 'copyright' -delete - find $SNAPCRAFT_PRIME/usr/share -type d -empty -delete + find $CRAFT_PRIME/usr/share/doc/ -type f -not -name 'copyright' -delete + find $CRAFT_PRIME/usr/share -type d -empty -delete diff --git a/res/CMakeLists.txt b/res/CMakeLists.txt index 7303c6f7..da12ec12 100644 --- a/res/CMakeLists.txt +++ b/res/CMakeLists.txt @@ -1,6 +1,7 @@ # First, set up registration functions for the kinds of resources we handle. set(resource_root ${CMAKE_CURRENT_SOURCE_DIR}/) set(resource_list) +set(resource_names) if(WIN32) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/win32/versioninfo.rc.in ${CMAKE_CURRENT_BINARY_DIR}/win32/versioninfo.rc) @@ -83,6 +84,23 @@ elseif(APPLE) DEPENDS ${source} VERBATIM) endfunction() +elseif(EMSCRIPTEN) + set(resource_dir ${CMAKE_BINARY_DIR}/src/res) + + function(add_resource name) + set(source ${CMAKE_CURRENT_SOURCE_DIR}/${name}) + set(target ${resource_dir}/${name}) + set(resource_list "${resource_list};${target}" PARENT_SCOPE) + set(resource_names "${resource_names};res/${name}" PARENT_SCOPE) + + add_custom_command( + OUTPUT ${target} + COMMAND ${CMAKE_COMMAND} -E make_directory ${resource_dir} + COMMAND ${CMAKE_COMMAND} -E copy ${source} ${target} + COMMENT "Copying resource ${name}" + DEPENDS ${source} + VERBATIM) + endfunction() else() # Unix include(GNUInstallDirs) @@ -111,7 +129,8 @@ endif() function(add_resources) foreach(name ${ARGN}) add_resource(${name}) - set(resource_list "${resource_list}" PARENT_SCOPE) + set(resource_list "${resource_list}" PARENT_SCOPE) + set(resource_names "${resource_names}" PARENT_SCOPE) endforeach() endfunction() @@ -262,6 +281,7 @@ add_resources( icons/text-window/shaded.png icons/text-window/workplane.png locales.txt + locales/cs_CZ.po locales/de_DE.po locales/en_US.po locales/fr_FR.po @@ -270,6 +290,7 @@ add_resources( locales/tr_TR.po locales/ru_RU.po locales/zh_CN.po + locales/ja_JP.po fonts/unifont.hex.gz fonts/private/0-check-false.png fonts/private/1-check-true.png @@ -304,4 +325,6 @@ add_custom_target(resources DEPENDS ${resource_list}) if(WIN32) set_property(TARGET resources PROPERTY EXTRA_SOURCES ${rc_file}) +elseif(EMSCRIPTEN) + set_property(TARGET resources PROPERTY NAMES ${resource_names}) endif() diff --git a/res/freedesktop/com.solvespace.SolveSpace.metainfo.xml.in b/res/freedesktop/com.solvespace.SolveSpace.metainfo.xml.in index 3e88165b..0479aae4 100644 --- a/res/freedesktop/com.solvespace.SolveSpace.metainfo.xml.in +++ b/res/freedesktop/com.solvespace.SolveSpace.metainfo.xml.in @@ -19,7 +19,7 @@ SolveSpace is a free (GPLv3) parametric 3d CAD tool. Applications include: