citrun

watch C/C++ source code execute
Log | Files | Refs | LICENSE

commit b511a74e86945c875342429c8b1205a5121b289b
parent e724aca2a3416b17b9a9a6966c633cd6de951d18
Author: Kyle Milz <kyle@0x30.net>
Date:   Sat,  7 Oct 2017 01:56:52 -0600

jam: delete some indirection

Diffstat:
MJamfile | 86-------------------------------------------------------------------------------
MJamrules | 131+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------
Mbin/Jamfile | 50++++++++++++++++++++++++++++++++------------------
Mlib/Jamfile | 2++
4 files changed, 135 insertions(+), 134 deletions(-)

diff --git a/Jamfile b/Jamfile @@ -4,89 +4,3 @@ SubInclude TOP bin ; SubInclude TOP lib ; SubInclude TOP man ; SubInclude TOP share citrun ; - -actions PkgConfig -{ - set -e - type pkg-config - echo - - gl_pkgs="osmesa glfw3 glew freetype2" - for pkg in $gl_pkgs; do - echo -n "$pkg = " - pkg-config --modversion $pkg || echo "NOT FOUND" - done -} - -actions C++11 -{ - $(C++) -x c++ -std=c++11 -E - < /dev/null > /dev/null -} - -C++11 check_dependencies ; -PkgConfig check_dependencies ; - -# -# Run clang static analysis on the build. -# -actions Analysis -{ - scan-build --use-c++=eg++ ./configure - scan-build -o html --use-c++=eg++ jam -} - -# -# Get test coverage of integration test suite. -# -actions TestCoverage -{ - set -e - CFLAGS="-coverage" LDFLAGS="-coverage" ./configure - jam - - # Roll libgcov.a into libcitrun.a. - ar -M < t/libcitrun_gcov.mri - - prove - # prove tt - - mkdir gcov - # The output from gcov is valuable to save too. - gcov -o lib lib/lib*.c | tee gcov/SUMMARY - egcov -r bin/*.cc | tee -a gcov/SUMMARY - mv *.gcov gcov/ -} - -# -# Use C It Run on itself. -# -actions CCItRunRun -{ - set -e - - # - # Namespace global instrumentation variables such that they don't - # collide with the actual instrumentation. - # - sed -i \ - -e "s,struct citrun_node,struct ccitrunrun_node," \ - -e "s,citrun_node_add,ccitrunrun_node_add," \ - -e "s,citrun_major,ccitrunrun_major,g" \ - -e "s,citrun_minor,ccitrunrun_minor,g" \ - lib.h lib.c inst_action.cc inst_fe.cc gl_procfile.cc - - # - # Change binary names so we can do a side by side installation. - # - sed -i \ - -e "s,citrun_inst,ccitrunrun_inst," \ - -e "s,citrun_term,ccitrunrun_term," \ - -e "s,citrun_gl,ccitrunrun_gl," \ - -e "s,libcitrun,libccitrunrun," \ - Jamfile lib.c inst_main.cc - jam -} - -Analysis analysis ; -TestCoverage coverage ; -CCItRunRun ccitrunrun ; diff --git a/Jamrules b/Jamrules @@ -4,13 +4,14 @@ echo ░▀▀▀░░░▀▀▀░░▀░░░░▀░▀░▀▀▀░ echo ; PREFIX ?= `pwd` ; -CC = clang ; -C++ = clang++ ; +CC = $(CC:E=clang) ; +C++ = $(CXX:E=clang++) ; echo PREFIX \= $(PREFIX) ; echo CC \= $(CC) ; echo C++ \= $(C++) ; echo CFLAGS \= $(CFLAGS) ; +echo LDFLAGS \= $(LDFLAGS) ; echo ; if $(OS) = "OPENBSD" { @@ -43,34 +44,6 @@ C++FLAGS += $(CFLAGS) -Wall -W -Wcast-qual LINKFLAGS += $(LDFLAGS) ; -GL_CFLAGS = `pkg-config --cflags glfw3 glew freetype2` ; -GL_LIBS = $(GL_EXTRALIB) `pkg-config --libs glfw3 glew freetype2` ; -GLTEST_LIBS = `pkg-config --libs osmesa` ; - -INST_CFLAGS = `llvm-config --cxxflags` ; -INST_LDFLAGS = -nopie ; - -INST_LIBS = - `llvm-config --ldflags` - $(INST_EXTRALIB) - -lclangTooling - -lclangFrontendTool - -lclangFrontend - -lclangDriver - -lclangSerialization - -lclangCodeGen - -lclangParse - -lclangSema - -lclangAnalysis - -lclangRewrite - -lclangRewriteFrontend - -lclangEdit - -lclangAST - -lclangLex - -lclangBasic - `llvm-config --system-libs --libs bitreader mcparser transformutils option` - ; - # Quote an entire file and add a variable declaration prefixing the string. rule Stringize { @@ -86,3 +59,101 @@ actions Stringize >> $(<) cat $(>) >> $(<) echo ")\";" } + +actions ReplacePrefix { + sed -i -e "s, PREFIX ,$(PREFIX)," $(<) +} + +actions PkgConfig +{ + set -e + type pkg-config + echo + + gl_pkgs="osmesa glfw3 glew freetype2" + for pkg in $gl_pkgs; do + echo -n "$pkg = " + pkg-config --modversion $pkg || echo "NOT FOUND" + done +} + +actions C++11 +{ + $(C++) -x c++ -std=c++11 -E - < /dev/null > /dev/null +} + +C++11 check_dependencies ; +PkgConfig check_dependencies ; + +# +# Run clang static analysis on the build. +# +actions Analysis +{ + scan-build --use-c++=clang++ -o html jam -j4 +} + +# +# Get test coverage from black box suite. +# +actions TestCoverage +{ + set -e + #CFLAGS="-coverage" LDFLAGS="-coverage" ./configure + #CFLAGS="--coverage" LDFLAGS="--coverage" jam -j4 + CXX=/usr/local/bin/clang++ CFLAGS="-fprofile-instr-generate -fcoverage-mapping" LDFLAGS=${CFLAGS} jam -dx + +exit 1 + # Roll libgcov.a into libcitrun.a. + ar -M < t/libcitrun_gcov.mri + + prove + # prove tt + + mkdir gcov + # The output from gcov is valuable to save too. + gcov -o lib lib/lib*.c | tee gcov/SUMMARY + egcov -r bin/*.cc | tee -a gcov/SUMMARY + mv *.gcov gcov/ +} + +# +# Use C It Run on itself. +# +actions CCItRunRun +{ + set -e + echo + read go?"Target destructively changes source code. Proceed? (y/n) " + + if [ $go != y ]; then + echo Aborting + exit 0 + fi + + # + # Namespace global instrumentation variables such that they don't + # collide with the actual instrumentation. + # + sed -i \ + -e "s,struct citrun_node,struct ccitrunrun_node," \ + -e "s,citrun_node_add,ccitrunrun_node_add," \ + -e "s,citrun_major,ccitrunrun_major,g" \ + -e "s,citrun_minor,ccitrunrun_minor,g" \ + lib.h lib.c inst_action.cc inst_fe.cc gl_procfile.cc + + # + # Change binary names so we can do a side by side installation. + # + sed -i \ + -e "s,citrun_inst,ccitrunrun_inst," \ + -e "s,citrun_term,ccitrunrun_term," \ + -e "s,citrun_gl,ccitrunrun_gl," \ + -e "s,libcitrun,libccitrunrun," \ + Jamfile lib.c inst_main.cc + jam +} + +Analysis analysis ; +TestCoverage coverage ; +CCItRunRun ccitrunrun ; diff --git a/bin/Jamfile b/bin/Jamfile @@ -1,25 +1,20 @@ SubDir TOP bin ; SubDirHdrs $(TOP) lib ; -actions ShellReplace { - sed -e "s, PREFIX ,$(PREFIX)," < $(>) > $(<) - chmod +x $(<) -} - # # citrun_report # -SHELLHEADER = "#!/usr/bin/awk -f" ; +SHELLHEADER on citrun_report = "#!/usr/bin/awk -f" ; MakeLocate citrun_report : bin ; Shell citrun_report : report.awk ; # # citrun_wrap # +SHELLHEADER on citrun_wrap = "#!/bin/sh" ; MakeLocate citrun_wrap : bin ; -Depends all : citrun_wrap ; -Clean clean : citrun_wrap ; -ShellReplace citrun_wrap : wrap.sh ; +Shell citrun_wrap : wrap.sh ; +ReplacePrefix citrun_wrap ; # # citrun_inst @@ -31,12 +26,29 @@ INST_SRCS = inst_action.cc inst_visitor.cc ; -Stringize lib_h.h : lib.h ; - -ObjectC++Flags $(INST_SRCS) : $(INST_CFLAGS) -DPREFIX=\\\"$(PREFIX)\\\" ; - -LINKFLAGS on citrun_inst = $(LINKFLAGS) $(INST_LDFLAGS) ; -LINKLIBS on citrun_inst += $(INST_LIBS) ; +ObjectC++Flags $(INST_SRCS) : `llvm-config --cppflags` -DPREFIX=\\\"$(PREFIX)\\\" ; + +LINKFLAGS on citrun_inst = $(LINKFLAGS) ; +LINKLIBS on citrun_inst += + `llvm-config --ldflags` + $(INST_EXTRALIB) + -lclangTooling + -lclangFrontendTool + -lclangFrontend + -lclangDriver + -lclangSerialization + -lclangCodeGen + -lclangParse + -lclangSema + -lclangAnalysis + -lclangRewrite + -lclangRewriteFrontend + -lclangEdit + -lclangAST + -lclangLex + -lclangBasic + `llvm-config --system-libs --libs bitreader mcparser transformutils option` + ; Main citrun_inst : $(INST_SRCS) ; @@ -61,10 +73,12 @@ Stringize demo_atlas_glsl.h : demo_atlas.glsl ; Stringize demo_vshader_glsl.h : demo_vshader.glsl ; Stringize demo_fshader_glsl.h : demo_fshader.glsl ; -ObjectC++Flags gl_main.cc gltest.cc $(GL_SRCS) : $(GL_CFLAGS) ; +ObjectC++Flags gl_main.cc gltest.cc $(GL_SRCS) : `pkg-config --cflags glfw3 glew freetype2` ; + +LINKLIBS on citrun_gl += -lm $(GL_EXTRALIB) `pkg-config --libs glfw3 glew freetype2` ; +LINKLIBS on citrun_gltest += -lm `pkg-config --libs glfw3 osmesa freetype2` ; +LINKLIBS on citrun_gltest += bin/glew-2.1.0/lib/libGLEW.a ; -LINKLIBS on citrun_gl citrun_gltest += -lm $(GL_LIBS) ; -LINKLIBS on citrun_gltest += $(GLTEST_LIBS) ; LinkLibraries citrun_gl citrun_gltest : gl_common libglyphy ; Main citrun_gl : gl_main.cc ; diff --git a/lib/Jamfile b/lib/Jamfile @@ -1,5 +1,7 @@ SubDir TOP lib ; +Stringize lib_h.h : lib.h ; + ObjectCcFlags lib.c lib_unix.c : -fPIC -ansi ; Library libcitrun : lib.c lib_unix.c ;