@@ -2,14 +2,12 @@ cmake_minimum_required(VERSION 3.15)
2
2
3
3
# Metadata
4
4
5
- project (NativeScript)
5
+ project (NativeScript CXX OBJCXX )
6
6
7
7
set (NAME NativeScript)
8
8
set (VERSION 0.1.0)
9
9
set (BUNDLE_IDENTIFIER "org.nativescript.runtime" )
10
10
11
- enable_language (OBJCXX)
12
-
13
11
set (CMAKE_CXX_STANDARD 20)
14
12
15
13
set (BUILD_FRAMEWORK TRUE )
@@ -21,8 +19,9 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_FLAGS}")
21
19
# Arguments
22
20
23
21
set (TARGET_PLATFORM "macos" CACHE STRING "Target platform for the Objective-C bridge" )
24
- set (TARGET_ENGINE "hermes " CACHE STRING "Target JS engine for the NativeScript runtime" )
22
+ set (TARGET_ENGINE "v8 " CACHE STRING "Target JS engine for the NativeScript runtime" )
25
23
set (METADATA_SIZE 0 CACHE STRING "Size of embedded metadata in bytes" )
24
+ set (BUILD_CLI_BINARY OFF CACHE BOOL "Build the NativeScript CLI binary" )
26
25
27
26
if (TARGET_PLATFORM STREQUAL "ios" )
28
27
set (CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET "13.0" )
@@ -72,7 +71,7 @@ elseif(TARGET_ENGINE STREQUAL "hermes")
72
71
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -std=c++20 -DTARGET_ENGINE_HERMES" )
73
72
elseif (TARGET_ENGINE STREQUAL "v8" )
74
73
set (TARGET_ENGINE_V8 TRUE )
75
- add_link_options ("-fuse-ld=/opt/homebrew/opt/llvm/bin/ld64. lld" )
74
+ add_link_options ("-fuse-ld=lld" )
76
75
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -stdlib=libc++ -std=c++20 -DTARGET_ENGINE_V8" )
77
76
elseif (TARGET_ENGINE STREQUAL "quickjs" )
78
77
set (TARGET_ENGINE_QUICKJS TRUE )
86
85
endif ()
87
86
88
87
if (ENABLE_JS_RUNTIME)
88
+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DENABLE_JS_RUNTIME" )
89
89
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_JS_RUNTIME" )
90
90
elseif (TARGET_PLATFORM_MACOS)
91
91
# If building a generic library for macOS, we'll build a dylib instead of a framework
@@ -102,7 +102,6 @@ message(STATUS "ENABLE_JS_RUNTIME = ${ENABLE_JS_RUNTIME}")
102
102
include_directories (
103
103
./
104
104
../metadata-generator/include
105
- ada
106
105
napi/common
107
106
libffi/${LIBFFI_BUILD} /include
108
107
)
@@ -128,20 +127,30 @@ set(SOURCE_FILES
128
127
ffi/Interop.mm
129
128
ffi/InlineFunctions.mm
130
129
ffi/ClassBuilder.mm
130
+ ffi/NativeScriptException.mm
131
131
)
132
132
133
133
if (ENABLE_JS_RUNTIME)
134
134
set (SOURCE_FILES
135
135
${SOURCE_FILES}
136
- runtime/Console.cpp
136
+ runtime/modules/console/ Console.cpp
137
137
runtime/Runtime.cpp
138
- runtime/Require.cpp
139
- runtime/Performance.cpp
138
+ runtime/modules/worker/Worker.mm
139
+ runtime/modules/worker/MessageJSON.cpp
140
+ runtime/modules/worker/MessageV8.cpp
141
+ runtime/modules/worker/ConcurrentQueue.cpp
142
+ runtime/modules/worker/WorkerImpl.mm
143
+ runtime/modules/worker/WorkerImpl.mm
144
+ runtime/modules/module/ModuleInternal.cpp
145
+ runtime/modules/performance/Performance.cpp
140
146
runtime/Bundle .mm
141
- runtime/Timers.mm
142
- runtime/App.mm
147
+ runtime/modules/timers/ Timers.mm
148
+ runtime/modules/app/ App.mm
143
149
runtime/NativeScript.mm
144
150
runtime/RuntimeConfig.cpp
151
+ runtime/modules/url/ada/ada.cpp
152
+ runtime/modules/url/URL.cpp
153
+ runtime/modules/url/URLSearchParams.cpp
145
154
)
146
155
147
156
if (TARGET_ENGINE_V8)
@@ -220,6 +229,13 @@ else()
220
229
)
221
230
endif ()
222
231
232
+ if (BUILD_CLI_BINARY)
233
+ set (SOURCE_FILES ${SOURCE_FILES}
234
+ cli/main.cpp
235
+ cli/segappend.cpp
236
+ )
237
+ endif ()
238
+
223
239
# Find SDK
224
240
225
241
find_program (XCODEBUILD_EXECUTABLE xcodebuild)
@@ -248,11 +264,15 @@ message(STATUS "SDK = ${CMAKE_OSX_SYSROOT}")
248
264
249
265
# Build targets
250
266
251
- add_library (
252
- ${NAME}
253
- SHARED
254
- ${SOURCE_FILES}
255
- )
267
+ if (BUILD_CLI_BINARY)
268
+ add_executable (${NAME} ${SOURCE_FILES} )
269
+ else ()
270
+ add_library (
271
+ ${NAME}
272
+ SHARED
273
+ ${SOURCE_FILES}
274
+ )
275
+ endif ()
256
276
257
277
target_sources (
258
278
${NAME}
0 commit comments