Skip to content

Commit dcd429e

Browse files
author
François Baldassari
committed
Make target provide jerry-port.c
JerryScript-DCO-1.0-Signed-off-by: François Baldassari francois@pebble.com
1 parent 073ab05 commit dcd429e

File tree

6 files changed

+140
-2
lines changed

6 files changed

+140
-2
lines changed

CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,15 @@ project (Jerry C ASM)
132132
set(INCLUDE_LIBC_INTERFACE ${EXTERNAL_LIBC_INTERFACE})
133133
endif()
134134

135+
136+
# Should we use external jerry-port.c?
137+
if(DEFINED EXTERNAL_PORT_FILE AND NOT EXTERNAL_PORT_FILE STREQUAL "UNDEFINED")
138+
set(SOURCE_PORT_IMPLEMENTATION ${EXTERNAL_PORT_FILE})
139+
set(USE_DEFAULT_PORT FALSE)
140+
else()
141+
set(USE_DEFAULT_PORT TRUE)
142+
endif()
143+
135144
# Are there any interfaces for external libraries, other than libc, that should be registered?
136145
if(DEFINED EXTERNAL_LIBS_INTERFACE AND NOT EXTERNAL_LIBS_INTERFACE STREQUAL "UNDEFINED")
137146
set(INCLUDE_EXTERNAL_LIBS_INTERFACE )

build/configs/toolchain_external.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ include(CMakeForceCompiler)
1717
set(CMAKE_SYSTEM_NAME EXTERNAL)
1818
set(CMAKE_SYSTEM_PROCESSOR "${EXTERNAL_CMAKE_SYSTEM_PROCESSOR}")
1919

20-
CMAKE_FORCE_C_COMPILER(${EXTERNAL_CMAKE_C_COMPILER} GNU)
20+
CMAKE_FORCE_C_COMPILER(${EXTERNAL_CMAKE_C_COMPILER} ${EXTERNAL_CMAKE_C_COMPILER_FAMILY})

jerry-core/CMakeLists.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,13 @@ project (JerryCore C ASM)
147147
${SOURCE_CORE_PARSER_REGEXP}
148148
${SOURCE_CORE_JRT})
149149

