概念:dependencies, targets, rules
make和Makefile
- 根据modify time确定什么文件需要regenerate
target: prerequisite1 prerequisite2 ...
command1
command2 (需要tab)paper.pdf: paper.tex plot-data.png
pdflatex paper.tex
plot-%.png: %.dat plot.py
./plot.py -i $*.dat -o $@# specify all source files here
SRCS = hw.c helper.c
# specify target here (name of executable)
TARG = hw
# specify compiler, compile flags, and needed libs
CC = gcc
OPTS = -Wall -O
LIBS = -lm
# this translates .c files in src list to .o’s
OBJS = $(SRCS:.c=.o)
# all is not really needed, but is used to generate the target, default directive
all: $(TARG)
# this generates the target executable
$(TARG): $(OBJS)
$(CC) -o $(TARG) $(OBJS) $(LIBS)
# this is a generic rule for .o files
%.o: %.c
$(CC) $(OPTS) -c $< -o $@
# and finally, a clean line
.PHONY: clean
clean:
rm -f $(OBJS) $(TARG)- 第一个directive是default goal
- indent后面的命令是建立依赖的语句
- .PHONY避免clean和名为clean的文件冲突
SUBDIRS = foo bar baz
.PHONY: subdirs $(SUBDIRS)
subdirs: $(SUBDIRS)
$(SUBDIRS):
$(MAKE) -C $@
foo: baz- 配合git ls-files,写make的标准targets
- 可以利用
.git/hooks中的pre-commit在每次commit之前make特定的文件
概念:repository, versioning, version number, semantic versioning
- If a new release does not change the API, increase the patch version.
- If you add to your API in a backwards-compatible way, increase the minor version.
- If you change the API in a non-backwards-compatible way, increase the major version.
- Rust's build system,可帮助理解版本号以及dependency管理
lock file: a file that lists the exact version you are currently depending on of each dependency
- vendoring: copy all the code of your dependencies into your own project
makedepend工具能帮助寻找依赖
“stuff that runs whenever your code changes”
- e.g. Travis CI, Azure Pipelines, and GitHub Actions
- Pages is a CI action that runs the Jekyll blog software on every push to
masterand makes the built site available on a particular GitHub domain
testing
- Test suite: a collective term for all the tests
- Unit test: a “micro-test” that tests a specific feature in isolation
- Integration test: a “macro-test” that runs a larger part of the system to check that different feature or components work together.
- Regression test: a test that implements a particular pattern that previously caused a bug to ensure that the bug does not resurface.
- Mocking: the replace a function, module, or type with a fake implementation to avoid testing unrelated functionality. For example, you might “mock the network” or “mock the disk”.
- Set up a simple auto-published page using GitHub Pages. Add a GitHub Action to the repository to run
shellcheckon any shell files in that repository (here is one way to do it). Check that it works! - Build your own GitHub action to run
proselintorwrite-goodon all the.mdfiles in the repository. Enable it in your repository, and check that it works by filing a pull request with a typo in it.
个人blog的建立: