-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.sh
executable file
·99 lines (83 loc) · 2.32 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/bash
#if you have not installed OpenSCAD over package manager, download OpenSCAD (as appImage for example)
#and set 'export OPENSCADBINPATH=<DIRECTORY>/OpenSCAD-***.appImage'
#check if openscad is available
#search in default PATH and then search if OPENSCADBINPATH is set
echo "Check OpenSCAD PATH..."
if [ -x openscad ]
then
echo "OpenSCAD found..."
OPENSCADBINPATH=openscad
else
if [ -z $OPENSCADBINPATH ]
then
echo "OpenSCAD not found! Install OpenSCAD or set 'export OPENSCADBINPATH=path/to/openscad'"
exit 1
else
echo "OpenSCAD PATH is $OPENSCADBINPATH"
fi
fi
#check 1st parameter and set config file
if [ -z $1 ]
then
echo "No parameter given..."
echo "Give Keyboard name as 1st parameter: ./build.sh andimotoXYZ <configfile>"
echo "Do not give scad file extension. 2nd parameter is optional. You can give other conf file to call other modules."
exit 1
else
#set vars
keebcu=$1
scadFile=$keebcu.scad
fi
if [ -z $2 ]
then
confFile=conf/module-calls.conf
else
confFile=$2
fi
echo "scad File: $scadFile"
echo "config File: $confFile"
# get line until print out scad file into temporary scad file
LINE=`grep -n BUILD_LINE $scadFile | cut -d : -f 1`
# get all modules to build
modules=`cat $confFile | grep module | cut -d : -f 2`
echo "************************"
echo "Building:"
for i in $modules; do
echo module: $i
done
echo "************************"
# create temporary directory for build
outputDir=stl/$keebcu
tempDir=temp$RANDOM
mkdir $tempDir
#check output directory exists
if [ -d $outputDir ]
then
echo "Output directory is $outputDir"
else
echo "Creating Output directory $outputDir"
mkdir $outputDir
fi
#copy constants.scad and keyboardParts.scad into tempDir
cp constants.scad $tempDir
cp keyboardParts.scad $tempDir
echo
for i in $modules; do
echo "################### calling module: $i ###################"
head -n $LINE $scadFile > $tempDir/temp$scadFile
echo $i >> $tempDir/temp$scadFile
outputFile=`echo "$i" | cut -d \( -f 1`
outputFile=$keebcu\_$outputFile\.stl
echo $outputFile
$OPENSCADBINPATH -o $outputDir/$outputFile $tempDir/temp$scadFile
if [ $? == 0 ]
then
echo "################### done module: $i ###################"
else
echo "################### error in module: $i ###################"
fi
echo
done
# remove temprary directory
rm -rf $tempDir