150+
# Jerry port
151+
if(USE_DEFAULT_PORT)
152+
file(GLOB SOURCE_PORT_FILES ${CMAKE_SOURCE_DIR}/targets/default/*.c)
153+
else()
154+
set(SOURCE_PORT_FILES ${SOURCE_PORT_IMPLEMENTATION})
155+
endif()
156+
150157
# All-in-one build
151158
if("${ENABLE_ALL_IN_ONE}" STREQUAL "ON")
152159
set(ALL_IN_FILE "${CMAKE_BINARY_DIR}/jerry-all-in.c")
@@ -157,9 +164,13 @@ project (JerryCore C ASM)
157164
file(APPEND ${ALL_IN_FILE} "#include \"${FILE}\"\n")
158165
endforeach()
159166

167+
foreach(FILE ${SOURCE_PORT_FILES})
168+
file(APPEND ${ALL_IN_FILE} "#include \"${FILE}\"\n")
169+
endforeach()
170+
160171
set(SOURCE_CORE ${ALL_IN_FILE})
161172
else()
162-
set(SOURCE_CORE ${SOURCE_CORE_FILES})
173+
set(SOURCE_CORE ${SOURCE_CORE_FILES} ${SOURCE_PORT_FILES})
163174
endif()
164175

165176
# Per-option configuration
File renamed without changes.

targets/pebble/Makefile.pebble

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
CURDIR = `pwd`
2+
SRCPATH = ${CURDIR}/targets/pebble/source
3+
TYPE = release
4+
MODIFIER ?=
5+
BUILD_DIR ?= build
6+
INTERM = $(BUILD_DIR)/obj-pebble
7+
OUTPUT = $(BUILD_DIR)/bin/$(TYPE).pebble
8+
COPYTARGET = $(BUILD_DIR)/lib
9+
JERRYHEAP ?= 8
10+
PORT_FILE = $(SRCPATH)/jerry_port.c
11+
12+
CFLAGS += -Wno-error=format
13+
CFLAGS += -Wno-error=unused-parameter
14+
CFLAGS += -Wno-error=unused-variable
15+
CFLAGS += -Wno-strict-aliasing
16+
CFLAGS += -Wno-pedantic
17+
18+
CMAKE_FLAGS = \
19+
-DENABLE_LTO=OFF \
20+
-DCMAKE_RULE_MESSAGES=OFF \
21+
-DCMAKE_TOOLCHAIN_FILE=build/configs/toolchain_external.cmake \
22+
-DEXTERNAL_CMAKE_C_COMPILER=$(CC) \
23+
-DEXTERNAL_COMPILE_FLAGS="$(CFLAGS)" \
24+
-DEXTERNAL_PORT_FILE="$(PORT_FILE)" \
25+
-DEXTERNAL_MEM_HEAP_SIZE_KB=$(JERRYHEAP)
26+
27+
28+
ifdef PBLTEST
29+
$(warning RUNNING PBLTEST)
30+
CFLAGS += -Wno-conversion
31+
CFLAGS += -Wno-unknown-warning-option
32+
CMAKE_FLAGS += -DUSE_COMPILER_DEFAULT_LIBC=YES
33+
CMAKE_FLAGS += -DEXTERNAL_CMAKE_C_COMPILER_FAMILY=CLANG
34+
else
35+
# Building firmware -> use pblibc
36+
CMAKE_FLAGS += -DUSE_COMPILER_DEFAULT_LIBC=NO
37+
CMAKE_FLAGS += -DEXTERNAL_LIBC_INTERFACE=$(CURDIR)/../../../libc/include/
38+
CMAKE_FLAGS += -DEXTERNAL_CMAKE_C_COMPILER_FAMILY=GNU
39+
endif
40+
41+
42+
.PHONY: jerry clean
43+
44+
45+
all: jerry
46+
47+
48+
jerry:
49+
mkdir -p $(INTERM)
50+
mkdir -p $(OUTPUT)
51+
mkdir -p $(COPYTARGET)
52+
cmake -B$(INTERM) -H./ $(CMAKE_FLAGS)
53+
make -s -C $(INTERM) $(TYPE).external$(MODIFIER)
54+
cp `cat $(INTERM)/$(TYPE).external$(MODIFIER)/list` $(OUTPUT)/.
55+
cp $(OUTPUT)/lib$(TYPE)$(MODIFIER).jerry-core.a $(COPYTARGET)/libjerrycore.a
56+
cp $(OUTPUT)/lib$(TYPE)$(MODIFIER).jerry-fdlibm.third_party.lib.a $(COPYTARGET)/libfdlibm.a
57+
58+
59+
clean:
60+
rm -rf $(INTERM)
61+
rm -rf $(OUTPUT)
62+

targets/pebble/source/jerry_port.c

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#include "jerry-port.h"
2+
#include <stdarg.h>
3+
#include <stdint.h>
4+
5+
void pbl_log(uint8_t log_level, const char* src_filename, int src_line_number, const char* fmt, ...);
6+
7+
#define LOG_LEVEL_DEBUG 200
8+
#define LOG_LEVEL_ERROR 1
9+
10+
/**
11+
* Provide log message to filestream implementation for the engine.
12+
*/
13+
int jerry_port_logmsg (FILE* stream, const char* format, ...)
14+
{
15+
va_list args;
16+
va_start(args, format);
17+
18+
pbl_log(LOG_LEVEL_DEBUG, "JERRY-LOG", 0, format, args);
19+
20+
va_end(args);
21+
22+
return 0;
23+
}
24+
25+
/**
26+
* Provide error message to console implementation for the engine.
27+
*/
28+
int jerry_port_errormsg (const char* format, ...)
29+
{
30+
va_list args;
31+
va_start(args, format);
32+
33+
pbl_log(LOG_LEVEL_ERROR, "JERRY-ERROR", 0, format, args);
34+
35+
va_end(args);
36+
37+
return 0;
38+
}
39+
40+
void dbgserial_putchar(uint8_t c);
41+
42+
/**
43+
* Provide output character to console implementation for the engine.
44+
*/
45+
int jerry_port_putchar (int c)
46+
{
47+
dbgserial_putchar((uint8_t)c);
48+
return c;
49+
}
50+
51+
void wtf(void);
52+
53+
void jerry_port_abort () {
54+
wtf();
55+
}
56+

0 commit comments

Comments
 (0)