Donald Meyers / Mbed OS evan
Committer:
djmeyers
Date:
Sat Mar 18 22:37:16 2017 +0000
Revision:
0:06ee5f8a484a
Initial commit

Who changed what in which revision?

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