build-all.sh 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #!/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. # This script, build-all.sh, is a simple sanity check that the tests pass and
  17. # the example programs (including fuzz programs) compile.
  18. #
  19. # If you're just looking to get started with Wuffs, running this script isn't
  20. # necessary (as Wuffs doesn't have the "configure; make; make install" dance or
  21. # its equivalent), although studying this script can help you learn how the
  22. # pieces fit together.
  23. #
  24. # For example, this script builds command line tools, such as 'wuffs' and
  25. # 'wuffs-fmt', that are used when *developing* Wuffs, but aren't necessary if
  26. # all you want to do is *use* Wuffs as a third party library. In the latter
  27. # case, the only files you need are those under the release/ directory.
  28. #
  29. # Instead of running this script, you should be able to run the example
  30. # programs (except the 'example/library' special case) out of the box, without
  31. # having to separately configure, build or install a library:
  32. #
  33. # git clone https://github.com/google/wuffs.git
  34. # cd wuffs
  35. # gcc ./example/zcat/zcat.c
  36. # ./a.out < ./test/data/romeo.txt.gz
  37. if [ ! -e release/c/wuffs-unsupported-snapshot.c ]; then
  38. echo "$0 should be run from the Wuffs root directory."
  39. exit 1
  40. fi
  41. CC=${CC:-gcc}
  42. CXX=${CXX:-g++}
  43. go install github.com/google/wuffs/cmd/...
  44. go test github.com/google/wuffs/...
  45. wuffs gen
  46. # Compiler warning flags are discussed at
  47. # http://fastcompression.blogspot.com/2019/01/compiler-warnings.html
  48. WARNING_FLAGS="-Wall -Werror -Wpedantic -Wcast-qual -Wcast-align -Wpointer-arith -Wfloat-equal -Wundef -Wvla -Wconversion"
  49. echo "Checking snapshot compiles cleanly (as C)"
  50. $CC -c $WARNING_FLAGS -std=c99 -Wc++-compat \
  51. release/c/wuffs-unsupported-snapshot.c -o /dev/null
  52. $CC -c $WARNING_FLAGS -DWUFFS_IMPLEMENTATION -std=c99 -Wc++-compat \
  53. release/c/wuffs-unsupported-snapshot.c -o /dev/null
  54. echo "Checking snapshot compiles cleanly (as C++)"
  55. $CXX -c $WARNING_FLAGS -std=c++11 -x c++ \
  56. release/c/wuffs-unsupported-snapshot.c -o /dev/null
  57. $CXX -c $WARNING_FLAGS -DWUFFS_IMPLEMENTATION -std=c++11 -x c++ \
  58. release/c/wuffs-unsupported-snapshot.c -o /dev/null
  59. wuffs genlib -skipgen
  60. wuffs test -skipgen -mimic
  61. wuffs bench -skipgen -mimic -reps=1 -iterscale=1
  62. ./build-example.sh
  63. ./build-fuzz.sh
  64. for f in gen/bin/fuzz-*; do
  65. echo "Running $f"
  66. $f test/data > /dev/null
  67. done