Skip to content

Commit

Permalink
updated build scripts for macOS and Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
wschadow committed Jul 8, 2024
1 parent 22fd2fd commit c0b65fd
Show file tree
Hide file tree
Showing 11 changed files with 873 additions and 246 deletions.
442 changes: 267 additions & 175 deletions BuildLinux.sh

Large diffs are not rendered by default.

273 changes: 273 additions & 0 deletions BuildmacOS.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,273 @@
#!/bin/bash
#
# This script can download and compile dependencies, compile CaribouSlicer
# and optional build a .tgz and an appimage.
#
# Original script from SuperSclier by supermerill https://github.com/supermerill/SuperSlicer
#
# Change log:
#
# 20 Nov 2023, wschadow, branding and minor changes
# 01 Jan 2024, wschadow, debranding for the Prusa version, added build options
#

export ROOT=`pwd`
export NCORES=`sysctl -n hw.ncpu`

OS_FOUND=$( command -v uname)

case $( "${OS_FOUND}" | tr '[:upper:]' '[:lower:]') in
linux*)
TARGET_OS="linux"
;;
msys*|cygwin*|mingw*)
# or possible 'bash on windows'
TARGET_OS='windows'
;;
nt|win*)
TARGET_OS='windows'
;;
darwin)
TARGET_OS='macos'
;;
*)
TARGET_OS='unknown'
;;
esac

# check operating system
echo
if [ $TARGET_OS == "macos" ]; then
if [ $(uname -m) == "x86_64" ]; then
echo -e "$(tput setaf 2)macOS x86_64 found$(tput sgr0)\n"
Processor="64"
elif [[ $(uname -m) == "i386" || $(uname -m) == "i686" ]]; then
echo "$(tput setaf 2)macOS arm64 found$(tput sgr0)\n"
Processor="64"
else
echo "$(tput setaf 1)Unsupported OS: macOS $(uname -m)"
exit -1
fi
else
echo -e "$(tput setaf 1)This script doesn't support your Operating system!"
echo -e "Please use a macOS.$(tput sgr0)\n"
exit -1
fi

# Check if CMake is installed
export CMAKE_INSTALLED=`which cmake`
if [[ -z "$CMAKE_INSTALLED" ]]
then
echo "Can't find CMake. Either is not installed or not in the PATH. Aborting!"
exit -1
fi

BUILD_ARCH=$(uname -m)

while getopts ":idaxbhcsltwr" opt; do
case ${opt} in
i )
BUILD_IMAGE="1"
;;
d )
BUILD_DEPS="1"
;;
a )
BUILD_ARCH="arm64"
BUILD_IMG="-a"
;;
x )
BUILD_ARCH="x86_64"
BUILD_IMG="-x"
;;
b )
BUILD_DEBUG="1"
;;
s )
BUILD_CARIBOUSLICER="1"
;;
l )
UPDATE_POTFILE="1"
;;
c)
BUILD_XCODE="1"
;;
w )
BUILD_WIPE="1"
;;
r )
BUILD_CLEANDEPEND="1"
;;
h ) echo "Usage: ./BuildMacOS.sh [-h][-w][-a][-r][-x][-b][-c][-d][-s][-l][-t][-i]"
echo " -h: this message"
echo " -w: wipe build directories bfore building"
echo " -a: build for arm64 (Apple Silicon)"
echo " -r: clean dependencies"
echo " -x: build for x86_64 (Intel)"
echo " -b: build with debug symbols"
echo " -c: build for XCode"
echo " -d: build dependencies"
echo " -s: build CaribouSlicer"
echo " -t: build tests (in combination with -s)"
echo " -i: generate .tgz and DMG image (optional)\n"
exit 0
;;
esac
done

