tooling improvements

This commit is contained in:
2026-02-17 13:37:17 -06:00
parent 2e78e7e0b8
commit c02fbbd9e0
10 changed files with 371 additions and 186 deletions

View File

@@ -172,6 +172,11 @@ 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)
}
// Content hash: command + file content
var file_content = fd.slurp(src_path)
var hash_input = cmd_str + '\n' + text(file_content)
@@ -183,8 +188,10 @@ Build.compile_file = function(pkg, file, target, opts) {
// Check if already compiled
if (fd.is_file(obj_path)) {
if (_opts.verbose) print('[verbose] cache hit: ' + file)
return obj_path
}
if (_opts.verbose) print('[verbose] cache miss: ' + file)
// Compile — capture stderr to detect missing-header vs real errors
var err_path = '/tmp/cell_build_err_' + hash + '.log'
@@ -308,6 +315,10 @@ Build.build_module_dylib = function(pkg, file, target, opts) {
var cmd_str = null
var ret = null
if (_opts.verbose) {
print('[verbose] LDFLAGS: ' + text(resolved_ldflags, ' '))
}
if (!fd.is_file(dylib_path)) {
cmd_parts = [cc, '-shared', '-fPIC']
@@ -340,6 +351,7 @@ 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)
log.console('Linking module ' + file + ' -> ' + fd.basename(dylib_path))
ret = os.system(cmd_str)
if (ret != 0) {
@@ -361,6 +373,7 @@ Build.build_module_dylib = function(pkg, file, target, opts) {
ensure_dir(install_dir)
var install_path = shop.get_lib_dir() + '/' + shop.lib_name_for_package(pkg) + '/' + file_stem + dylib_ext
fd.slurpwrite(install_path, fd.slurp(dylib_path))
if (_opts.verbose) print('[verbose] install: ' + install_path)
return dylib_path
}
@@ -368,9 +381,10 @@ Build.build_module_dylib = function(pkg, file, target, opts) {
// Build a dynamic library for a package (one dylib per C file)
// Returns array of {file, symbol, dylib} for each module
// Also writes a manifest mapping symbols to dylib paths
Build.build_dynamic = function(pkg, target, buildtype) {
Build.build_dynamic = function(pkg, target, buildtype, opts) {
var _target = target || Build.detect_host_target()
var _buildtype = buildtype || 'release'
var _opts = opts || {}
var c_files = pkg_tools.get_c_files(pkg, _target, true)
var results = []
@@ -382,13 +396,13 @@ Build.build_dynamic = function(pkg, target, buildtype) {
var sources = pkg_tools.get_sources(pkg)
var support_objects = []
arrfor(sources, function(src_file) {
var obj = Build.compile_file(pkg, src_file, _target, {buildtype: _buildtype, cflags: cached_cflags})
var obj = Build.compile_file(pkg, src_file, _target, {buildtype: _buildtype, cflags: cached_cflags, verbose: _opts.verbose})
push(support_objects, obj)
})
arrfor(c_files, function(file) {
var sym_name = shop.c_symbol_for_file(pkg, file)
var dylib = Build.build_module_dylib(pkg, file, _target, {buildtype: _buildtype, extra_objects: support_objects, cflags: cached_cflags})
var dylib = Build.build_module_dylib(pkg, file, _target, {buildtype: _buildtype, extra_objects: support_objects, cflags: cached_cflags, verbose: _opts.verbose})
if (dylib) {
push(results, {file: file, symbol: sym_name, dylib: dylib})
}
@@ -847,9 +861,10 @@ Build.generate_module_table = function(modules, output) {
// ============================================================================
// Build dynamic libraries for all installed packages
Build.build_all_dynamic = function(target, buildtype) {
Build.build_all_dynamic = function(target, buildtype, opts) {
var _target = target || Build.detect_host_target()
var _buildtype = buildtype || 'release'
var _opts = opts || {}
var packages = shop.list_packages()
var results = []
@@ -860,14 +875,14 @@ Build.build_all_dynamic = function(target, buildtype) {
// Build core first
if (find(packages, function(p) { return p == 'core' }) != null) {
core_mods = Build.build_dynamic('core', _target, _buildtype)
core_mods = Build.build_dynamic('core', _target, _buildtype, _opts)
push(results, {package: 'core', modules: core_mods})
}
// Build other packages
arrfor(packages, function(pkg) {
if (pkg == 'core') return
var pkg_mods = Build.build_dynamic(pkg, _target, _buildtype)
var pkg_mods = Build.build_dynamic(pkg, _target, _buildtype, _opts)
push(results, {package: pkg, modules: pkg_mods})
})