aboutsummaryrefslogtreecommitdiff
path: root/buildroot/bin
diff options
context:
space:
mode:
authorGeorgiy Bondarenko <69736697+nehilo@users.noreply.github.com>2021-03-04 20:54:23 +0300
committerGeorgiy Bondarenko <69736697+nehilo@users.noreply.github.com>2021-03-04 20:54:23 +0300
commite8701195e66f2d27ffe17fb514eae8173795aaf7 (patch)
tree9f519c4abf6556b9ae7190a6210d87ead1dfadde /buildroot/bin
downloadkp3s-lgvl-e8701195e66f2d27ffe17fb514eae8173795aaf7.tar.xz
kp3s-lgvl-e8701195e66f2d27ffe17fb514eae8173795aaf7.zip
Initial commit
Diffstat (limited to 'buildroot/bin')
-rw-r--r--buildroot/bin/.gitattributes1
-rw-r--r--buildroot/bin/format_code30
-rw-r--r--buildroot/bin/generate_version144
-rw-r--r--buildroot/bin/opt_add3
-rw-r--r--buildroot/bin/opt_disable13
-rw-r--r--buildroot/bin/opt_enable13
-rw-r--r--buildroot/bin/opt_set12
-rw-r--r--buildroot/bin/pins_set11
-rw-r--r--buildroot/bin/restore_configs5
-rw-r--r--buildroot/bin/uncrust16
-rw-r--r--buildroot/bin/use_example_configs21
11 files changed, 269 insertions, 0 deletions
diff --git a/buildroot/bin/.gitattributes b/buildroot/bin/.gitattributes
new file mode 100644
index 0000000..6313b56
--- /dev/null
+++ b/buildroot/bin/.gitattributes
@@ -0,0 +1 @@
+* text=auto eol=lf
diff --git a/buildroot/bin/format_code b/buildroot/bin/format_code
new file mode 100644
index 0000000..8ae04b1
--- /dev/null
+++ b/buildroot/bin/format_code
@@ -0,0 +1,30 @@
+#!/usr/bin/env bash
+#
+# format_code [dir/file...]
+#
+
+HERE=`dirname $0`
+
+while [[ $# -gt 0 ]]; do
+
+ val="$1"
+
+ if [ -d "$val" ]; then
+
+ find $val -name *.cpp -exec "$HERE/uncrust" '{}' \;
+
+ elif [ -d "./Marlin/src/$val" ]; then
+
+ find "./Marlin/src/$val" -name *.cpp -exec "$HERE/uncrust" '{}' \;
+
+ elif [ -f "./Marlin/src/$val" ]; then
+
+ uncrust "./Marlin/src/$val"
+
+ elif [ -f "$val" ]; then
+
+ uncrust "$val"
+
+ fi
+
+done
diff --git a/buildroot/bin/generate_version b/buildroot/bin/generate_version
new file mode 100644
index 0000000..b88e3de
--- /dev/null
+++ b/buildroot/bin/generate_version
@@ -0,0 +1,144 @@
+#!/usr/bin/env bash
+#
+# generate_version
+#
+# Make a Version.h file to accompany CUSTOM_VERSION_FILE
+#
+
+DIR=${1:-"Marlin"}
+
+# MRCC3=$( git merge-base HEAD upstream/bugfix-2.0.x 2>/dev/null )
+# MRCC2=$( git merge-base HEAD upstream/bugfix-1.1.x 2>/dev/null )
+# MRCC1=$( git merge-base HEAD upstream/1.1.x 2>/dev/null )
+
+# BASE='?'
+# if [[ -n $MRCC3 && $MRCC3 != $MRCC2 ]]; then
+# BASE=bugfix-2.0.x
+# elif [[ -n $MRCC2 ]]; then
+# BASE=bugfix-1.1.x
+# elif [[ -n $MRCC1 ]]; then
+# BASE=1.1.x
+# fi
+
+BUILDATE=$(date '+%s')
+DISTDATE=$(date '+%Y-%m-%d %H:%M')
+
+BRANCH=$(git -C "${DIR}" symbolic-ref -q --short HEAD)
+VERSION=$(git -C "${DIR}" describe --tags --first-parent 2>/dev/null)
+
+[ -z "${BRANCH}" ] && BRANCH=$(echo "${TRAVIS_BRANCH}")
+[ -z "${VERSION}" ] && VERSION=$(git -C "${DIR}" describe --tags --first-parent --always 2>/dev/null)
+
+SHORT_BUILD_VERSION=$(echo "${BRANCH}")
+DETAILED_BUILD_VERSION=$(echo "${BRANCH}-${VERSION}")
+
+# Gets some misc options from their defaults
+DEFAULT_MACHINE_UUID=$(awk -F'"' \
+ '/#define DEFAULT_MACHINE_UUID/{ print $2 }' < "${DIR}/Version.h")
+MACHINE_NAME=$(awk -F'"' \
+ '/#define MACHINE_NAME/{ print $2 }' < "${DIR}/Version.h")
+PROTOCOL_VERSION=$(awk -F'"' \
+ '/#define PROTOCOL_VERSION/{ print $2 }' < "${DIR}/Version.h")
+SOURCE_CODE_URL=$(awk -F'"' \
+ '/#define SOURCE_CODE_URL/{ print $2 }' < "${DIR}/Version.h")
+WEBSITE_URL=$(awk -F'"' \
+ '/#define WEBSITE_URL/{ print $2 }' < "${DIR}/Version.h")
+
+cat > "${DIR}/Version.h" <<EOF
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+#pragma once
+
+/**
+ * THIS FILE IS AUTOMATICALLY GENERATED DO NOT MANUALLY EDIT IT.
+ * IT DOES NOT GET COMMITTED TO THE REPOSITORY.
+ *
+ * Branch: ${BRANCH}
+ * Version: ${VERSION}
+ */
+
+/**
+ * Marlin release version identifier
+ */
+#ifndef SHORT_BUILD_VERSION
+ #define SHORT_BUILD_VERSION "${SHORT_BUILD_VERSION}"
+#endif
+
+/**
+ * Verbose version identifier which should contain a reference to the location
+ * from where the binary was downloaded or the source code was compiled.
+ */
+#ifndef DETAILED_BUILD_VERSION
+ #define DETAILED_BUILD_VERSION "${DETAILED_BUILD_VERSION}"
+#endif
+
+/**
+ * The STRING_DISTRIBUTION_DATE represents when the binary file was built,
+ * here we define this default string as the date where the latest release
+ * version was tagged.
+ */
+#ifndef STRING_DISTRIBUTION_DATE
+ #define STRING_DISTRIBUTION_DATE "${DISTDATE}"
+#endif
+
+/**
+ * The protocol for communication to the host. Protocol indicates communication
+ * standards such as the use of ASCII, "echo:" and "error:" line prefixes, etc.
+ * (Other behaviors are given by the firmware version and capabilities report.)
+ */
+#ifndef PROTOCOL_VERSION
+ #define PROTOCOL_VERSION "${PROTOCOL_VERSION}"
+#endif
+
+/**
+ * Defines a generic printer name to be output to the LCD after booting Marlin.
+ */
+#ifndef MACHINE_NAME
+ #define MACHINE_NAME "${MACHINE_NAME}"
+#endif
+
+/**
+ * The SOURCE_CODE_URL is the location where users will find the Marlin Source
+ * Code which is installed on the device. In most cases —unless the manufacturer
+ * has a distinct Github fork— the Source Code URL should just be the main
+ * Marlin repository.
+ */
+#ifndef SOURCE_CODE_URL
+ #define SOURCE_CODE_URL "${SOURCE_CODE_URL}"
+#endif
+
+/**
+ * Default generic printer UUID.
+ */
+#ifndef DEFAULT_MACHINE_UUID
+ #define DEFAULT_MACHINE_UUID "${DEFAULT_MACHINE_UUID}"
+#endif
+
+/**
+ * The WEBSITE_URL is the location where users can get more information such as
+ * documentation about a specific Marlin release.
+ */
+#ifndef WEBSITE_URL
+ #define WEBSITE_URL "${WEBSITE_URL}"
+#endif
+
+EOF
diff --git a/buildroot/bin/opt_add b/buildroot/bin/opt_add
new file mode 100644
index 0000000..2306ebd
--- /dev/null
+++ b/buildroot/bin/opt_add
@@ -0,0 +1,3 @@
+#!/usr/bin/env bash
+
+eval "echo '#define ${@}' | cat - Marlin/Configuration.h > temp && mv temp Marlin/Configuration.h"
diff --git a/buildroot/bin/opt_disable b/buildroot/bin/opt_disable
new file mode 100644
index 0000000..1152613
--- /dev/null
+++ b/buildroot/bin/opt_disable
@@ -0,0 +1,13 @@
+#!/usr/bin/env bash
+
+# exit on first failure
+set -e
+
+SED=$(which gsed || which sed)
+
+for opt in "$@" ; do
+ # Logic for returning nonzero based on answer here: https://stackoverflow.com/a/15966279/104648
+ eval "${SED} -i '/\([[:blank:]]*\)\(\/\/\)*\([[:blank:]]*\)\(#define \b${opt}\b\)/{s//\1\3\/\/\4/;h};\${x;/./{x;q0};x;q9}' Marlin/Configuration.h" ||
+ eval "${SED} -i '/\([[:blank:]]*\)\(\/\/\)*\([[:blank:]]*\)\(#define \b${opt}\b\)/{s//\1\3\/\/\4/;h};\${x;/./{x;q0};x;q9}' Marlin/Configuration_adv.h" ||
+ (echo "ERROR: opt_disable Can't find ${opt}" >&2 && exit 9)
+done
diff --git a/buildroot/bin/opt_enable b/buildroot/bin/opt_enable
new file mode 100644
index 0000000..96686d6
--- /dev/null
+++ b/buildroot/bin/opt_enable
@@ -0,0 +1,13 @@
+#!/usr/bin/env bash
+
+# exit on first failure
+set -e
+
+SED=$(which gsed || which sed)
+
+for opt in "$@" ; do
+ # Logic for returning nonzero based on answer here: https://stackoverflow.com/a/15966279/104648
+ eval "${SED} -i '/\(\/\/\)*[[:blank:]]*\(#define \b${opt}\b\)/{s//\2/;h};\${x;/./{x;q0};x;q9}' Marlin/Configuration.h" ||
+ eval "${SED} -i '/\(\/\/\)*[[:blank:]]*\(#define \b${opt}\b\)/{s//\2/;h};\${x;/./{x;q0};x;q9}' Marlin/Configuration_adv.h" ||
+ (echo "ERROR: opt_enable Can't find ${opt}" >&2 && exit 9)
+done
diff --git a/buildroot/bin/opt_set b/buildroot/bin/opt_set
new file mode 100644
index 0000000..a646e09
--- /dev/null
+++ b/buildroot/bin/opt_set
@@ -0,0 +1,12 @@
+#!/usr/bin/env bash
+
+# exit on first failure
+set -e
+
+SED=$(which gsed || which sed)
+
+# Logic for returning nonzero based on answer here: https://stackoverflow.com/a/15966279/104648
+eval "${SED} -i '/\(\/\/\)*\([[:blank:]]*\)\(#define\s\+\b${1}\b\).*$/{s//\2\3 ${2}/;h};\${x;/./{x;q0};x;q9}' Marlin/Configuration.h" ||
+eval "${SED} -i '/\(\/\/\)*\([[:blank:]]*\)\(#define\s\+\b${1}\b\).*$/{s//\2\3 ${2}/;h};\${x;/./{x;q0};x;q9}' Marlin/Configuration_adv.h" ||
+eval "echo '#define ${@}' >>Marlin/Configuration_adv.h" ||
+(echo "ERROR: opt_set Can't set or add ${1}" >&2 && exit 9)
diff --git a/buildroot/bin/pins_set b/buildroot/bin/pins_set
new file mode 100644
index 0000000..87a8692
--- /dev/null
+++ b/buildroot/bin/pins_set
@@ -0,0 +1,11 @@
+#!/usr/bin/env bash
+
+IFS='/' read -r -a PINPATH <<< "$1"
+DIR=${PINPATH[0]}
+NAM=${PINPATH[1]}
+PIN=$2
+VAL=$3
+
+SED=$(which gsed || which sed)
+eval "${SED} -i '/\(\/\/\)*\(#define \+${PIN}\b\).*$/{s//\2 ${VAL}/;h};\${x;/./{x;q0};x;q9}' Marlin/src/pins/$DIR/pins_${NAM}.h" ||
+(echo "ERROR: pins_set Can't find ${PIN}" >&2 && exit 9)
diff --git a/buildroot/bin/restore_configs b/buildroot/bin/restore_configs
new file mode 100644
index 0000000..b2d0ea1
--- /dev/null
+++ b/buildroot/bin/restore_configs
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+
+git checkout Marlin/Configuration*.h 2>/dev/null
+git checkout Marlin/src/pins/ramps/pins_RAMPS.h 2>/dev/null
+rm -f Marlin/_Bootscreen.h Marlin/_Statusscreen.h
diff --git a/buildroot/bin/uncrust b/buildroot/bin/uncrust
new file mode 100644
index 0000000..9893b5c
--- /dev/null
+++ b/buildroot/bin/uncrust
@@ -0,0 +1,16 @@
+#!/usr/bin/env bash
+#
+# Run uncrustify for a file in-place
+#
+
+TMPDIR=`mktemp -d`
+
+# Reformat a single file to tmp/
+uncrustify -l CPP -c ./buildroot/share/extras/uncrustify.cfg -f "$1" >$TMPDIR/uncrustify.out
+
+# Replace the original file
+cp "$TMPDIR/uncrustify.out" "$1"
+
+# Clean up, deliberately
+rm "$TMPDIR/uncrustify.out"
+rmdir "$TMPDIR"
diff --git a/buildroot/bin/use_example_configs b/buildroot/bin/use_example_configs
new file mode 100644
index 0000000..83c0f54
--- /dev/null
+++ b/buildroot/bin/use_example_configs
@@ -0,0 +1,21 @@
+#!/usr/bin/env bash
+
+IFS=: read -r PART1 PART2 <<< "$@"
+[ -n "${PART2}" ] && { REPO="$PART1" ; RDIR="${PART2// /%20}" ; } \
+ || { REPO=bugfix-2.0.x ; RDIR="${PART1// /%20}" ; }
+EXAMPLES="https://raw.githubusercontent.com/MarlinFirmware/Configurations/$REPO/config/examples"
+
+which curl >/dev/null && TOOL='curl -L -s -S -f -o wgot'
+which wget >/dev/null && TOOL='wget -q -O wgot'
+
+restore_configs
+
+cd Marlin
+
+$TOOL "$EXAMPLES/$RDIR/Configuration.h" >/dev/null 2>&1 && mv wgot Configuration.h
+$TOOL "$EXAMPLES/$RDIR/Configuration_adv.h" >/dev/null 2>&1 && mv wgot Configuration_adv.h
+$TOOL "$EXAMPLES/$RDIR/_Bootscreen.h" >/dev/null 2>&1 && mv wgot _Bootscreen.h
+$TOOL "$EXAMPLES/$RDIR/_Statusscreen.h" >/dev/null 2>&1 && mv wgot _Statusscreen.h
+
+rm -f wgot
+cd - >/dev/null