refactoring
- keep using find-exec (more bin files) - parse_convert command with spaces works
This commit is contained in:
@@ -2,18 +2,15 @@
|
||||
# Parse zodiac config
|
||||
#
|
||||
|
||||
# Ignore comments and empty lines
|
||||
action == "config" && (NF == 0 || /^;/) {
|
||||
next
|
||||
}
|
||||
|
||||
# Get the current section
|
||||
action == "config" && (/^\[/ && match($0, /\[([[:alnum:]_]).*\]/)) {
|
||||
action == "config" && match($0, /\[([[:alnum:]_]).*\]/) {
|
||||
section = substr($0, (RSTART + 1), (RLENGTH - 2))
|
||||
next
|
||||
}
|
||||
|
||||
# Get filters in the parse section
|
||||
action == "config" && section == "parse" {
|
||||
n = split($0, exts, ",")
|
||||
for (i in exts) {
|
||||
@@ -24,21 +21,19 @@ action == "config" && section == "parse" {
|
||||
next
|
||||
}
|
||||
|
||||
# Get filters in the parse_convert section
|
||||
action == "config" && section == "parse_convert" && (NF > 1) {
|
||||
ext_list = $1
|
||||
cmd = $2
|
||||
cmd = substr($0, length(ext_list) + 1)
|
||||
n = split(ext_list, exts, ",")
|
||||
for (i in exts) {
|
||||
ext = exts[i]
|
||||
gsub(/ /, "", ext)
|
||||
filter[ext] = cmd
|
||||
print cmd >> "awk.log"
|
||||
}
|
||||
next
|
||||
}
|
||||
|
||||
# Get ignore patterns
|
||||
action == "config" && section == "ignore" {
|
||||
ignore[ignore_count++] = $0
|
||||
next
|
||||
}
|
||||
|
||||
30
lib/find_cmd.awk
Normal file
30
lib/find_cmd.awk
Normal file
@@ -0,0 +1,30 @@
|
||||
BEGIN {
|
||||
section = "none"
|
||||
action = "config"
|
||||
}
|
||||
|
||||
END {
|
||||
for (ext in filter) {
|
||||
exts[ext_count++] = "-name \"*." ext "\""
|
||||
}
|
||||
for (i = 0; i < length(ignore); i++) {
|
||||
opts[opt_count++] = "!"
|
||||
opts[opt_count++] = "-name \"" ignore[i] "\""
|
||||
}
|
||||
if (phase == "render") {
|
||||
opts[opt_count++] = exts[0]
|
||||
for (i = 1; i < length(exts); i++) {
|
||||
opts[opt_count++] = "-o"
|
||||
opts[opt_count++] = exts[i]
|
||||
}
|
||||
} else if (phase == "copy") {
|
||||
for (i = 0; i < length(exts); i++) {
|
||||
opts[opt_count++] = "!"
|
||||
opts[opt_count++] = exts[i]
|
||||
}
|
||||
}
|
||||
for (i = 0; i < length(opts); i++) {
|
||||
optpart = optpart " " opts[i]
|
||||
}
|
||||
printf "find \"%s\" -type f \\( %s \\) -exec zod-%s \"%s\" \"%s\" \"%s\" {} \\;", proj, optpart, phase, zod_lib, proj, target
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
#
|
||||
# Build find options
|
||||
#
|
||||
|
||||
BEGIN {
|
||||
section = "none"
|
||||
action = "config"
|
||||
}
|
||||
|
||||
END {
|
||||
for (ext in filter) {
|
||||
exts[ext_count++] = "\"" "*." ext "\""
|
||||
}
|
||||
for (i = 0; i < length(ignore); i++) {
|
||||
instructions[inst_count++] = "not"
|
||||
instructions[inst_count++] = "\"" ignore[i] "\""
|
||||
}
|
||||
if (phase == "render") {
|
||||
instructions[inst_count++] = exts[0]
|
||||
for (i = 1; i < length(exts); i++) {
|
||||
instructions[inst_count++] = "or"
|
||||
instructions[inst_count++] = exts[i]
|
||||
}
|
||||
} else if (phase == "copy") {
|
||||
for (i = 0; i < length(exts); i++) {
|
||||
instructions[inst_count++] = "not"
|
||||
instructions[inst_count++] = exts[i]
|
||||
}
|
||||
}
|
||||
# print all instructions
|
||||
for (i = 0; i < length(instructions); i++) {
|
||||
instruction = instruction " " instructions[i]
|
||||
}
|
||||
print instruction
|
||||
}
|
||||
@@ -13,7 +13,7 @@ BEGIN {
|
||||
{
|
||||
split(FILENAME, parts, ".")
|
||||
ext = parts[length(parts)]
|
||||
if ((FILENAME == "config") || (FILENAME == "-")) {
|
||||
if (FILENAME == "-") {
|
||||
action = "config"
|
||||
} else if (ext == "meta") {
|
||||
action = "meta"
|
||||
|
||||
Reference in New Issue
Block a user