Skip to content

Commit

Permalink
Release 3.1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
edjubuh committed Feb 18, 2019
2 parents f185362 + 5a642a7 commit cb1c2ad
Show file tree
Hide file tree
Showing 29 changed files with 816 additions and 343 deletions.
154 changes: 49 additions & 105 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,70 +1,66 @@
################################################################################
######################### User configurable parameters #########################
# filename extensions
CEXTS:=c
ASMEXTS:=s S
CXXEXTS:=cpp c++ cc

WARNFLAGS=-Wall -Wpedantic

LIBNAME=libpros
LIBAR=$(BINDIR)/$(LIBNAME).a

# probably shouldn't modify these, but you may need them below
ROOT=.
FWDIR:=$(ROOT)/firmware
BINDIR=$(ROOT)/bin
SRCDIR=$(ROOT)/src
INCDIR=$(ROOT)/include
IFI_INC=$(FWDIR)/libv5rts/sdk/vexv5/include
SDK=$(FWDIR)/libv5rts/sdk/vexv5/libv5rts.a

.DEFAULT_GOAL:=quick
EXTRA_INCDIR=$(FWDIR)/libv5rts/sdk/vexv5/include

-include ./common.mk

EXCLUDE_SRCDIRS=$(SRCDIR)/tests
EXCLUDE_FROM_LIB=$(SRCDIR)/opcontrol.cpp $(SRCDIR)/initialize.cpp $(SRCDIR)/autonomous.cpp
LIBV5RTS_EXTRACTION_DIR=$(BINDIR)/libv5rts
# Directories to be excluded from all builds
EXCLUDE_SRCDIRS+=$(SRCDIR)/tests

