diff --git a/.gitignore b/.gitignore index ab33bd8d1d..142f6bc823 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ library/static_libraries/* !library/static_libraries/keep_folder tools/**/* +!tools/build_all_projects.sh !tools/cpplint !tools/FlashMagic !tools/Hercules.exe diff --git a/demos/multiplatform/delay/source/main.cpp b/demos/multiplatform/delay/source/main.cpp index 09df456013..9b73e8cd09 100644 --- a/demos/multiplatform/delay/source/main.cpp +++ b/demos/multiplatform/delay/source/main.cpp @@ -17,11 +17,11 @@ int main() "more then that. This is due to the fact that we delay for a whole " "second, but it takes time to print each statement."); - uint32_t counter = 0; + int counter = 0; while (true) { - LOG_INFO("[%lu] Uptime = %" PRId64 "ns", counter++, sjsu::Uptime().count()); + LOG_INFO("[%d] Uptime = %" PRId64 "ns", counter++, sjsu::Uptime().count()); sjsu::Delay(1s); } return 0; diff --git a/demos/multiplatform/dual_platforms/source/main.cpp b/demos/multiplatform/dual_platforms/source/main.cpp index 81f32b74a2..1febcacbfe 100644 --- a/demos/multiplatform/dual_platforms/source/main.cpp +++ b/demos/multiplatform/dual_platforms/source/main.cpp @@ -11,8 +11,8 @@ int main() // Phase #1: // Define all of the peripheral you plan to use as pointers. Pointers must be // used in order to do the next step - const sjsu::Gpio * button_gpio; - const sjsu::Gpio * led_gpio; + const sjsu::Gpio * button_gpio = &sjsu::GetInactive(); + const sjsu::Gpio * led_gpio = &sjsu::GetInactive(); // Phase #2: // Use "constexpr if" to instantiate the peripherals for each platform if constexpr (sjsu::build::kPlatform == sjsu::build::Platform::lpc17xx) diff --git a/demos/multiplatform/task_scheduler/source/main.cpp b/demos/multiplatform/task_scheduler/source/main.cpp index 64919e9586..19883093b4 100644 --- a/demos/multiplatform/task_scheduler/source/main.cpp +++ b/demos/multiplatform/task_scheduler/source/main.cpp @@ -36,7 +36,7 @@ class PrinterTask final : public sjsu::rtos::Task<512> { run_count_ += 1; xSemaphoreTake(print_mutex, portMAX_DELAY); - LOG_INFO("%s: %ld", message_, run_count_); + LOG_INFO("%s: %d", message_, run_count_); xSemaphoreGive(print_mutex); if (run_count_ == 10) { @@ -48,7 +48,7 @@ class PrinterTask final : public sjsu::rtos::Task<512> private: inline static SemaphoreHandle_t print_mutex; const char * message_; - uint32_t run_count_; + int run_count_; }; PrinterTask printer_one("Printer A", "I am a printer, I am faster"); diff --git a/library/L0_Platform/linux/linux.mk b/library/L0_Platform/linux/linux.mk index 72f5b2447b..c44991a348 100644 --- a/library/L0_Platform/linux/linux.mk +++ b/library/L0_Platform/linux/linux.mk @@ -16,7 +16,7 @@ DEVICE_GDB := gdb COMMON_FLAGS += -m32 -LINKFLAGS = $(COMMON_FLAGS) -m32 -pthread -Wl,--gc-sections -Wl,-Map,"$(MAP)" +LINK_FLAGS = $(COMMON_FLAGS) -m32 -pthread -Wl,--gc-sections -Wl,-Map,"$(MAP)" include $(LIBRARY_DIR)/L0_Platform/freertos/freertos.mk diff --git a/library/third_party/semihost/trace.cpp b/library/third_party/semihost/trace.cpp index 06db54d23e..867f72803c 100644 --- a/library/third_party/semihost/trace.cpp +++ b/library/third_party/semihost/trace.cpp @@ -18,8 +18,9 @@ #pragma GCC diagnostic ignored "-Wconversion" #pragma GCC diagnostic ignored "-Wfloat-equal" #pragma GCC diagnostic ignored "-Wdouble-promotion" +#if !defined(__clang__) #pragma GCC diagnostic ignored "-Wuseless-cast" - +#endif #ifndef OS_INTEGER_TRACE_PRINTF_TMP_ARRAY_SIZE #define OS_INTEGER_TRACE_PRINTF_TMP_ARRAY_SIZE (256) #endif diff --git a/library/third_party/semihost/trace_impl.cpp b/library/third_party/semihost/trace_impl.cpp index bbe591239a..0932996318 100644 --- a/library/third_party/semihost/trace_impl.cpp +++ b/library/third_party/semihost/trace_impl.cpp @@ -13,7 +13,9 @@ #pragma GCC diagnostic ignored "-Wconversion" #pragma GCC diagnostic ignored "-Wfloat-equal" #pragma GCC diagnostic ignored "-Wdouble-promotion" +#if !defined(__clang__) #pragma GCC diagnostic ignored "-Wuseless-cast" +#endif #include "trace.h" #include "L0_Platform/lpc40xx/LPC40xx.h" diff --git a/makefile b/makefile index 5539f21bcb..085a137a55 100644 --- a/makefile +++ b/makefile @@ -95,10 +95,12 @@ ifneq ($(PREVIOUS_SETUP_VERSION), $(CURRENT_SETUP_VERSION)) $(info $(shell printf '$(RESET)')) $(warning ) endif + # ============================================================================== # Setting the number of threads # ============================================================================== -ifneq ($(MAKECMDGOALS), presubmit) +DO_NOT_MULTITHREAD = presubmit all-projects execute program +ifneq ($(MAKECMDGOALS), $(filter $(MAKECMDGOALS), $(DO_NOT_MULTITHREAD))) NPROCS := 1 OS := $(shell uname -s) @@ -182,8 +184,8 @@ DEBUG_FLAG = -g WARNINGS = -Wall -Wextra -Wshadow -Wfloat-equal -Wundef \ -Wno-format-nonliteral -Wconversion -Wdouble-promotion \ -Wswitch -Wnull-dereference -Wformat=2 -CPP_WARNINGS = -Wold-style-cast -Woverloaded-virtual -Wsuggest-override \ - -Wuseless-cast +CPP_WARNINGS = -Wold-style-cast -Woverloaded-virtual -Wsuggest-override \ + -Wsuggest-final-types -Wsuggest-final-methods DEFINES = -D ELF_FILE=\"$(EXECUTABLE)\" DISABLED_WARNINGS = -Wno-main -Wno-variadic-macros # ============================================================================== @@ -321,9 +323,7 @@ C_FLAGS := $(CPP_FLAGS) else C_FLAGS := $(C_FLAGS_COMMON) -D PLATFORM=$(PLATFORM) \ -DTRACE -DOS_USE_TRACE_SEMIHOSTING_STDOUT -CPP_FLAGS := $(C_FLAGS) $(CPP_WARNINGS) $(CPP_OPTIMIZE) $(WARNINGS) \ - -Wlogical-op -Wduplicated-cond -Wsuggest-final-types \ - -Wsuggest-final-methods +CPP_FLAGS := $(C_FLAGS) $(CPP_WARNINGS) $(CPP_OPTIMIZE) $(WARNINGS) endif # ============================================================================== # Final products @@ -371,10 +371,10 @@ application: $(LIST) $(HEX) $(BINARY) $(SIZE) execute: flash flash: - @$(MAKE) --quiet application + +@$(MAKE) --quiet application @printf \ '$(MAGENTA)Programming chip via In-System Programming (ISP)...$(RESET)\n' - @$(MAKE) --quiet platform-flash + +@$(MAKE) --quiet platform-flash debug: @@ -396,14 +396,13 @@ debug-test: jtag-flash: program program: - @$(MAKE) --quiet application + +@$(MAKE) --quiet application @printf '$(MAGENTA)Programming chip via debug device...$(RESET)\n' @$(OPENOCD_DIR)/bin/$(OPENOCD_EXE) -s $(OPENOCD_DIR)/scripts/ \ -c "source [find interface/$(JTAG).cfg]" -f $(OPENOCD_CONFIG) \ -c "program \"$(EXECUTABLE)\" reset exit" - library-test: test $(TEST_EXEC) # NOTE: From issue #374, we found that we need to remove the old gcda files # otherwise if the test has been recompiled between executions of run-test, the @@ -468,6 +467,10 @@ spellcheck: @$(TOOLS_DIR)/spell_checker.sh $(LINT_FILES) +all-projects: + +@$(TOOLS_DIR)/build_all_projects.sh + + FILES_WITH_TESTS=$(filter-out $(NO_TEST_NEEDED), $(LINT_FILES)) find-missing-tests: @$(TOOLS_DIR)/find_sources_without_tests.sh $(FILES_WITH_TESTS) @@ -527,13 +530,13 @@ $(SIZE): $(EXECUTABLE) $(LIST): $(EXECUTABLE) - @$(OBJDUMP) --disassemble --all-headers --source --demangle --wide "$<" > "$@" + @$(OBJDUMP) --disassemble --all-headers --source --demangle "$<" > "$@" @echo -e '$(YELLOW)Disassembly Generated!$(RESET) : $@' $(CORE_STATIC_LIBRARY): $(LIBRARIES) @rm -f "$@" - @$(DEVICE_AR) -rcT "$@" $^ + @$(DEVICE_AR) rcT "$@" $^ @$(DEVICE_RANLIB) "$@" @echo -e '$(YELLOW)Final Library file ( A ) $(RESET): $@' diff --git a/tools/build_all_projects.sh b/tools/build_all_projects.sh new file mode 100755 index 0000000000..322cafaa58 --- /dev/null +++ b/tools/build_all_projects.sh @@ -0,0 +1,105 @@ +#!/bin/bash + +BUILD_CAPTURE=0 + +# Get base path +SJBASE=$(dirname "$0") +SJBASE=$(cd "$SJBASE/.." ; pwd -P) + +. $SJBASE/tools/common.sh + +#################################### +# All Projects Build Check # +#################################### +print_divider "Checking that all projects build" + +# Get all multiplatform projects +LIST_OF_PROJECT=$(find $SJBASE/demos/multiplatform -name "makefile") +LIST_OF_PLATFORMS=(lpc40xx lpc17xx stm32f4xx stm32f10x) + +for d in $LIST_OF_PROJECT +do + for p in "${LIST_OF_PLATFORMS[@]}" + do + PROJECT_PATH=$(dirname $d) + cd "$PROJECT_PATH" + printf "$YELLOW" + printf " Building Multiplatform Demo ($p)\n" + printf " $PROJECT_PATH" + printf "$RESET " + # Clean the build and start building from scratch + SILENCE=$(make clean) + # Check if the system can build without any warnings! + SILENCE=$(make application WARNINGS_ARE_ERRORS=-Werror PLATFORM=$p) + # Add the return codes of the previous build capture. None zero means that + # at least one of the captures failed. + SPECIFIC_BUILD_CAPTURE=$? + BUILD_CAPTURE=$(($BUILD_CAPTURE + $SPECIFIC_BUILD_CAPTURE)) + print_status $SPECIFIC_BUILD_CAPTURE + echo "" + done +done + +printf "$YELLOW Building hello_world Project $RESET" +# Change to the hello_world project +cd "$SJBASE/projects/hello_world" +# Purge repository of all application and framework build files and start +# building from scratch +SILENCE=$(make purge) +# Check if the system can build without any warnings! +SILENCE=$(make -s application WARNINGS_ARE_ERRORS=-Werror) +# Set build capture to return code from the build +BUILD_CAPTURE=$? +print_status $BUILD_CAPTURE +echo "" + +printf "$YELLOW Building Starter Project $RESET" +# Change to the Hyperload project +cd "$SJBASE/projects/starter" +# Clean the build and start building from scratch +SILENCE=$(make clean) +# Check if the system can build without any warnings! +SILENCE=$(make -s application WARNINGS_ARE_ERRORS=-Werror) +# Set build capture to return code from the build +SPECIFIC_BUILD_CAPTURE=$? +BUILD_CAPTURE=$(($BUILD_CAPTURE + $SPECIFIC_BUILD_CAPTURE)) +print_status $SPECIFIC_BUILD_CAPTURE +echo "" + +printf "$YELLOW Building Barebones Project $RESET" +# Change to the Hyperload project +cd "$SJBASE/projects/barebones" +# Clean the build and start building from scratch +SILENCE=$(make clean) +# Check if the system can build without any warnings! +SILENCE=$(make -s application WARNINGS_ARE_ERRORS=-Werror) +# Set build capture to return code from the build +SPECIFIC_BUILD_CAPTURE=$? +BUILD_CAPTURE=$(($BUILD_CAPTURE + $SPECIFIC_BUILD_CAPTURE)) +print_status $SPECIFIC_BUILD_CAPTURE +echo "" + +# Build all example projects +cd $SJBASE/demos/ +# Get all demos with makefiles but ignore multiplatform projects +LIST_OF_PROJECT=$(find $SJBASE/demos/ -name "makefile" | \ + grep -v "multiplatform") + +for d in $LIST_OF_PROJECT +do + PROJECT_PATH=$(dirname $d) + cd "$PROJECT_PATH" + printf "$YELLOW Building Demo $PROJECT_PATH $RESET" + # Clean the build and start building from scratch + SILENCE=$(make clean) + # Check if the system can build without any warnings! + SILENCE=$(make application WARNINGS_ARE_ERRORS=-Werror) + # Add the return codes of the previous build capture. None zero means that at + # least one of the captures failed. + SPECIFIC_BUILD_CAPTURE=$? + BUILD_CAPTURE=$(($BUILD_CAPTURE + $SPECIFIC_BUILD_CAPTURE)) + print_status $SPECIFIC_BUILD_CAPTURE + echo "" +done + +exit $BUILD_CAPTURE diff --git a/tools/makefile_help_menu.txt b/tools/makefile_help_menu.txt index fbfa357935..a00417c589 100644 --- a/tools/makefile_help_menu.txt +++ b/tools/makefile_help_menu.txt @@ -59,6 +59,9 @@ GENERAL TARGETS ________________________________________________________________ DEVELOPER TARGETS ______________________________________________________________ + all-projects ----------------------------------------------------------------- + Checks that all projects compile without warnings or errors. + lint ------------------------------------------------------------------------- Check that source files abide by the SJSU-Dev2 coding standard. @@ -75,7 +78,7 @@ DEVELOPER TARGETS ______________________________________________________________ presubmit -------------------------------------------------------------------- Runs the presubmit checks which is used for continuous integration. The following checks will be performed: - 1. Checks that all projects compile without warnings or errors. + 1. Performs `make all-projects` 2. Performs `make lint` 3. Performs `make tidy` 4. Performs `make library-test` diff --git a/tools/presubmit.sh b/tools/presubmit.sh index db3cf4b8f0..04a05b0d95 100755 --- a/tools/presubmit.sh +++ b/tools/presubmit.sh @@ -50,73 +50,16 @@ function check exit 0 fi } + +# Return to home project +cd $SJBASE/projects/hello_world + #################################### -# All Projects Build Check # +# Build All Projects # #################################### -print_divider "Checking that all projects build" - -printf "$YELLOW Building hello_world Project $RESET" -# Change to the hello_world project -cd "$SJBASE/projects/hello_world" -# Purge repository of all application and framework build files and start -# building from scratch -SILENCE=$(make purge) -# Check if the system can build without any warnings! -SILENCE=$(make -s application WARNINGS_ARE_ERRORS=-Werror) -# Set build capture to return code from the build +make all-projects BUILD_CAPTURE=$? -print_status $BUILD_CAPTURE -echo "" - -printf "$YELLOW Building Starter Project $RESET" -# Change to the Hyperload project -cd "$SJBASE/projects/starter" -# Clean the build and start building from scratch -SILENCE=$(make clean) -# Check if the system can build without any warnings! -SILENCE=$(make -s application WARNINGS_ARE_ERRORS=-Werror) -# Set build capture to return code from the build -SPECIFIC_BUILD_CAPTURE=$? -BUILD_CAPTURE=$(($BUILD_CAPTURE + $SPECIFIC_BUILD_CAPTURE)) -print_status $SPECIFIC_BUILD_CAPTURE -echo "" -printf "$YELLOW Building Barebones Project $RESET" -# Change to the Hyperload project -cd "$SJBASE/projects/barebones" -# Clean the build and start building from scratch -SILENCE=$(make clean) -# Check if the system can build without any warnings! -SILENCE=$(make -s application WARNINGS_ARE_ERRORS=-Werror) -# Set build capture to return code from the build -SPECIFIC_BUILD_CAPTURE=$? -BUILD_CAPTURE=$(($BUILD_CAPTURE + $SPECIFIC_BUILD_CAPTURE)) -print_status $SPECIFIC_BUILD_CAPTURE -echo "" - -# Build all example projects -cd $SJBASE/demos/ - -LIST_OF_PROJECT=$(find ./ -name "makefile") -for d in $LIST_OF_PROJECT -do -PROJECT_PATH=$(dirname $d) -cd "$SJBASE/demos/$PROJECT_PATH" -printf "$YELLOW Building Example $d $RESET" -# Clean the build and start building from scratch -SILENCE=$(make clean) -# Check if the system can build without any warnings! -SILENCE=$(make application WARNINGS_ARE_ERRORS=-Werror) -# Add the return codes of the previous build capture. None zero means that at -# least one of the captures failed. -SPECIFIC_BUILD_CAPTURE=$? -BUILD_CAPTURE=$(($BUILD_CAPTURE + $SPECIFIC_BUILD_CAPTURE)) -print_status $SPECIFIC_BUILD_CAPTURE -echo "" -done - -# Return to home project -cd $SJBASE/projects/hello_world #################################### # Lint Check # ####################################