Add Linux related build scripts
including following changes: - Linux build scripts from SuperSlicer project; - Update BuildLinux dev dependencies, remove unused bits; - Update BuildLinuxImage to use nproc for cpus; - CMake: render BuildLinuxImage and build_appimage templates; - Fix "DSO missing" linking problems; - Add Podman Containerfile for building; - Update BuildLinux.sh to work better in container build; - fixes to create AppImage inside container; - add env to build environment; - Update build instructions in Containerfile; Change-Id: I73e30ab488cda8c1b0886cd34858e125596f282b (cherry picked from commit 83fc26670ca592c91c7af1d4033a04b587cfd4cd)
This commit is contained in:
parent
014152f078
commit
f5a4862da5
7 changed files with 376 additions and 0 deletions
227
BuildLinux.sh
Executable file
227
BuildLinux.sh
Executable file
|
@ -0,0 +1,227 @@
|
|||
#!/bin/bash
|
||||
set -e # exit on first error
|
||||
|
||||
export ROOT=`pwd`
|
||||
export NCORES=`nproc --all`
|
||||
FOUND_GTK2=$(dpkg -l libgtk* | grep gtk2)
|
||||
FOUND_GTK3=$(dpkg -l libgtk* | grep gtk-3)
|
||||
|
||||
unset name
|
||||
while getopts ":dsiuhgb" opt; do
|
||||
case ${opt} in
|
||||
u )
|
||||
UPDATE_LIB="1"
|
||||
;;
|
||||
i )
|
||||
BUILD_IMAGE="1"
|
||||
;;
|
||||
d )
|
||||
BUILD_DEPS="1"
|
||||
;;
|
||||
s )
|
||||
BUILD_BAMBU_STUDIO="1"
|
||||
;;
|
||||
b )
|
||||
BUILD_DEBUG="1"
|
||||
;;
|
||||
g )
|
||||
FOUND_GTK3=""
|
||||
;;
|
||||
h ) echo "Usage: ./BuildLinux.sh [-i][-u][-d][-s][-b][-g]"
|
||||
echo " -i: Generate appimage (optional)"
|
||||
echo " -g: force gtk2 build"
|
||||
echo " -b: build in debug mode"
|
||||
echo " -d: build deps (optional)"
|
||||
echo " -s: build bambu-studio (optional)"
|
||||
echo " -u: only update clock & dependency packets (optional and need sudo)"
|
||||
echo "For a first use, you want to 'sudo ./BuildLinux.sh -u'"
|
||||
echo " and then './BuildLinux.sh -dsi'"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ $OPTIND -eq 1 ]
|
||||
then
|
||||
echo "Usage: ./BuildLinux.sh [-i][-u][-d][-s][-b][-g]"
|
||||
echo " -i: Generate appimage (optional)"
|
||||
echo " -g: force gtk2 build"
|
||||
echo " -b: build in debug mode"
|
||||
echo " -d: build deps (optional)"
|
||||
echo " -s: build bambu-studio (optional)"
|
||||
echo " -u: only update clock & dependency packets (optional and need sudo)"
|
||||
echo "For a first use, you want to 'sudo ./BuildLinux.sh -u'"
|
||||
echo " and then './BuildLinux.sh -dsi'"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# mkdir build
|
||||
if [ ! -d "build" ]
|
||||
then
|
||||
mkdir build
|
||||
fi
|
||||
|
||||
# Addtional Dev packages for BambuStudio
|
||||
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"
|
||||
# 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
|
||||
fi
|
||||
|
||||
#FIXME: require root for -u option
|
||||
if [[ -n "$UPDATE_LIB" ]]
|
||||
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.04:
|
||||
ubu_version="$(cat /etc/issue)"
|
||||
if [[ $ubu_version == "Ubuntu 22.04"* ]]
|
||||
then
|
||||
apt install -y curl 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
|
||||
fi
|
||||
|
||||
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" ]]
|
||||
then
|
||||
echo "Error, you must install the dependencies before."
|
||||
echo "Use option -u with sudo"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "[1/9] Updating submodules..."
|
||||
{
|
||||
# update submodule profiles
|
||||
pushd resources/profiles
|
||||
git submodule update --init
|
||||
popd
|
||||
}
|
||||
|
||||
echo "[2/9] 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 "$BUILD_DEPS" ]]
|
||||
then
|
||||
echo "[3/9] Configuring dependencies..."
|
||||
BUILD_ARGS=""
|
||||
if [[ -n "$FOUND_GTK3_DEV" ]]
|
||||
then
|
||||
BUILD_ARGS="-DDEP_WX_GTK3=ON"
|
||||
fi
|
||||
if [[ -n "$BUILD_DEBUG" ]]
|
||||
then
|
||||
# have to build deps with debug & release or the cmake won't find evrything it needs
|
||||
mkdir deps/build/release
|
||||
pushd deps/build/release
|
||||
cmake ../.. -DDESTDIR="../destdir" $BUILD_ARGS
|
||||
make -j$NCORES
|
||||
popd
|
||||
BUILD_ARGS="${BUILD_ARGS} -DCMAKE_BUILD_TYPE=Debug"
|
||||
fi
|
||||
|
||||
# cmake deps
|
||||
pushd deps/build
|
||||
cmake .. $BUILD_ARGS
|
||||
echo "done"
|
||||
|
||||
# make deps
|
||||
echo "[4/9] Building dependencies..."
|
||||
make -j$NCORES
|
||||
echo "done"
|
||||
|
||||
# rename wxscintilla # TODO: DeftDawg: Does BambuStudio 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"
|
||||
fi
|
||||
|
||||
if [[ -n "$BUILD_BAMBU_STUDIO" ]]
|
||||
then
|
||||
echo "[7/9] Configuring Slic3r..."
|
||||
BUILD_ARGS=""
|
||||
if [[ -n "$FOUND_GTK3_DEV" ]]
|
||||
then
|
||||
BUILD_ARGS="-DSLIC3R_GTK=3"
|
||||
fi
|
||||
if [[ -n "$BUILD_DEBUG" ]]
|
||||
then
|
||||
BUILD_ARGS="${BUILD_ARGS} -DCMAKE_BUILD_TYPE=Debug"
|
||||
fi
|
||||
|
||||
# cmake
|
||||
pushd build
|
||||
cmake .. -DCMAKE_PREFIX_PATH="$PWD/../deps/build/destdir/usr/local" -DSLIC3R_STATIC=1 ${BUILD_ARGS}
|
||||
echo "done"
|
||||
|
||||
# make Slic3r
|
||||
echo "[8/9] Building Slic3r..."
|
||||
make -j$NCORES BambuStudio # Slic3r
|
||||
|
||||
# make .mo
|
||||
# make gettext_po_to_mo # FIXME: DeftDawg: complains about msgfmt not existing even in SuperSlicer, did this ever work?
|
||||
|
||||
popd
|
||||
echo "done"
|
||||
fi
|
||||
|
||||
if [[ -e $ROOT/build/src/BuildLinuxImage.sh ]]; then
|
||||
# Give proper permissions to script
|
||||
chmod 755 $ROOT/build/src/BuildLinuxImage.sh
|
||||
|
||||
echo "[9/9] Generating Linux app..."
|
||||
pushd build
|
||||
if [[ -n "$BUILD_IMAGE" ]]
|
||||
then
|
||||
$ROOT/build/src/BuildLinuxImage.sh -i
|
||||
else
|
||||
$ROOT/build/src/BuildLinuxImage.sh
|
||||
fi
|
||||
popd
|
||||
echo "done"
|
||||
fi
|
|
@ -675,6 +675,11 @@ if(SLIC3R_BUILD_TESTS)
|
|||
add_subdirectory(tests)
|
||||
endif()
|
||||
|
||||
if (NOT WIN32 AND NOT APPLE)
|
||||
set(SLIC3R_APP_CMD "bambu-studio")
|
||||
configure_file(${LIBDIR}/platform/unix/build_appimage.sh.in ${CMAKE_CURRENT_BINARY_DIR}/build_appimage.sh @ONLY)
|
||||
endif()
|
||||
|
||||
option(BUILD_BBS_TEST_TOOLS "Build bbs test tools" OFF)
|
||||
if(BUILD_BBS_TEST_TOOLS)
|
||||
add_subdirectory(bbs_test_tools)
|
||||
|
|
44
Containerfile
Normal file
44
Containerfile
Normal file
|
@ -0,0 +1,44 @@
|
|||
# Build Bambu Slicer in a container
|
||||
#
|
||||
# Build an AppImage:
|
||||
# rm -rf build; sudo podman build .. -t bambu-studio && sudo podman run --rm localhost/bambu-studio /bin/bash -c 'tar -c $(find build | grep ubu64.AppImage | head -1)' | tar -xv
|
||||
#
|
||||
# Troubleshooting:
|
||||
# sudo podman run -it localhost/bambu-studio /bin/bash
|
||||
|
||||
FROM docker.io/ubuntu:kinetic
|
||||
LABEL maintainer "DeftDawg <DeftDawg@gmail.com>"
|
||||
|
||||
# Add a deb-src
|
||||
RUN echo deb-src http://archive.ubuntu.com/ubuntu \
|
||||
$(cat /etc/*release | grep VERSION_CODENAME | cut -d= -f2) main universe>> /etc/apt/sources.list
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
git \
|
||||
build-essential \
|
||||
autoconf \
|
||||
cmake \
|
||||
libglu1-mesa-dev \
|
||||
libgtk-3-dev \
|
||||
libdbus-1-dev \
|
||||
curl \
|
||||
wget \
|
||||
sudo
|
||||
|
||||
COPY ../BambuStudio BambuStudio
|
||||
|
||||
WORKDIR BambuStudio
|
||||
|
||||
# These can run together, but we run them seperate for podman caching
|
||||
# Update System dependencies
|
||||
RUN ./BuildLinux.sh -u
|
||||
|
||||
# Build dependencies in ./deps
|
||||
RUN ./BuildLinux.sh -d
|
||||
|
||||
# Build slic3r
|
||||
RUN ./BuildLinux.sh -s
|
||||
|
||||
# Build AppImage
|
||||
ENV container podman
|
||||
RUN ./BuildLinux.sh -i
|
|
@ -118,6 +118,8 @@ endif (MINGW)
|
|||
if (NOT WIN32 AND NOT APPLE)
|
||||
# Binary name on unix like systems (Linux, Unix)
|
||||
set_target_properties(BambuStudio PROPERTIES OUTPUT_NAME "bambu-studio")
|
||||
set(SLIC3R_APP_CMD "bambu-studio")
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/platform/unix/BuildLinuxImage.sh.in ${CMAKE_CURRENT_BINARY_DIR}/BuildLinuxImage.sh @ONLY)
|
||||
endif ()
|
||||
|
||||
target_link_libraries(BambuStudio libslic3r cereal)
|
||||
|
|
57
src/platform/unix/BuildLinuxImage.sh.in
Normal file
57
src/platform/unix/BuildLinuxImage.sh.in
Normal file
|
@ -0,0 +1,57 @@
|
|||
#!/bin/bash
|
||||
|
||||
export ROOT=$(echo $ROOT | grep . || pwd)
|
||||
export NCORES=`nproc --all`
|
||||
|
||||
while getopts ":ih" opt; do
|
||||
case ${opt} in
|
||||
i )
|
||||
export BUILD_IMAGE="1"
|
||||
;;
|
||||
h ) echo "Usage: ./BuildLinuxImage.sh [-i]"
|
||||
echo " -i: Generate Appimage (optional)"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
echo -n "[9/9] Generating Linux app..."
|
||||
#{
|
||||
# create directory and copy into it
|
||||
if [ -d "package" ]
|
||||
then
|
||||
rm -rf package/*
|
||||
rm -rf package/.* 2&>/dev/null
|
||||
else
|
||||
mkdir package
|
||||
fi
|
||||
mkdir package/bin
|
||||
|
||||
# copy Resources
|
||||
cp -Rf ../resources package/resources
|
||||
cp -f src/@SLIC3R_APP_CMD@ package/bin/@SLIC3R_APP_CMD@
|
||||
# remove unneeded po from resources
|
||||
## find package/resources/localization -name "*.po" -type f -delete ## FIXME: DD - do we need this?
|
||||
|
||||
# create bin
|
||||
echo -e '#!/bin/bash\nDIR=$(readlink -f "$0" | xargs dirname)\nexport LD_LIBRARY_PATH="$DIR/bin"\nexec "$DIR/bin/@SLIC3R_APP_CMD@" "$@"' >@SLIC3R_APP_CMD@
|
||||
chmod ug+x @SLIC3R_APP_CMD@
|
||||
cp -f @SLIC3R_APP_CMD@ package/@SLIC3R_APP_CMD@
|
||||
pushd package
|
||||
tar -cvf ../@SLIC3R_APP_KEY@.tar . &>/dev/null
|
||||
popd
|
||||
#} &> $ROOT/Build.log # Capture all command output
|
||||
echo "done"
|
||||
|
||||
if [[ -n "$BUILD_IMAGE" ]]
|
||||
then
|
||||
echo -n "Creating Appimage for distribution..."
|
||||
#{
|
||||
pushd package
|
||||
chmod +x ../build_appimage.sh
|
||||
../build_appimage.sh
|
||||
popd
|
||||
mv package/"@SLIC3R_APP_KEY@_ubu64.AppImage" "@SLIC3R_APP_KEY@_ubu64.AppImage"
|
||||
#} &> $ROOT/Build.log # Capture all command output
|
||||
echo "done"
|
||||
fi
|
30
src/platform/unix/build_appimage.sh.in
Normal file
30
src/platform/unix/build_appimage.sh.in
Normal file
|
@ -0,0 +1,30 @@
|
|||
#!/bin/sh
|
||||
APPIMAGETOOLURL="https://github.com/AppImage/AppImageKit/releases/latest/download/appimagetool-x86_64.AppImage"
|
||||
|
||||
|
||||
APP_IMAGE="@SLIC3R_APP_KEY@_ubu64.AppImage"
|
||||
|
||||
wget ${APPIMAGETOOLURL} -O ../appimagetool.AppImage
|
||||
chmod +x ../appimagetool.AppImage
|
||||
|
||||
sed -i -e 's#/usr#././#g' bin/@SLIC3R_APP_CMD@
|
||||
mv @SLIC3R_APP_CMD@ AppRun
|
||||
chmod +x AppRun
|
||||
|
||||
cp resources/images/@SLIC3R_APP_KEY@_192px.png @SLIC3R_APP_KEY@.png
|
||||
mkdir -p usr/share/icons/hicolor/192x192/apps
|
||||
cp resources/images/@SLIC3R_APP_KEY@_192px.png usr/share/icons/hicolor/192x192/apps/@SLIC3R_APP_KEY@.png
|
||||
cat <<EOF > @SLIC3R_APP_KEY@.desktop
|
||||
[Desktop Entry]
|
||||
Name=@SLIC3R_APP_KEY@
|
||||
Exec=AppRun %F
|
||||
Icon=@SLIC3R_APP_KEY@
|
||||
Type=Application
|
||||
Categories=Utility;
|
||||
MimeType=model/stl;application/vnd.ms-3mfdocument;application/prs.wavefront-obj;application/x-amf;
|
||||
EOF
|
||||
|
||||
|
||||
../appimagetool.AppImage . $([ ! -z "${container}" ] && echo '--appimage-extract-and-run')
|
||||
mv @SLIC3R_APP_KEY@-x86_64.AppImage ${APP_IMAGE}
|
||||
chmod +x ${APP_IMAGE}
|
|
@ -416,7 +416,18 @@ target_link_libraries(libslic3r_gui libslic3r cereal imgui minilzo GLEW::GLEW Op
|
|||
if (MSVC)
|
||||
target_link_libraries(libslic3r_gui Setupapi.lib)
|
||||
elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
FIND_LIBRARY(WAYLAND_SERVER_LIBRARIES NAMES wayland-server)
|
||||
FIND_LIBRARY(WAYLAND_EGL_LIBRARIES NAMES wayland-egl)
|
||||
FIND_LIBRARY(WAYLAND_CLIENT_LIBRARIES NAMES wayland-client)
|
||||
find_package(CURL REQUIRED)
|
||||
target_link_libraries(libslic3r_gui ${DBUS_LIBRARIES} OSMesa)
|
||||
target_link_libraries(libslic3r_gui
|
||||
OpenGL::EGL
|
||||
${WAYLAND_SERVER_LIBRARIES}
|
||||
${WAYLAND_EGL_LIBRARIES}
|
||||
${WAYLAND_CLIENT_LIBRARIES}
|
||||
${CURL_LIBRARIES}
|
||||
)
|
||||
elseif (APPLE)
|
||||
target_link_libraries(libslic3r_gui ${DISKARBITRATION_LIBRARY})
|
||||
endif()
|
||||
|
|
Loading…
Reference in a new issue