你不可能空手建起一座城堡。
--mark
1、注释自动生成文档
./scripts/kernel-doc -v -html *.c > outfile.html
2、linux coding-style
./scripts/Lindent -kr -i8 -ts8 -sob -l80 -ss -bs -psl <file>
3、创建补丁和打补丁
diff -urN ../pre-branch/ . > my-patch
patch -p1 < ../next-brach/my-patch
4、Latex 用于比较正规的文档(框架参考Ones里面)
5、git必须提下!
单机开发模式:
git init git add . git branch mark #切换到mark分支 git checkout mark git commit -v -a #合并分支,将mark分支与当前分支合并 git merge mark # 查看commit详情 git log git checkout <hash-value> # 查看所有commit、checkout记录 git reflog # 回滚某次commit git reset --hard <hash-value> #查看当前状态 git status #保存和恢复进度 git stash #为某个hash-value(commit)建立一个版本 git tag <label-name> <hash-value>
6、Makefile涉及的东西太多了,不过正则表达式和shell是必须要了解的
范例一:
.PHONY : clean # use '.PHONY' forbit a file named clean # use variable to Increase code maintainability # all : first second third # $@ = all # $^ = first second third # $< = first(maybe is %.c, then is all *.c file) CC = gcc RM = rm BIN = simple SRCS = $(wildcard *.c) OBJS = $(patsubst %.c, %.o, $(SRCS)) $(BIN) : $(OBJS) $(CC) -o $@ $^ %.o : %.c $(CC) -o $@ $^ -c clean : $(RM) -rf $(BIN) $(OBJS)
范例二:
.PHONY: all clean touch ROOT = $(realpath .) DIRS = $(ROOT)/code/*/src RM = rm RMFLAGS = -fr RMS = $(ROOT)/build/exes $(ROOT)/build/libs #make有4种赋值方式 # = : 赋值 # ?= : 若已赋值则不赋值,否则赋值 # := : 只展开一次,若要对其重新赋值请用 = # += : 追加 #不使用隐式规则将大大提高编译速度,故加入 make -r 选项 all clean: @set -e ; \ for dir in $(DIRS) ; \ do \ cd $$dir && $(MAKE) -r ROOT=$(ROOT) $@ ; \ done @set -e ; \ if [ "$(MAKECMDGOALS)" = "clean" ] ; \ then $(RM) $(RMFLAGS) $(RMS) ; \ fi @echo @echo "^_^ Completed" @echo #如果从另外一台机器拷贝工程过来可能出现这个问题 #找到工程的文件并touch之 touch: @find $(ROOT) -exec touch {} \; @echo @echo "change the time..." @echo
范例三:
.PHONY : all clean MKDIR = mkdir RM = rm RMFLAGS = -rf CC = gcc DIR_OBJS = objs DIR_EXES = exes DIR_DEPS = deps DIRS = $(DIR_OBJS) $(DIR_DEPS) $(DIR_EXES) EXE = hello.exe EXE := $(addprefix $(DIR_EXES)/, $(EXE)) SRCS = $(wildcard *.c) OBJS = $(patsubst %.c, %.o, $(SRCS)) OBJS := $(addprefix $(DIR_OBJS)/, $(OBJS)) DEPS = $(patsubst %.c, %.dep, $(SRCS)) DEPS := $(addprefix $(DIR_DEPS)/, $(DEPS)) ifeq ("$(wildcard $(DIR_OBJS))", "") DEP_DIR_OBJS := $(DIR_OBJS) endif ifeq ("$(wildcard $(DIR_EXES))", "") DEP_DIR_EXES:= $(DIR_EXES) endif ifeq ("$(wildcard $(DIR_DEPS))", "") DEP_DIR_DEPS:= $(DIR_DEPS) endif all : $(EXE) ifneq ($(MAKECMDGOALS), clean) include $(DEPS) endif $(DIRS) : $(MKDIR) $@ $(EXE) : $(DEP_DIR_EXES) $(OBJS) $(CC) -o $@ $(filter %.o, $^) $(DIR_OBJS)/%.o : $(DEP_DIR_OBJS) %.c $(CC) -o $@ -c $(filter %.c, $^) $(DIR_DEPS)/%.dep : $(DEP_DIR_DEPS) %.c #set 告诉shell,执行出错退出,加上 ';'表示在一个shell中执行 #sed 语句表示在所有行中替换.o为后缀并且后面跟着' '或':'的单词 # 加入前缀'obj/' #\(\) 保存匹配的字符,如s/\(love\)able/\1rs,loveable被替换成lovers @echo "Creating $@ ..." @set -e; \ $(RM) $(RMFLAGS) $@.tmp; \ $(CC) -E -MM $(filter %.c, $^) > $@.tmp; \ sed 's,\(.*\)\.o[ :]*,objs/\1.o $@: ,g' < $@.tmp > $@; \ $(RM) $(RMFLAGS) $@.tmp clean : $(RM) $(RMFLAGS) $(DIRS)
find . -type f -name "*.mk" -printf "\n# ===========================================\n" -print -printf "# ===========================================\n\n" -exec cat {} \; > all_android_mk_file.txt