revolver

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

build.sh (1681B)


      1 #!/usr/bin/env bash
      2 
      3 set -e
      4 
      5 sources=(./examples/test.c)
      6 
      7 for arg in "$@"
      8 do
      9     case ${arg} in
     10         "events") sources=(./examples/events.c) ;;
     11         "test")   sources=(./examples/test.c)   ;;
     12         "uniform")   sources=(./examples/uniform.c)   ;;
     13         "simple_triangle")   sources=(./examples/simple_triangle.c)   ;;
     14         "simple_texture")   sources=(./examples/simple_texture.c)   ;;
     15         "hello_window")   sources=(./examples/hello_window.c)   ;;
     16         "instancing")   sources=(./examples/instancing.c)   ;;
     17         "bump_cache")   sources=(./examples/bump_cache.c)   ;;
     18         "idraw2d")   sources=(./examples/idraw2d.c)   ;;
     19         "tex_load")   sources=(./examples/tex_load.c)   ;;
     20     esac
     21 done
     22 
     23 if [ "$1" = "events" ]; then
     24     sources=(./examples/events.c)
     25 fi
     26 
     27 output=(./bin/App)
     28 CC="clang"
     29 compiler_flags=(
     30     -g
     31     -O0
     32     #-march=native -ffast-math
     33 
     34     -Wall
     35     -Wno-missing-braces -Wno-nan-infinity-disabled -Wno-unused-function -Wno-unused-variable -Wno-unused-but-set-variable -Wno-initializer-overrides -Wfatal-errors
     36 
     37     -std=c11
     38 
     39     -Isrc/
     40 
     41     #-DRV_WIN_X11=0
     42     -D_GNU_SOURCE=1
     43 )
     44 common_flags=(
     45     -fsanitize=address,float-divide-by-zero,float-cast-overflow -fno-sanitize=null,alignment -fno-sanitize-recover=all -fno-omit-frame-pointer
     46 )
     47 linker_flags=(
     48     -lm
     49     -lxcb -lxcb-xkb -lEGL -lGL
     50     #-lX11 -lXi
     51     -fuse-ld=mold
     52 )
     53 
     54 mkdir -p $(dirname "${output}")
     55 
     56 echo "Compiling..."
     57 ${CC} ${compiler_flags[*]} ${common_flags[*]} ${sources[*]}  ${linker_flags[*]} -o ${output}
     58 echo "Done"
     59 
     60 
     61 for arg in "$@"
     62 do
     63     if [ ${arg} = "run" ]; then
     64         echo "Running"
     65         pushd examples
     66         ../${output}
     67         popd
     68     fi
     69 done