Compile all parts in project, optionally using GNU parallel if available.

This commit is contained in:
Matt McWilliams 2023-08-21 19:04:39 -04:00
parent 98e1e73163
commit de6f0d0495
10 changed files with 45 additions and 28 deletions

View File

@ -1,5 +1,5 @@
{
"version": "1.8.3",
"version": "1.8.4",
"ext_port": 1111,
"profiles": {
"mcopy": {

2
app/package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "mcopy-app",
"version": "1.8.3",
"version": "1.8.4",
"lockfileVersion": 2,
"requires": true,
"packages": {

View File

@ -1,6 +1,6 @@
{
"name": "mcopy-app",
"version": "1.8.3",
"version": "1.8.4",
"description": "GUI for the mcopy small gauge film optical printer platform",
"main": "main.js",
"scripts": {

View File

@ -1,5 +1,5 @@
{
"version": "1.8.3",
"version": "1.8.4",
"ext_port": 1111,
"profiles": {
"mcopy": {

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "mcopy",
"version": "1.8.3",
"version": "1.8.4",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "mcopy",
"version": "1.8.3",
"version": "1.8.4",
"license": "MIT",
"dependencies": {
"arduino": "file:app/lib/arduino",

View File

@ -1,6 +1,6 @@
{
"name": "mcopy",
"version": "1.8.3",
"version": "1.8.4",
"description": "Small gauge film optical printer platform",
"main": "build.js",
"directories": {

View File

@ -1,5 +1,5 @@
{
"version": "1.8.3",
"version": "1.8.4",
"ext_port": 1111,
"profiles": {
"mcopy": {

17
scripts/common.sh Normal file
View File

@ -0,0 +1,17 @@
#!/bin/bash
listParts () {
cat "${1}" | grep 'PART ==' | grep -v 'debug' | awk -F'"' '{print $2}'
}
allParts () {
PARTS=($(listParts "scad/${1}.scad"))
for part in "${PARTS[@]}"; do
bash ./scripts/openscadPart.sh "${1}.scad" "${part}" "${1}_${part}.stl"
done
}
parallelParts () {
PARTS=($(listParts "scad/${1}.scad"))
parallel --use-cpus-instead-of-cores bash ./scripts/openscadPart.sh "${1}.scad" "{}" "${1}_{}.stl" ::: "${PARTS[@]}"
}

8
scripts/openscadPart.sh Normal file
View File

@ -0,0 +1,8 @@
#!/bin/bash
openscad -o "./stl/${3}" -D"PART=\"${2}\"" "./scad/${1}"
echo "Compiled ${3} from ${1}"
if [ -f "./scad/common/c14n_stl.py" ]; then
python3 ./scad/common/c14n_stl.py "./stl/${3}"
echo "Normalized ${3}"
fi

View File

@ -1,5 +1,7 @@
#!/bin/bash
source ./scripts/common.sh
FILES=(
arri_s
bellows
@ -8,25 +10,11 @@ FILES=(
mcopy_projector
)
openscadPart () {
openscad -o "./stl/${3}" -D"PART=\"${2}\"" "./scad/${1}"
echo "Compiled ${3} from ${1}"
if [ -f "./scad/common/c14n_stl.py" ]; then
python3 ./scad/common/c14n_stl.py "./stl/${3}"
echo "Normalized ${3}"
fi
}
listParts () {
cat "${1}" | grep 'PART ==' | grep -v 'debug' | awk -F'"' '{print $2}'
}
allParts () {
PARTS=($(listParts "scad/${1}.scad"))
for part in "${PARTS[@]}"; do
echo opencadPart "${1}.scad" "${part}" "${1}_${part}.stl"
done
}
PARALLEL=0
HAS_PARALLEL=$(which parallel)
if [[ "${HAS_PARALLEL}" != "" ]]; then
PARALLEL=1
fi
if [[ "${1}" == "all" ]]; then
for file in "${FILES[@]}"; do
@ -34,7 +22,11 @@ if [[ "${1}" == "all" ]]; then
done
else
if [ -f "scad/${1}.scad" ]; then
allParts "${1}"
if [ ${PARALLEL} -eq 1 ]; then
parallelParts "${1}"
else
allParts "${1}"
fi
elif [[ "${1}" != "" ]]; then
echo "File scad/${1}.scad not found"
exit 2