summaryrefslogtreecommitdiff
path: root/build-aux/ndk-module-extract.awk
blob: 6ff30973d671bb920b438f671e1bf8be47390c46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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 = ""
}