Skip to content

Commit ccc8d6d

Browse files
committed
update(quckjs): Move to shared library
1 parent 2ab369d commit ccc8d6d

File tree

3 files changed

+1020
-947
lines changed

3 files changed

+1020
-947
lines changed

.github/workflows/builder.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
uses: actions/upload-artifact@v4
4646
with:
4747
name: Swiftly.JS.Linux
48-
path: ${{ github.workspace }}/quickjs/build/libqjs.a
48+
path: ${{ github.workspace }}/quickjs/build/libqjs.so
4949

5050
- name: Upload Headers
5151
if: matrix.os == 'ubuntu-latest'
@@ -59,4 +59,4 @@ jobs:
5959
uses: actions/upload-artifact@v4
6060
with:
6161
name: Swiftly.JS.Windows
62-
path: ${{ github.workspace }}/quickjs/build/Release/qjs.lib
62+
path: ${{ github.workspace }}/quickjs/build/Release/*

CMakeLists.txt

Lines changed: 3 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ endmacro()
121121
xoption(BUILD_SHARED_LIBS "Build a shared library" OFF)
122122
if(BUILD_SHARED_LIBS)
123123
message(STATUS "Building a shared library")
124+
add_definitions(-D${OPTION_NAME})
124125
endif()
125126

126127
# note: QJS_ENABLE_TSAN is currently incompatible with the other sanitizers but we
@@ -219,6 +220,8 @@ set(qjs_sources
219220
quickjs.c
220221
)
221222

223+
add_definitions(-DQUICKJS_BUILDDLL)
224+
222225
if(QJS_BUILD_LIBC)
223226
list(APPEND qjs_sources quickjs-libc.c)
224227
endif()
@@ -265,59 +268,6 @@ if(EMSCRIPTEN)
265268
target_link_libraries(qjs_wasm m)
266269
endif()
267270

268-
269-
# QuickJS bytecode compiler
270-
#
271-
272-
add_executable(qjsc
273-
qjsc.c
274-
)
275-
add_qjs_libc_if_needed(qjsc)
276-
add_static_if_needed(qjsc)
277-
target_compile_definitions(qjsc PRIVATE ${qjs_defines})
278-
target_link_libraries(qjsc qjs)
279-
280-
281-
# QuickJS CLI
282-
#
283-
284-
add_executable(qjs_exe
285-
gen/repl.c
286-
gen/standalone.c
287-
qjs.c
288-
)
289-
add_qjs_libc_if_needed(qjs_exe)
290-
add_static_if_needed(qjs_exe)
291-
set_target_properties(qjs_exe PROPERTIES
292-
OUTPUT_NAME "qjs"
293-
)
294-
target_compile_definitions(qjs_exe PRIVATE ${qjs_defines})
295-
target_link_libraries(qjs_exe qjs)
296-
if(NOT WIN32)
297-
set_target_properties(qjs_exe PROPERTIES ENABLE_EXPORTS TRUE)
298-
endif()
299-
if(QJS_BUILD_CLI_WITH_MIMALLOC OR QJS_BUILD_CLI_WITH_STATIC_MIMALLOC)
300-
find_package(mimalloc REQUIRED)
301-
# Upstream mimalloc doesn't provide a way to know if both libraries are supported.
302-
if(QJS_BUILD_CLI_WITH_STATIC_MIMALLOC)
303-
target_link_libraries(qjs_exe mimalloc-static)
304-
else()
305-
target_link_libraries(qjs_exe mimalloc)
306-
endif()
307-
endif()
308-
309-
# Test262 runner
310-
#
311-
312-
if(NOT EMSCRIPTEN)
313-
add_executable(run-test262
314-
run-test262.c
315-
)
316-
add_qjs_libc_if_needed(run-test262)
317-
target_compile_definitions(run-test262 PRIVATE ${qjs_defines})
318-
target_link_libraries(run-test262 qjs)
319-
endif()
320-
321271
# Interrupt test
322272
#
323273

@@ -337,14 +287,6 @@ add_executable(unicode_gen EXCLUDE_FROM_ALL
337287
)
338288
target_compile_definitions(unicode_gen PRIVATE ${qjs_defines})
339289

340-
add_executable(function_source
341-
gen/function_source.c
342-
)
343-
add_qjs_libc_if_needed(function_source)
344-
target_include_directories(function_source PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
345-
target_compile_definitions(function_source PRIVATE ${qjs_defines})
346-
target_link_libraries(function_source qjs)
347-
348290
# Examples
349291
#
350292

@@ -416,8 +358,6 @@ if(NOT IOS)
416358
if(QJS_BUILD_LIBC)
417359
install(FILES quickjs-libc.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
418360
endif()
419-
install(TARGETS qjs_exe RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
420-
install(TARGETS qjsc RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
421361
install(TARGETS qjs EXPORT qjsConfig
422362
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
423363
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}

0 commit comments

Comments
 (0)