Skip to content

Commit

Permalink
Merge branch 'SoftFever:main' into middle-outer-inner-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
igiannakas committed Apr 15, 2024
2 parents 5c7ac9b + 8ae358e commit 4b63ff3
Show file tree
Hide file tree
Showing 680 changed files with 25,104 additions and 7,716 deletions.
233 changes: 79 additions & 154 deletions BuildLinux.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#!/bin/bash

export ROOT=`pwd`
export NCORES=`nproc --all`
export CMAKE_BUILD_PARALLEL_LEVEL=${NCORES}
FOUND_GTK2=$(dpkg -l libgtk* | grep gtk2)
FOUND_GTK3=$(dpkg -l libgtk* | grep gtk-3)
export ROOT=$(dirname $(readlink -f ${0}))

set -e # exit on first error

Expand All @@ -21,238 +17,167 @@ function check_available_memory_and_disk() {
exit 2
fi

if [[ ${FREE_DISK_KB} -le ${MIN_DISK_KB} ]]; then
echo -e "\nERROR: Orca Slicer Builder requires at least $(echo $MIN_DISK_KB |awk '{ printf "%.1fG\n", $1/1024/1024; }') (systen has only $(echo ${FREE_DISK_KB} | awk '{ printf "%.1fG\n", $1/1024/1024; }') disk free)"
if [[ ${FREE_DISK_KB} -le ${MIN_DISK_KB} ]]; then
echo -e "\nERROR: Orca Slicer Builder requires at least $(echo ${MIN_DISK_KB} |awk '{ printf "%.1fG\n", $1/1024/1024; }') (systen has only $(echo ${FREE_DISK_KB} | awk '{ printf "%.1fG\n", $1/1024/1024; }') disk free)"
echo && df -h . && echo
exit 1
fi
}

function usage() {
echo "Usage: ./BuildLinux.sh [-i][-u][-d][-s][-b][-g]"
echo " -i: Generate appimage (optional)"
echo " -g: force gtk2 build"
echo "Usage: ./BuildLinux.sh [-1][-b][-c][-d][-i][-r][-s][-u]"
echo " -1: limit builds to 1 core (where possible)"
echo " -b: build in debug mode"
echo " -c: force a clean build"
echo " -d: build deps (optional)"
echo " -h: this help output"
echo " -i: Generate appimage (optional)"
echo " -r: skip ram and disk checks (low ram compiling)"
echo " -s: build orca-slicer (optional)"
echo " -u: only update clock & dependency packets (optional and need sudo)"
echo " -r: skip free ram check (low ram compiling)"
echo " -u: update and build dependencies (optional and need sudo)"
echo "For a first use, you want to 'sudo ./BuildLinux.sh -u'"
echo " and then './BuildLinux.sh -dsi'"
}

unset name
while getopts ":dsiuhgbr" opt; do
while getopts ":1bcdghirsu" opt; do
case ${opt} in
u )
UPDATE_LIB="1"
1 )
export CMAKE_BUILD_PARALLEL_LEVEL=1
;;
i )
BUILD_IMAGE="1"
b )
BUILD_DEBUG="1"
;;
c )
CLEAN_BUILD=1
;;
d )
BUILD_DEPS="1"
;;
s )
BUILD_ORCA="1"
;;
b )
BUILD_DEBUG="1"
h ) usage
exit 0
;;
g )
FOUND_GTK3=""
i )
BUILD_IMAGE="1"
;;
r )
SKIP_RAM_CHECK="1"
SKIP_RAM_CHECK="1"
;;
h ) usage
exit 0
s )
BUILD_ORCA="1"
;;
u )
UPDATE_LIB="1"
;;
esac
done

if [ $OPTIND -eq 1 ]
if [ ${OPTIND} -eq 1 ]
then
usage
exit 0
fi

# Addtional Dev packages for OrcaSlicer
export REQUIRED_DEV_PACKAGES="libmspack-dev libgstreamerd-3-dev libsecret-1-dev libwebkit2gtk-4.0-dev libosmesa6-dev libssl-dev libcurl4-openssl-dev eglexternalplatform-dev libudev-dev libdbus-1-dev extra-cmake-modules texinfo"
# libwebkit2gtk-4.1-dev ??
export DEV_PACKAGES_COUNT=$(echo ${REQUIRED_DEV_PACKAGES} | wc -w)
if [ $(dpkg --get-selections | grep -E "$(echo ${REQUIRED_DEV_PACKAGES} | tr ' ' '|')" | wc -l) -lt ${DEV_PACKAGES_COUNT} ]; then
sudo apt install -y ${REQUIRED_DEV_PACKAGES} git cmake wget file gettext
fi

