From d843f1a76fe753d7ffdc6c53ed06f46a015d7139 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Thu, 11 Oct 2018 15:19:53 +0200 Subject: [PATCH] Fix resources dir location, add wxWidgets to Windows deps build script --- CMakeLists.txt | 26 ++++++++++++++-- doc/deps-build/windows/slic3r-makedeps.ps1 | 32 ++++++++++++++++++-- resources/localization/CMakeLists.txt | 8 ----- src/slic3r.cpp | 35 +++++++++------------- 4 files changed, 67 insertions(+), 34 deletions(-) delete mode 100644 resources/localization/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f4e89283..b0f908e90 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.2) include("version.inc") set(SLIC3R_RESOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/resources") +file(TO_NATIVE_PATH "${SLIC3R_RESOURCES_DIR}" SLIC3R_RESOURCES_DIR_WIN) if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) message(STATUS "No build type selected, default to Release") @@ -214,8 +215,29 @@ if (NOT GLEW_FOUND) endif () include_directories(${GLEW_INCLUDE_DIRS}) -# l10n -add_subdirectory(resources/localization) +# Resources and l10n +set(L10N_DIR "${SLIC3R_RESOURCES_DIR}/localization") +add_custom_target(pot + # FIXME: file list stale + COMMAND xgettext --keyword=L --from-code=UTF-8 --debug + -f "${L10N_DIR}/list.txt" + -o "${L10N_DIR}/Slic3rPE.pot" + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + COMMENT "Generate pot file from strings in the source tree" +) +if (MSVC) + file(TO_NATIVE_PATH "${CMAKE_BINARY_DIR}/src/resources" WIN_RESOURCES_SYMLINK) + add_custom_target(resources_symlink ALL + COMMAND if not exist "${WIN_RESOURCES_SYMLINK}" ( mklink /J "${WIN_RESOURCES_SYMLINK}" "${SLIC3R_RESOURCES_DIR_WIN}" ) + VERBATIM + ) +else () + add_custom_target(resources_symlink ALL + COMMAND ln -sf "${SLIC3R_RESOURCES_DIR}" "${CMAKE_BINARY_DIR}/resources" + VERBATIM + ) +endif() + # libslic3r, Slic3r GUI and the slic3r executable. add_subdirectory(src) diff --git a/doc/deps-build/windows/slic3r-makedeps.ps1 b/doc/deps-build/windows/slic3r-makedeps.ps1 index e256d61e4..228244d0b 100644 --- a/doc/deps-build/windows/slic3r-makedeps.ps1 +++ b/doc/deps-build/windows/slic3r-makedeps.ps1 @@ -40,6 +40,8 @@ $BOOST = 'boost_1_63_0' $CURL = 'curl-7.58.0' $TBB_SHA = 'a0dc9bf76d0120f917b641ed095360448cabc85b' $TBB = "tbb-$TBB_SHA" +$WXWIDGETS_VER = "3.1.1" +$WXWIDGETS = "wxWidgets-$WXWIDGETS_VER" try @@ -72,13 +74,21 @@ echo 'Downloading sources ...' if (!(Test-Path "$BOOST.zip")) { $webclient.DownloadFile("https://dl.bintray.com/boostorg/release/1.63.0/source/$BOOST.zip", "$BOOST.zip") } if (!(Test-Path "$TBB.zip")) { $webclient.DownloadFile("https://github.com/wjakob/tbb/archive/$TBB_SHA.zip", "$TBB.zip") } if (!(Test-Path "$CURL.zip")) { $webclient.DownloadFile("https://curl.haxx.se/download/$CURL.zip", ".\$CURL.zip") } +if (!(Test-Path "$WXWIDGETS.zip")) { $webclient.DownloadFile("https://github.com/wxWidgets/wxWidgets/releases/download/v$WXWIDGETS_VER/$WXWIDGETS.zip", ".\$WXWIDGETS.zip") } # Unpack sources: echo 'Unpacking ...' -if (!(Test-Path $BOOST)) { [IO.Compression.ZipFile]::ExtractToDirectory("$BOOST.zip", '.') } -if (!(Test-Path $TBB)) { [IO.Compression.ZipFile]::ExtractToDirectory("$TBB.zip", '.') } -if (!(Test-Path $CURL)) { [IO.Compression.ZipFile]::ExtractToDirectory("$CURL.zip", '.') } +if (!(Test-Path "$BOOST")) { [IO.Compression.ZipFile]::ExtractToDirectory("$BOOST.zip", '.') } +if (!(Test-Path "$TBB")) { [IO.Compression.ZipFile]::ExtractToDirectory("$TBB.zip", '.') } +if (!(Test-Path "$CURL")) { [IO.Compression.ZipFile]::ExtractToDirectory("$CURL.zip", '.') } +if (!(Test-Path "$WXWIDGETS")) { [IO.Compression.ZipFile]::ExtractToDirectory("$WXWIDGETS.zip", "$WXWIDGETS") } + + +# Patch PNG in wxWidgets +# PNG prefix is not applied properly to two functions +$pngprefix_h = "$WXWIDGETS\src\png\pngprefix.h" +"#define png_write_eXIf wx_png_write_eXIf`n#define png_handle_eXIf wx_png_handle_eXIf`n`n" + (Get-Content $pngprefix_h | Out-String) | Set-Content $pngprefix_h # Build libraries: @@ -127,6 +137,22 @@ Copy-Item -R -Force ..\builds\libcurl-*-winssl\include\* "$destdir\usr\local\inc Copy-Item -R -Force ..\builds\libcurl-*-winssl\lib\* "$destdir\usr\local\lib\" popd +# Build wxWidgets +pushd "$WXWIDGETS" +pushd "build\msw" +$target_cpu_opt = ("", "TARGET_CPU=X64")[!$b32] +$lib_dir = ("vc_lib", "vc_x64_lib")[!$b32] +nmake /f makefile.vc ` + BUILD=release ` + SHARED=0 ` + UNICODE=1 ` + USE_GUI=1 ` + "$target_cpu_opt" +popd +Copy-Item -R -Force include\* "$destdir\usr\local\include\" +Copy-Item -R -Force "lib\$lib_dir" "$destdir\usr\local\lib\" +popd + echo "" echo "All done!" diff --git a/resources/localization/CMakeLists.txt b/resources/localization/CMakeLists.txt deleted file mode 100644 index 8a7fba068..000000000 --- a/resources/localization/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -set(L10N_DIR "${PROJECT_SOURCE_DIR}/resources/localization") -add_custom_target(pot - COMMAND xgettext --keyword=L --from-code=UTF-8 --debug - -f "${L10N_DIR}/list.txt" - -o "${L10N_DIR}/Slic3rPE.pot" - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - COMMENT "Generate pot file from strings in the source tree" -) diff --git a/src/slic3r.cpp b/src/slic3r.cpp index 296d99414..03e337db5 100644 --- a/src/slic3r.cpp +++ b/src/slic3r.cpp @@ -70,31 +70,24 @@ int main(int argc, char **argv) } boost::filesystem::path path_to_binary = boost::filesystem::system_complete(argv[0]); - boost::filesystem::path path_resources = path_to_binary.parent_path(); + // Path from the Slic3r binary to its resources. - path_resources /= (path_to_binary.stem().string() == "slic3r-gui") ? - // Running from the build directory: -// "../../resources" : // ? #ys_FIXME - "../../../resources" : // ! #ys_FIXME - // Running from an installation directory: #ifdef __APPLE__ - // The application is packed in the .dmg archive as 'Slic3r.app/Contents/MacOS/Slic3r' - // The resources are packed to 'Slic3r.app/Contents/Resources' - "../Resources" + // The application is packed in the .dmg archive as 'Slic3r.app/Contents/MacOS/Slic3r' + // The resources are packed to 'Slic3r.app/Contents/Resources' + boost::filesystem::path path_resources = path_to_binary.parent_path() / "../Resources"; +#elif defined _WIN32 + // The application is packed in the .zip archive in the root, + // The resources are packed to 'resources' + // Path from Slic3r binary to resources: + boost::filesystem::path path_resources = path_to_binary.parent_path() / "resources"; #else - #ifdef _WIN32 - // The application is packed in the .zip archive in the root, - // The resources are packed to 'resources' - // Path from Slic3r binary to resources: - "resources" - #else - // The application is packed in the .tar.bz archive (or in AppImage) as 'bin/slic3r', - // The resources are packed to 'resources' - // Path from Slic3r binary to resources: - "../resources" - #endif + // The application is packed in the .tar.bz archive (or in AppImage) as 'bin/slic3r', + // The resources are packed to 'resources' + // Path from Slic3r binary to resources: + boost::filesystem::path path_resources = path_to_binary.parent_path() / "../resources"; #endif - ; + set_resources_dir(path_resources.string()); set_var_dir((path_resources / "icons").string()); set_local_dir((path_resources / "localization").string());