diff --git a/.travis.yml b/.travis.yml index a34433a9b..ede2099d9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,35 +1,43 @@ language: perl -install: export LDLOADLIBS=-lstdc++ -script: perl ./Build.PL -perl: - - "5.14" - - "5.18" - - "5.20" +install: +- export LDLOADLIBS=-lstdc++ +- export BOOST_DIR=$HOME/boost_1_63_0 +- export SLIC3R_STATIC=1 +- export CXX=g++-4.9 +- export CC=g++-4.9 +- source $HOME/perl5/perlbrew/etc/bashrc +script: +- bash package/linux/travis-setup.sh +- perlbrew switch slic3r-perl +- perl ./Build.PL +after_success: +- package/linux/make_archive.sh linux-x64 +- package/deploy-bintray.sh *.bz2 branches: only: - - master - - xsgui -sudo: false + - master + - xsgui cache: apt: true directories: - - local-lib + - "$HOME/cache" + - "$HOME/perl5/perlbrew" addons: apt: sources: - - boost-latest - ubuntu-toolchain-r-test packages: - - libboost-thread1.55-dev - - libboost-system1.55-dev - - libboost-filesystem1.55-dev - - liblocal-lib-perl - g++-4.9 -env: CC=g++-4.9 + - gcc-4.9 notifications: irc: channels: - - "chat.freenode.net#slic3r" + - chat.freenode.net#slic3r on_success: change on_failure: always use_notice: true +sudo: required +dist: trusty +env: + matrix: + - secure: esNwHmYdri6Wn/AruRMLqk+HWelnLaPPNtLysGvdwp4K26K81Ys++1/M00IRgZi2LDqXWNlIUAcDCFMlKpZ0m6o0r0q4ukIiMRFFbg2cTGHW8qBuHIEmNliex9uFquU1r5PVEl4eVbHbhNjUDeMwlF74A+3PUxTEvI2X0rLdMKM= diff --git a/package/common/util.sh b/package/common/util.sh new file mode 100644 index 000000000..e27151d83 --- /dev/null +++ b/package/common/util.sh @@ -0,0 +1,84 @@ +#!/bin/bash + +# must be run from the root +function set_version () +{ +SLIC3R_VERSION=$(grep "VERSION" xs/src/libslic3r/libslic3r.h | awk -F\" '{print $2}') +} +# Cache the SHA1 for this build commit. +function get_commit () { + if [ ! -z ${TRAVIS_COMMIT+x} ]; then + # Travis sets the sha1 in TRAVIS_COMMIT + COMMIT_SHA1=$(git rev-parse --short $TRAVIS_COMMIT) + else + # should be able to get it properly + COMMIT_SHA1=$(git rev-parse --short HEAD) + fi +} +function set_build_id () +{ +echo "Setting SLIC3R_BUILD_ID" +if [ $(git describe &>/dev/null) ]; then + SLIC3R_BUILD_ID=$(git describe) + TAGGED=true +else + SLIC3R_BUILD_ID=${SLIC3R_VERSION}-${COMMIT_SHA1} +fi + +} + +function set_branch () +{ + echo "Setting current_branch" + if [ -z ${TRAVIS_BRANCH} ] && [ -z ${GIT_BRANCH+x} ] && [ -z ${APPVEYOR_REPO_BRANCH+x} ]; then + current_branch=$(git symbolic-ref HEAD | sed 's!refs\/heads\/!!') + else + current_branch="unknown" + if [ ! -z ${GIT_BRANCH+x} ]; then + echo "Setting to GIT_BRANCH" + current_branch=$(echo $GIT_BRANCH | cut -d / -f 2) + fi + if [ ! -z ${APPVEYOR_REPO_BRANCH+x} ]; then + echo "Setting to APPVEYOR_REPO_BRANCH" + current_branch=$APPVEYOR_REPO_BRANCH + fi + if [ ! -z ${TRAVIS_BRANCH} ]; then + echo "Setting to TRAVIS_BRANCH" + current_branch=$TRAVIS_BRANCH + fi + fi + + if [ -z ${current_branch+x} ]; then + current_branch="unknown" + fi +} + +function set_app_name () +{ + set_branch + if [ "$current_branch" == "master" ]; then + appname=Slic3r + else + appname=Slic3r-${current_branch} + fi +} + + +function set_pr_id () +{ + echo "Setting PR_ID if available." + if [ ! -z ${GITHUB_PR_NUMBER+x} ]; then + PR_ID=$GITHUB_PR_NUMBER + fi + if [ ! -z ${APPVEYOR_PULL_REQUEST_NUMBER+x} ]; then + PR_ID=$APPVEYOR_PULL_REQUEST_NUMBER + fi + if [ ! -z ${TRAVIS_PULL_REQUEST_BRANCH+x} ]; then + PR_ID=$TRAVIS_PULL_REQUEST + fi +} + +function install_par () +{ + cpanm PAR::Packer +} diff --git a/package/deploy-bintray.sh b/package/deploy-bintray.sh index c24fa62b8..35b73da49 100755 --- a/package/deploy-bintray.sh +++ b/package/deploy-bintray.sh @@ -5,39 +5,12 @@ # BINTRAY_API_USER - Bintray username. # Run this from the repository root (required to get slic3r version) +source $(dirname $0)/common/util.sh SLIC3R_VERSION=$(grep "VERSION" xs/src/libslic3r/libslic3r.h | awk -F\" '{print $2}') -if [ $(git describe &>/dev/null) ]; then - SLIC3R_BUILD_ID=$(git describe) - TAGGED=true -else - SLIC3R_BUILD_ID=${SLIC3R_VERSION}-$(git rev-parse --short HEAD) -fi -if [ -z ${GIT_BRANCH+x} ] && [ -z ${APPVEYOR_REPO_BRANCH+x} ]; then - current_branch=$(git symbolic-ref HEAD | sed 's!refs\/heads\/!!') -else - current_branch="unknown" - if [ ! -z ${GIT_BRANCH+x} ]; then - echo "Setting to GIT_BRANCH" - current_branch=$(echo $GIT_BRANCH | cut -d / -f 2) - fi - if [ ! -z ${APPVEYOR_REPO_BRANCH+x} ]; then - echo "Setting to APPVEYOR_REPO_BRANCH" - current_branch=$APPVEYOR_REPO_BRANCH - fi -fi - -if [ -z ${current_branch+x} ]; then - current_branch="unknown" -fi - -if [ ! -z ${GITHUB_PR_NUMBER+x} ]; then - PR_ID=$GITHUB_PR_NUMBER -fi -if [ ! -z ${APPVEYOR_PULL_REQUEST_NUMBER+x} ]; then - PR_ID=$APPVEYOR_PULL_REQUEST_NUMBER -fi - - +get_commit +set_build_id +set_branch +set_pr_id if [ "$current_branch" == "master" ] && [ -z ${PR_ID} ]; then # If building master, goes in slic3r_dev or slic3r, depending on whether or not this is a tagged build if [ -z ${TAGGED+x} ]; then diff --git a/package/linux/appimage-bundler.sh b/package/linux/appimage-bundler.sh new file mode 100755 index 000000000..d12cb2129 --- /dev/null +++ b/package/linux/appimage-bundler.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +WD=$(dirname $0) +source $(dirname $0)/../common/util.sh +set_version +set_app_name +LOWERAPP=${appname,,} +wget -q https://github.com/probonopd/AppImages/raw/master/functions.sh -O ./functions.sh +. ./functions.sh + +srcfolder="$WD/${appname}" +if [ ! -e $srcfolder ]; then + echo "Run make_archive first." + exit 1 +fi + +cd $srcfolder + +# make shell exec and call it Slic3r + +mkdir -p /usr/{lib,bin} +mv -R Slic3r local-lib var perl-local slic3r.pl /usr/bin +mv -R bin/* /usr/lib +rm -rf bin + +get_apprun + +# Copy desktop and icon file to application root dir for Apprun to pick them up. +sed -e "s|SLIC3R_VERSION|$SLIC3R_VERSION|" -e"s|APPLICATION_NAME|$appname|" ../slic3r.desktop.in > ../slic3r.desktop +cp ../slic3r.desktop $LOWERAPP.desktop +cp ./var/Slic3r_192px_transparent.png ./slic3r.png + +# archive directory has everything we need. +delete_blacklisted + +get_desktopintegration $LOWERAPP + +GLIBC_NEEDED=$(glibc_needed) +VERSION=git$GIT_REV-glibc$GLIBC_NEEDED + +cd .. +mkdir -p out +generate_appimage + +transfer ../out/* diff --git a/package/linux/make_archive.sh b/package/linux/make_archive.sh new file mode 100755 index 000000000..92ce34e68 --- /dev/null +++ b/package/linux/make_archive.sh @@ -0,0 +1,116 @@ +#!/bin/bash + +# Assembles an installation archive from a built copy of Slic3r. +# Requires PAR::Packer to be installed for the version of +# perl copied. +# Adapted from script written by bubnikv for Prusa3D. +# Run from slic3r repo root directory. + +if [ "$#" -ne 1 ]; then + echo "Usage: $(basename $0) arch_name" + exit 1; +fi +libdirs=$(find ./local-lib -iname *.so -exec dirname {} \; | sort -u | paste -sd ";" -) +WD=./$(dirname $0) +source $(dirname $0)/../common/util.sh +# Determine if this is a tagged (release) commit. +# Change the build id accordingly. + +set_version +get_commit +set_build_id +set_branch +set_app_name +set_pr_id +install_par + +# If we're on a branch, add the branch name to the app name. +if [ "$current_branch" == "master" ]; then + dmgfile=slic3r-${SLIC3R_BUILD_ID}-${1}.tar.bz2 +else + dmgfile=slic3r-${SLIC3R_BUILD_ID}-${1}-${current_branch}.tar.bz2 +fi + +rm -rf $WD/_tmp +mkdir -p $WD/_tmp + +# Set the application folder infomation. +appfolder="$WD/${appname}" +archivefolder=$appfolder +resourcefolder=$appfolder + +echo "Appfolder: $appfolder, archivefolder: $archivefolder" + +# Our slic3r dir and location of perl +PERL_BIN=$(which perl) +PP_BIN=$(which pp) +SLIC3R_DIR="./" + +if [[ -d "${appfolder}" ]]; then + echo "Deleting old working folder: ${appfolder}" + rm -rf ${appfolder} +fi + +if [[ -e "${dmgfile}" ]]; then + echo "Deleting old archive: ${dmgfile}" + rm -rf ${dmgfile} +fi + +echo "Creating new app folder: $appfolder" +mkdir -p $appfolder + +echo "Copying resources..." +cp -rf $SLIC3R_DIR/var $resourcefolder/ +mv $resourcefolder/var/Slic3r.icns $resourcefolder + +echo "Copying Slic3r..." +cp $SLIC3R_DIR/slic3r.pl $archivefolder/slic3r.pl +cp -fRP $SLIC3R_DIR/local-lib $archivefolder/local-lib +cp -fRP $SLIC3R_DIR/lib/* $archivefolder/local-lib/lib/perl5/ + +mkdir $archivefolder/bin +echo "Symlinking libraries to $archivefolder/bin ..." +for bundle in $(find $archivefolder/local-lib/lib/perl5 -name '*.so' | grep "Wx") $(find $archivefolder/local-lib/lib/perl5 -name '*.so' -type f | grep "wxWidgets"); do + echo "$(LD_LIBRARY_PATH=$libdirs ldd $bundle | grep .so | grep local-lib | awk '{print $3}')" + for dylib in $(LD_LIBRARY_PATH=$libdirs ldd $bundle | grep .so | grep local-lib | awk '{print $3}'); do + install -v $dylib $archivefolder/bin + done +done + +echo "Copying startup script..." +cp -f $WD/startup_script.sh $archivefolder/$appname +chmod +x $archivefolder/$appname + +echo "Copying perl from $PERL_BIN" +cp -f $PERL_BIN $archivefolder/perl-local +${PP_BIN} -M attributes -M base -M bytes -M B -M POSIX \ + -M FindBin -M Unicode::Normalize -M Tie::Handle \ + -M Time::Local -M Math::Trig \ + -M lib -M overload \ + -M warnings -M local::lib \ + -M strict -M utf8 -M parent \ + -B -p -e "print 123" -o $WD/_tmp/test.par +unzip -qq -o $WD/_tmp/test.par -d $WD/_tmp/ +cp -rf $WD/_tmp/lib/* $archivefolder/local-lib/lib/perl5/ +rm -rf $WD/_tmp + +echo "Cleaning local-lib" +rm -rf $archivefolder/local-lib/bin +rm -rf $archivefolder/local-lib/man +rm -f $archivefolder/local-lib/lib/perl5/Algorithm/*.pl +rm -rf $archivefolder/local-lib/lib/perl5/unicore +rm -rf $archivefolder/local-lib/lib/perl5/App +rm -rf $archivefolder/local-lib/lib/perl5/Devel/CheckLib.pm +rm -rf $archivefolder/local-lib/lib/perl5/ExtUtils +rm -rf $archivefolder/local-lib/lib/perl5/Module/Build* +rm -rf $(pwd)$archivefolder/local-lib/lib/perl5/TAP +rm -rf $(pwd)/$archivefolder/local-lib/lib/perl5/Test* +find $(pwd)/$archivefolder/local-lib -type d -path '*/Wx/*' \( -name WebView \ + -or -name DocView -or -name STC -or -name IPC \ + -or -name AUI -or -name Calendar -or -name DataView \ + -or -name DateTime -or -name Media -or -name PerlTest \ + -or -name Ribbon \) -exec rm -rf "{}" \; +rm -rf $archivefolder/local-lib/lib/perl5/*/Alien/wxWidgets/*/include +find $archivefolder/local-lib -depth -type d -empty -exec rmdir "{}" \; + +tar -C$(pwd)/$(dirname $appfolder) -cjf $(pwd)/$dmgfile "$appname" diff --git a/package/linux/package_linux.sh b/package/linux/package_linux.sh deleted file mode 100755 index 9133f23b2..000000000 --- a/package/linux/package_linux.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -# Written by Joseph Lenox -# Licensed under the same license as the rest of Slic3r. -# ------------------------ - -pp -a "../../utils;utils" -a "../../var;var" -a "../../lib;lib" -a "../../local-lib;local-lib" -a "../../slic3r.pl;slic3r.pl" -M AutoLoader -M B -M Carp -M Class::Accessor -M Class::XSAccessor -M Class::XSAccessor::Heavy -M Config -M Cwd -M Devel::GlobalDestruction -M Digest -M Digest::MD5 -M Digest::SHA -M Digest::base -M DynaLoader -M Errno -M Exporter -M Exporter::Heavy -M Fcntl -M File::Basename -M File::Glob -M File::Spec -M File::Spec::Unix -M File::Spec::Win32 -M FindBin -M HTTP::Config -M HTTP::Date -M HTTP::Headers -M HTTP::Headers::Util -M HTTP::Message -M HTTP::Request -M HTTP::Request::Common -M HTTP::Response -M HTTP::Status -M IO -M IO::Handle -M IO::Select -M LWP -M LWP::MediaTypes -M LWP::MemberMixin -M LWP::Protocol -M LWP::Protocol::http -M LWP::UserAgent -M List::Util -M Math::Trig -M Method::Generate::Accessor -M Method::Generate::BuildAll -M Method::Generate::Constructor -M Module::Runtime -M POSIX -M Pod::Escapes -M Pod::Text -M Pod::Usage -M SelectSaver -M Socket -M Socket6 -M Storable -M Sub::Defer -M Sub::Exporter -M Sub::Exporter::Progressive -M Sub::Name -M Symbol -M Term::Cap -M Text::ParseWords -M Thread -M Thread::Queue -M Thread::Semaphore -M Tie::Handle -M Tie::Hash -M Tie::StdHandle -M Time::Local -M URI -M URI::Escape -M URI::http -M Unicode::Normalize -M XSLoader -B -M lib -p ../../slic3r.pl -o ../../slic3r.par diff --git a/package/linux/slic3r.desktop.in b/package/linux/slic3r.desktop.in new file mode 100644 index 000000000..0e1203ebf --- /dev/null +++ b/package/linux/slic3r.desktop.in @@ -0,0 +1,13 @@ +[Desktop Entry] + +Type=Application + +Version=SLIC3R_VERSION + +Name=APPLICATION_NAME + +Comment=Prepare 3D Models for printing + +Icon=slic3r + +Exec=Slic3r diff --git a/package/linux/startup_script.sh b/package/linux/startup_script.sh new file mode 100644 index 000000000..82757118b --- /dev/null +++ b/package/linux/startup_script.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +DIR=$(dirname "$0") +export LD_LIBRARY_PATH=./bin +exec "$DIR/perl-local" -I"$DIR/local-lib/lib/perl5" "$DIR/slic3r.pl" $@ diff --git a/package/linux/travis-setup.sh b/package/linux/travis-setup.sh new file mode 100755 index 000000000..cfc67227b --- /dev/null +++ b/package/linux/travis-setup.sh @@ -0,0 +1,17 @@ +#!/bin/bash +# Script to configure travis environment prior to build +if [ ! -e $HOME/cache/slic3r-perlbrew-5.24.tar.bz2 ]; then + curl -L "https://bintray.com/lordofhyphens/Slic3r/download_file?file_path=slic3r-perl.524.travis.tar.bz2" -o $HOME/cache/slic3r-perlbrew-5.24.tar.bz2; +fi + +if [ ! -e $HOME/cache/boost-compiled.tar.bz2 ]; then + curl -L "http://www.siusgs.com/slic3r/buildserver/boost_1_63_0.built.gcc-4.9.4-buildserver.tar.bz2" -o $HOME/cache/boost-compiled.tar.bz2 +fi + +if [ ! -e $HOME/cache/local-lib.tar.bz2 ]; then + curl -L "http://www.siusgs.com/slic3r/buildserver/slic3r-dependencies.travis.tar.bz2" -o $HOME/cache/local-lib.tar.bz2 +fi + +tar -C$TRAVIS_BUILD_DIR -xjf $HOME/cache/local-lib.tar.bz2 +tar -C$HOME/perl5/perlbrew/perls -xjf $HOME/cache/slic3r-perlbrew-5.24.tar.bz2 +tar -C$HOME -xjf $HOME/cache/boost-compiled.tar.bz2