Fix resources dir location, add wxWidgets to Windows deps build script

This commit is contained in:
Vojtech Kral 2018-10-11 15:19:53 +02:00
parent aa0c3bf2e3
commit d843f1a76f
4 changed files with 67 additions and 34 deletions

View File

@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.2)
include("version.inc") include("version.inc")
set(SLIC3R_RESOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/resources") 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) if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "No build type selected, default to Release") message(STATUS "No build type selected, default to Release")
@ -214,8 +215,29 @@ if (NOT GLEW_FOUND)
endif () endif ()
include_directories(${GLEW_INCLUDE_DIRS}) include_directories(${GLEW_INCLUDE_DIRS})
# l10n # Resources and l10n
add_subdirectory(resources/localization) 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. # libslic3r, Slic3r GUI and the slic3r executable.
add_subdirectory(src) add_subdirectory(src)

View File

@ -40,6 +40,8 @@ $BOOST = 'boost_1_63_0'
$CURL = 'curl-7.58.0' $CURL = 'curl-7.58.0'
$TBB_SHA = 'a0dc9bf76d0120f917b641ed095360448cabc85b' $TBB_SHA = 'a0dc9bf76d0120f917b641ed095360448cabc85b'
$TBB = "tbb-$TBB_SHA" $TBB = "tbb-$TBB_SHA"
$WXWIDGETS_VER = "3.1.1"
$WXWIDGETS = "wxWidgets-$WXWIDGETS_VER"
try 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 "$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 "$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 "$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: # Unpack sources:
echo 'Unpacking ...' echo 'Unpacking ...'
if (!(Test-Path $BOOST)) { [IO.Compression.ZipFile]::ExtractToDirectory("$BOOST.zip", '.') } if (!(Test-Path "$BOOST")) { [IO.Compression.ZipFile]::ExtractToDirectory("$BOOST.zip", '.') }
if (!(Test-Path $TBB)) { [IO.Compression.ZipFile]::ExtractToDirectory("$TBB.zip", '.') } if (!(Test-Path "$TBB")) { [IO.Compression.ZipFile]::ExtractToDirectory("$TBB.zip", '.') }
if (!(Test-Path $CURL)) { [IO.Compression.ZipFile]::ExtractToDirectory("$CURL.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: # 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\" Copy-Item -R -Force ..\builds\libcurl-*-winssl\lib\* "$destdir\usr\local\lib\"
popd 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 ""
echo "All done!" echo "All done!"

View File

@ -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"
)

View File

@ -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_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 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__ #ifdef __APPLE__
// The application is packed in the .dmg archive as 'Slic3r.app/Contents/MacOS/Slic3r' // The application is packed in the .dmg archive as 'Slic3r.app/Contents/MacOS/Slic3r'
// The resources are packed to 'Slic3r.app/Contents/Resources' // The resources are packed to 'Slic3r.app/Contents/Resources'
"../Resources" boost::filesystem::path path_resources = path_to_binary.parent_path() / "../Resources";
#else #elif defined _WIN32
#ifdef _WIN32
// The application is packed in the .zip archive in the root, // The application is packed in the .zip archive in the root,
// The resources are packed to 'resources' // The resources are packed to 'resources'
// Path from Slic3r binary to resources: // Path from Slic3r binary to resources:
"resources" boost::filesystem::path path_resources = path_to_binary.parent_path() / "resources";
#else #else
// The application is packed in the .tar.bz archive (or in AppImage) as 'bin/slic3r', // The application is packed in the .tar.bz archive (or in AppImage) as 'bin/slic3r',
// The resources are packed to 'resources' // The resources are packed to 'resources'
// Path from Slic3r binary to resources: // Path from Slic3r binary to resources:
"../resources" boost::filesystem::path path_resources = path_to_binary.parent_path() / "../resources";
#endif #endif
#endif
;
set_resources_dir(path_resources.string()); set_resources_dir(path_resources.string());
set_var_dir((path_resources / "icons").string()); set_var_dir((path_resources / "icons").string());
set_local_dir((path_resources / "localization").string()); set_local_dir((path_resources / "localization").string());