TEMPLATE_DIR=$(ROOT)/template
TEMPLATE_FILES=$(ROOT)/common.mk $(FWDIR)/v5.ld $(INCDIR)/api.h $(INCDIR)/main.h $(INCDIR)/pros/*.* $(SRCDIR)/opcontrol.cpp $(SRCDIR)/initialize.cpp $(SRCDIR)/autonomous.cpp $(INCDIR)/display
WARNFLAGS+=-Wall -Wpedantic
EXTRA_CFLAGS=
EXTRA_CXXFLAGS=

INCLUDE=-iquote$(INCDIR) -iquote$(IFI_INC)
.DEFAULT_GOAL=quick
USE_PACKAGE:=0

ASMSRC=$(foreach asmext,$(ASMEXTS),$(call rwildcard, $(SRCDIR),*.$(asmext), $1))
ASMOBJ=$(addprefix $(BINDIR)/,$(patsubst $(SRCDIR)/%,%.o,$(call ASMSRC,$1)))
CSRC=$(foreach cext,$(CEXTS),$(call rwildcard, $(SRCDIR),*.$(cext), $1))
COBJ=$(addprefix $(BINDIR)/,$(patsubst $(SRCDIR)/%,%.o,$(call CSRC,$1)))
CXXSRC=$(foreach cxxext,$(CXXEXTS),$(call rwildcard, $(SRCDIR),*.$(cxxext), $1))
CXXOBJ=$(addprefix $(BINDIR)/,$(patsubst $(SRCDIR)/%,%.o,$(call CXXSRC,$1)))
# Set this to 1 to add additional rules to compile your project as a PROS library template
IS_LIBRARY:=1
LIBNAME:=libpros
VERSION=$(shell cat $(ROOT)/version)
# EXCLUDE_SRC_FROM_LIB= $(SRCDIR)/unpublishedfile.c
EXCLUDE_SRC_FROM_LIB+=$(EXCLUDE_SRCDIRS)
# this line excludes opcontrol.c and similar files
EXCLUDE_SRC_FROM_LIB+=$(foreach file, $(SRCDIR)/opcontrol $(SRCDIR)/initialize $(SRCDIR)/autonomous,$(foreach cext,$(CEXTS),$(file).$(cext)) $(foreach cxxext,$(CXXEXTS),$(file).$(cxxext)))

GETALLOBJ=$(sort $(call ASMOBJ,$1) $(call COBJ,$1) $(call CXXOBJ,$1))
# files that get distributed to every user (beyond your source archive) - add
# whatever files you want here. This line is configured to add all header files
# that are in the the include directory get exported
TEMPLATE_FILES=$(ROOT)/common.mk $(FWDIR)/v5.ld $(FWDIR)/v5-common.ld $(FWDIR)/v5-hot.ld
TEMPLATE_FILES+= $(INCDIR)/api.h $(INCDIR)/main.h $(INCDIR)/pros/*.* $(INCDIR)/display
TEMPLATE_FILES+= $(SRCDIR)/opcontrol.cpp $(SRCDIR)/initialize.cpp $(SRCDIR)/autonomous.cpp

LIBRARIES=-L$(FWDIR) -Wl,--start-group $(wildcard $(FWDIR)/*.a) $(SDK) -lc -lm -lgcc -lstdc++ -lsupc++ -Wl,--end-group
ARCHIVE_TEXT_LIST:=$(subst $(SPACE),$(COMMA),$(notdir $(basename $(wildcard $(FWDIR)/*.a) $(SDK))))
PATCHED_SDK=$(FWDIR)/libv5rts/sdk/vexv5/libv5rts.patched.a

ifndef OUTBIN
OUTNAME:=output
endif
OUTBIN:=$(BINDIR)/$(OUTNAME).bin
OUTELF:=$(BINDIR)/$(OUTNAME).elf
LDTIMEOBJ:=$(BINDIR)/_pros_ld_timestamp.o
EXTRA_LIB_DEPS=$(INCDIR)/api.h $(PATCHED_SDK)

.PHONY: all clean quick library clean-library template clean-template version fix-libv5rts

quick: $(OUTBIN)

all: clean $(OUTBIN)
################################################################################
################################################################################
########## Nothing below this line should be edited by typical users ###########
-include ./common.mk

clean: clean-library
@echo Cleaning project
-$Drm -rf $(BINDIR)
.PHONY: $(INCDIR)/api.h
$(INCDIR)/api.h: version.py
$(VV)python version.py

clean-library:
@echo Cleaning libpros
-$Drm -f $(LIBAR)
$(PATCHED_SDK): $(FWDIR)/libv5rts/sdk/vexv5/libv5rts.a
@echo -n "Stripping unwanted symbols from libv5rts.a "
$(call test_output,$D$(STRIP) $^ @libv5rts-strip-options.txt -o $@, $(DONE_STRING))

library: version clean-library $(LIBAR)

version: version.py
$(VV)python version.py
CREATE_TEMPLATE_ARGS=--system "./**/*"
CREATE_TEMPLATE_ARGS+=--user "src/opcontrol.{c,cpp,cc}" --user "src/initialize.{cpp,c,cc}" --user "src/autonomous.{cpp,c,cc}" --user "include/main.{hpp,h,hh}" --user "Makefile"
CREATE_TEMPLATE_ARGS+=--target v5
CREATE_TEMPLATE_ARGS+=--output bin/monolith.bin --cold_output bin/cold.package.bin --hot_output bin/hot.package.bin --cold_addr 58720256 --hot_addr 125829120

template: clean-template library
$(VV)mkdir -p $(TEMPLATE_DIR)
Expand All @@ -74,68 +70,16 @@ template: clean-template library
$Dcp $(LIBAR) $(TEMPLATE_DIR)/firmware
$Dcp $(ROOT)/template-Makefile $(TEMPLATE_DIR)/Makefile
@echo "Creating template"
$Dprosv5 c create-template $(TEMPLATE_DIR) kernel $(shell cat $(ROOT)/version) --system "./**/*" --user "src/opcontrol.{c,cpp,cc}" --user "src/initialize.{cpp,c,cc}" --user "src/autonomous.{cpp,c,cc}" --user "include/main.{hpp,h,hh}" --user "Makefile" --target v5 --output bin/output.bin

