fix tests
This commit is contained in:
71
boot.ce
71
boot.ce
@@ -8,6 +8,8 @@
|
||||
|
||||
var shop = use('internal/shop')
|
||||
var fd = use('fd')
|
||||
var pkg_tools = use('package')
|
||||
var build = use('build')
|
||||
|
||||
var is_native = false
|
||||
var target_prog = null
|
||||
@@ -49,52 +51,7 @@ if (args && length(args) > 0) {
|
||||
|
||||
// Discover all transitive module dependencies for a file
|
||||
function discover_deps(file_path) {
|
||||
var visited = {}
|
||||
var scripts = []
|
||||
var c_packages = {}
|
||||
|
||||
function trace(fp) {
|
||||
if (visited[fp]) return
|
||||
visited[fp] = true
|
||||
|
||||
var fi = shop.file_info(fp)
|
||||
var file_pkg = fi.package
|
||||
var idx = null
|
||||
var j = 0
|
||||
var imp = null
|
||||
var mod_path = null
|
||||
var rinfo = null
|
||||
|
||||
// record this script (skip the root program itself)
|
||||
if (ends_with(fp, '.cm')) {
|
||||
scripts[] = {path: fp, package: file_pkg}
|
||||
}
|
||||
|
||||
var _trace = function() {
|
||||
idx = shop.index_file(fp)
|
||||
if (!idx || !idx.imports) return
|
||||
|
||||
j = 0
|
||||
while (j < length(idx.imports)) {
|
||||
imp = idx.imports[j]
|
||||
mod_path = imp.module_path
|
||||
rinfo = shop.resolve_import_info(mod_path, file_pkg)
|
||||
|
||||
if (rinfo) {
|
||||
if (rinfo.type == 'script' && rinfo.resolved_path) {
|
||||
trace(rinfo.resolved_path)
|
||||
} else if (rinfo.type == 'native' && rinfo.package) {
|
||||
c_packages[rinfo.package] = true
|
||||
}
|
||||
}
|
||||
j = j + 1
|
||||
}
|
||||
} disruption {}
|
||||
_trace()
|
||||
}
|
||||
|
||||
trace(file_path)
|
||||
return {scripts: scripts, c_packages: array(c_packages)}
|
||||
return shop.trace_deps(file_path)
|
||||
}
|
||||
|
||||
// Filter out already-cached modules
|
||||
@@ -118,11 +75,21 @@ function filter_uncached(deps) {
|
||||
j = j + 1
|
||||
}
|
||||
|
||||
// C packages always included — build_dynamic handles its own caching
|
||||
// Expand C packages into individual files for parallel compilation
|
||||
var target = build.detect_host_target()
|
||||
var pkg = null
|
||||
var c_files = null
|
||||
var k = 0
|
||||
j = 0
|
||||
while (j < length(deps.c_packages)) {
|
||||
if (deps.c_packages[j] != 'core') {
|
||||
uncached[] = {type: 'c_package', package: deps.c_packages[j]}
|
||||
pkg = deps.c_packages[j]
|
||||
if (pkg != 'core') {
|
||||
c_files = pkg_tools.get_c_files(pkg, target, true)
|
||||
k = 0
|
||||
while (k < length(c_files)) {
|
||||
uncached[] = {type: 'c_file', package: pkg, file: c_files[k]}
|
||||
k = k + 1
|
||||
}
|
||||
}
|
||||
j = j + 1
|
||||
}
|
||||
@@ -132,6 +99,7 @@ function filter_uncached(deps) {
|
||||
|
||||
function item_name(item) {
|
||||
if (item.path) return item.path
|
||||
if (item.file) return item.package + '/' + item.file
|
||||
return item.package
|
||||
}
|
||||
|
||||
@@ -147,7 +115,8 @@ function make_compile_requestor(item) {
|
||||
send(event.actor, {
|
||||
type: item.type,
|
||||
path: item.path,
|
||||
package: item.package
|
||||
package: item.package,
|
||||
file: item.file
|
||||
})
|
||||
}
|
||||
if (event.type == 'stop') {
|
||||
@@ -205,7 +174,7 @@ run_boot = function() {
|
||||
}
|
||||
|
||||
// Compile uncached modules in parallel using worker actors
|
||||
log.console('boot: compiling ' + text(length(uncached)) + ' modules...')
|
||||
log.console('boot: ' + text(length(uncached)) + ' modules to compile')
|
||||
requestors = array(uncached, make_compile_requestor)
|
||||
parallel(requestors)(function(results, reason) {
|
||||
if (reason) {
|
||||
|
||||
Reference in New Issue
Block a user