diff --git a/scripts/compile.ce b/scripts/compile.ce index bbe7d9ef..33f19d00 100644 --- a/scripts/compile.ce +++ b/scripts/compile.ce @@ -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 -O3 -DCELL_USE_NAME= -o 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) diff --git a/scripts/engine.cm b/scripts/engine.cm index 29d4f476..3a096911 100644 --- a/scripts/engine.cm +++ b/scripts/engine.cm @@ -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')