#!/bin/sh # Build cgit for development and debugging. The sanitizers stop the program at # a memory error or undefined behaviour, which makes it slow, so the result is # for testing rather than serving. With clang it also leaves a compilation # database in build/ for a language server, and with ctags a tags file there. # # Any arguments go on to make, the way Lua flags do where pkg-config cannot # find Lua: # # ./tools/build-development.sh LUA_PKGCONFIG=luajit # # Going back to a normal build takes make cleanall first. set -eu cd "$(dirname "$0")/.." # The build starts from clean so the bundled git objects pick up the same # flags, and cleanall rather than clean because only cleanall descends into # vendor/git. make cleanall make "$@" CFLAGS="-O0 -g3" DEVELOPER=1 SANITIZE=address,undefined \ GENERATE_COMPILATION_DATABASE=yes # clang writes one entry per object under vendor/git/compile_commands, each # ending in a comma, so they are joined into one array. cgit's are named after # ../../build, which a shell glob would pass over as hidden. if test -d vendor/git/compile_commands then find vendor/git/compile_commands -name '*.json' -exec cat {} + | sed -e '1s/^/[/' -e '$s/,$/]/' >build/compile_commands.json test -s build/compile_commands.json || rm -f build/compile_commands.json fi if command -v ctags >/dev/null then make tags fi