fix compile

This commit is contained in:
2025-12-02 06:45:09 -06:00
parent 20f5e4e81c
commit 0c5609c4e9
2 changed files with 24 additions and 11 deletions

View File

@@ -7,6 +7,18 @@ if (!fd.is_dir('.cell'))
var shop = use('shop')
var config = shop.load_config()
function get_flags(config, platform, key) {
var flags = ''
if (config.compilation && config.compilation[key]) {
flags += config.compilation[key]
}
if (config.compilation && config.compilation[platform] && config.compilation[platform][key]) {
if (flags != '') flags += ' '
flags += config.compilation[platform][key]
}
return flags
}
var files = fd.enumerate('.', true)
var objects = []
@@ -55,11 +67,8 @@ for (var i = 0; i < files.length; i++) {
// Compile command
// cc -fPIC -c <file> -O3 -DCELL_USE_NAME=<name> -o <obj_file>
var cmd = 'cc -fPIC -c ' + file + ' -O3 -DCELL_USE_NAME=' + use_name + ' -o ' + obj_file
if (config.compilation)
cmd += ` ${config.compilation.CFLAGS} `
if (config.compilation[os.platform()]?.CFLAGS)
cmd += ` ${config.compilation[os.platform()].CFLAGS} `
var cflags = get_flags(config, os.platform(), 'CFLAGS')
if (cflags != '') cmd += ' ' + cflags
var ret = os.system(cmd)
if (ret != 0) {
@@ -70,6 +79,14 @@ for (var i = 0; i < files.length; i++) {
}
}
// Check if there are any object files to link
if (objects.length == 0) {
log.console("No object files found, skipping linking.")
log.console("Build complete: no shared library created")
$_.stop()
return
}
// 4. Link shared library
var lib_ext = '.so'
var link_flags = '-shared'
@@ -87,11 +104,8 @@ if (!fd.is_dir('.cell/local'))
var lib_name = '.cell/local/local' + lib_ext
log.console("Linking " + lib_name)
if (config.compilation)
link_flags += ` ${config.compilation.LDFLAGS} `
if (config.compilation[os.platform()])
link_flags += ` ${config.compilation[os.platform()].LDFLAGS} `
var ldflags = get_flags(config, os.platform(), 'LDFLAGS')
if (ldflags != '') link_flags += ' ' + ldflags
var link_cmd = 'cc ' + link_flags + ' ' + objects.join(' ') + ' -lcell -lc -lc++ -o ' + lib_name
var ret = os.system(link_cmd)

View File

@@ -682,7 +682,6 @@ stone.p = function(object)
function guid(bits = 256)
{
log.console(os.random())
var guid = new blob(bits, os.random)
stone(guid)
return text(guid,'h')