收集的工作中可能会用到的片段,分别是Cscope,Vim、Makefile和代码(文件)行数统计工具。

Cscope

#!/bin/sh -
find . -name "*.h" -o -name "*.c" -o -name "*.cpp" -o -name "*.cc" > cscope.files
cscope -bkq -i cscope.files
ctags -R .

行数统计工具

#!/bin/sh -
find . -type f | xargs cat | wc -l
find . -name "*[.h|.cpp|.sh|.py]" | xargs cat | wc -l
find . -name "*[.h|.cpp|.sh|.py]" -type f | xargs cat | wc -l

Makefile模板

TARGET :=test
INCDIRS:= .
LIBS :=
LIBDIRS:= .
SOURCE := $(wildcard *.cpp)
#SOURCE := $(filter-out $(NO_SRCS),$(SOURCE)) 
OBJS := $(patsubst %.cpp,%.o,$(SOURCE))
CPPFLAGS := -g -Wall
CPPFLAGS += $(addprefix -I,$(INCDIRS)) 
CXX=g++
LDFLAGS= $(addprefix -L,$(LIBDIRS)) $(addprefix -l,$(LIBS)) 
 
$(TARGET):$(OBJS)
	$(CXX) -g -Wall -o $@ $^ $(LDFLAGS)

.PHONY:clean
clean:
	rm -fr $(OBJS)
	rm -fr *.o
	rm -fr $(TARGET)
 
# DO NOT DELETE