blob: 02905e8940a8d78db2da03033e7c1270f58bed6e [file] [log] [blame]
Nigel Tao4c1826a2018-08-05 21:55:50 +10001#!/bin/bash -eu
2# Copyright 2018 The Wuffs Authors.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# https://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16# ----------------
17
18# See build-all.sh for commentary.
19
20for f in example/*; do
21 echo "Building $f"
22 if [ "$f" = "example/crc32" ]; then
23 # example/crc32 is unusual in that it's C++, not C.
Nigel Tao845ffbe2018-08-05 22:24:03 +100024 g++ -O3 $f/*.cc -o $f/a.out
Nigel Tao4c1826a2018-08-05 21:55:50 +100025 elif [ "$f" = "example/library" ]; then
26 # example/library is unusual in that it uses separately compiled libraries
Nigel Taofce79372018-08-05 22:36:37 +100027 # (built by "wuffs genlib", e.g. by running build-all.sh) instead of
28 # directly #include'ing Wuffs' .c files.
29 if [ -e gen/lib/c/gcc-static/libwuffs.a ]; then
30 gcc -O3 -static -I.. $f/*.c gen/lib/c/gcc-static/libwuffs.a -o $f/a.out
31 else
32 echo " Skipping example/library; run \"wuffs genlib\" first"
33 fi
Nigel Tao4c1826a2018-08-05 21:55:50 +100034 elif [ -e $f/*.c ]; then
Nigel Tao845ffbe2018-08-05 22:24:03 +100035 gcc -O3 $f/*.c -o $f/a.out
Nigel Tao4c1826a2018-08-05 21:55:50 +100036 fi
37done