centralized ensure dir
This commit is contained in:
22
build.cm
22
build.cm
@@ -118,19 +118,7 @@ function get_build_dir() {
|
||||
return shop.get_build_dir()
|
||||
}
|
||||
|
||||
function ensure_dir(path) {
|
||||
if (fd.stat(path).isDirectory) return
|
||||
var parts = array(path, '/')
|
||||
var current = starts_with(path, '/') ? '/' : ''
|
||||
var i = 0
|
||||
for (i = 0; i < length(parts); i++) {
|
||||
if (parts[i] == '') continue
|
||||
current += parts[i] + '/'
|
||||
if (!fd.stat(current).isDirectory) fd.mkdir(current)
|
||||
}
|
||||
}
|
||||
|
||||
Build.ensure_dir = ensure_dir
|
||||
Build.ensure_dir = fd.ensure_dir
|
||||
|
||||
// ============================================================================
|
||||
// Dependency scanning helpers
|
||||
@@ -267,7 +255,7 @@ Build.compile_file = function(pkg, file, target, opts) {
|
||||
var fail_path = cache_path(quick_content, SALT_FAIL)
|
||||
|
||||
var build_dir = get_build_dir()
|
||||
ensure_dir(build_dir)
|
||||
fd.ensure_dir(build_dir)
|
||||
|
||||
// Check for cached failure (skip files that previously failed to compile)
|
||||
if (fd.is_file(fail_path)) {
|
||||
@@ -429,7 +417,7 @@ Build.build_module_dylib = function(pkg, file, target, opts) {
|
||||
all_objects = array(all_objects, _extra)
|
||||
var link_content = compute_link_content(all_objects, resolved_ldflags, target_ldflags, {target: _target, cc: cc})
|
||||
var build_dir = get_build_dir()
|
||||
ensure_dir(build_dir)
|
||||
fd.ensure_dir(build_dir)
|
||||
var dylib_path = cache_path(link_content, SALT_DYLIB)
|
||||
var cmd_parts = null
|
||||
var cmd_str = null
|
||||
@@ -703,7 +691,7 @@ Build.compile_native = function(src_path, target, buildtype, pkg) {
|
||||
var src = text(fd.slurp(src_path))
|
||||
var native_key = native_cache_content(src, _target, san_flags)
|
||||
var build_dir = get_build_dir()
|
||||
ensure_dir(build_dir)
|
||||
fd.ensure_dir(build_dir)
|
||||
|
||||
var dylib_path = cache_path(native_key, SALT_NATIVE)
|
||||
if (fd.is_file(dylib_path))
|
||||
@@ -775,7 +763,7 @@ Build.compile_native_ir = function(optimized, src_path, opts) {
|
||||
var src = text(fd.slurp(src_path))
|
||||
var native_key = native_cache_content(src, _target, san_flags)
|
||||
var build_dir = get_build_dir()
|
||||
ensure_dir(build_dir)
|
||||
fd.ensure_dir(build_dir)
|
||||
|
||||
var dylib_path = cache_path(native_key, SALT_NATIVE)
|
||||
if (fd.is_file(dylib_path))
|
||||
|
||||
Reference in New Issue
Block a user