-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·74 lines (60 loc) · 1.81 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
#!/bin/bash
compiled_resources=(
render/shaders/*.wgsl
)
# redirect all stdout to stderr
exec 1>&2
build_dir="build"
if [ "${CMAKE_BUILD_TYPE,,}" = "release" ]; then
build_dir="build_rel"
fi
target="$1"
if [ -z "$target" ]; then target="client"; fi
if [ "$target" = "clean" ]; then
echo "Cleaning build directory \"$build_dir\"..."
rm -r "$build_dir"
echo "Cleaning ${#compiled_resources[@]} compiled resources..."
for file in "${compiled_resources[@]}"; do
rm "${file}.h"
done
target="client"
fi
procs=$(nproc)
./generate_git_version.sh
if [ ! -d "$build_dir" ]; then
echo "Creating build directory \"$build_dir\"..."
mkdir "$build_dir"
fi
# validate shaders
if ! [ -z "$(which naga)" ]; then
echo "Validating shaders with naga-cli"
naga --bulk-validate render/shaders/*.wgsl || exit 1
fi
# compile resources
compiled_resources_total=0
compiled_resources_up_to_date=0
for file in "${compiled_resources[@]}"; do
((++compiled_resources_total))
result=$(./compile_resource_to_raw_string.sh "$file")
if grep -Fq "up to date" <<< "$result"; then
((++compiled_resources_up_to_date))
fi
done
echo "Compiled resources: $((compiled_resources_total - compiled_resources_up_to_date)) updated, $compiled_resources_up_to_date up to date ($compiled_resources_total total)"
cd "$build_dir"
ccache="$(which ccache)"
if [ -n "$ccache" ]; then
echo "CCache enabled"
export EM_COMPILER_WRAPPER="$ccache"
fi
if [ ! -f "Makefile" ] || [ "../CMakeLists.txt" -nt "Makefile" ]; then
echo "Running CMAKE to generate Makefile..."
emcmake cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 .. || exit 1
fi
echo "Running make..."
#emmake make -j"$procs" VERBOSE=1 "$target" || exit 1
emmake make -j"$procs" "$target" || exit 1
#echo "Assembling resources..."
#cd ..
#rsync -ar --progress "resources/"* "$build_dir/"
echo "Done."