clean-template:
-$Drm -rf $(TEMPLATE_DIR)

fix-libv5rts:
@echo -n "Stripping unwanted symbols from libv5rts.a "
$(call test_output,$D$(STRIP) $(SDK) @libv5rts-strip-options.txt,$(DONE_STRING))
$Dprosv5 c create-template $(TEMPLATE_DIR) kernel $(shell cat $(ROOT)/version) $(CREATE_TEMPLATE_ARGS)

$(LIBAR): fix-libv5rts $(call GETALLOBJ,$(EXCLUDE_SRCDIRS) $(EXCLUDE_FROM_LIB))
LIBV5RTS_EXTRACTION_DIR=$(BINDIR)/libv5rts
$(LIBAR): $(call GETALLOBJ,$(EXCLUDE_SRC_FROM_LIB)) $(EXTRA_LIB_DEPS)
$(VV)mkdir -p $(LIBV5RTS_EXTRACTION_DIR)
@echo -n "Extracting libv5rts "
$(call test_output,$Dcd $(LIBV5RTS_EXTRACTION_DIR) && $(AR) x ../../$(SDK),$(DONE_STRING))
$(eval LIBV5RTS_OBJECTS := $(shell $(AR) t $(SDK)))
$(call test_output,$Dcd $(LIBV5RTS_EXTRACTION_DIR) && $(AR) x ../../$(PATCHED_SDK),$(DONE_STRING))
$(eval LIBV5RTS_OBJECTS := $(shell $(AR) t $(PATCHED_SDK)))
-$Drm -f $@
@echo -n "Creating $@ "
$(call test_output,$D$(AR) rcs $@ $(addprefix $(LIBV5RTS_EXTRACTION_DIR)/, $(LIBV5RTS_OBJECTS)) $(filter-out fix-libv5rts,$^),$(DONE_STRING))
$(call test_output,$D$(AR) rcs $@ $(addprefix $(LIBV5RTS_EXTRACTION_DIR)/, $(LIBV5RTS_OBJECTS)) $(call GETALLOBJ,$(EXCLUDE_SRC_FROM_LIB)),$(DONE_STRING))
# @echo -n "Stripping non-public symbols "
# $(call test_output,$D$(OBJCOPY) -S -D -g --strip-unneeded --keep-symbols public_symbols.txt $@,$(DONE_STRING))

$(OUTBIN): $(OUTELF)
$(VV)mkdir -p $(dir $@)
@echo -n "Creating $@ for $(DEVICE) "
$(call test_output,$D$(OBJCOPY) $< -O binary $@,$(DONE_STRING))

$(OUTELF): fix-libv5rts $(call GETALLOBJ,$(EXCLUDE_SRCDIRS))
$(call _pros_ld_timestamp)
@echo -n "Linking project with $(ARCHIVE_TEXT_LIST) "
$(call test_output,$D$(LD) $(LDFLAGS) $(filter-out fix-libv5rts,$^) $(LDTIMEOBJ) $(LIBRARIES) -o $@,$(OK_STRING))
@echo Section sizes:
-$(VV)$(SIZETOOL) $(SIZEFLAGS) $@ $(SIZES_SED) $(SIZES_NUMFMT)

define asm_rule
$(BINDIR)/%.$1.o: $(SRCDIR)/%.$1
$(VV)mkdir -p $$(dir $$@)
@echo -n "Compiling $$< "
$(VV)mkdir -p $$(dir $$@)
$$(call test_output,$D$(AS) -c $(ASMFLAGS) -o $$@ $$<,$(OK_STRING))
endef
$(foreach asmext,$(ASMEXTS),$(eval $(call asm_rule,$(asmext))))

