fix issue where linked packages would not load dylibs correctly
This commit is contained in:
@@ -563,18 +563,27 @@ Shop.open_package_dylib = function(pkg) {
|
||||
if (cfg.dependencies) {
|
||||
for (var alias in cfg.dependencies) {
|
||||
var dep_pkg = cfg.dependencies[alias]
|
||||
try {
|
||||
Shop.open_package_dylib(dep_pkg)
|
||||
} catch (dep_e) {
|
||||
// Dependency dylib load failed, continue with others
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
// Ignore errors reading cell.toml
|
||||
// Error reading toml, continue
|
||||
}
|
||||
}
|
||||
|
||||
var dl_path = get_lib_path(pkg)
|
||||
if (fd.is_file(dl_path)) {
|
||||
if (!open_dls[dl_path]) {
|
||||
try {
|
||||
open_dls[dl_path] = os.dylib_open(dl_path)
|
||||
} catch (e) {
|
||||
dylib_visited[pkg] = false
|
||||
throw e
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -582,9 +591,8 @@ Shop.open_package_dylib = function(pkg) {
|
||||
// Resolve a C symbol by searching:
|
||||
// 1. If package_context is null, only check core internal symbols
|
||||
// 2. Otherwise: own package (internal then dylib) -> other packages (internal then dylib) -> core (internal only)
|
||||
// Core is never loaded as a dynamic library via dlopen
|
||||
function resolve_c_symbol(path, package_context)
|
||||
{
|
||||
// Core is never loaded as a dynamic library via dlopen
|
||||
function resolve_c_symbol(path, package_context) {
|
||||
var explicit = split_explicit_package_import(path)
|
||||
if (explicit) {
|
||||
if (is_internal_path(explicit.path) && package_context && explicit.package != package_context)
|
||||
|
||||
31
package.cm
31
package.cm
@@ -3,6 +3,7 @@ var package = {}
|
||||
var fd = use('fd')
|
||||
var toml = use('toml')
|
||||
var os = use('os')
|
||||
var link = use('link')
|
||||
|
||||
// Convert package name to a safe directory name
|
||||
// For absolute paths (local packages), replace / with _
|
||||
@@ -22,6 +23,18 @@ function get_path(name)
|
||||
// If name is already an absolute path, use it directly
|
||||
if (name.startsWith('/'))
|
||||
return name
|
||||
|
||||
// Check if this package is linked - if so, use the link target directly
|
||||
// This avoids symlink-related issues with file reading
|
||||
var link_target = link.get_target(name)
|
||||
if (link_target) {
|
||||
// If link target is a local path, use it directly
|
||||
if (link_target.startsWith('/'))
|
||||
return link_target
|
||||
// Otherwise it's another package name, resolve that
|
||||
return os.global_shop_path + '/packages/' + link_target.replaceAll('@', '_')
|
||||
}
|
||||
|
||||
// Remote packages use nested directories, so don't transform slashes
|
||||
return os.global_shop_path + '/packages/' + name.replaceAll('@', '_')
|
||||
}
|
||||
@@ -36,7 +49,12 @@ package.load_config = function(name)
|
||||
if (!content || content.trim().length == 0)
|
||||
return {}
|
||||
|
||||
return toml.decode(content)
|
||||
var result = toml.decode(content)
|
||||
if (!result) {
|
||||
return {}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
package.save_config = function(name, config)
|
||||
@@ -131,12 +149,19 @@ package.split_alias = function(name, path)
|
||||
var parts = path.split('/')
|
||||
var first_part = parts[0]
|
||||
|
||||
try {
|
||||
var config = package.load_config(name)
|
||||
if (config.dependencies && config.dependencies[first_part]) {
|
||||
var dep_locator = config.dependencies[first_part]
|
||||
if (!config) return null
|
||||
|
||||
var deps = config.dependencies
|
||||
if (deps && deps[first_part]) {
|
||||
var dep_locator = deps[first_part]
|
||||
var remaining_path = parts.slice(1).join('/')
|
||||
return { package: dep_locator, path: remaining_path }
|
||||
}
|
||||
} catch (e) {
|
||||
// Config doesn't exist or couldn't be loaded
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user