Skip to content

Commit

Permalink
Merge branch 'merill-merge'
Browse files Browse the repository at this point in the history
  • Loading branch information
remi durand committed Aug 7, 2021
2 parents d88d4bc + f88f224 commit 4c2038d
Show file tree
Hide file tree
Showing 10 changed files with 184 additions and 97 deletions.
165 changes: 98 additions & 67 deletions BuildLinux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,28 @@
export ROOT=`pwd`
export NCORES=`nproc --all`

while getopts ":ih" opt; do

while getopts ":dsiuh" opt; do
case ${opt} in
u )
UPDATE_LIB="1"
;;
i )
export BUILD_IMAGE="1"
BUILD_IMAGE="1"
;;
d )
BUILD_DEPS="1"
;;
h ) echo "Usage: ./BuildLinux.sh [-i][-u]"
s )
BUILD_SLIC3R="1"
;;
h ) echo "Usage: ./BuildLinux.sh [-i][-u][-d][-s]"
echo " -i: Generate appimage (optional)"
echo " -d: build deps (optional)"
echo " -s: build slic3r (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
Expand All @@ -22,33 +36,40 @@ then
mkdir build
fi


if [[ -n "$BUILD_IMAGE" ]]
if [[ -n "$UPDATE_LIB" ]]
then
echo -n "Updating linux ..."
{
hwclock -s
apt update
apt install libgtk2.0-dev libglew-dev libudev-dev libdbus-1-dev
} > $ROOT/build/Build.log # Capture all command output
hwclock -s
apt update
apt install libgtk2.0-dev libglew-dev libudev-dev libdbus-1-dev cmake git
echo "done"
exit 0
fi

echo -n "[1/9] Updating submodules..."
FOUND_GTK2=$(dpkg -l libgtk* | grep gtk2.0-dev)
echo "FOUND_GTK2=$FOUND_GTK2)"
if [[ -z "$FOUND_GTK2" ]]
then
echo "Error, you must install the dependencies before."
echo "Use option -u with sudo"
exit 0
fi

echo "[1/9] Updating submodules..."
{
# update submodule profiles
pushd resources/profiles
git submodule update --init
popd
} > $ROOT/build/Build.log # Capture all command output
}
# > $ROOT/build/Build.log # Capture all command output

echo -n "[2/9] Changing date in version..."
echo "[2/9] Changing date in version..."
{
# change date in version
sed "s/+UNKNOWN/_$(date '+%F')/" version.inc > version.date.inc
mv version.date.inc version.inc
} &> $ROOT/build/Build.log # Capture all command output
sed -i "s/+UNKNOWN/_$(date '+%F')/" version.inc
}
# &> $ROOT/build/Build.log # Capture all command output
echo "done"

# mkdir in deps
Expand All @@ -57,66 +78,76 @@ then
mkdir deps/build
fi

echo -n "[3/9] Configuring dependencies..."
{
# cmake deps
pushd deps/build
cmake .. -DCMAKE_OSX_DEPLOYMENT_TARGET="10.13"
} &> $ROOT/build/Build.log # Capture all command output
echo "done"

echo -n "[4/9] Building dependencies..."
{
# make deps
make -j$NCORES
} &> $ROOT/build/Build.log # Capture all command output
echo "done"

echo -n "[5/9] Renaming wxscintilla library..."
{
# rename wxscintilla
pushd destdir/usr/local/lib
cp libwxscintilla-3.1.a libwx_gtk2u_scintilla-3.1.a
popd
} &> $ROOT/build/Build.log # Capture all command output
echo "done"

echo -n "[6/9] Cleaning dependencies..."
{
# clean deps
rm -rf dep_*
popd
} &> $ROOT/build/Build.log # Capture all command output
echo "done"

echo -n "[7/9] Configuring Slic3r..."
{
# cmake
pushd build
cmake .. -DCMAKE_PREFIX_PATH="$PWD/../deps/build/destdir/usr/local" -DCMAKE_OSX_DEPLOYMENT_TARGET="10.13" -DSLIC3R_STATIC=1
} &> $ROOT/build/Build.log # Capture all command output
echo "done"

