From f67d70941eba392badbfc08cf38c69acfd8ef065 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Thu, 1 Mar 2018 16:14:36 +0100 Subject: [PATCH] Doc: Add dependency build scripts and building how-tos --- doc/How to build - UNIX.md | 2 + doc/How to build - Windows.md | 86 +++++++++++++ doc/deps-build/unix-static/Makefile | 132 +++++++++++++++++++ doc/deps-build/windows/slic3r-makedeps.ps1 | 141 +++++++++++++++++++++ 4 files changed, 361 insertions(+) create mode 100644 doc/How to build - UNIX.md create mode 100644 doc/How to build - Windows.md create mode 100644 doc/deps-build/unix-static/Makefile create mode 100644 doc/deps-build/windows/slic3r-makedeps.ps1 diff --git a/doc/How to build - UNIX.md b/doc/How to build - UNIX.md new file mode 100644 index 000000000..77ce54419 --- /dev/null +++ b/doc/How to build - UNIX.md @@ -0,0 +1,2 @@ +# Building Slic3r PE on Linux/UNIX + diff --git a/doc/How to build - Windows.md b/doc/How to build - Windows.md new file mode 100644 index 000000000..8209954bd --- /dev/null +++ b/doc/How to build - Windows.md @@ -0,0 +1,86 @@ +# Building Slic3r PE on Microsoft Windows + +The currently supported way of building Slic3r PE on Windows is with MS Visual Studio 2013 +using our Perl binary distribution (compiled from official Perl sources). +You can use the free [Visual Studio 2013 Community Edition](https://www.visualstudio.com/vs/older-downloads/). + +Other setups (such as mingw + Strawberry Perl) _may_ work, but we cannot guarantee this will work +and cannot provide guidance. + + +### Geting the dependencies + +First, download and upnack our Perl + wxWidgets binary distribution: + + - 32 bit, release mode: [wperl32-5.24.0-2018-03-02.7z](https://bintray.com/vojtechkral/Slic3r-PE/download_file?file_path=wperl32-5.24.0-2018-03-02.7z) + - 64 bit, release mode: [wperl64-5.24.0-2018-03-02.7z](https://bintray.com/vojtechkral/Slic3r-PE/download_file?file_path=wperl64-5.24.0-2018-03-02.7z) + - 64 bit, release mode + debug symbols: [wperl64d-5.24.0-2018-03-02.7z](https://bintray.com/vojtechkral/Slic3r-PE/download_file?file_path=wperl64d-5.24.0-2018-03-02.7z) + +It is recommended to unpack this package into `C:\`. + +Apart from wxWidgets and Perl, you will also need additional dependencies: + + - Boost + - Intel TBB + - libcurl + +We have prepared a binary package of the listed libraries: + + - 32 bit: [slic3r-destdir-32.7z](https://bintray.com/vojtechkral/Slic3r-PE/download_file?file_path=slic3r-destdir-32.7z) + - 64 bit: [slic3r-destdir-64.7z](https://bintray.com/vojtechkral/Slic3r-PE/download_file?file_path=slic3r-destdir-64.7z) + +It is recommended you unpack this package into `C:\local\` as the environment +setup script expects it there. + +Alternatively you can also compile the additional dependencies yourself. +There is a [powershell script](./deps-build/windows/slic3r-makedeps.ps1) which automates this process. + +### Building Slic3r PE + +Once the dependencies are set up in their respective locations, +go to the `wperl*` directory extracted earlier and launch the `cmdline.lnk` file +which opens a command line prompt with appropriate environment variables set up. + +In this command line, `cd` into the directory with Slic3r sources +and use these commands to build the Slic3r from the command line: + + perl Build.PL + perl Build.PL --gui + mkdir build + cd build + cmake .. -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release + nmake + ctest --verbose # TODO: ??? + cd .. + perl slic3r.pl + +The above commands use `nmake` Makefiles. +You may also build Slic3r PE with other build tools: + + +### Building with Visual Studio + +To build, lanuch and/or debug Slic3r PE with Visual Studio (64 bits), replace the `cmake` command with: + + cmake .. -G "Visual Studio 12 Win64" -DCMAKE_CONFIGURATION_TYPES=Release;RelWithDebInfo || exit /b + +For the 32-bit variant, use: + + cmake .. -G "Visual Studio 12" -DCMAKE_CONFIGURATION_TYPES=Release;RelWithDebInfo || exit /b + +After `cmake` has finished, go to the `Slic3r\build` directory and open the `Slic3r.sln` solution file. +This should open Visual Studio and load all the Slic3r solution containing all the projects. +Make sure you use Visual Studio 2013 to open the solution. + +You can then use the usual Visual Studio controls to build Slic3r. +If you want to run or debug Slic3r from within Visual Studio, make sure the `slic3r` project is activated. +There are multiple projects in the Slic3r solution, but only the `slic3r` project is configured with the right +commands to run Slic3r. + + +### Building with ninja + +To use [Ninja](TODO), replace the `cmake` and `nmake` commands with: + + cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release + ninja diff --git a/doc/deps-build/unix-static/Makefile b/doc/deps-build/unix-static/Makefile new file mode 100644 index 000000000..e7588b994 --- /dev/null +++ b/doc/deps-build/unix-static/Makefile @@ -0,0 +1,132 @@ + +# +# This makefile downloads, configures and builds Slic3r PE dependencies for Unix. +# (That is, all dependencies except perl + wxWidgets.) +# The libraries are installed in DESTDIR, which you can customize like so: +# +# DESTDIR=foo/bar make +# +# The default DESTDIR is ~/slic3r-destdir +# If the DESTDIR doesn't exits, the makefile tries to create it +# +# To pass the DESTDIR path along to cmake, set the use CMAKE_PREFIX_PATH variable +# and set it to $DESTDIR/usr/local +# +# You can also customize the NPROC variable in the same way to configure the number +# of cores the build process uses. By default this is set to what the `nproc` command says. +# + + +DESTDIR ?= $(HOME)/slic3r-destdir +NPROC ?= $(shell nproc) + + +BOOST = boost_1_66_0 +TBB_SHA = a0dc9bf76d0120f917b641ed095360448cabc85b +TBB = tbb-$(TBB_SHA) +OPENSSL = openssl-OpenSSL_1_1_0g +CURL = curl-7.58.0 + +.PHONY: all destdir boost libcurl libopenssl libtbb + +all: destdir boost libtbb libcurl + @echo + @echo "All done!" + @echo + +destdir: + mkdir -p $(DESTDIR) + + + +boost: $(BOOST).tar.gz + tar -zxvf $(BOOST).tar.gz + cd $(BOOST) && ./bootstrap.sh --with-libraries=system,filesystem,thread,log,locale,regex --prefix=$(DESTDIR)/usr/local + cd $(BOOST) && ./b2 \ + -j $(NPROC) \ + link=static \ + variant=release \ + threading=multi \ + boost.locale.icu=off \ + cxxflags=-fPIC cflags=-fPIC \ + install + +$(BOOST).tar.gz: + curl -L -o $@ https://dl.bintray.com/boostorg/release/1.66.0/source/$@ + + + +libtbb: $(TBB).tar.gz + tar -zxvf $(TBB).tar.gz + mkdir -p $(TBB)/mybuild + cd $(TBB)/mybuild && cmake .. -DTBB_BUILD_SHARED=OFF -DTBB_BUILD_TESTS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON + $(MAKE) -C $(TBB)/mybuild -j$(NPROC) + $(MAKE) -C $(TBB)/mybuild install DESTDIR=$(DESTDIR) + +$(TBB).tar.gz: + curl -L -o $@ https://github.com/wjakob/tbb/archive/$(TBB_SHA).tar.gz + + + +libopenssl: $(OPENSSL).tar.gz + tar -zxvf $(OPENSSL).tar.gz + cd $(OPENSSL) && ./config --openssldir=/etc/ssl shared no-ssl3-method no-dynamic-engine '-Wa,--noexecstack' + make -C $(OPENSSL) depend + make -C $(OPENSSL) -j$(NPROC) + make -C $(OPENSSL) install DESTDIR=$(DESTDIR) + +$(OPENSSL).tar.gz: + curl -L -o $@ 'https://github.com/openssl/openssl/archive/OpenSSL_1_1_0g.tar.gz' + + + +libcurl: libopenssl $(CURL).tar.gz + tar -zxvf $(CURL).tar.gz +# XXX: disable shared? +# Setting PKG_CONFIG_PATH should make libcurl find our previously built openssl + cd $(CURL) && PKG_CONFIG_PATH=$(DESTDIR)/usr/local/lib/pkgconfig ./configure \ + --enable-static \ + --enable-shared \ + --with-pic \ + --enable-ipv6 \ + --enable-versioned-symbols \ + --enable-threaded-resolver \ + --with-random=/dev/urandom \ + --with-ca-bundle=/etc/ssl/certs/ca-certificates.crt \ + --disable-ldap \ + --disable-ldaps \ + --disable-manual \ + --disable-rtsp \ + --disable-dict \ + --disable-telnet \ + --disable-pop3 \ + --disable-imap \ + --disable-smb \ + --disable-smtp \ + --disable-gopher \ + --disable-crypto-auth \ + --without-gssapi \ + --without-libpsl \ + --without-libidn2 \ + --without-gnutls \ + --without-polarssl \ + --without-mbedtls \ + --without-cyassl \ + --without-nss \ + --without-axtls \ + --without-brotli \ + --without-libmetalink \ + --without-libssh \ + --without-libssh2 \ + --without-librtmp \ + --without-nghttp2 \ + --without-zsh-functions-dir + $(MAKE) -C $(CURL) -j$(NPROC) + $(MAKE) -C $(CURL) install DESTDIR=$(DESTDIR) + +$(CURL).tar.gz: + curl -L -o $@ https://curl.haxx.se/download/$@ + + +clean: + rm -rf $(BOOST) $(BOOST).tar.gz $(TBB) $(TBB).tar.gz $(OPENSSL) $(OPENSSL).tar.gz $(CURL) $(CURL).tar.gz diff --git a/doc/deps-build/windows/slic3r-makedeps.ps1 b/doc/deps-build/windows/slic3r-makedeps.ps1 new file mode 100644 index 000000000..8b39cae30 --- /dev/null +++ b/doc/deps-build/windows/slic3r-makedeps.ps1 @@ -0,0 +1,141 @@ +#!powershell +# +# This script downloads, configures and builds Slic3r PE dependencies for Unix. +# (That is, all dependencies except perl + wxWidgets.) +# +# To use this script, launch the Visual Studio command line, +# `cd` into the directory containing this script and use this command: +# +# powershell .\slic3r-makedeps.ps1 +# +# The dependencies will be downloaded and unpacked into the current dir. +# This script WILL NOT try to guess the build architecture (64 vs 32 bits), +# it will by default build the 64-bit variant. To build the 32-bit variant, use: +# +# powershell .\slic3r-makedeps.ps1 -b32 +# +# Built libraries are installed into $destdir, +# which by default is C:\local\slic3r-destdir-$bits +# You can customize the $destdir using: +# +# powershell .\slic3r-makedeps.ps1 -destdir C:\foo\bar +# +# To pass the $destdir path along to cmake, set the use CMAKE_PREFIX_PATH variable +# and set it to $destdir\usr\local +# +# Script requirements: PowerShell 3.0, .NET 4.5 +# + + +param( + [switch]$b32 = $false, + [string]$destdir = "" +) + +if ($destdir -eq "") { + $destdir = "C:\local\slic3r-destdir-" + ('32', '64')[!$b32] +} + +$BOOST = 'boost_1_63_0' +$CURL = 'curl-7.28.0' +$TBB_SHA = 'a0dc9bf76d0120f917b641ed095360448cabc85b' +$TBB = "tbb-$TBB_SHA" + + +try +{ + + +# Set up various settings and utilities: +[Environment]::CurrentDirectory = Get-Location +$NPROC = (Get-WmiObject -class Win32_processor).NumberOfLogicalProcessors +Add-Type -A System.IO.Compression.FileSystem +# This fxies SSL/TLS errors, credit goes to Ansible; see their `win_get_url.ps1` file +$security_protcols = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::SystemDefault +if ([Net.SecurityProtocolType].GetMember('Tls11').Count -gt 0) { + $security_protcols = $security_protcols -bor [Net.SecurityProtocolType]::Tls11 +} +if ([Net.SecurityProtocolType].GetMember('Tls12').Count -gt 0) { + $security_protcols = $security_protcols -bor [Net.SecurityProtocolType]::Tls12 +} +[Net.ServicePointManager]::SecurityProtocol = $security_protcols +$webclient = New-Object System.Net.WebClient + + +# Ensure DESTDIR exists: +mkdir $destdir -ea 0 +mkdir "$destdir\usr\local" -ea 0 + + +# Download sources: +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") } + + +# 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", '.') } + + +# Build libraries: +echo 'Building ...' + +# Build boost +pushd "$BOOST" +.\bootstrap +$adr_mode = ('32', '64')[!$b32] +.\b2 ` + -j "$NPROC" ` + --with-system ` + --with-filesystem ` + --with-thread ` + --with-log ` + --with-locale ` + --with-regex ` + "--prefix=$destdir/usr/local" ` + "address-model=$adr_mode" ` + toolset=msvc-12.0 ` + link=static ` + variant=release ` + threading=multi ` + boost.locale.icu=off ` + install +popd + +# Build TBB +pushd "$TBB" +mkdir 'mybuild' -ea 0 +cd 'mybuild' +$generator = ('Visual Studio 12', 'Visual Studio 12 Win64')[!$b32] +cmake .. ` + -G "$generator" ` + -DCMAKE_CONFIGURATION_TYPES=Release ` + -DTBB_BUILD_SHARED=OFF ` + -DTBB_BUILD_TESTS=OFF "-DCMAKE_INSTALL_PREFIX:PATH=$destdir\usr\local" +msbuild /P:Configuration=Release INSTALL.vcxproj +popd + +# Build libcurl: +pushd "$CURL\winbuild" +$machine = ("x86", "x64")[!$b32] +nmake /f Makefile.vc mode=static VC=12 GEN_PDB=yes DEBUG=no "MACHINE=$machine" +Copy-Item -R -Force ..\builds\libcurl-*-winssl\include\* "$destdir\usr\local\include\" +Copy-Item -R -Force ..\builds\libcurl-*-winssl\lib\* "$destdir\usr\local\lib\" +popd + + +echo "" +echo "All done!" +echo "" + + +} +catch [Exception] +{ + # This prints errors in a verbose manner + echo $_.Exception|format-list -force +}