length
This commit is contained in:
22
package.cm
22
package.cm
@@ -123,7 +123,7 @@ package.find_package_dir = function(file)
|
||||
if (fd.is_file(dir))
|
||||
dir = fd.dirname(dir)
|
||||
|
||||
while (dir && dir.length > 0) {
|
||||
while (dir && length(dir) > 0) {
|
||||
var toml_path = dir + '/cell.toml'
|
||||
if (fd.is_file(toml_path)) {
|
||||
return dir
|
||||
@@ -141,7 +141,7 @@ package.find_package_dir = function(file)
|
||||
// Returns null if no alias is found for the given path
|
||||
package.split_alias = function(name, path)
|
||||
{
|
||||
if (!path || path.length == 0) {
|
||||
if (!path || length(path) == 0) {
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ package.list_files = function(pkg) {
|
||||
var list = fd.readdir(current_dir)
|
||||
if (!list) return
|
||||
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
for (var i = 0; i < length(list); i++) {
|
||||
var item = list[i]
|
||||
if (item == '.' || item == '..') continue
|
||||
if (starts_with(item, '.')) continue
|
||||
@@ -227,7 +227,7 @@ package.list_files = function(pkg) {
|
||||
package.list_modules = function(name) {
|
||||
var files = package.list_files(name)
|
||||
var modules = []
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
for (var i = 0; i < length(files); i++) {
|
||||
if (ends_with(files[i], '.cm')) {
|
||||
modules.push(text(files[i], 0, -3))
|
||||
}
|
||||
@@ -238,7 +238,7 @@ package.list_modules = function(name) {
|
||||
package.list_programs = function(name) {
|
||||
var files = package.list_files(name)
|
||||
var programs = []
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
for (var i = 0; i < length(files); i++) {
|
||||
if (ends_with(files[i], '.ce')) {
|
||||
programs.push(text(files[i], 0, -3))
|
||||
}
|
||||
@@ -257,13 +257,13 @@ package.get_flags = function(name, flag_type, target) {
|
||||
// Base flags
|
||||
if (config.compilation && config.compilation[flag_type]) {
|
||||
var base = config.compilation[flag_type]
|
||||
flags = array(flags, filter(array(base, /\s+/), function(f) { return f.length > 0 }))
|
||||
flags = array(flags, filter(array(base, /\s+/), function(f) { return length(f) > 0 }))
|
||||
}
|
||||
|
||||
// Target-specific flags
|
||||
if (target && config.compilation && config.compilation[target] && config.compilation[target][flag_type]) {
|
||||
var target_flags = config.compilation[target][flag_type]
|
||||
flags = array(flags, filter(array(target_flags, /\s+/), function(f) { return f.length > 0 }))
|
||||
flags = array(flags, filter(array(target_flags, /\s+/), function(f) { return length(f) > 0 }))
|
||||
}
|
||||
|
||||
return flags
|
||||
@@ -280,12 +280,12 @@ package.get_c_files = function(name, target, exclude_main) {
|
||||
// Group files by their base name (without target suffix)
|
||||
var groups = {} // base_key -> { generic: file, variants: { target: file } }
|
||||
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
for (var i = 0; i < length(files); i++) {
|
||||
var file = files[i]
|
||||
if (!ends_with(file, '.c') && !ends_with(file, '.cpp')) continue
|
||||
|
||||
var ext = ends_with(file, '.cpp') ? '.cpp' : '.c'
|
||||
var base = text(file, 0, -ext.length)
|
||||
var base = text(file, 0, -length(ext))
|
||||
var name_part = fd.basename(base)
|
||||
var dir_part = fd.dirname(base)
|
||||
var dir = (dir_part && dir_part != '.') ? dir_part + '/' : ''
|
||||
@@ -295,12 +295,12 @@ package.get_c_files = function(name, target, exclude_main) {
|
||||
var variant_target = null
|
||||
var generic_name = name_part
|
||||
|
||||
for (var t = 0; t < known_targets.length; t++) {
|
||||
for (var t = 0; t < length(known_targets); t++) {
|
||||
var suffix = '_' + known_targets[t]
|
||||
if (ends_with(name_part, suffix)) {
|
||||
is_variant = true
|
||||
variant_target = known_targets[t]
|
||||
generic_name = text(name_part, 0, -suffix.length)
|
||||
generic_name = text(name_part, 0, -length(suffix))
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user