if [ $OPTIND -eq 1 ]
then
echo "Usage: ./BuildLinux.sh [-h][-w][-a][-r][-x][-b][-c][-d][-s][-l][-t][-i]"
echo " -h: this message"
echo " -w: wipe build directories bfore building"
echo " -a: Build for arm64 (Apple Silicon)"
echo " -r: clean dependencies"
echo " -x: build for x86_64 (Intel)"
echo " -b: build with debug symbols"
echo " -c: build for XCode"
echo " -d: build dependencies"
echo " -s: build CaribouSlicer"
echo " -t: build tests (in combination with -s)"
echo -e " -i: Generate .tgz and DMG image (optional)\n"
exit 0
fi

export $BUILD_ARCH
export LIBRARY_PATH=$LIBRARY_PATH:$(brew --prefix zstd)/lib/

if [[ -n "$BUILD_DEPS" ]]
then
if [[ -n $BUILD_WIPE ]]
then
echo -e "\n wiping deps/build directory ...\n"
rm -fr deps/build
echo -e " ... done\n"
fi
# mkdir in deps
if [ ! -d "deps/build" ]
then
mkdir deps/build
fi
echo -e " \n[1/9] Configuring dependencies ... \n"
BUILD_ARGS=""
if [[ -n "$BUILD_ARCH" ]]
then
BUILD_ARGS="${BUILD_ARGS} -DCMAKE_OSX_ARCHITECTURES:STRING=${BUILD_ARCH}"
fi
if [[ -n "$BUILD_DEBUG" ]]
then
BUILD_ARGS="${BUILD_ARGS} -DCMAKE_BUILD_TYPE=Debug"
fi
# cmake deps
echo "Cmake command: cmake .. -DCMAKE_OSX_DEPLOYMENT_TARGET=\"10.15\" ${BUILD_ARCH} "
pushd deps/build > /dev/null
cmake .. -DCMAKE_OSX_DEPLOYMENT_TARGET="10.15" $BUILD_ARGS

echo -e "\n ... done\n"

echo -e "[2/9] Building dependencies ...\n"

# make deps
make -j1

echo -e "\n ... done\n"

echo -e "[3/9] Renaming wxscintilla library ...\n"

# rename wxscintilla
pushd destdir/usr/local/lib > /dev/null
cp libwxscintilla-3.1.a libwx_osx_cocoau_scintilla-3.1.a

popd > /dev/null
popd > /dev/null
echo -e "\n ... done\n"
fi

if [[ -n "$BUILD_CLEANDEPEND" ]]
then
echo -e "[4/9] Cleaning dependencies...\n"
pushd deps/build > /dev/null
pwd
rm -fr dep_*
popd > /dev/null
echo -e "\n ... done\n"
fi

if [[ -n "$BUILD_CARIBOUSLICER" ]]
then
echo -e "[5/9] Configuring CaribouSlicer ...\n"

if [[ -n $BUILD_WIPE ]]
then
echo -e "\n wiping build directory...\n"
rm -fr build
echo -e " ... done\n"
fi

# mkdir build
if [ ! -d "build" ]
then
mkdir build
fi

BUILD_ARGS=""
if [[ -n "$BUILD_ARCH" ]]
then
BUILD_ARGS="${BUILD_ARGS} -DCMAKE_OSX_ARCHITECTURES=${BUILD_ARCH}"
fi
if [[ -n "$BUILD_DEBUG" ]]
then
BUILD_ARGS="-DCMAKE_BUILD_TYPE=Debug ${BUILD_ARGS}"
fi
if [[ -n "$BUILD_XCODE" ]]
then
BUILD_ARGS="-GXcode ${BUILD_ARGS}"
fi

if [[ -n "$BUILD_TESTS" ]]
then
BUILD_ARGS="${BUILD_ARGS} -DCMAKE_BUILD_TESTS=1"
else
BUILD_ARGS="${BUILD_ARGS} -DCMAKE_BUILD_TESTS=0"
fi

# cmake
pushd build > /dev/null
cmake .. -DCMAKE_PREFIX_PATH="$PWD/../deps/build/destdir/usr/local" -DCMAKE_OSX_DEPLOYMENT_TARGET="10.14" -DSLIC3R_STATIC=1 ${BUILD_ARGS}
echo -e "\n ... done"