#FIXME: require root for -u option
if [[ -n "$UPDATE_LIB" ]]
DISTRIBUTION=$(awk -F= '/^ID=/ {print $2}' /etc/os-release)
if [ ! -f ./linux.d/${DISTRIBUTION} ]
then
echo -n -e "Updating linux ...\n"
# hwclock -s # DeftDawg: Why does SuperSlicer want to do this?
apt update
if [[ -z "$FOUND_GTK3" ]]
then
echo -e "\nInstalling: libgtk2.0-dev libglew-dev libudev-dev libdbus-1-dev cmake git\n"
apt install -y libgtk2.0-dev libglew-dev libudev-dev libdbus-1-dev cmake git
else
echo -e "\nFind libgtk-3, installing: libgtk-3-dev libglew-dev libudev-dev libdbus-1-dev cmake git\n"
apt install -y libgtk-3-dev libglew-dev libudev-dev libdbus-1-dev cmake git
fi
# for ubuntu 22+ and 23+:
ubu_major_version="$(grep VERSION_ID /etc/os-release | cut -d "=" -f 2 | cut -d "." -f 1 | tr -d /\"/)"
if [ $ubu_major_version == "22" ] || [ $ubu_major_version == "23" ]
then
apt install -y curl libfuse-dev libssl-dev libcurl4-openssl-dev m4
fi
if [[ -n "$BUILD_DEBUG" ]]
then
echo -e "\nInstalling: libssl-dev libcurl4-openssl-dev\n"
apt install -y libssl-dev libcurl4-openssl-dev
fi
echo -e "done\n"
exit 0
echo "Your distribution does not appear to be currently supported by these build scripts"
exit 1
fi
source ./linux.d/${DISTRIBUTION}

FOUND_GTK2_DEV=$(dpkg -l libgtk* | grep gtk2.0-dev || echo '')
FOUND_GTK3_DEV=$(dpkg -l libgtk* | grep gtk-3-dev || echo '')
echo "FOUND_GTK2=$FOUND_GTK2)"
if [[ -z "$FOUND_GTK2_DEV" ]]
then
if [[ -z "$FOUND_GTK3_DEV" ]]
echo "FOUND_GTK3=${FOUND_GTK3}"
if [[ -z "${FOUND_GTK3_DEV}" ]]
then
echo "Error, you must install the dependencies before."
echo "Use option -u with sudo"
exit 0
fi
exit 1
fi

echo "[1/9] Updating submodules..."
{
# update submodule profiles
pushd resources/profiles
git submodule update --init
popd
}

echo "[2/9] Changing date in version..."
echo "Changing date in version..."
{
# change date in version
sed -i "s/+UNKNOWN/_$(date '+%F')/" version.inc
}
echo "done"

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

if ! [[ -n "$SKIP_RAM_CHECK" ]]
if ! [[ -n "${SKIP_RAM_CHECK}" ]]
then
check_available_memory_and_disk
check_available_memory_and_disk
fi

if [[ -n "$BUILD_DEPS" ]]
if [[ -n "${BUILD_DEPS}" ]]
then
echo "[3/9] Configuring dependencies..."
BUILD_ARGS=""
if [[ -n "$FOUND_GTK3_DEV" ]]
echo "Configuring dependencies..."
BUILD_ARGS="-DDEP_WX_GTK3=ON"
if [[ -n "${CLEAN_BUILD}" ]]
then
rm -fr deps/build
fi
if [ ! -d "deps/build" ]
then
BUILD_ARGS="-DDEP_WX_GTK3=ON"
mkdir deps/build
fi
if [[ -n "$BUILD_DEBUG" ]]
if [[ -n "${BUILD_DEBUG}" ]]
then
# have to build deps with debug & release or the cmake won't find everything it needs
mkdir deps/build/release
pushd deps/build/release
echo -e "cmake ../.. -DDESTDIR=\"../destdir\" $BUILD_ARGS"
cmake ../.. -DDESTDIR="../destdir" $BUILD_ARGS
make -j$NCORES
popd
cmake -S deps -B deps/build/release -G Ninja -DDESTDIR="../destdir" ${BUILD_ARGS}
cmake --build deps/build/release
BUILD_ARGS="${BUILD_ARGS} -DCMAKE_BUILD_TYPE=Debug"
fi

# cmake deps
pushd deps/build
echo "cmake .. $BUILD_ARGS"
cmake .. $BUILD_ARGS
echo "done"

# make deps
echo "[4/9] Building dependencies..."
make deps -j$NCORES
echo "done"

# rename wxscintilla # TODO: DeftDawg: Does OrcaSlicer need this?
# echo "[5/9] Renaming wxscintilla library..."
# pushd destdir/usr/local/lib
# if [[ -z "$FOUND_GTK3_DEV" ]]
# then
# cp libwxscintilla-3.1.a libwx_gtk2u_scintilla-3.1.a
# else
# cp libwxscintilla-3.1.a libwx_gtk3u_scintilla-3.1.a
# fi
# popd
# echo "done"

# FIXME: only clean deps if compiling succeeds; otherwise reruns waste tonnes of time!
# clean deps
# echo "[6/9] Cleaning dependencies..."
# rm -rf dep_*
popd
echo "done"
echo "cmake -S deps -B deps/build -G Ninja ${BUILD_ARGS}"
cmake -S deps -B deps/build -G Ninja ${BUILD_ARGS}
cmake --build deps/build
fi

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

