Merge branch 'master' into osxbuild

This commit is contained in:
Alessandro Ranellucci 2018-11-08 17:29:47 +01:00
commit b2ec596037
7 changed files with 72 additions and 63 deletions

View File

@ -1046,7 +1046,6 @@ sub build {
my $optgroup = $page->new_optgroup('Optional information'); my $optgroup = $page->new_optgroup('Optional information');
$optgroup->append_single_option_line('filament_density', 0); $optgroup->append_single_option_line('filament_density', 0);
$optgroup->append_single_option_line('filament_cost', 0); $optgroup->append_single_option_line('filament_cost', 0);
$optgroup->append_single_option_line('filament_settings_id', 0);
} }
} }

View File

@ -160,7 +160,10 @@ sub export {
$self->_print_first_layer_temperature(0) $self->_print_first_layer_temperature(0)
if $include_start_extruder_temp; if $include_start_extruder_temp;
printf $fh "%s\n", Slic3r::ConditionalGCode::apply_math($gcodegen->placeholder_parser->process($self->config->start_gcode)); printf $fh "%s\n", Slic3r::ConditionalGCode::apply_math($gcodegen->placeholder_parser->process($self->config->start_gcode));
my $filament_extruder = 0;
foreach my $start_gcode (@{ $self->config->start_filament_gcode }) { # process filament gcode in order foreach my $start_gcode (@{ $self->config->start_filament_gcode }) { # process filament gcode in order
$gcodegen->placeholder_parser->set("filament_extruder_id", $filament_extruder);
$filament_extruder++;
printf $fh "%s\n", Slic3r::ConditionalGCode::apply_math($gcodegen->placeholder_parser->process($start_gcode)); printf $fh "%s\n", Slic3r::ConditionalGCode::apply_math($gcodegen->placeholder_parser->process($start_gcode));
} }
$self->_print_first_layer_temperature(1) $self->_print_first_layer_temperature(1)
@ -303,7 +306,10 @@ sub export {
# write end commands to file # write end commands to file
print $fh $gcodegen->retract; # TODO: process this retract through PressureRegulator in order to discharge fully print $fh $gcodegen->retract; # TODO: process this retract through PressureRegulator in order to discharge fully
print $fh $gcodegen->writer->set_fan(0); print $fh $gcodegen->writer->set_fan(0);
$filament_extruder = 0;
foreach my $end_gcode (@{ $self->config->end_filament_gcode }) { # Process filament-specific gcode in extruder order. foreach my $end_gcode (@{ $self->config->end_filament_gcode }) { # Process filament-specific gcode in extruder order.
$gcodegen->placeholder_parser->set("filament_extruder_id", $filament_extruder);
$filament_extruder++;
printf $fh "%s\n", Slic3r::ConditionalGCode::apply_math($gcodegen->placeholder_parser->process($end_gcode)); printf $fh "%s\n", Slic3r::ConditionalGCode::apply_math($gcodegen->placeholder_parser->process($end_gcode));
} }
printf $fh "%s\n", Slic3r::ConditionalGCode::apply_math($gcodegen->placeholder_parser->process($self->config->end_gcode)); printf $fh "%s\n", Slic3r::ConditionalGCode::apply_math($gcodegen->placeholder_parser->process($self->config->end_gcode));

View File

