forked from Moo-Ack-Productions/MCprep
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompile.sh
executable file
·130 lines (105 loc) · 2.76 KB
/
compile.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/usr/bin/env bash
#
# Compile the addon into a zip and install into blender (if available).
# Will install into blender if addons paths defined by blender_installs.txt
# which should have a path that ends in e.g. Blender/2.90/scripts/addons
# To skip zipping and do a fast reload
if [ -z "$1" ] || [ "$1" != "-fast" ]
then
echo "Running a slow compile"
FAST_RELOAD=false
else
echo "Running a fast compile"
FAST_RELOAD=true
fi
NAME=MCprep_addon
BLENDER_INSTALLS=blender_installs.txt
# Remove left over files in the build folder, but leaves the zip.
function clean(){
echo "Cleaning build folder"
rm -r build/$NAME/
}
# Create a local build zip of the local addon.
function build() {
# If fast reloading, don't clean up old files.
# if [ "$FAST_RELOAD" = false ]
# then
# clean
# fi
clean
# Create the build dir as needed
if [ ! -d build ]
then
mkdir -p build
fi
mkdir -p build/$NAME
# Specific files and subfolders to copy into the MCprep build
echo "Creating local build"
cp $NAME/*.py build/$NAME/
cp $NAME/*.txt build/$NAME/
cp -r $NAME/icons build/$NAME/
cp -r $NAME/materials build/$NAME/
cp -r $NAME/spawner build/$NAME/
if [ "$FAST_RELOAD" = false ]
then
echo "Copying resources and building zip"
# These resources are the most intense to reload, so don't do if 'fast'
cp -r $NAME/MCprep_resources build/$NAME/
# Making the zip with all the sub files is also slow.
cd build
rm $NAME.zip # Compeltely remove old version (else it's append/replace)
zip $NAME.zip -rq $NAME
cd ../
fi
}
# Autogenerate the blender_installs.txt file if missing,
# populating the highest versions of blender in the file first.
# Note: For every version of blender included, one install will be made
# and potentially tested by run_tests.sh.
function detect_installs() {
if [ ! -f "$BLENDER_INSTALLS" ]
then
echo "Generating new $BLENDER_INSTALLS"
if [ "$(uname)" == "Darwin" ]
then
# Add all
ls -rd -- /Users/*/Library/Application\ Support/Blender/*/scripts/addons/ > $BLENDER_INSTALLS
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]
then
echo "TODO support platform, manually populate"
exit
else
echo "Unsupported platform, manually populate"
exit
fi
else
echo "Loading installs from $BLENDER_INSTALLS"
fi
}
# Install the addon to this path
function install_path(){
i=$1
if [ "$FAST_RELOAD" = false ]
then
# echo "Remove prior: $i/$NAME/"
# ls "$i/$NAME/"
rm -r "$i/$NAME/"
fi
mkdir -p "$i/$NAME"
cp -R build/$NAME "$i/"
echo "Installed at: $i/"
}
function install_all(){
# Load in all target blender version(s)
IFS=$'\n' read -d '' -r -a lines < $BLENDER_INSTALLS
for i in "${lines[@]}"
do
install_path "$i"
done
}
# Main build calls.
detect_installs
build
install_all
clean
echo "Reloaded addon"