echo -n "[8/9] Building Slic3r..."
{
# make Slic3r
make -j$NCORES Slic3r
if [[ -n "$BUILD_DEPS" ]]
then
echo "[3/9] Configuring dependencies..."

# cmake deps
pushd deps/build
cmake ..

# &> $ROOT/build/Build.log # Capture all command output
echo "done"

echo "[4/9] Building dependencies..."

# make deps
make -j$NCORES

# &> $ROOT/build/Build.log # Capture all command output
echo "done"

echo "[5/9] Renaming wxscintilla library..."

# rename wxscintilla
pushd destdir/usr/local/lib
cp libwxscintilla-3.1.a libwx_gtk2u_scintilla-3.1.a
popd
# &> $ROOT/build/Build.log # Capture all command output
echo "done"

echo "[6/9] Cleaning dependencies..."

# clean deps
rm -rf dep_*
popd
# &> $ROOT/build/Build.log # Capture all command output
echo "done"
fi

# make .mo
make gettext_po_to_mo
} &> $ROOT/build/Build.log # Capture all command output
echo "done"
if [[ -n "$BUILD_SLIC3R" ]]
then
echo "[7/9] Configuring Slic3r..."

# cmake
pushd build
cmake .. -DCMAKE_PREFIX_PATH="$PWD/../deps/build/destdir/usr/local" -DSLIC3R_STATIC=1
# &> $ROOT/build/Build.log # Capture all command output
echo "done"

echo "[8/9] Building Slic3r..."

# make Slic3r
make -j$NCORES Slic3r

# make .mo
make gettext_po_to_mo

popd
# &> $ROOT/build/Build.log # Capture all command output
echo "done"
fi

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

