diff --git a/.gitignore b/.gitignore index 6a54082e9..cff27a05f 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,8 @@ include/*.h.gch .gcc-flags.json .project .cproject +template/template.pros +template/src/* +!template/src/Makefile +template/include +template/firmware diff --git a/Makefile b/Makefile index 0f63c9de7..e76990640 100644 --- a/Makefile +++ b/Makefile @@ -62,7 +62,7 @@ library: clean $(BINDIR) $(SUBDIRS) $(ASMOBJ) $(COBJ) $(CPPOBJ) TEMPLATEFILES:=src/auto.c src/init.c src/opcontrol.c include/API.h include/main.h firmware template: library -rm -rf $(addprefix $(ROOT)/template/,$(TEMPLATEFILES)) - mkdir -p $(ROOT)/template/src $(ROOT)/template/inlcude $(ROOT)/template/firmware + mkdir -p $(ROOT)/template/src $(ROOT)/template/include $(ROOT)/template/firmware $(foreach f,$(TEMPLATEFILES),cp -r $(ROOT)/$(f) $(ROOT)/template/$(f); ) cp $(BINDIR)/$(LIBNAME).a $(ROOT)/template/firmware/$(LIBNAME).a pros conduct create-template kernel $(VERSION) pros-mainline --location $(ROOT)/template -u "firmware/$(LIBNAME).a" -u "include/API.h" -u "common.mk" -i "template.pros" diff --git a/README.md b/README.md index 7652e09c1..88bde1adc 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ We have a number of resources available on our website, including Drop us a line - at pros_development@cs.purdue.edu - on the [VEX Forum](https://www.vexforum.com/index.php/) +- on VEX Teams of the World Discord ### I think I found a bug! We maintain GitHub repositories for the three major components of the PROS ecosystem: @@ -35,4 +36,4 @@ We maintain GitHub repositories for the three major components of the PROS ecosy - The Atom plugin at [purduesigbots/pros-atom](github.com/purduesigbots/pros-atom) - The kernel [here](github.com/purduesigbots/pros) -If you find a problem with our documentation or tutorials, we have a repository for that, too, at [purduesigbots/pros-docs](github.com/purduesigbots/pros-docs). +If you find a problem with our documentation or tutorials, we have a repository for that, too, at purduesigbots/pros-docs. diff --git a/template/Makefile b/template/Makefile index ea5c3e021..89368c792 100644 --- a/template/Makefile +++ b/template/Makefile @@ -1,11 +1,11 @@ # Universal C Makefile for MCU targets -# Path to project root (NO trailing slash!) -ROOT=.. +# Path to project root (for top-level, so the project is in ./; first-level, ../; etc.) +ROOT=. # Binary output directory BINDIR=$(ROOT)/bin # Subdirectories to include in the build -SUBDIRS= +SUBDIRS=src # Nothing below here needs to be modified by typical users @@ -21,32 +21,48 @@ CPPSRC:=$(wildcard *.$(CPPEXT)) CPPOBJ:=$(patsubst %.o,$(BINDIR)/%.o,$(CPPSRC:.$(CPPEXT)=.o)) OUT:=$(BINDIR)/$(OUTNAME) -.PHONY: all do_subdirs _force_look +.PHONY: all clean upload _force_look # By default, compile program -all: do_subdirs . +all: $(BINDIR) $(OUT) + +# Remove all intermediate object files (remove the binary directory) +clean: + -rm -f $(OUT) + -rm -rf $(BINDIR) + +# Uploads program to device +upload: all + $(UPLOAD) # Phony force-look target _force_look: @true -# Compiles the program if anything is changed -.: $(SUBDIRS) $(ASMOBJ) $(COBJ) $(CPPOBJ) - @touch . +# Looks in subdirectories for things to make +$(SUBDIRS): %: _force_look + @$(MAKE) --no-print-directory -C $@ + +# Ensure binary directory exists +$(BINDIR): + -@mkdir -p $(BINDIR) -# Builds the subdirectories -do_subdirs: _force_look - @for dir in $(SUBDIRS); do $(MAKE) --no-print-directory -C $$dir || exit 1; done +# Compile program +$(OUT): $(SUBDIRS) $(ASMOBJ) $(COBJ) $(CPPOBJ) + @echo LN $(BINDIR)/*.o $(LIBRARIES) to $@ + @$(CC) $(LDFLAGS) $(BINDIR)/*.o $(LIBRARIES) -o $@ + @$(MCUPREFIX)size $(SIZEFLAGS) $(OUT) + $(MCUPREPARE) # Assembly source file management -$(ASMOBJ): $(BINDIR)/%.o: %.$(ASMEXT) +$(ASMOBJ): $(BINDIR)/%.o: %.$(ASMEXT) $(HEADERS) @echo AS $< @$(AS) $(AFLAGS) -o $@ $< # Object management $(COBJ): $(BINDIR)/%.o: %.$(CEXT) $(HEADERS) @echo CC $(INCLUDE) $< - @$(CC) $(INCLUDE) $(CFLAGS) -o $@ $< + $(CC) $(INCLUDE) $(CFLAGS) -o $@ $< $(CPPOBJ): $(BINDIR)/%.o: %.$(CPPEXT) $(HEADERS) @echo CPC $(INCLUDE) $< diff --git a/template/src/Makefile b/template/src/Makefile new file mode 100644 index 000000000..9e5b95202 --- /dev/null +++ b/template/src/Makefile @@ -0,0 +1,50 @@ +# Makefile for compiling PROS projects + +# Path to project root (NO trailing slash!) +ROOT=.. +# Binary output directory +BINDIR=$(ROOT)/bin + +# Nothing below here needs to be modified by typical users + +# Include common aspects of this project +-include $(ROOT)/common.mk + +ASMSRC:=$(wildcard *.$(ASMEXT)) +ASMOBJ:=$(patsubst %.o,$(BINDIR)/%.o,$(ASMSRC:.$(ASMEXT)=.o)) +HEADERS:=$(wildcard *.$(HEXT)) +### Special section for Cortex projects ### +HEADERS_2:=$(wildcard ../include/*.$(HEXT)) +### End special section ### +CSRC=$(wildcard *.$(CEXT)) +COBJ:=$(patsubst %.o,$(BINDIR)/%.o,$(CSRC:.$(CEXT)=.o)) +CPPSRC:=$(wildcard *.$(CPPEXT)) +CPPOBJ:=$(patsubst %.o,$(BINDIR)/%.o,$(CPPSRC:.$(CPPEXT)=.o)) +OUT:=$(BINDIR)/$(OUTNAME) + +.PHONY: all + +# By default, compile program +all: . + +# Compiles the program if anything is changed +.: $(ASMOBJ) $(COBJ) $(CPPOBJ) + @touch . + +# Assembly source file management +$(ASMOBJ): $(BINDIR)/%.o: %.$(ASMEXT) + @echo AS $< + @$(AS) $(AFLAGS) -o $@ $< + +### Special section for Cortex projects ### + +# Object management +$(COBJ): $(BINDIR)/%.o: %.$(CEXT) $(HEADERS) $(HEADERS_2) + @echo CC $(INCLUDE) $< + @$(CC) $(INCLUDE) $(CFLAGS) -o $@ $< + +$(CPPOBJ): $(BINDIR)/%.o: %.$(CPPEXT) $(HEADERS) $(HEADERS_2) + @echo CPC $(INCLUDE) $< + @$(CPPCC) $(INCLUDE) $(CPPFLAGS) -o $@ $< + +### End special section ###