Skip to content

Commit

Permalink
Merge branch 'master' into osxbuild
Browse files Browse the repository at this point in the history
  • Loading branch information
alranel committed Nov 8, 2018
2 parents ab694ef + 86a728b commit b2ec596
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 63 deletions.
1 change: 0 additions & 1 deletion lib/Slic3r/GUI/PresetEditor.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,6 @@ sub build {
my $optgroup = $page->new_optgroup('Optional information');
$optgroup->append_single_option_line('filament_density', 0);
$optgroup->append_single_option_line('filament_cost', 0);
$optgroup->append_single_option_line('filament_settings_id', 0);
}
}

Expand Down
6 changes: 6 additions & 0 deletions lib/Slic3r/Print/GCode.pm
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,10 @@ sub export {
$self->_print_first_layer_temperature(0)
if $include_start_extruder_temp;
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
$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));
}
$self->_print_first_layer_temperature(1)
Expand Down Expand Up @@ -303,7 +306,10 @@ sub export {
# write end commands to file
print $fh $gcodegen->retract; # TODO: process this retract through PressureRegulator in order to discharge fully
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.
$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($self->config->end_gcode));
Expand Down
91 changes: 50 additions & 41 deletions package/osx/make_dmg.sh
Original file line number Diff line number Diff line change
@@ -1,53 +1,55 @@
#!/bin/bash
set -euo pipefail

# Assembles an installation bundle from a built copy of Slic3r.
# Requires PAR::Packer to be installed for the version of
# perl copied.
# Adapted from script written by bubnikv for Prusa3D.
# 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)
appname=Slic3r

# Determine if this is a tagged (release) commit.
# Change the build id accordingly.
if [ $(git describe &>/dev/null) ]; then
TAGGED=true
if [ $(git describe --exact-match &>/dev/null) ]; then
echo "This is a tagged build"
SLIC3R_BUILD_ID=$(git describe)
else
TAGGED=false
SLIC3R_BUILD_ID=${SLIC3R_VERSION}
fi
if [ -z ${GIT_BRANCH+x} ] && [ -z ${APPVEYOR_REPO_BRANCH+x} ]; then
current_branch=$(git symbolic-ref HEAD | sed 's!refs\/heads\/!!')
else
current_branch="unknown"
if [ ! -z ${GIT_BRANCH+x} ]; then
echo "Setting to GIT_BRANCH"
current_branch=$(echo $GIT_BRANCH | cut -d / -f 2)
# Get the current branch
if [ -z ${GIT_BRANCH+x} ] && [ -z ${APPVEYOR_REPO_BRANCH+x} ]; then
current_branch=$(git symbolic-ref HEAD | sed 's!refs\/heads\/!!')
else
current_branch="unknown"
if [ ! -z ${GIT_BRANCH+x} ]; then
echo "Setting to GIT_BRANCH"
current_branch=$(echo $GIT_BRANCH | cut -d / -f 2)
fi
if [ ! -z ${APPVEYOR_REPO_BRANCH+x} ]; then
echo "Setting to APPVEYOR_REPO_BRANCH"
current_branch=$APPVEYOR_REPO_BRANCH
fi
fi
if [ ! -z ${APPVEYOR_REPO_BRANCH+x} ]; then
echo "Setting to APPVEYOR_REPO_BRANCH"
current_branch=$APPVEYOR_REPO_BRANCH

