Skip to content

Commit

Permalink
Fix linux build break from makefile refactor
Browse files Browse the repository at this point in the history
- Split out building all projects from presubmit into its own script.
- Fix warnings generated by demos that have warnings on specific platforms.
- Build multiplatform demos for every platform (except for linux due to
  many complications).

Resolves #1038
  • Loading branch information
kammce committed Jan 20, 2020
1 parent 5ba6cad commit 1ba21cb
Show file tree
Hide file tree
Showing 11 changed files with 142 additions and 84 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions demos/multiplatform/delay/source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions demos/multiplatform/dual_platforms/source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<sjsu::Gpio>();
const sjsu::Gpio * led_gpio = &sjsu::GetInactive<sjsu::Gpio>();
// Phase #2:
// Use "constexpr if" to instantiate the peripherals for each platform
if constexpr (sjsu::build::kPlatform == sjsu::build::Platform::lpc17xx)
Expand Down
4 changes: 2 additions & 2 deletions demos/multiplatform/task_scheduler/source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion library/L0_Platform/linux/linux.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion library/third_party/semihost/trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions library/third_party/semihost/trace_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
27 changes: 15 additions & 12 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
# ==============================================================================
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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): $@'

Expand Down
105 changes: 105 additions & 0 deletions tools/build_all_projects.sh
Original file line number Diff line number Diff line change
@@ -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
5 changes: 4 additions & 1 deletion tools/makefile_help_menu.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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`
Expand Down
69 changes: 6 additions & 63 deletions tools/presubmit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 #
####################################
Expand Down

0 comments on commit 1ba21cb

Please sign in to comment.