define c_rule
$(BINDIR)/%.$1.o: $(SRCDIR)/%.$1
$(VV)mkdir -p $$(dir $$@)
@echo -n "Compiling $$< "
$(VV)mkdir -p $$(dir $$@)
$$(call test_output,$D$(CC) -c $(INCLUDE) -iquote$(INCDIR)/$$(dir $$*) $(CFLAGS) $(EXTRA_CFLAGS) -o $$@ $$<,$(OK_STRING))
endef
$(foreach cext,$(CEXTS),$(eval $(call c_rule,$(cext))))

define cxx_rule
$(BINDIR)/%.$1.o: $(SRCDIR)/%.$1
$(VV)mkdir -p $$(dir $$@)
@echo -n "Compiling $$< "
$(VV)mkdir -p $$(dir $$@)
$$(call test_output,$D$(CXX) -c $(INCLUDE) -iquote$(INCDIR)/$$(dir $$*) $(CXXFLAGS) $(EXTRA_CXXFLAGS) -o $$@ $$<,$(OK_STRING))
endef
$(foreach cxxext,$(CXXEXTS),$(eval $(call cxx_rule,$(cxxext))))

define _pros_ld_timestamp
@echo -n "Adding timestamp "
@# Pipe a line of code defining _PROS_COMPILE_TOOLSTAMP and _PROS_COMPILE_DIRECTORY into GCC,
@# which allows compilation from stdin. We define _PROS_COMPILE_DIRECTORY using a command line-defined macro
@# which is the pwd | sed ... | tail bit, which will grab the last 3 segments of the path and truncate it 23 characters
$(call test_output, @echo 'char const * const _PROS_COMPILE_TIMESTAMP = __DATE__ " " __TIME__; char const * const _PROS_COMPILE_DIRECTORY = PCD;' | $(CC) -c -x c $(CFLAGS) $(EXTRA_CFLAGS) -DPCD="\"`pwd | tail -c 23`\"" -o $(LDTIMEOBJ) -,$(OK_STRING))
endef
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# PROS Kernel for the VEX V5 Brain

[![Build Status](https://dev.azure.com/purdue-acm-sigbots/Kernel/_apis/build/status/purduesigbots.pros?branchName=develop)](https://dev.azure.com/purdue-acm-sigbots/Kernel/_build/latest?definitionId=5&branchName=develop)

### What is PROS?
PROS is a lightweight and fast alternative open source operating system for the VEX V5 Brain. PROS is built with developers in mind and with a focus on providing an environment for industry-applicable experience.

Expand Down
52 changes: 52 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
jobs:
- job: BuildTemplate
pool:
vmImage: 'ubuntu-16.04'
steps:
- task: InstallSSHKey@0
inputs:
sshKeySecureFile: id_sigbot_github_azure_devops
hostName: $(gh.knownhosts)
sshPublicKey: $(gh.publickey)
- checkout: self
- bash: |
sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa
sudo apt-get update
sudo apt-get install gcc-arm-embedded
displayName: Install gcc-arm-embedded
- task: UsePythonVersion@0
inputs:
addToPath: true
versionSpec: '3.6'
- task: PipAuthenticate@0
inputs:
artifactFeeds: 'pros-cli'
- bash: pip install pros-cli-v5
displayName: Install CLI
- bash: |
make template
mkdir -p artifacts
cp template/*.zip artifacts
displayName: Build template
- bash: |
echo "##vso[build.UpdateBuildNumber]`cat version`"
echo "##vso[task.setvariable variable=KernelVersion]`cat version`"
displayName: Update Build Number
- bash: |
make
displayName: Build binaries
- task: PublishPipelineArtifact@0
inputs:
targetPath: artifacts
artifactName: template
condition: succeeded()
# - task: UniversalPackages@0
# inputs:
# command: publish
# publishDirectory: artifacts
# vstsFeedPublish: 'pros-depot-nightly'
# vstsFeedPackagePublish: 'kernel'
# versionOption: custom
# versionPublish: $(KernelVersion)
# packagePublishDescription: 'CI Build of Kernel'
# condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq(variables['Build.SourceBranch'], 'refs/heads/develop')))
Loading

0 comments on commit cb1c2ad

Please sign in to comment.