FRDM K64F Metronome

Committer:
ram54288
Date:
Sun May 14 18:35:07 2017 +0000
Revision:
0:a2cb7295a1f7
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ram54288 0:a2cb7295a1f7 1 # -----------------------------------------------------------------------
ram54288 0:a2cb7295a1f7 2 # Copyright (c) 2016 ARM Limited. All rights reserved.
ram54288 0:a2cb7295a1f7 3 # SPDX-License-Identifier: Apache-2.0
ram54288 0:a2cb7295a1f7 4 # Licensed under the Apache License, Version 2.0 (the License); you may
ram54288 0:a2cb7295a1f7 5 # not use this file except in compliance with the License.
ram54288 0:a2cb7295a1f7 6 # You may obtain a copy of the License at
ram54288 0:a2cb7295a1f7 7 #
ram54288 0:a2cb7295a1f7 8 # http://www.apache.org/licenses/LICENSE-2.0
ram54288 0:a2cb7295a1f7 9 #
ram54288 0:a2cb7295a1f7 10 # Unless required by applicable law or agreed to in writing, software
ram54288 0:a2cb7295a1f7 11 # distributed under the License is distributed on an AS IS BASIS, WITHOUT
ram54288 0:a2cb7295a1f7 12 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ram54288 0:a2cb7295a1f7 13 # See the License for the specific language governing permissions and
ram54288 0:a2cb7295a1f7 14 # limitations under the License.
ram54288 0:a2cb7295a1f7 15 # -----------------------------------------------------------------------
ram54288 0:a2cb7295a1f7 16
ram54288 0:a2cb7295a1f7 17
ram54288 0:a2cb7295a1f7 18 ###########################################################################
ram54288 0:a2cb7295a1f7 19 # Define test targets based on PROJECT
ram54288 0:a2cb7295a1f7 20 # Make files that include this must define PROJECT and TARGET_PLATFORM
ram54288 0:a2cb7295a1f7 21 # Requirements
ram54288 0:a2cb7295a1f7 22 # - mbed-cli must be installed
ram54288 0:a2cb7295a1f7 23 # - MORPHEUS_ROOT must be defined ( e.g. $(PAL_ROOT)/mbed-os)
ram54288 0:a2cb7295a1f7 24 #
ram54288 0:a2cb7295a1f7 25 # To install mbed-os the following may help:
ram54288 0:a2cb7295a1f7 26 #pip uninstall mbed-cli
ram54288 0:a2cb7295a1f7 27 #cd mbed-client-pal
ram54288 0:a2cb7295a1f7 28 #mbed new
ram54288 0:a2cb7295a1f7 29 #mbed deploy
ram54288 0:a2cb7295a1f7 30 #mbed config root mbed-client-pal/mbed-os
ram54288 0:a2cb7295a1f7 31 #cd mbed-os
ram54288 0:a2cb7295a1f7 32 #sudo pip install -r core/requirements.txt
ram54288 0:a2cb7295a1f7 33 #sudo pip install -U colorama
ram54288 0:a2cb7295a1f7 34 #sudo pip install -U jinja2
ram54288 0:a2cb7295a1f7 35 #mbed remove frameworks/unity
ram54288 0:a2cb7295a1f7 36 #
ram54288 0:a2cb7295a1f7 37 # The following targets may also be defined:
ram54288 0:a2cb7295a1f7 38 # $(PROJECT)_ADDITIONAL_SOURCES
ram54288 0:a2cb7295a1f7 39 #
ram54288 0:a2cb7295a1f7 40 # Clive Bluston
ram54288 0:a2cb7295a1f7 41 ###########################################################################
ram54288 0:a2cb7295a1f7 42
ram54288 0:a2cb7295a1f7 43 # Add targets for platform/project combination
ram54288 0:a2cb7295a1f7 44 .PHONY: $(TARGET_PLATFORM)_all $(TARGET_PLATFORM)_clean $(TARGET_PLATFORM)_check
ram54288 0:a2cb7295a1f7 45 $(TARGET_PLATFORM)_all: $(TARGET_PLATFORM)_$(PROJECT)
ram54288 0:a2cb7295a1f7 46 $(TARGET_PLATFORM)_clean: $(TARGET_PLATFORM)_clean_$(PROJECT)
ram54288 0:a2cb7295a1f7 47 $(TARGET_PLATFORM)_check: $(TARGET_PLATFORM)_check_$(PROJECT)
ram54288 0:a2cb7295a1f7 48
ram54288 0:a2cb7295a1f7 49 # Process command line argument of the form INCLUDE=, in order to pass it to the compilation.
ram54288 0:a2cb7295a1f7 50 # One or more tests can be selected in this way. If the argument is not present then all tests are selected.
ram54288 0:a2cb7295a1f7 51 $(info PAL_TEST=$(PAL_TEST))
ram54288 0:a2cb7295a1f7 52 ifeq ($(strip $(PAL_TEST)),)
ram54288 0:a2cb7295a1f7 53 CC_TESTS = PAL_INCLUDE=1
ram54288 0:a2cb7295a1f7 54 else
ram54288 0:a2cb7295a1f7 55 CC_TESTS = PAL_INCLUDE=0 $(patsubst %,%=1, $(PAL_TEST))
ram54288 0:a2cb7295a1f7 56 endif
ram54288 0:a2cb7295a1f7 57
ram54288 0:a2cb7295a1f7 58 # Define variables to be used in the recipes of the targets in the context of the main target.
ram54288 0:a2cb7295a1f7 59 # We do this because the original variables will be overridden by other make files by the time the
ram54288 0:a2cb7295a1f7 60 # recipe is executed. Note that these variables are recursively inherited by all prerequisites.
ram54288 0:a2cb7295a1f7 61 $(TARGET_PLATFORM)_$(PROJECT) : MORPHEUS_CC_TESTS_D := $(patsubst %,-D%, $(CC_TESTS))
ram54288 0:a2cb7295a1f7 62 #################################################################################################################
ram54288 0:a2cb7295a1f7 63 # Target platform dependant definitions.
ram54288 0:a2cb7295a1f7 64 # All os references relative to the root.
ram54288 0:a2cb7295a1f7 65 # Can define a MBEDOS_ROOT somewhere else
ram54288 0:a2cb7295a1f7 66
ram54288 0:a2cb7295a1f7 67 ifeq ($(strip $(MBEDOS_ROOT)),)
ram54288 0:a2cb7295a1f7 68 MORPHEUS_ROOT := $(PAL_ROOT)/Test
ram54288 0:a2cb7295a1f7 69 else
ram54288 0:a2cb7295a1f7 70 MORPHEUS_ROOT := $(strip $(MBEDOS_ROOT))
ram54288 0:a2cb7295a1f7 71 endif
ram54288 0:a2cb7295a1f7 72
ram54288 0:a2cb7295a1f7 73
ram54288 0:a2cb7295a1f7 74 ifeq ($(DEBUG), 1)
ram54288 0:a2cb7295a1f7 75 $(info "DEBUG")
ram54288 0:a2cb7295a1f7 76 $(TARGET_PLATFORM)_$(PROJECT) : DEBUG_FLAGS += -DDEBUG
ram54288 0:a2cb7295a1f7 77 endif
ram54288 0:a2cb7295a1f7 78
ram54288 0:a2cb7295a1f7 79 ifeq ($(PAL_IGNORE_UNIQUE_THREAD_PRIORITY), 1)
ram54288 0:a2cb7295a1f7 80 $(info "PAL_IGNORE_UNIQUE_THREAD_PRIORITY")
ram54288 0:a2cb7295a1f7 81 $(TARGET_PLATFORM)_$(PROJECT) : DEBUG_FLAGS += -DPAL_IGNORE_UNIQUE_THREAD_PRIORITY
ram54288 0:a2cb7295a1f7 82 endif
ram54288 0:a2cb7295a1f7 83
ram54288 0:a2cb7295a1f7 84 ifeq ($(VERBOSE), 1)
ram54288 0:a2cb7295a1f7 85 $(info "VERBOSE")
ram54288 0:a2cb7295a1f7 86 $(TARGET_PLATFORM)_$(PROJECT) : DEBUG_FLAGS += -DVERBOSE
ram54288 0:a2cb7295a1f7 87 endif
ram54288 0:a2cb7295a1f7 88
ram54288 0:a2cb7295a1f7 89 #################################################################################################################
ram54288 0:a2cb7295a1f7 90
ram54288 0:a2cb7295a1f7 91 ### UNITY FILES ###
ram54288 0:a2cb7295a1f7 92 UNITY_ROOT=$(PAL_ROOT)/Test/Unity
ram54288 0:a2cb7295a1f7 93 UNITY_INCLUDE_PATHS=$(UNITY_ROOT)/src $(UNITY_ROOT)/extras/fixture/src
ram54288 0:a2cb7295a1f7 94 INCLUDE_PATHS = $(UNITY_INCLUDE_PATHS) $(PAL_ROOT)/Source/PAL-Impl/Services-API $(PAL_ROOT)/Source/Port/Platform-API $(PAL_ROOT)/Test/Common
ram54288 0:a2cb7295a1f7 95 # mbed compile command searches include folders for c files, so it will find unity c files
ram54288 0:a2cb7295a1f7 96 # If we were to specify them here, they would be muliply defined.
ram54288 0:a2cb7295a1f7 97 UNITY_OBJECTS =
ram54288 0:a2cb7295a1f7 98 #UNITY_OBJECTS = $(UNITY_ROOT)/src/unity.c $(UNITY_ROOT)/extras/fixture/src/unity_fixture.c
ram54288 0:a2cb7295a1f7 99 ###################
ram54288 0:a2cb7295a1f7 100
ram54288 0:a2cb7295a1f7 101 # Add this optional file to the dependencies only if it exists.
ram54288 0:a2cb7295a1f7 102 ifneq ("$(wildcard $(PAL_ROOT)/Test/Common/$(PROJECT)_test_utils.c)","")
ram54288 0:a2cb7295a1f7 103 # mbed compile command searches include folders for c files, so it will find /Test/Common c files
ram54288 0:a2cb7295a1f7 104 # If we were to specify them here, they would be muliply defined.
ram54288 0:a2cb7295a1f7 105 # $(PROJECT)_ADDITIONAL_SOURCES += $(PAL_ROOT)/Test/Common/$(PROJECT)_test_utils.c
ram54288 0:a2cb7295a1f7 106 endif
ram54288 0:a2cb7295a1f7 107
ram54288 0:a2cb7295a1f7 108 # Fixed list of test files for each test executable.
ram54288 0:a2cb7295a1f7 109 TST_SOURCES:= $(INCLUDE_PATHS) \
ram54288 0:a2cb7295a1f7 110 $(UNITY_OBJECTS) \
ram54288 0:a2cb7295a1f7 111 $(MORPHEUS_ROOT)/mbed-os \
ram54288 0:a2cb7295a1f7 112 $(PAL_ROOT)/Test/$(TYPE)/$(PROJECT)_test.c \
ram54288 0:a2cb7295a1f7 113 $(PAL_ROOT)/Test/$(TYPE)/$(PROJECT)_test_runner.c \
ram54288 0:a2cb7295a1f7 114 $(PAL_ROOT)/Test/$(TYPE)/$(PROJECT)_test_main_$(TARGET_PLATFORM).cpp \
ram54288 0:a2cb7295a1f7 115 $($(PROJECT)_ADDITIONAL_SOURCES)
ram54288 0:a2cb7295a1f7 116 ifeq ($(findstring HAS_UPDATE,$(TARGET_CONFIGURATION_DEFINES)),HAS_UPDATE)
ram54288 0:a2cb7295a1f7 117 TST_SOURCES:= $(TST_SOURCES) \
ram54288 0:a2cb7295a1f7 118 $(MORPHEUS_ROOT)/storage-volume-manager \
ram54288 0:a2cb7295a1f7 119 $(MORPHEUS_ROOT)/storage-abstraction/ \
ram54288 0:a2cb7295a1f7 120 $(MORPHEUS_ROOT)/mbed-client-libservice \
ram54288 0:a2cb7295a1f7 121 $(MORPHEUS_ROOT)/mbed-trace/
ram54288 0:a2cb7295a1f7 122
ram54288 0:a2cb7295a1f7 123 endif
ram54288 0:a2cb7295a1f7 124
ram54288 0:a2cb7295a1f7 125 # Build executables and listings.
ram54288 0:a2cb7295a1f7 126 .PHONY: $(TARGET_PLATFORM)_$(PROJECT)
ram54288 0:a2cb7295a1f7 127 $(TARGET_PLATFORM)_$(PROJECT): $(MORPHEUS_ROOT) $(OUTOBJ) $(OUT)/$(PROJECT).bin
ram54288 0:a2cb7295a1f7 128
ram54288 0:a2cb7295a1f7 129 $(TARGET_PLATFORM)_$(PROJECT): MORPHEUS_ROOT:=$(MORPHEUS_ROOT)
ram54288 0:a2cb7295a1f7 130
ram54288 0:a2cb7295a1f7 131
ram54288 0:a2cb7295a1f7 132 $(OUT)/$(PROJECT).bin: $(TST_SOURCES)
ram54288 0:a2cb7295a1f7 133 # Always remove the test runner since PAL_TEST argument change requires that it is recompiled
ram54288 0:a2cb7295a1f7 134 $(RM) $(dir $@)obj/$(PROJECT)_test_runner.o
ram54288 0:a2cb7295a1f7 135 # Ignore some mbed libraries in the subsequent build. (The minus ignores the error if the library does not exist)
ram54288 0:a2cb7295a1f7 136 -$(ECHO) "*" > $(strip $(MORPHEUS_ROOT))/mbed-os/features/frameworks/unity/.mbedignore
ram54288 0:a2cb7295a1f7 137 # Morpheus build.
ram54288 0:a2cb7295a1f7 138 mbed compile -v -N ../$(notdir $(basename $@)) --build $(dir $@)obj -t GCC_ARM -m K64F $(addprefix --source=, $^) $(MORPHEUS_CC_TESTS_D) $(DEBUG_FLAGS)
ram54288 0:a2cb7295a1f7 139
ram54288 0:a2cb7295a1f7 140 # Create a list of files to delete for each target on the first pass of the make
ram54288 0:a2cb7295a1f7 141 $(TARGET_PLATFORM)_clean_$(PROJECT) : OUTPUTS:= $(OUT)
ram54288 0:a2cb7295a1f7 142
ram54288 0:a2cb7295a1f7 143
ram54288 0:a2cb7295a1f7 144 # Remove files in the list $(PROJECT)_OUTPUTS.
ram54288 0:a2cb7295a1f7 145 # We dynamically create the list variable from the target
ram54288 0:a2cb7295a1f7 146 PHONY: $(TARGET_PLATFORM)_clean_$(PROJECT)
ram54288 0:a2cb7295a1f7 147 $(TARGET_PLATFORM)_clean_$(PROJECT):
ram54288 0:a2cb7295a1f7 148 $(RM) $(OUTPUTS)
ram54288 0:a2cb7295a1f7 149
ram54288 0:a2cb7295a1f7 150 # Check that the script exists
ram54288 0:a2cb7295a1f7 151 $(PAL_ROOT)/Test/Scripts/perform_test_mbedos.py:
ram54288 0:a2cb7295a1f7 152
ram54288 0:a2cb7295a1f7 153 # This makes sure anyone who is dependant on it always executes its recipe
ram54288 0:a2cb7295a1f7 154 .FORCE:
ram54288 0:a2cb7295a1f7 155
ram54288 0:a2cb7295a1f7 156 # Always run the test.
ram54288 0:a2cb7295a1f7 157 $(OUT)/$(PROJECT)_result.txt: $(PAL_ROOT)/Test/Scripts/perform_test_mbedOS.py $(TARGET_PLATFORM)_$(PROJECT) $(OUT)/$(PROJECT).bin .FORCE
ram54288 0:a2cb7295a1f7 158 # Install and run the test. Pass script and binary file.
ram54288 0:a2cb7295a1f7 159 python $(word 1, $^) $(word 3, $^)
ram54288 0:a2cb7295a1f7 160
ram54288 0:a2cb7295a1f7 161 # check. Install and run tests
ram54288 0:a2cb7295a1f7 162 .PHONY: $(TARGET_PLATFORM)check_$(PROJECT)
ram54288 0:a2cb7295a1f7 163 $(TARGET_PLATFORM)_check_$(PROJECT): $(OUT)/$(PROJECT)_result.txt