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