FRDM K64F Metronome

Committer:
ram54288
Date:
Sun May 14 18:37:05 2017 +0000
Revision:
0:dbad57390bd1
Initial commit

Who changed what in which revision?

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