if [[ -n "$BUILD_ORCA" ]]
if [[ -n "${BUILD_ORCA}" ]]
then
echo "[7/9] Configuring Slic3r..."
echo "Configuring OrcaSlicer..."
if [[ -n "${CLEAN_BUILD}" ]]
then
rm -fr build
fi
BUILD_ARGS=""
if [[ -n "$FOUND_GTK3_DEV" ]]
if [[ -n "${FOUND_GTK3_DEV}" ]]
then
BUILD_ARGS="-DSLIC3R_GTK=3"
fi
if [[ -n "$BUILD_DEBUG" ]]
if [[ -n "${BUILD_DEBUG}" ]]
then
BUILD_ARGS="${BUILD_ARGS} -DCMAKE_BUILD_TYPE=Debug -DBBL_INTERNAL_TESTING=1"
else
BUILD_ARGS="${BUILD_ARGS} -DBBL_RELEASE_TO_PUBLIC=1 -DBBL_INTERNAL_TESTING=0"
fi

# cmake
pushd build
echo -e "cmake .. -DCMAKE_PREFIX_PATH=\"$PWD/../deps/build/destdir/usr/local\" -DSLIC3R_STATIC=1 -DORCA_TOOLS=ON ${BUILD_ARGS}"
cmake .. -DCMAKE_PREFIX_PATH="$PWD/../deps/build/destdir/usr/local" -DSLIC3R_STATIC=1 ${BUILD_ARGS} -DORCA_TOOLS=ON
echo "done"

# make Slic3r
echo "[8/9] Building Slic3r..."
make -j$NCORES OrcaSlicer # Slic3r

# make OrcaSlicer_profile_validator
make -j$NCORES OrcaSlicer_profile_validator
popd
echo -e "cmake -S . -B build -G Ninja -DCMAKE_PREFIX_PATH="${PWD}/deps/build/destdir/usr/local" -DSLIC3R_STATIC=1 ${BUILD_ARGS}"
cmake -S . -B build -G Ninja \
-DCMAKE_PREFIX_PATH="${PWD}/deps/build/destdir/usr/local" \
-DSLIC3R_STATIC=1 \
-DORCA_TOOLS=ON \
${BUILD_ARGS}
echo "done"
echo "Building OrcaSlicer ..."
cmake --build build --target OrcaSlicer
echo "Building OrcaSlicer_profile_validator .."
cmake --build build --target OrcaSlicer_profile_validator
./run_gettext.sh
echo "done"
fi

if [[ -e $ROOT/build/src/BuildLinuxImage.sh ]]; then
if [[ -e ${ROOT}/build/src/BuildLinuxImage.sh ]]; then
# Give proper permissions to script
chmod 755 $ROOT/build/src/BuildLinuxImage.sh
chmod 755 ${ROOT}/build/src/BuildLinuxImage.sh

echo "[9/9] Generating Linux app..."
pushd build
if [[ -n "$BUILD_IMAGE" ]]
if [[ -n "${BUILD_IMAGE}" ]]
then
$ROOT/build/src/BuildLinuxImage.sh -i
${ROOT}/build/src/BuildLinuxImage.sh -i
else
$ROOT/build/src/BuildLinuxImage.sh
${ROOT}/build/src/BuildLinuxImage.sh
fi
popd
echo "done"
Expand Down
3 changes: 3 additions & 0 deletions linux.d/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Files in this directory are named for the **exact** output of `awk -F= '/^ID=/ {print $2}' /etc/os-release` for their respective distribution.

When `BuildLinux.sh` is executed, the respective file for the distribution will be sourced so the distribution specific instructions/logic are used.
44 changes: 44 additions & 0 deletions linux.d/arch
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# these are the Arch Linux specific build functions
FOUND_GTK3=$(pacman -Q gtk3)

# Addtional Dev packages for OrcaSlicer
export REQUIRED_DEV_PACKAGES=(
cmake
curl
dbus
eglexternalplatform
extra-cmake-modules
file
gettext
git
glew
gstreamer
gstreamermm
gtk3
libmspack
libsecret
mesa
ninja
openssl
texinfo
wayland-protocols
webkit2gtk
wget
)

if [[ -n "$UPDATE_LIB" ]]
then
echo -n -e "Updating linux ...\n"
NEEDED_PKGS=""
for PKG in ${REQUIRED_DEV_PACKAGES[@]}; do
pacman -Q ${PKG} > /dev/null || NEEDED_PKGS+=" ${PKG}"
done

if [ -n "${NEEDED_PKGS}" ]; then
sudo pacman -Syy --noconfirm ${NEEDED_PKGS}
fi
echo -e "done\n"
exit 0
fi

FOUND_GTK3_DEV=${FOUND_GTK3}

0 comments on commit 4b63ff3

Please sign in to comment.