.PHONY: run build doc png test1 test2 tests help json json-errors runPdf doc-serve \
demo-cluster reinstall-mdbook run_1 run_2 run_3 run_4 demo-expand show-report clean
.DEFAULT: help
include scripts/colorprint
sandbox:=sandbox
srcdir:=demo_projects
my_C_tool:=yamake/target/debug/examples/c_project_demo
expand_demo:=yamake/target/debug/examples/expand_demo
my_Pdf_tool:=yamake/target/debug/examples/Latex_demo_project
help:
@echo "Available commands:"
@grep -E '^[ a-zA-Z_0-9-]+:.*?## .*$$' Makefile | awk 'BEGIN {FS = ":.*?## "}; {printf "$(Red)%-20s$(Color_Off) : $(Blue)%s$(Color_Off)\n", $$1, $$2}'
run_1: build
@rm -rf $(sandbox)
@mkdir -p $(sandbox)
@git checkout HEAD -- demo_projects
@printf "\n$(White)$(On_Blue)run yamake tool to build the C program$(Color_Off)\n"
$(my_C_tool) $(srcdir) $(sandbox)
@printf "\n$(White)$(On_Blue)run the compiled program$(Color_Off)\n"
@./$(sandbox)/project_C/demo
@printf "\n$(White)$(On_Blue)end of run$(Color_Off)\n"
@cp $(sandbox)/make-report.json doc/src/make-reports/run_1.json
run_2: build
@rm -rf $(sandbox)
@mkdir -p $(sandbox)
@git checkout HEAD -- demo_projects
@printf "\n$(White)$(On_Blue)run yamake tool to build the C program$(Color_Off)\n"
$(my_C_tool) $(srcdir) $(sandbox)
@printf "\n$(White)$(On_Blue)delete add.o, build again$(Color_Off)\n"
rm $(sandbox)/project_C/add.o
$(my_C_tool) $(srcdir) $(sandbox)
@printf "\n$(White)$(On_Blue)end of run$(Color_Off)\n"
@cp $(sandbox)/make-report.json doc/src/make-reports/run_2.json
run_3: build
@rm -rf $(sandbox)
@mkdir -p $(sandbox)
@git checkout HEAD -- demo_projects
@printf "\n$(White)$(On_Blue)run yamake tool to build the C program$(Color_Off)\n"
$(my_C_tool) $(srcdir) $(sandbox)
@printf "\n$(White)$(On_Blue)add a comment$(Color_Off)\n"
echo "// a C comment " >> $(srcdir)/project_C/add.c
$(my_C_tool) $(srcdir) $(sandbox)
@printf "\n$(White)$(On_Blue)end of run$(Color_Off)\n"
@cp $(sandbox)/make-report.json doc/src/make-reports/run_3.json
run_4: build
@rm -rf $(sandbox)
@mkdir -p $(sandbox)
@git checkout HEAD -- demo_projects
@printf "\n$(White)$(On_Blue)run yamake tool to build the C program$(Color_Off)\n"
$(my_C_tool) $(srcdir) $(sandbox)
@printf "\n$(White)$(On_Blue)add a comment$(Color_Off)\n"
echo "blah blah " >> $(srcdir)/project_C/add.c
$(my_C_tool) $(srcdir) $(sandbox)
@printf "\n$(White)$(On_Blue)end of run$(Color_Off)\n"
@cp $(sandbox)/make-report.json doc/src/make-reports/run_4.json
run : build
@mkdir -p $(sandbox)
@printf "\n$(White)$(On_Blue)run yamake tool to build the C program$(Color_Off)\n"
$(my_C_tool) $(srcdir) $(sandbox)
@printf "\n$(White)$(On_Blue)run the compiled program$(Color_Off)\n"
./$(sandbox)/project_C/demo
@printf "\n$(White)$(On_Blue)end of run$(Color_Off)\n"
runPdf : build
@mkdir -p $(sandbox)
@printf "\n$(White)$(On_Blue)run yamake tool to build the Pdf doc generator$(Color_Off)\n"
$(my_Pdf_tool) --nb-workers 1 $(srcdir) $(sandbox)
@printf "\n$(White)$(On_Blue)run the tool to build the pdf$(Color_Off)\n"
ls -l $(sandbox)/project_latex/*.pdf
@printf "\n$(White)$(On_Blue)end of run$(Color_Off)\n"
test1 : build
$(my_C_tool) $(srcdir) $(sandbox) && \
rm $(sandbox)/project_C/demo && \
$(my_C_tool) $(srcdir) $(sandbox) && \
ls $(sandbox)/project_C/demo
test2 : build
$(my_C_tool) $(srcdir) $(sandbox) && \
rm $(sandbox)/project_C/main.o && \
$(my_C_tool) $(srcdir) $(sandbox) && \
ls $(sandbox)/project_C/demo
test_pdf : build
test: build
echo "" > yamake.log
cargo fmt && cargo test ${args}
png : run
@printf "$(Blue)when running$(Color_Off) $(Red)our demo tool$(Color_Off)$(Blue), dot files of the build graph are generated$(Color_Off) => use graphviz to get png files\n"
dot -Tpng -o $(sandbox)/before-scan.png $(sandbox)/before-scan.dot
dot -Tpng -o $(sandbox)/after-scan.png $(sandbox)/after-scan.dot
cp $(sandbox)/*scan.png doc/src/howto/.
build:
@printf "\n$(White)$(On_Blue)build the demo$(Color_Off)\n"
( cargo fmt && cargo build --examples )
@printf "finished building\n"
clean:
rm -rf $(sandbox)
mkdir $(sandbox)
show-report:
jq ".items[] | { target:.target,status:.status}" $(sandbox)/make-report.json
show-errors:
@printf "\n$(White)$(On_Blue)use make-report.json to find error and print relevant logs$(Color_Off)\n"
@sandbox=$(shell jq '.sandbox ' $(sandbox)/make-report.json) ;\
srcdir=$(shell jq '.srcdir ' $(sandbox)/make-report.json) ;\
stdoutfiles=$(shell jq '.items[] | select(.status == "Failed") | .stdout ' $(sandbox)/make-report.json) ; \
stderrfiles=$(shell jq '.items[] | select(.status == "Failed") | .stderr ' $(sandbox)/make-report.json) ; \
for f in $$stdoutfiles ; do \
echo "----------- stdout " ; \
echo "ERROR while building target ${Red}$$f${Color_Off}" ; \
echo "----------- " ; \
cat $$sandbox/$$f | sed "s#$$sandbox#$$srcdir#g" ; \
echo "----------- end stdout" ; \
done ; \
for f in $$stderrfiles ; do \
echo "----------- stderr " ; \
echo "ERROR while building target ${Red}$$f${Color_Off}" ; \
echo "----------- " ; \
cat $$sandbox/$$f | sed "s#$$sandbox#$$srcdir#g" ; \
echo "----------- end stderr" ; \
done ; \
echo "\n$(White)$(On_Blue)end show-errors$(Color_Off)\n"
reinstall-mdbook:
cargo install mdbook@0.5.2 --force
cargo install mdbook-mermaid --force
cargo install mdbook-admonish --force
cargo install mdbook-toc --force
doc-serve:
cd doc && mdbook serve
demo-expand: build
@rm -rf $(sandbox)
@mkdir -p $(sandbox)
@git checkout HEAD -- demo_projects
@printf "\n$(White)$(On_Blue)run the builder$(Color_Off)\n" && \
$(expand_demo) $(srcdir) $(sandbox) && \
printf "\n$(White)$(On_Blue)run the builded demo program$(Color_Off)\n" && \
./$(sandbox)/demo_expand/demo && \
printf "\n$(White)$(On_Blue)end of run$(Color_Off)\n" && \
cp $(sandbox)/make-report.json doc/src/make-reports/run_1.json