mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
The 'external' toolchain file does nothing but transitively sets some cmake system variables from values received on the command line, and forcibly sets the C compiler. However, the same cmake system variables can be directly set via the command line, together with the C compiler, and specifying a toolchain is not a must. Thus, this patch drops the superfluous 'external' toolchain file and updates cmake-based targets to invoke cmake in a simpler form. Related changes in this commit: - While updating the cmake invocations, all the command line arguments have been reviewed and simplified (removed those, which did not change the defaults). - Removed unnecessary forced C compiler settings from some toolchain files (and/or changed them to setting the "compiler works" flag to true, thus keeping cmake's compiler identification logic but disabling some of its overzealous compiler sanity checks). JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
88 lines
2.6 KiB
Makefile
88 lines
2.6 KiB
Makefile
# Copyright JS Foundation and other contributors, http://js.foundation
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
CURDIR = `pwd`
|
|
ESP_LIB = $(SDK_PATH)/lib
|
|
BUILD_DIR = build/obj-esp8266
|
|
COPYTARGET = targets/esp8266/libs
|
|
USBDEVICE ?= /dev/ttyUSB0
|
|
JERRYHEAP ?= 20
|
|
ESPTOOL ?= /opt/Espressif/esptool-py/esptool.py
|
|
|
|
# compile flags
|
|
ESP_CFLAGS := -D__TARGET_ESP8266 -D__attr_always_inline___=
|
|
|
|
MFORCE32 = $(shell xtensa-lx106-elf-gcc --help=target | grep mforce-l32)
|
|
|
|
ifneq ($(MFORCE32),)
|
|
# Your compiler supports the -mforce-l32 flag which means that
|
|
# constants can be placed in ROM to free additional RAM
|
|
ESP_CFLAGS += -DJERRY_CONST_DATA="__attribute__((aligned(4))) __attribute__((section(\".irom.text\")))"
|
|
ESP_CFLAGS += -mforce-l32
|
|
endif
|
|
|
|
ESP_CFLAGS += -Wl,-EL -fno-inline-functions
|
|
ESP_CFLAGS += -ffunction-sections -fdata-sections
|
|
ESP_CFLAGS += -mlongcalls -mtext-section-literals -mno-serialize-volatile
|
|
|
|
.PHONY: jerry js2c mkbin check-env flash clean
|
|
|
|
all: check-env jerry js2c mkbin
|
|
|
|
jerry:
|
|
mkdir -p $(BUILD_DIR)
|
|
mkdir -p $(COPYTARGET)
|
|
cmake -B$(BUILD_DIR) -H./ \
|
|
-DCMAKE_SYSTEM_NAME=MCU \
|
|
-DCMAKE_SYSTEM_PROCESSOR=xtensia-lx106 \
|
|
-DCMAKE_C_COMPILER=xtensa-lx106-elf-gcc \
|
|
-DCMAKE_C_COMPILER_WORKS=TRUE \
|
|
-DENABLE_LTO=OFF \
|
|
-DENABLE_ALL_IN_ONE=ON \
|
|
-DJERRY_LIBC=OFF \
|
|
-DJERRY_CMDLINE=OFF \
|
|
-DEXTERNAL_COMPILE_FLAGS="$(ESP_CFLAGS)" \
|
|
-DMEM_HEAP_SIZE_KB=$(JERRYHEAP)
|
|
|
|
make -C$(BUILD_DIR) jerry-core jerry-libm
|
|
cp $(BUILD_DIR)/lib/libjerry-core.a $(COPYTARGET)/
|
|
cp $(BUILD_DIR)/lib/libjerry-libm.a $(COPYTARGET)/
|
|
|
|
js2c:
|
|
tools/js2c.py --dest targets/esp8266/include --js-source targets/esp8266/js
|
|
|
|
mkbin:
|
|
make -Ctargets/esp8266 clean
|
|
make -Ctargets/esp8266 BOOT=new APP=0 SPI_SPEED=40 SPI_MODE=DIO SPI_SIZE_MAP=4
|
|
|
|
check-env:
|
|
ifndef SDK_PATH
|
|
$(error SDK_PATH is undefined for ESP8266)
|
|
endif
|
|
ifndef BIN_PATH
|
|
$(error BIN_PATH is undefined for ESP8266)
|
|
endif
|
|
|
|
flash:
|
|
$(ESPTOOL) --port $(USBDEVICE) write_flash \
|
|
0x00000 $(BIN_PATH)/eagle.flash.bin \
|
|
0x20000 $(BIN_PATH)/eagle.irom0text.bin \
|
|
0x3FC000 $(SDK_PATH)/bin/esp_init_data_default.bin
|
|
|
|
erase_flash:
|
|
$(ESPTOOL) --port $(USBDEVICE) erase_flash
|
|
|
|
clean:
|
|
rm -rf $(BUILD_DIR)
|