Skip to content

Commit 348426b

Browse files
committed
feat: use jerryscripts default port implementation
1 parent ef14b32 commit 348426b

File tree

4 files changed

+33
-130
lines changed

4 files changed

+33
-130
lines changed

docs/modules/ROOT/pages/install.adoc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,11 @@ Patch the JerryScript source with our CMake shim and install it:
121121
tar -xf jerryscript-3.0.0.tar.gz <.>
122122
cp ../mrdocs/third-party/patches/jerryscript/CMakeLists.txt ./jerryscript-3.0.0/CMakeLists.txt <.>
123123
cp ../mrdocs/third-party/patches/jerryscript/jerryscriptConfig.cmake.in ./jerryscript-3.0.0/jerryscriptConfig.cmake.in <.>
124-
cp ../mrdocs/third-party/patches/jerryscript/port.c ./jerryscript-3.0.0/port.c <.>
125124
cd jerryscript-3.0.0
126125
127126
cmake -S . -B ./build -DCMAKE_BUILD_TYPE=Release \
128127
-DJERRY_PROFILE=es.next -DJERRY_CMDLINE=OFF -DJERRY_TESTS=OFF -DJERRY_DEBUGGER=OFF \
129-
-DJERRY_SNAPSHOT_SAVE=OFF -DJERRY_SNAPSHOT_EXEC=OFF -DJERRY_PORT_DEFAULT=ON \
128+
-DJERRY_SNAPSHOT_SAVE=OFF -DJERRY_SNAPSHOT_EXEC=OFF \
130129
-DJERRY_MEM_STATS=OFF -DJERRY_PARSER_STATS=OFF -DJERRY_LINE_INFO=OFF \
131130
-DJERRY_LTO=OFF -DJERRY_LIBC=OFF -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL
132131
cmake --build ./build --config Release
@@ -135,7 +134,9 @@ cmake --install ./build --prefix ./install
135134
136135
<.> Extracts the `JerryScript` source code.
137136
<.> Adds CMake packaging files maintained in this repository.
138-
<.> Provides the port layer and CMake config used by MrDocs.
137+
138+
The build uses JerryScript's upstream default port implementation; no custom
139+
`port.c` from MrDocs is required.
139140
140141
=== Libxml2
141142

third-party/patches/jerryscript/CMakeLists.txt

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Minimal CMake packaging wrapper for JerryScript
2-
# Builds a static jerry-core with ES.next profile, no tools/debugger/snapshots, and a custom port layer for MrDocs.
2+
# Builds a static jerry-core with ES.next profile, no tools/debugger/snapshots, and reuses the upstream default port.
33

44
cmake_minimum_required(VERSION 3.16)
55
project(jerryscript VERSION 3.0.0 LANGUAGES C)
@@ -18,7 +18,21 @@ option(JERRY_PARSER_STATS "Enable parser statistics" OFF)
1818
option(JERRY_LINE_INFO "Enable line info" OFF)
1919
option(JERRY_LTO "Enable LTO" OFF)
2020
option(JERRY_LIBC "Use bundled libc" OFF)
21-
option(JERRY_PORT_DEFAULT "Use default port implementation" ON)
21+
option(JERRY_PORT "Build default port implementation" ON)
22+
23+
# Minimal platform/compiler detection to satisfy jerry-port CMake expectations.
24+
set(PLATFORM "${CMAKE_SYSTEM_NAME}")
25+
string(TOUPPER "${PLATFORM}" PLATFORM)
26+
27+
if(MSVC)
28+
set(USING_MSVC 1)
29+
endif()
30+
if(CMAKE_C_COMPILER_ID MATCHES "GNU")
31+
set(USING_GCC 1)
32+
endif()
33+
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
34+
set(USING_CLANG 1)
35+
endif()
2236

2337
if (MSVC AND NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
2438
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL" CACHE STRING "" FORCE)
@@ -27,22 +41,27 @@ endif()
2741
# Upstream expects an amalgam target; stub it.
2842
add_custom_target(amalgam)
2943

30-
add_library(jerryscript-port STATIC port.c)
31-
target_include_directories(jerryscript-port PUBLIC
32-
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/jerry-core/include>
33-
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
34-
3544
add_subdirectory(jerry-core)
45+
if (JERRY_PORT)
46+
add_subdirectory(jerry-port)
47+
endif()
3648

3749
set_target_properties(jerry-core PROPERTIES POSITION_INDEPENDENT_CODE ON)
3850
set_target_properties(jerry-core PROPERTIES
3951
INTERFACE_INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/jerry-core/include>;$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
4052
)
41-
target_link_libraries(jerry-core jerryscript-port)
53+
if (TARGET jerry-port)
54+
target_link_libraries(jerry-core jerry-port)
55+
endif()
4256

4357
add_library(jerryscript ALIAS jerry-core)
4458

45-
install(TARGETS jerry-core jerryscript-port
59+
set(_install_targets jerry-core)
60+
if (TARGET jerry-port)
61+
list(APPEND _install_targets jerry-port)
62+
endif()
63+
64+
install(TARGETS ${_install_targets}
4665
EXPORT jerryscriptTargets
4766
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
4867
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}

third-party/patches/jerryscript/port.c

Lines changed: 0 additions & 117 deletions
This file was deleted.

third-party/recipes/jerryscript.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"-DJERRY_SNAPSHOT_EXEC=OFF",
2323
"-DJERRY_CMDLINE=OFF",
2424
"-DJERRY_TESTS=OFF",
25-
"-DJERRY_PORT_DEFAULT=ON",
25+
"-DJERRY_PORT=ON",
2626
"-DJERRY_MEM_STATS=OFF",
2727
"-DJERRY_PARSER_STATS=OFF",
2828
"-DJERRY_LINE_INFO=OFF",

0 commit comments

Comments
 (0)