This commit is contained in:
2026-02-20 15:33:46 -06:00
parent 11fb213a74
commit 5af76bce9b
40 changed files with 284 additions and 314 deletions

View File

@@ -192,7 +192,7 @@ Build.compile_file = function(pkg, file, target, opts) {
var core_dir = null
if (!fd.is_file(src_path)) {
print('Source file not found: ' + src_path)
log.error('Source file not found: ' + src_path)
return null
}
@@ -256,8 +256,8 @@ Build.compile_file = function(pkg, file, target, opts) {
var cmd_str = text(cmd_parts, ' ')
if (_opts.verbose) {
print('[verbose] CFLAGS: ' + text(cflags, ' '))
print('[verbose] compile: ' + cmd_str)
log.build('[verbose] CFLAGS: ' + text(cflags, ' '))
log.build('[verbose] compile: ' + cmd_str)
}
// Two-level cache: quick hash for deps file, full hash for object
@@ -271,7 +271,7 @@ Build.compile_file = function(pkg, file, target, opts) {
// Check for cached failure (skip files that previously failed to compile)
if (fd.is_file(fail_path)) {
if (_opts.verbose) print('[verbose] skipping ' + file + ' (cached failure)')
if (_opts.verbose) log.build('[verbose] skipping ' + file + ' (cached failure)')
log.shop('skip ' + file + ' (cached failure)')
return null
}
@@ -288,7 +288,7 @@ Build.compile_file = function(pkg, file, target, opts) {
full_content = hash_all_deps(cmd_str, deps)
obj_path = cache_path(full_content, SALT_OBJ)
if (fd.is_file(obj_path)) {
if (_opts.verbose) print('[verbose] cache hit: ' + file)
if (_opts.verbose) log.build('[verbose] cache hit: ' + file)
log.shop('cache hit ' + file)
return obj_path
}
@@ -304,7 +304,7 @@ Build.compile_file = function(pkg, file, target, opts) {
// Check if object exists (might exist from previous build with same deps)
if (fd.is_file(obj_path)) {
fd.slurpwrite(deps_path, stone(blob(text(deps, '\n'))))
if (_opts.verbose) print('[verbose] cache hit: ' + file + ' (after dep scan)')
if (_opts.verbose) log.build('[verbose] cache hit: ' + file + ' (after dep scan)')
log.shop('cache hit ' + file + ' (after dep scan)')
return obj_path
}
@@ -330,11 +330,11 @@ Build.compile_file = function(pkg, file, target, opts) {
if (missing != null) {
err_lines = array(err_text, "\n")
first_err = length(err_lines) > 0 ? err_lines[0] : err_text
print(file + ': ' + first_err + ' (SDK not installed?)')
log.error(file + ': ' + first_err + ' (SDK not installed?)')
} else {
print('Compilation failed: ' + file)
if (err_text) print(err_text)
else print('Command: ' + full_cmd)
log.error('Compilation failed: ' + file)
if (err_text) log.error(err_text)
else log.error('Command: ' + full_cmd)
}
// Cache the failure so we don't retry on every build
fd.slurpwrite(fail_path, stone(blob(err_text || 'compilation failed')))
@@ -436,7 +436,7 @@ Build.build_module_dylib = function(pkg, file, target, opts) {
var ret = null
if (_opts.verbose) {
print('[verbose] LDFLAGS: ' + text(resolved_ldflags, ' '))
log.build('[verbose] LDFLAGS: ' + text(resolved_ldflags, ' '))
}
if (!fd.is_file(dylib_path)) {
@@ -471,12 +471,12 @@ Build.build_module_dylib = function(pkg, file, target, opts) {
push(cmd_parts, '"' + dylib_path + '"')
cmd_str = text(cmd_parts, ' ')
if (_opts.verbose) print('[verbose] link: ' + cmd_str)
if (_opts.verbose) log.build('[verbose] link: ' + cmd_str)
log.shop('linking ' + file)
log.console('Linking module ' + file + ' -> ' + fd.basename(dylib_path))
ret = os.system(cmd_str)
if (ret != 0) {
print('Linking failed: ' + file)
log.error('Linking failed: ' + file)
return null
}
} else {
@@ -574,7 +574,7 @@ Build.build_static = function(packages, target, output, buildtype) {
})
if (length(all_objects) == 0) {
print('No object files to link'); disrupt
log.error('No object files to link'); disrupt
}
// Link
@@ -608,7 +608,7 @@ Build.build_static = function(packages, target, output, buildtype) {
log.console('Linking ' + out_path)
var ret = os.system(cmd_str)
if (ret != 0) {
print('Linking failed: ' + cmd_str); disrupt
log.error('Linking failed: ' + cmd_str); disrupt
}
log.console('Built ' + out_path)
@@ -637,7 +637,7 @@ function compile_native_single(il_parts, cc, tmp_prefix, extra_flags) {
fd.slurpwrite(s_path, stone(blob(asm_text)))
rc = os.system(cc + _extra + ' -c ' + s_path + ' -o ' + o_path)
if (rc != 0) {
print('Assembly failed'); disrupt
log.error('Assembly failed'); disrupt
}
return [o_path]
}
@@ -679,7 +679,7 @@ Build.compile_native = function(src_path, target, buildtype, pkg) {
var qbe_rt_path = null
if (!fd.is_file(src_path)) {
print('Source file not found: ' + src_path); disrupt
log.error('Source file not found: ' + src_path); disrupt
}
var tc = toolchains[_target]
@@ -721,7 +721,7 @@ Build.compile_native = function(src_path, target, buildtype, pkg) {
qbe_rt_path = shop.get_package_dir('core') + '/qbe_rt.c'
rc = os.system(cc + san_flags + ' -c ' + qbe_rt_path + ' -o ' + rt_o_path + ' -fPIC')
if (rc != 0) {
print('QBE runtime stubs compilation failed'); disrupt
log.error('QBE runtime stubs compilation failed'); disrupt
}
}
@@ -741,7 +741,7 @@ Build.compile_native = function(src_path, target, buildtype, pkg) {
rc = os.system(link_cmd)
if (rc != 0) {
print('Linking native dylib failed for: ' + src_path); disrupt
log.error('Linking native dylib failed for: ' + src_path); disrupt
}
log.console('Built native: ' + fd.basename(dylib_path))
@@ -793,7 +793,7 @@ Build.compile_native_ir = function(optimized, src_path, opts) {
qbe_rt_path = shop.get_package_dir('core') + '/qbe_rt.c'
rc = os.system(cc + san_flags + ' -c ' + qbe_rt_path + ' -o ' + rt_o_path + ' -fPIC')
if (rc != 0) {
print('QBE runtime stubs compilation failed'); disrupt
log.error('QBE runtime stubs compilation failed'); disrupt
}
}
@@ -813,7 +813,7 @@ Build.compile_native_ir = function(optimized, src_path, opts) {
rc = os.system(link_cmd)
if (rc != 0) {
print('Linking native dylib failed for: ' + src_path); disrupt
log.error('Linking native dylib failed for: ' + src_path); disrupt
}
log.console('Built native: ' + fd.basename(dylib_path))
@@ -829,7 +829,7 @@ Build.compile_native_ir = function(optimized, src_path, opts) {
// Returns the raw mach bytes as a blob
Build.compile_cm_to_mach = function(src_path) {
if (!fd.is_file(src_path)) {
print('Source file not found: ' + src_path); disrupt
log.error('Source file not found: ' + src_path); disrupt
}
var json = use('json')
var optimized = shop.compile_file(src_path)
@@ -919,7 +919,7 @@ Build.build_all_dynamic = function(target, buildtype, opts) {
})
// Print build report
print('\n--- Build Report ---')
log.build('--- Build Report ---')
arrfor(results, function(r) {
var pkg_dir = shop.get_package_dir(r.package)
var c_files = pkg_tools.get_c_files(r.package, _target, true)
@@ -931,10 +931,10 @@ Build.build_all_dynamic = function(target, buildtype, opts) {
total_fail = total_fail + fail_count
if (file_count == 0) return
var status = fail_count == 0 ? 'OK' : `${ok_count}/${file_count}`
print(` ${r.package}: ${status}`)
log.build(` ${r.package}: ${status}`)
})
print(`Total: ${total_ok}/${total_files} compiled, ${total_fail} failed`)
print('--------------------\n')
log.build(`Total: ${total_ok}/${total_files} compiled, ${total_fail} failed`)
log.build('--------------------')
return results
}