compile cpp files

This commit is contained in:
2025-11-30 16:37:36 -06:00
parent b29cdc8b93
commit b44d79ccab

View File

@@ -15,8 +15,8 @@ var objects = []
for (var i = 0; i < files.length; i++) {
var file = files[i]
if (file.endsWith('.c')) {
var path_no_ext = file.substring(0, file.length - 2)
if (file.endsWith('.c') || file.endsWith('.cpp')) {
var path_no_ext = file.substring(0, file.lastIndexOf('.'))
var safe_path = path_no_ext.replace(/\//g, '_').replace(/\\/g, '_')
if (safe_path.startsWith('._')) safe_path = safe_path.substring(2)
@@ -58,6 +58,12 @@ 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 ret = os.system(cmd)
if (ret != 0) {
log.console("Compilation failed for " + file)
@@ -85,9 +91,11 @@ if (!io.exists('.cell/local')) {
var lib_name = '.cell/local/local' + lib_ext
log.console("Linking " + lib_name)
if (config.compilation) {
if (config.compilation)
link_flags += ` ${config.compilation.LDFLAGS} `
}
if (config.compilation[os.platform()])
link_flags += ` ${config.compilation[os.platform()].LDFLAGS} `
var link_cmd = 'cc ' + link_flags + ' ' + objects.join(' ') + ' -lcell -o ' + lib_name
var ret = os.system(link_cmd)