@ -1,53 +1,55 @@
#!/bin/bash #!/bin/bash
set -euo pipefail
# Assembles an installation bundle from a built copy of Slic3r. # Assembles an installation bundle from a built copy of Slic3r.
# Requires PAR::Packer to be installed for the version of # Requires PAR::Packer to be installed for the version of
# perl copied. # perl copied.
# Adapted from script written by bubnikv for Prusa3D. # Adapted from script written by bubnikv for Prusa3D.
# Run from slic3r repo root directory. # Run from slic3r repo root directory.
SLIC3R_VERSION=$(grep "VERSION" xs/src/libslic3r/libslic3r.h | awk -F\" '{print $2}')
if [ "$#" -ne 1 ]; then
echo "Usage: $(basename $0) dmg_name"
exit 1;
fi
WD=$(dirname $0) WD=$(dirname $0)
appname=Slic3r
# Determine if this is a tagged (release) commit. # Determine if this is a tagged (release) commit.
# Change the build id accordingly. # Change the build id accordingly.
if [ $(git describe &>/dev/null) ]; then if [ $(git describe --exact-match &>/dev/null) ]; then
TAGGED=true echo "This is a tagged build"
SLIC3R_BUILD_ID=$(git describe) SLIC3R_BUILD_ID=$(git describe)
else else
TAGGED=false # Get the current branch
SLIC3R_BUILD_ID=${SLIC3R_VERSION} if [ -z ${GIT_BRANCH+x} ] && [ -z ${APPVEYOR_REPO_BRANCH+x} ]; then
fi current_branch=$(git symbolic-ref HEAD | sed 's!refs\/heads\/!!')
if [ -z ${GIT_BRANCH+x} ] && [ -z ${APPVEYOR_REPO_BRANCH+x} ]; then else
current_branch=$(git symbolic-ref HEAD | sed 's!refs\/heads\/!!') current_branch="unknown"
else if [ ! -z ${GIT_BRANCH+x} ]; then
current_branch="unknown" echo "Setting to GIT_BRANCH"
if [ ! -z ${GIT_BRANCH+x} ]; then current_branch=$(echo $GIT_BRANCH | cut -d / -f 2)
echo "Setting to GIT_BRANCH" fi
current_branch=$(echo $GIT_BRANCH | cut -d / -f 2) if [ ! -z ${APPVEYOR_REPO_BRANCH+x} ]; then
echo "Setting to APPVEYOR_REPO_BRANCH"
current_branch=$APPVEYOR_REPO_BRANCH
fi
fi fi
if [ ! -z ${APPVEYOR_REPO_BRANCH+x} ]; then
echo "Setting to APPVEYOR_REPO_BRANCH" if [ "$current_branch" == "master" ]; then
current_branch=$APPVEYOR_REPO_BRANCH echo "This is a build of the master branch"
SLIC3R_VERSION=$(grep "VERSION" xs/src/libslic3r/libslic3r.h | awk -F\" '{print $2}')
SLIC3R_BUILD_ID=${SLIC3R_VERSION}-$(git rev-parse --short HEAD)
else
echo "This is a build of a non-master branch"
appname=Slic3r-${current_branch}
SLIC3R_BUILD_ID=${current_branch}-$(git rev-parse --short HEAD)
fi fi
fi fi
dmgfile=slic3r-${SLIC3R_BUILD_ID}.dmg
echo "DMG filename: ${dmgfile}"
# If we're on a branch, add the branch name to the app name. # If we're on a branch, add the branch name to the app name.
if [ "$current_branch" == "master" ]; then
appname=Slic3r
dmgfile=slic3r-${SLIC3R_BUILD_ID}-${1}.dmg
else
appname=Slic3r-$(git symbolic-ref HEAD | sed 's!refs\/heads\/!!')
dmgfile=slic3r-${SLIC3R_BUILD_ID}-${1}-$(git symbolic-ref HEAD | sed 's!refs\/heads\/!!').dmg
fi
rm -rf $WD/_tmp rm -rf $WD/_tmp
mkdir -p $WD/_tmp mkdir -p $WD/_tmp
# OSX Application folder shenanigans. # OSX Application folder shenanigans.
appfolder="$WD/${appname}.app" appfolder="$WD/${appname}.app"
macosfolder=$appfolder/Contents/MacOS macosfolder=$appfolder/Contents/MacOS
@ -104,10 +106,9 @@ echo "Copying perl from $PERL_BIN"
cp -f $PERL_BIN $macosfolder/perl-local cp -f $PERL_BIN $macosfolder/perl-local
${PP_BIN} \ ${PP_BIN} \
-M $(grep -v "^#" ${WD}/../common/coreperl | xargs | awk 'BEGIN { OFS=" -M "}; {$1=$1; print $0}') \ -M $(grep -v "^#" ${WD}/../common/coreperl | xargs | awk 'BEGIN { OFS=" -M "}; {$1=$1; print $0}') \
-B -p -e "print 123" -o $WD/_tmp/test.par -B -p -e "print 123" -o $WD/_tmp/bundle.par
unzip -o $WD/_tmp/test.par -d $WD/_tmp/ unzip -o $WD/_tmp/bundle.par -d $WD/_tmp/
cp -rf $WD/_tmp/lib/* $macosfolder/local-lib/lib/perl5/ cp -rf $WD/_tmp/lib/* $macosfolder/local-lib/lib/perl5/
rm -rf $WD/_tmp
echo "Cleaning bundle" echo "Cleaning bundle"
rm -rf $macosfolder/local-lib/bin rm -rf $macosfolder/local-lib/bin
@ -140,23 +141,31 @@ make_plist
echo $PkgInfoContents >$appfolder/Contents/PkgInfo echo $PkgInfoContents >$appfolder/Contents/PkgInfo
if [[ -e "${KEYCHAIN_FILE}" ]]; then KEYCHAIN_FILE_=${KEYCHAIN_FILE:-}
if [ ! -z $KEYCHAIN_FILE_ ]; then
echo "Signing app..." echo "Signing app..."
chmod -R +w $macosfolder/* chmod -R +w $macosfolder/*
security list-keychains -s "${KEYCHAIN_FILE}" security list-keychains -s "${KEYCHAIN_FILE_}"
security default-keychain -s "${KEYCHAIN_FILE}" security default-keychain -s "${KEYCHAIN_FILE_}"
security unlock-keychain -p "${KEYCHAIN_PASSWORD}" "${KEYCHAIN_FILE}" security unlock-keychain -p "${KEYCHAIN_PASSWORD}" "${KEYCHAIN_FILE_}"
codesign --sign "${KEYCHAIN_IDENTITY}" --deep "$appfolder" codesign --sign "${KEYCHAIN_IDENTITY}" --deep "$appfolder"
else
echo "No KEYCHAIN_FILE env variable; skipping codesign"
fi fi
echo "Creating dmg file...." echo "Creating dmg file...."
hdiutil create -fs HFS+ -srcfolder "$appfolder" -volname "$appname" "$dmgfile" hdiutil create -fs HFS+ -srcfolder "$appfolder" -volname "$appname" "$WD/_tmp/$dmgfile"
if [[ -e "${KEYCHAIN_FILE}" ]]; then # Compress the DMG image
hdiutil convert "$WD/_tmp/$dmgfile" -format UDZO -imagekey zlib-level=9 -o "$dmgfile"
if [ ! -z $KEYCHAIN_FILE_ ]; then
echo "Signing app dmg..." echo "Signing app dmg..."
chmod +w $dmgfile chmod +w $dmgfile
security list-keychains -s "${KEYCHAIN_FILE}" security list-keychains -s "${KEYCHAIN_FILE_}"
security default-keychain -s "${KEYCHAIN_FILE}" security default-keychain -s "${KEYCHAIN_FILE_}"
security unlock-keychain -p "${KEYCHAIN_PASSWORD}" "${KEYCHAIN_FILE}" security unlock-keychain -p "${KEYCHAIN_PASSWORD}" "${KEYCHAIN_FILE_}"
codesign --sign "${KEYCHAIN_IDENTITY}" "$dmgfile" codesign --sign "${KEYCHAIN_IDENTITY}" "$dmgfile"
fi fi
rm -rf $WD/_tmp

View File

@ -18,11 +18,7 @@ cat << EOF > $plistfile
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
EOF EOF
if [ $TAGGED ]; then echo " <string>Slic3r $SLIC3R_BUILD_ID</string>" >>$plistfile
echo " <string>Slic3r $SLIC3R_BUILD_ID</string>" >>$plistfile
else
echo " <string>Slic3r $SLIC3R_BUILD_ID-$(git rev-parse --short head)</string>" >>$plistfile
fi
cat << EOF >> $plistfile cat << EOF >> $plistfile
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>

View File

@ -447,15 +447,8 @@ PrintConfigDef::PrintConfigDef()
def->default_value = opt; def->default_value = opt;
} }
def = this->add("filament_settings_id", coStrings); def = this->add("filament_settings_id", coString);
def->label = __TRANS("Custom GCode ID"); def->default_value = new ConfigOptionString("");
def->tooltip = __TRANS("Identifer for this filament. Used to mark specific filament profiles for custom gcode.");
def->cli = "filament-settings-id=s@";
{
ConfigOptionStrings* opt = new ConfigOptionStrings();
opt->values.push_back("");
def->default_value = opt;
}
def = this->add("fill_angle", coFloat); def = this->add("fill_angle", coFloat);
def->label = __TRANS("Fill angle"); def->label = __TRANS("Fill angle");

View File

@ -336,7 +336,6 @@ class GCodeConfig : public virtual StaticPrintConfig
ConfigOptionFloats filament_cost; ConfigOptionFloats filament_cost;
ConfigOptionFloats filament_max_volumetric_speed; ConfigOptionFloats filament_max_volumetric_speed;
ConfigOptionStrings filament_notes; ConfigOptionStrings filament_notes;
ConfigOptionStrings filament_settings_id;
ConfigOptionBool gcode_comments; ConfigOptionBool gcode_comments;
ConfigOptionEnum<GCodeFlavor> gcode_flavor; ConfigOptionEnum<GCodeFlavor> gcode_flavor;
ConfigOptionBool label_printed_objects; ConfigOptionBool label_printed_objects;
@ -381,7 +380,6 @@ class GCodeConfig : public virtual StaticPrintConfig
OPT_PTR(filament_cost); OPT_PTR(filament_cost);
OPT_PTR(filament_max_volumetric_speed); OPT_PTR(filament_max_volumetric_speed);
OPT_PTR(filament_notes); OPT_PTR(filament_notes);
OPT_PTR(filament_settings_id);
OPT_PTR(gcode_comments); OPT_PTR(gcode_comments);
OPT_PTR(gcode_flavor); OPT_PTR(gcode_flavor);
OPT_PTR(label_printed_objects); OPT_PTR(label_printed_objects);

View File

@ -130,9 +130,12 @@ PrintGCode::output()
// Apply gcode math to start gcode // Apply gcode math to start gcode
fh << apply_math(gcodegen.placeholder_parser->process(config.start_gcode.value)); fh << apply_math(gcodegen.placeholder_parser->process(config.start_gcode.value));
{
for(const auto& start_gcode : config.start_filament_gcode.values) { auto filament_extruder {0U};
fh << apply_math(gcodegen.placeholder_parser->process(start_gcode)); for(const auto& start_gcode : config.start_filament_gcode.values) {
gcodegen.placeholder_parser->set("filament_extruder_id", filament_extruder++);
fh << apply_math(gcodegen.placeholder_parser->process(start_gcode));
}
} }
if (include_start_extruder_temp) this->_print_first_layer_temperature(1); if (include_start_extruder_temp) this->_print_first_layer_temperature(1);
@ -278,8 +281,13 @@ PrintGCode::output()
// Write end commands to file. // Write end commands to file.
fh << gcodegen.retract(); // TODO: process this retract through PressureRegulator in order to discharge fully fh << gcodegen.retract(); // TODO: process this retract through PressureRegulator in order to discharge fully
for(const auto& end_gcode : config.end_filament_gcode.values) {
fh << apply_math(gcodegen.placeholder_parser->process(end_gcode)); {
auto filament_extruder {0U};
for(const auto& end_gcode : config.end_filament_gcode.values) {
gcodegen.placeholder_parser->set("filament_extruder_id", filament_extruder++);
fh << apply_math(gcodegen.placeholder_parser->process(end_gcode));
}
} }
fh << apply_math(gcodegen.placeholder_parser->process(config.end_gcode)); fh << apply_math(gcodegen.placeholder_parser->process(config.end_gcode));