fix resolving c symbols in C

This commit is contained in:
2026-02-20 20:01:26 -06:00
parent bb8536f6c9
commit 68ae10bed0

View File

@@ -72,11 +72,19 @@ function get_packages_dir() {
// Get the core directory (in the global shop)
var core_package = 'core'
var _core_realpath = null
Shop.get_core_dir = function() {
return get_packages_dir() + '/' + core_package
}
function is_core_dir(dir) {
if (dir == 'core') return true
if (_core_realpath == null)
_core_realpath = fd.realpath(Shop.get_core_dir()) || false
return _core_realpath && dir == _core_realpath
}
// Get the reports directory (in the global shop)
Shop.get_reports_dir = function() {
return global_shop_path + '/reports'
@@ -818,9 +826,9 @@ function resolve_path(path, ctx)
ctx_path = ctx_dir + '/' + path
if (fd.is_file(ctx_path)) {
is_core = (ctx == 'core') || (ctx_dir == Shop.get_core_dir())
is_core = (ctx == 'core') || is_core_dir(ctx_dir)
scope = is_core ? SCOPE_CORE : SCOPE_LOCAL
return {path: ctx_path, scope: scope, pkg: ctx}
return {path: ctx_path, scope: scope, pkg: is_core ? 'core' : ctx}
}
if (is_internal_path(path))
@@ -973,7 +981,8 @@ function try_dylib_symbol(sym, pkg, file_stem) {
// Resolve a C symbol by searching:
// At each scope: check build-cache dylib first, then internal (static)
function resolve_c_symbol(path, package_context) {
function resolve_c_symbol(path, _pkg_ctx) {
var package_context = is_core_dir(_pkg_ctx) ? 'core' : _pkg_ctx
var explicit = split_explicit_package_import(path)
var sym = null
var loader = null
@@ -1284,7 +1293,8 @@ function get_module(path, package_context) {
return execute_module(info)
}
Shop.use = function use(path, package_context) {
Shop.use = function use(path, _pkg_ctx) {
var package_context = is_core_dir(_pkg_ctx) ? 'core' : _pkg_ctx
// Check for embedded module (static builds)
var embed_key = 'embedded:' + path
var embedded = null