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, "ext_port": 1111,
"profiles": { "profiles": {
"mcopy": { "mcopy": {

2
app/package-lock.json generated
View File

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

View File

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

View File

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

4
package-lock.json generated
View File

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

View File

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

View File

@ -1,5 +1,5 @@
{ {
"version": "1.8.3", "version": "1.8.4",
"ext_port": 1111, "ext_port": 1111,
"profiles": { "profiles": {
"mcopy": { "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 #!/bin/bash
source ./scripts/common.sh
FILES=( FILES=(
arri_s arri_s
bellows bellows
@ -8,25 +10,11 @@ FILES=(
mcopy_projector mcopy_projector
) )
openscadPart () { PARALLEL=0
openscad -o "./stl/${3}" -D"PART=\"${2}\"" "./scad/${1}" HAS_PARALLEL=$(which parallel)
echo "Compiled ${3} from ${1}" if [[ "${HAS_PARALLEL}" != "" ]]; then
if [ -f "./scad/common/c14n_stl.py" ]; then PARALLEL=1
python3 ./scad/common/c14n_stl.py "./stl/${3}" fi
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
}
if [[ "${1}" == "all" ]]; then if [[ "${1}" == "all" ]]; then
for file in "${FILES[@]}"; do for file in "${FILES[@]}"; do
@ -34,7 +22,11 @@ if [[ "${1}" == "all" ]]; then
done done
else else
if [ -f "scad/${1}.scad" ]; then if [ -f "scad/${1}.scad" ]; then
allParts "${1}" if [ ${PARALLEL} -eq 1 ]; then
parallelParts "${1}"
else
allParts "${1}"
fi
elif [[ "${1}" != "" ]]; then elif [[ "${1}" != "" ]]; then
echo "File scad/${1}.scad not found" echo "File scad/${1}.scad not found"
exit 2 exit 2