if [ "$current_branch" == "master" ]; then
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

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 [ "$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
mkdir -p $WD/_tmp


# OSX Application folder shenanigans.
appfolder="$WD/${appname}.app"
macosfolder=$appfolder/Contents/MacOS
Expand Down Expand Up @@ -104,10 +106,9 @@ echo "Copying perl from $PERL_BIN"
cp -f $PERL_BIN $macosfolder/perl-local
${PP_BIN} \
-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
unzip -o $WD/_tmp/test.par -d $WD/_tmp/
-B -p -e "print 123" -o $WD/_tmp/bundle.par
unzip -o $WD/_tmp/bundle.par -d $WD/_tmp/
cp -rf $WD/_tmp/lib/* $macosfolder/local-lib/lib/perl5/
rm -rf $WD/_tmp

echo "Cleaning bundle"
rm -rf $macosfolder/local-lib/bin
Expand Down Expand Up @@ -140,23 +141,31 @@ make_plist

echo $PkgInfoContents >$appfolder/Contents/PkgInfo

if [[ -e "${KEYCHAIN_FILE}" ]]; then
KEYCHAIN_FILE_=${KEYCHAIN_FILE:-}
if [ ! -z $KEYCHAIN_FILE_ ]; then
echo "Signing app..."
chmod -R +w $macosfolder/*
security list-keychains -s "${KEYCHAIN_FILE}"
security default-keychain -s "${KEYCHAIN_FILE}"
security unlock-keychain -p "${KEYCHAIN_PASSWORD}" "${KEYCHAIN_FILE}"
security list-keychains -s "${KEYCHAIN_FILE_}"
security default-keychain -s "${KEYCHAIN_FILE_}"
security unlock-keychain -p "${KEYCHAIN_PASSWORD}" "${KEYCHAIN_FILE_}"
codesign --sign "${KEYCHAIN_IDENTITY}" --deep "$appfolder"
else
echo "No KEYCHAIN_FILE env variable; skipping codesign"
fi

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..."
chmod +w $dmgfile
security list-keychains -s "${KEYCHAIN_FILE}"
security default-keychain -s "${KEYCHAIN_FILE}"
security unlock-keychain -p "${KEYCHAIN_PASSWORD}" "${KEYCHAIN_FILE}"
security list-keychains -s "${KEYCHAIN_FILE_}"
security default-keychain -s "${KEYCHAIN_FILE_}"
security unlock-keychain -p "${KEYCHAIN_PASSWORD}" "${KEYCHAIN_FILE_}"
codesign --sign "${KEYCHAIN_IDENTITY}" "$dmgfile"
fi

rm -rf $WD/_tmp
6 changes: 1 addition & 5 deletions package/osx/plist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ cat << EOF > $plistfile
<key>CFBundleShortVersionString</key>
EOF

if [ $TAGGED ]; then
echo " <string>Slic3r $SLIC3R_BUILD_ID</string>" >>$plistfile
else
echo " <string>Slic3r $SLIC3R_BUILD_ID-$(git rev-parse --short head)</string>" >>$plistfile
fi
echo " <string>Slic3r $SLIC3R_BUILD_ID</string>" >>$plistfile

cat << EOF >> $plistfile
<key>CFBundleIdentifier</key>
Expand Down
11 changes: 2 additions & 9 deletions xs/src/libslic3r/PrintConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,15 +447,8 @@ PrintConfigDef::PrintConfigDef()
def->default_value = opt;
}

def = this->add("filament_settings_id", coStrings);
def->label = __TRANS("Custom GCode ID");
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("filament_settings_id", coString);
def->default_value = new ConfigOptionString("");

def = this->add("fill_angle", coFloat);
def->label = __TRANS("Fill angle");
Expand Down
2 changes: 0 additions & 2 deletions xs/src/libslic3r/PrintConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,6 @@ class GCodeConfig : public virtual StaticPrintConfig
ConfigOptionFloats filament_cost;
ConfigOptionFloats filament_max_volumetric_speed;
ConfigOptionStrings filament_notes;
ConfigOptionStrings filament_settings_id;
ConfigOptionBool gcode_comments;
ConfigOptionEnum<GCodeFlavor> gcode_flavor;
ConfigOptionBool label_printed_objects;
Expand Down Expand Up @@ -381,7 +380,6 @@ class GCodeConfig : public virtual StaticPrintConfig
OPT_PTR(filament_cost);
OPT_PTR(filament_max_volumetric_speed);
OPT_PTR(filament_notes);
OPT_PTR(filament_settings_id);
OPT_PTR(gcode_comments);
OPT_PTR(gcode_flavor);
OPT_PTR(label_printed_objects);
Expand Down
18 changes: 13 additions & 5 deletions xs/src/libslic3r/PrintGCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,12 @@ PrintGCode::output()

// Apply gcode math to start gcode
fh << apply_math(gcodegen.placeholder_parser->process(config.start_gcode.value));

for(const auto& start_gcode : config.start_filament_gcode.values) {
fh << apply_math(gcodegen.placeholder_parser->process(start_gcode));
{
auto filament_extruder {0U};
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);
Expand Down Expand Up @@ -278,8 +281,13 @@ PrintGCode::output()

// Write end commands to file.
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));
Expand Down

0 comments on commit b2ec596

Please sign in to comment.