summaryrefslogtreecommitdiff
path: root/build-aux/ndk-module-extract.awk
diff options
context:
space:
mode:
Diffstat (limited to 'build-aux/ndk-module-extract.awk')
-rw-r--r--build-aux/ndk-module-extract.awk88
1 files changed, 88 insertions, 0 deletions
diff --git a/build-aux/ndk-module-extract.awk b/build-aux/ndk-module-extract.awk
new file mode 100644
index 00000000000..6ff30973d67
--- /dev/null
+++ b/build-aux/ndk-module-extract.awk
@@ -0,0 +1,88 @@
+/^Building.+$/ {
+ kind = $2
+}
+
+/^Start Imports$/ {
+ imports = 1
+}
+
+// {
+ if (imports && ++imports > 2)
+ {
+ if (!match ($0, /^End Imports$/))
+ makefile_imports = makefile_imports " " $0
+ }
+ else if (!match ($0, /^End$/) && !match ($0, /^Building.+$/))
+ {
+ if (kind)
+ {
+ if (target_found)
+ cxx_deps = $0
+ else if (ldflags_found)
+ {
+ target = $0
+ target_found = 1
+ }
+ else if (cflags_found)
+ {
+ ldflags = $0
+ ldflags_found = 1
+ }
+ else if (includes_found)
+ {
+ cflags = $0
+ cflags_found = 1
+ }
+ else if (src_found)
+ {
+ includes = $0
+ includes_found = 1
+ }
+ else if (name_found)
+ {
+ src = $0
+ src_found = 1;
+ }
+ else
+ {
+ name = $0
+ name_found = 1
+ }
+ }
+ }
+}
+
+/^End$/ {
+ if (name == MODULE && (kind == "shared" || kind == "static"))
+ {
+ printf "module_name=%s\n", name
+ printf "module_kind=%s\n", kind
+ printf "module_src=\"%s\"\n", src
+ printf "module_includes=\"%s\"\n", includes
+ printf "module_cflags=\"%s\"\n", cflags
+ printf "module_ldflags=\"%s\"\n", ldflags
+ printf "module_target=\"%s\"\n", target
+ printf "module_cxx_deps=\"%s\"\n", cxx_deps
+ }
+
+ src = ""
+ name = ""
+ kind = ""
+ includes = ""
+ cflags = ""
+ ldflags = ""
+ name_found = ""
+ src_found = ""
+ includes_found = ""
+ cflags_found = ""
+ ldflags_found = ""
+ target_found = ""
+}
+
+/^End Imports$/ {
+ imports = ""
+ # Strip off leading whitespace.
+ gsub (/^[ \t]+/, "", makefile_imports)
+ printf "module_imports=\"%s\"\n", makefile_imports
+ makefile_imports = ""
+}