Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if(APPLE)
enable_language(OBJC)
endif()

fetch_package("github:holepunchto/bare@1.36.1")
fetch_package("github:holepunchto/bare@1.36.2")

add_subdirectory(src)

Expand Down
20 changes: 1 addition & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"homepage": "https://github.com/holepunchto/bare-kit#readme",
"dependencies": {
"bare-console": "^6.0.0",
"bare-crypto": "^1.2.8",
"bare-fs": "^4.0.1",
"bare-logger": "^2.0.0",
"bare-module": "^7.5.0",
Expand Down
138 changes: 129 additions & 9 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ add_bare_bundle(

add_library(bare_kit OBJECT)

add_library(bare::kit ALIAS bare_kit)

set_target_properties(
bare_kit
PROPERTIES
Expand Down Expand Up @@ -37,7 +39,7 @@ target_include_directories(
bare_kit
PUBLIC
../include
$<TARGET_PROPERTY:bare,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:bare::headers,INTERFACE_INCLUDE_DIRECTORIES>
)

if(APPLE)
Expand Down Expand Up @@ -120,16 +122,16 @@ endif()
target_link_libraries(
bare_kit
INTERFACE
$<LINK_LIBRARY:WHOLE_ARCHIVE,bare_static>
$<LINK_LIBRARY:WHOLE_ARCHIVE,bare::static>
PUBLIC
rlimit_static
)

if(LINUX)
if(APPLE OR LINUX)
target_sources(
bare_kit
PRIVATE
linux/symbols.c
unix/symbols.c
)

target_link_libraries(
Expand All @@ -145,21 +147,123 @@ else()
)
endif()

link_bare_modules(bare_kit WORKING_DIRECTORY ..)
link_bare_modules(
bare_kit
WORKING_DIRECTORY ..
EXCLUDE
bare-buffer
bare-hrtime
bare-inspect
bare-logger
bare-module
bare-module-lexer
bare-path
bare-structured-clone
bare-system-logger
bare-timers
bare-type
bare-type-stripper
bare-url
)

file(READ exports.json exports_json)

set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS exports.json)

set(exports)

string(JSON symbols LENGTH "${exports_json}")

math(EXPR last_symbol "${symbols} - 1")

foreach(i RANGE ${last_symbol})
string(JSON symbol GET "${exports_json}" ${i})

list(APPEND exports ${symbol})
endforeach()

if(ANDROID)
list(APPEND exports JNI_OnLoad)
endif()

add_library(bare_kit_exports INTERFACE)

add_library(bare::kit::exports ALIAS bare_kit_exports)

if(WIN32)
set(exports_file "${CMAKE_CURRENT_BINARY_DIR}/bare-kit.def")

list(TRANSFORM exports PREPEND " ")
list(JOIN exports "\n" exports)

file(CONFIGURE OUTPUT "${exports_file}" CONTENT "EXPORTS\n${exports}\n" @ONLY)

target_sources(
bare_kit_exports
INTERFACE
"${exports_file}"
)
elseif(APPLE)
set(exports_file "${CMAKE_CURRENT_BINARY_DIR}/bare-kit.exp")

list(TRANSFORM exports PREPEND "_")
list(JOIN exports "\n" exports)

file(CONFIGURE OUTPUT "${exports_file}" CONTENT "${exports}\n" @ONLY)

target_link_options(
bare_kit_exports
INTERFACE
"-Wl,-exported_symbols_list,${exports_file}"
)
else()
set(exports_file "${CMAKE_CURRENT_BINARY_DIR}/bare-kit.map")

list(TRANSFORM exports PREPEND " ")
list(JOIN exports ";\n" exports)

file(CONFIGURE OUTPUT "${exports_file}" CONTENT "{\n global:\n${exports};\n\n local:\n *;\n};\n" @ONLY)

target_link_options(
bare_kit_exports
INTERFACE
"-Wl,--version-script=${exports_file}"
)
endif()

set_target_properties(
bare_kit_exports
PROPERTIES
INTERFACE_LINK_DEPENDS "${exports_file}"
)

target_link_libraries(
bare_kit_exports
INTERFACE
bare::exports
)

add_library(bare_kit_shared SHARED)

add_library(bare::kit::shared ALIAS bare_kit_shared)

set_target_properties(
bare_kit_shared
PROPERTIES
OUTPUT_NAME bare-kit
)

if(WIN32)
target_sources(
target_link_libraries(
bare_kit_shared
PUBLIC
win32/bare-kit.def
bare_kit_exports
)
else()
target_link_libraries(
bare_kit_shared
PRIVATE
bare_kit_exports
)
endif()

Expand All @@ -175,6 +279,20 @@ target_link_libraries(
bare_kit
)

if(APPLE)
target_link_options(
bare_kit_shared
PRIVATE
$<$<CONFIG:Release>:-Wl,-dead_strip,-S,-x>
)
elseif(ANDROID OR LINUX)
target_link_options(
bare_kit_shared
PRIVATE
$<$<CONFIG:Release>:-Wl,--gc-sections,--strip-all>
)
endif()

if(ANDROID)
target_link_options(
bare_kit_shared
Expand All @@ -193,6 +311,8 @@ endif()

add_library(bare_kit_static STATIC)

add_library(bare::kit::static ALIAS bare_kit_static)

set_target_properties(
bare_kit_static
PROPERTIES
Expand All @@ -201,10 +321,10 @@ set_target_properties(
)

if(WIN32)
target_sources(
target_link_libraries(
bare_kit_static
PUBLIC
win32/bare-kit.def
bare_kit_exports
)
endif()

Expand Down
2 changes: 0 additions & 2 deletions src/builtins.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
[
{ "addon": "bare-buffer" },
{ "addon": "bare-crypto" },
{ "addon": "bare-fs" },
{ "addon": "bare-hrtime" },
{ "addon": "bare-inspect" },
{ "addon": "bare-logger" },
{ "addon": "bare-module" },
{ "addon": "bare-module-lexer" },
{ "addon": "bare-os" },
{ "addon": "bare-path" },
{ "addon": "bare-structured-clone" },
{ "addon": "bare-system-logger" },
Expand Down
31 changes: 31 additions & 0 deletions src/exports.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[
"bare_worklet_optimize_for_memory",
"bare_worklet_teardown",
"bare_worklet_create",
"bare_worklet_destroy",
"bare_worklet_on_suspend",
"bare_worklet_on_wakeup",
"bare_worklet_on_idle",
"bare_worklet_on_resume",
"bare_worklet_on_exit",
"bare_worklet_get_data",
"bare_worklet_set_data",
"bare_worklet_start",
"bare_worklet_suspend",
"bare_worklet_resume",
"bare_worklet_wakeup",
"bare_worklet_terminate",
"bare_ipc_create",
"bare_ipc_close",
"bare_ipc_end",
"bare_ipc_destroy",
"bare_ipc_read",
"bare_ipc_write",
"bare_ipc_poll_create",
"bare_ipc_poll_destroy",
"bare_ipc_poll_get_data",
"bare_ipc_poll_set_data",
"bare_ipc_poll_get_ipc",
"bare_ipc_poll_start",
"bare_ipc_poll_stop"
]
4 changes: 2 additions & 2 deletions src/linux/symbols.c → src/unix/symbols.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

void
bare_kit__expose_symbols(void) {
// As glibc ignores `-z global`, promote the library to the global scope in
// case it was loaded with `RTLD_LOCAL`.
// Addons resolve the symbols of Bare from the global scope, so promote the
// library to it in case it was loaded with `RTLD_LOCAL`.
Dl_info info;

if (dladdr((void *) bare_kit__expose_symbols, &info) == 0 || info.dli_fname == NULL) return;
Expand Down
30 changes: 0 additions & 30 deletions src/win32/bare-kit.def

This file was deleted.

3 changes: 1 addition & 2 deletions src/worklet.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const path = require('bare-path')
const fs = require('bare-fs')
const crypto = require('bare-crypto')
const { pathToFileURL } = require('bare-url')
const URL = require('bare-url')
const Module = require('bare-module')
Expand Down Expand Up @@ -157,7 +156,7 @@ function extract(resources, filename, readResource) {
// Worklets may extract the same resources at once, so each file is moved into
// place whole.
function write(target, data) {
const tmp = target + '.' + crypto.randomBytes(8).toString('hex')
const tmp = target + '.' + Math.random().toString(16).slice(2)

fs.mkdirSync(path.dirname(target), { recursive: true })
fs.writeFileSync(tmp, Buffer.from(data))
Expand Down
Loading
Loading