1# Copyright JS Foundation and other contributors, http://js.foundation 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15# USAGE: 16# specify the board using the command line: 17# make BOARD=[mbed board name] 18 19BOARD=$(subst [mbed] ,,$(shell mbed target)) 20HEAPSIZE=16 21 22DEBUG?=0 23NO_JS?=0 24MBED_VERBOSE?=0 25 26MBED_CLI_FLAGS=-j0 --source . --source ../../ 27 28EXTRA_SRC= 29 30ifneq ($(EXTRA_SRC),) 31EXTRA_SRC_MOD=--source $(subst :, --source ,$(EXTRA_SRC)) 32MBED_CLI_FLAGS += $(EXTRA_SRC_MOD) 33endif 34 35EXTERN_BUILD_DIR= 36 37ifneq ($(EXTERN_BUILD_DIR),) 38MBED_CLI_FLAGS += --build $(EXTERN_BUILD_DIR) 39endif 40 41ifeq ($(DEBUG), 1) 42MBED_CLI_FLAGS += --profile ./mbed-os/tools/profiles/debug.json 43endif 44 45ifeq ($(MBED_VERBOSE), 1) 46MBED_CLI_FLAGS += -v 47else ifeq ($(MBED_VERBOSE), 2) 48MBED_CLI_FLAGS += -vv 49endif 50 51MBED_CLI_FLAGS += -D "JERRY_GLOBAL_HEAP_SIZE=$(HEAPSIZE)" 52MBED_CLI_FLAGS += -t GCC_ARM 53 54.PHONY: all js2c getlibs rebuild library 55all: source/jerry-targetjs.h source/pins.cpp .mbed ../../.mbedignore 56 mbed target $(BOARD) 57 mbed compile $(MBED_CLI_FLAGS) 58 59library: .mbed ../../.mbedignore 60 # delete encoded js code if it exists 61 rm -f source/jerry-targetjs.h 62 mbed target $(BOARD) 63 mbed compile $(MBED_CLI_FLAGS) --library 64 65clean: 66 rm -rf ./BUILD/$(BOARD) 67 68js2c: js/main.js js/flash_leds.js 69 python ../../tools/js2c.py --ignore pins.js 70 71source/pins.cpp: 72 python tools/generate_pins.py ${BOARD} 73 74ifeq ($(NO_JS),0) 75source/jerry-targetjs.h: js2c 76else 77source/jerry-targetjs.h: ; 78endif 79 80getlibs: .mbed 81 82.mbed: 83 echo 'ROOT=.' > .mbed 84 mbed config root . 85 mbed toolchain GCC_ARM 86 mbed target $(BOARD) 87 mbed deploy 88 89../../.mbedignore: 90ifeq ($(OS),Windows_NT) 91 copy template-mbedignore.txt ..\..\.mbedignore 92else 93 cp ./template-mbedignore.txt ../../.mbedignore 94endif 95