echo -n "[9/9] Generating Linux app..."
{
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
} &> $ROOT/build/Build.log # Capture all command output
# &> $ROOT/build/Build.log # Capture all command output
echo "done"
1 change: 1 addition & 0 deletions src/PrusaSlicer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ int CLI::run(int argc, char **argv)
if (! m_config.opt_bool("dont_arrange")) {
ArrangeParams arrange_cfg;
arrange_cfg.min_obj_distance = scaled(PrintConfig::min_object_distance(&m_print_config)) * 2;
arrange_cfg.min_obj_distance += m_print_config.opt_float("duplicate_distance");
if (dups > 1) {
try {
// if all input objects have defined position(s) apply duplication to the whole model
Expand Down
25 changes: 17 additions & 8 deletions src/libslic3r/Format/3mf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2806,8 +2806,18 @@ namespace Slic3r {
}

// stores object's config data
for (const std::string& key : obj->config.keys()) {
stream << " <" << METADATA_TAG << " " << TYPE_ATTR << "=\"" << OBJECT_TYPE << "\" " << KEY_ATTR << "=\"" << key << "\" " << VALUE_ATTR << "=\"" << obj->config.opt_serialize(key) << "\"/>\n";
if (file_path == MODEL_PRUSA_CONFIG_FILE) {
for (std::string key : obj->config.keys()) {
// convert to prusa config
std::string value = obj->config.opt_serialize(key);
obj->config.to_prusa(key, value);
if (!key.empty())
stream << " <" << METADATA_TAG << " " << TYPE_ATTR << "=\"" << OBJECT_TYPE << "\" " << KEY_ATTR << "=\"" << key << "\" " << VALUE_ATTR << "=\"" << value << "\"/>\n";
}
} else {
for (const std::string& key : obj->config.keys()) {
stream << " <" << METADATA_TAG << " " << TYPE_ATTR << "=\"" << OBJECT_TYPE << "\" " << KEY_ATTR << "=\"" << key << "\" " << VALUE_ATTR << "=\"" << obj->config.opt_serialize(key) << "\"/>\n";
}
}

for (const ModelVolume* volume : obj_metadata.second.object->volumes)
Expand Down Expand Up @@ -2868,18 +2878,17 @@ namespace Slic3r {
}

// stores volume's config data
for (std::string key : volume->config.keys())
{
// config
if (file_path == MODEL_PRUSA_CONFIG_FILE) {
if (file_path == MODEL_PRUSA_CONFIG_FILE) {
for (std::string key : volume->config.keys()) {
// convert to prusa config
std::string value = volume->config.opt_serialize(key);
volume->config.to_prusa(key, value);
if (!key.empty())
stream << " <" << METADATA_TAG << " " << TYPE_ATTR << "=\"" << VOLUME_TYPE << "\" " << KEY_ATTR << "=\"" << key << "\" " << VALUE_ATTR << "=\"" << value << "\"/>\n";
} else {
stream << " <" << METADATA_TAG << " " << TYPE_ATTR << "=\"" << VOLUME_TYPE << "\" " << KEY_ATTR << "=\"" << key << "\" " << VALUE_ATTR << "=\"" << volume->config.opt_serialize(key) << "\"/>\n";
}
} else {
for (const std::string& key : volume->config.keys())
stream << " <" << METADATA_TAG << " " << TYPE_ATTR << "=\"" << VOLUME_TYPE << "\" " << KEY_ATTR << "=\"" << key << "\" " << VALUE_ATTR << "=\"" << volume->config.opt_serialize(key) << "\"/>\n";
}

stream << " </" << VOLUME_TAG << ">\n";
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/Print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,7 @@ static inline bool sequential_print_horizontal_clearance_valid(const Print &prin
Polygons convex_hulls_other;
std::map<ObjectID, Polygon> map_model_object_to_convex_hull;
for (const PrintObject *print_object : print.objects()) {
double dist_grow = PrintConfig::min_object_distance(&print.full_print_config());// &print_object->config());
double dist_grow = PrintConfig::min_object_distance(&print.full_print_config()) * 2 ;// &print_object->config());
assert(! print_object->model_object()->instances.empty());
assert(! print_object->instances().empty());
ObjectID model_object_id = print_object->model_object()->id();
Expand Down
8 changes: 3 additions & 5 deletions src/libslic3r/PrintConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ void PrintConfigDef::init_fff_params()
def = this->add("duplicate_distance", coFloat);
def->label = L("Distance between objects");
def->category = OptionCategory::output;
def->tooltip = L("Distance used for the auto-arrange feature of the plater.");
def->tooltip = L("Default distance used for the auto-arrange feature of the plater.\nSet to 0 to use the last value instead.");
def->sidetext = L("mm");
def->aliases = { "multiply_distance" };
def->min = 0;
Expand Down Expand Up @@ -5660,9 +5660,7 @@ double PrintConfig::min_object_distance(const ConfigBase *config, double ref_hei
//test if called from usaslicer::l240 where it's called on an empty config...
if (dd_opt == nullptr) return 0;

// /2 becasue we only count the grawing for the current object
const double duplicate_distance = dd_opt->value / 2;
double base_dist = duplicate_distance;
double base_dist = 0;
//std::cout << "START min_object_distance =>" << base_dist << "\n";
const ConfigOptionBool* co_opt = config->option<ConfigOptionBool>("complete_objects");
if (co_opt && co_opt->value) {
Expand All @@ -5676,7 +5674,7 @@ double PrintConfig::min_object_distance(const ConfigBase *config, double ref_hei
// min object distance is max(duplicate_distance, clearance_radius)
// /2 becasue we only count the grawing for the current object
//add 1 as safety offset.
double extruder_clearance_radius = config->option("extruder_clearance_radius")->getFloat() / 2 + 1;
double extruder_clearance_radius = config->option("extruder_clearance_radius")->getFloat() / 2;
if (extruder_clearance_radius > base_dist) {
base_dist = extruder_clearance_radius;
}
Expand Down
23 changes: 15 additions & 8 deletions src/platform/unix/BuildLinuxImage.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ while getopts ":ih" opt; do
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
mkdir package/bin

# copy Resources
Expand All @@ -32,17 +33,23 @@ echo -n "[9/9] Generating Linux app..."

# 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 u+x @SLIC3R_APP_CMD@
tar -cvf ../@[email protected] .
} &> $ROOT/Build.log # Capture all command output
chmod ug+x @SLIC3R_APP_CMD@
cp -f @SLIC3R_APP_CMD@ package/@SLIC3R_APP_CMD@
pushd package
tar -cvf ../@[email protected] . &>/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
} &> $ROOT/Build.log # Capture all command output
popd
mv package/"@SLIC3R_APP_KEY@_ubu64.AppImage" "@SLIC3R_APP_KEY@_ubu64.AppImage"
#} &> $ROOT/Build.log # Capture all command output
echo "done"
fi
Loading

0 comments on commit 4c2038d

Please sign in to comment.