fix build hangs
This commit is contained in:
12
build.cm
12
build.cm
@@ -91,6 +91,7 @@ var SALT_NATIVE = 'native' // native-compiled .cm dylib
|
||||
var SALT_MACH = 'mach' // mach bytecode blob
|
||||
var SALT_MCODE = 'mcode' // mcode IR (JSON)
|
||||
var SALT_DEPS = 'deps' // cached cc -MM dependency list
|
||||
var SALT_FAIL = 'fail' // cached compilation failure
|
||||
|
||||
function cache_path(content, salt) {
|
||||
return get_build_dir() + '/' + content_hash(content + '\n' + salt)
|
||||
@@ -246,10 +247,18 @@ Build.compile_file = function(pkg, file, target, opts) {
|
||||
var file_content = fd.slurp(src_path)
|
||||
var quick_content = cmd_str + '\n' + text(file_content)
|
||||
var deps_path = cache_path(quick_content, SALT_DEPS)
|
||||
var fail_path = cache_path(quick_content, SALT_FAIL)
|
||||
|
||||
var build_dir = get_build_dir()
|
||||
ensure_dir(build_dir)
|
||||
|
||||
// Check for cached failure (skip files that previously failed to compile)
|
||||
if (fd.is_file(fail_path)) {
|
||||
if (_opts.verbose) print('[verbose] skipping ' + file + ' (cached failure)')
|
||||
log.shop('skip ' + file + ' (cached failure)')
|
||||
return null
|
||||
}
|
||||
|
||||
var deps = null
|
||||
var full_content = null
|
||||
var obj_path = null
|
||||
@@ -310,6 +319,8 @@ Build.compile_file = function(pkg, file, target, opts) {
|
||||
if (err_text) print(err_text)
|
||||
else print('Command: ' + full_cmd)
|
||||
}
|
||||
// Cache the failure so we don't retry on every build
|
||||
fd.slurpwrite(fail_path, stone(blob(err_text || 'compilation failed')))
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -944,6 +955,7 @@ Build.SALT_NATIVE = SALT_NATIVE
|
||||
Build.SALT_MACH = SALT_MACH
|
||||
Build.SALT_MCODE = SALT_MCODE
|
||||
Build.SALT_DEPS = SALT_DEPS
|
||||
Build.SALT_FAIL = SALT_FAIL
|
||||
Build.cache_path = cache_path
|
||||
|
||||
return Build
|
||||
|
||||
Reference in New Issue
Block a user