# make Slic3r
if [[ -z "$BUILD_XCODE" ]]
then
echo -e "\n[6/9] Building CaribouSlicer ...\n"
make -j$NCORES
echo -e "\n ... done"
fi

echo -e "\n[7/9] Generating language files ...\n"
#make .mo
if [[ -n "$UPDATE_POTFILE" ]]
then
make gettext_make_pot
fi
make gettext_po_to_mo

popd > /dev/null
echo -e "\n ... done"

# Give proper permissions to script
chmod 755 $ROOT/build/src/BuildMacOSImage.sh

pushd build > /dev/null
$ROOT/build/src/BuildMacOSImage.sh -a
popd > /dev/null
fi

if [[ -n "$BUILD_IMAGE" ]]
then
# Give proper permissions to script
chmod 755 $ROOT/build/src/BuildMacOSImage.sh
pushd build > /dev/null
$ROOT/build/src/BuildMacOSImage.sh -i
popd > /dev/null
fi
8 changes: 4 additions & 4 deletions cmake/CPackConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ set(CPACK_GENERATOR "STGZ;TGZ;TZ")
set(CPACK_INSTALL_CMAKE_PROJECTS "/home/wschadow/github/Software/Slicer/SuperSlicer/build;Slic3r;ALL;/")
set(CPACK_INSTALL_PREFIX "/usr/local")
set(CPACK_MODULE_PATH "/home/wschadow/github/Software/Slicer/SuperSlicer/cmake/modules/")
set(CPACK_NSIS_DISPLAY_NAME "SuperSlicer 2.5.59")
set(CPACK_NSIS_DISPLAY_NAME "SuperSlicer 2.5.60")
set(CPACK_NSIS_DISPLAY_NAME_SET "TRUE")
set(CPACK_NSIS_INSTALLER_ICON_CODE "")
set(CPACK_NSIS_INSTALLER_MUI_ICON_CODE "")
set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES")
set(CPACK_NSIS_PACKAGE_NAME "SuperSlicer 2.5.59")
set(CPACK_NSIS_PACKAGE_NAME "SuperSlicer 2.5.60")
set(CPACK_NSIS_UNINSTALL_NAME "Uninstall")
set(CPACK_OBJCOPY_EXECUTABLE "/usr/bin/objcopy")
set(CPACK_OBJDUMP_EXECUTABLE "/usr/bin/objdump")
Expand All @@ -36,8 +36,8 @@ set(CPACK_PACKAGE_DEFAULT_LOCATION "/")
set(CPACK_PACKAGE_DESCRIPTION_FILE "/home/wschadow/github/Software/Slicer/SuperSlicer/README.md")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "CMake is a build tool")
set(CPACK_PACKAGE_EXECUTABLES "superslicer")
set(CPACK_PACKAGE_FILE_NAME "SuperSlicer-2.5.59-Linux-x86_64")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "SuperSlicer 2.5.59")
set(CPACK_PACKAGE_FILE_NAME "SuperSlicer-2.5.60-Linux-x86_64")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "SuperSlicer 2.5.60")
set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "SuperSlicer_2.5.60.0_2024-07-01")
set(CPACK_PACKAGE_NAME "SuperSlicer")
set(CPACK_PACKAGE_RELOCATABLE "true")
Expand Down
4 changes: 4 additions & 0 deletions deps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ if (NPROC EQUAL 0)
set(NPROC 1)
endif ()

if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.24)
cmake_policy(SET CMP0135 NEW)
endif ()

set(DESTDIR "${CMAKE_CURRENT_BINARY_DIR}/destdir" CACHE PATH "Destination directory")
set(DEP_DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR} CACHE PATH "Path for downloaded source packages.")

Expand Down
Loading

0 comments on commit c0b65fd

Please sign in to comment.