main wrapper

This commit is contained in:
2025-12-05 12:52:40 -06:00
parent 230880a02f
commit d6daa97ac7
4 changed files with 33 additions and 17 deletions

View File

@@ -187,20 +187,9 @@ else
link += '-Wl,-export_dynamic' link += '-Wl,-export_dynamic'
endif endif
cell_bin = executable('cell_bin', sources,
dependencies: deps,
include_directories: includers,
link_args: link,
build_rpath: '$ORIGIN',
install: false
)
cell_dep = declare_dependency( cell_so = shared_library(
link_with: cell_bin 'cell_runtime',
)
cell_so = both_libraries(
'cell',
sources, sources,
include_directories: includers, include_directories: includers,
dependencies: deps, dependencies: deps,
@@ -215,9 +204,30 @@ qop_target = custom_target('core.qop',
build_always_stale: true build_always_stale: true
) )
# Create final cell executable by appending core.zip to cell_bin # Determine RPATH based on OS
# MacOS uses @loader_path, Linux uses $ORIGIN
# We include both the current directory (for build) and ../lib (for install)
rpath_dirs = []
if host_machine.system() == 'darwin'
rpath_dirs += ['@loader_path', '@loader_path/../lib']
elif host_machine.system() == 'linux'
rpath_dirs += ['$ORIGIN', '$ORIGIN/../lib']
endif
# Create main executable linked against the cell library
cell_exe = executable('cell_exe',
'source/main.c',
dependencies: deps,
include_directories: includers,
link_with: cell_so,
link_args: link,
build_rpath: ':'.join(rpath_dirs),
install: false
)
# Create final cell executable by appending core.zip to cell_exe
cell = custom_target('cell', cell = custom_target('cell',
input: [cell_bin, qop_target], input: [cell_exe, qop_target],
output: 'cell' + exe_ext, output: 'cell' + exe_ext,
command: [ command: [
'sh', '-c', 'sh', '-c',

View File

@@ -1239,7 +1239,7 @@ Shop.build_package = function(package)
objs_str += '"$HERE/' + c_objects[i] + '" ' objs_str += '"$HERE/' + c_objects[i] + '" '
} }
var link_cmd = 'HERE=$(pwd); cd ' + module_dir + ' && cc ' + link_flags + ' ' + objs_str + ' -lcell -lc -lc++ -o ' + temp_lib var link_cmd = 'HERE=$(pwd); cd ' + module_dir + ' && cc ' + link_flags + ' ' + objs_str + ' -lcell_runtime -lc -lc++ -o ' + temp_lib
var ret = os.system(link_cmd) var ret = os.system(link_cmd)
if (ret != 0) { if (ret != 0) {
log.error("Linking failed") log.error("Linking failed")

View File

@@ -460,7 +460,7 @@ static void signal_handler(int sig)
exit_handler(); exit_handler();
} }
int main(int argc, char **argv) int cell_init(int argc, char **argv)
{ {
int profile_enabled = 0; int profile_enabled = 0;
int script_start = 1; int script_start = 1;

6
source/main.c Normal file
View File

@@ -0,0 +1,6 @@
extern int cell_init(int argc, char **argv);
int main(int argc, char **argv)
{
return cell_init(argc, argv);
}