+ /**
+ * Reads Makefile variable assignments of the form =, :=, or ?=, ignoring white
+ * spaces. To be used with very simple included Makefiles only.
+ */
+ Map<String, String> readeMakefileVariables(Path path) throws IOException {
+ Map<String, String> context = new HashMap<>();
+ List<String> sdkMkLines = Files.readAllLines(path);
+ lines: for (String line : sdkMkLines) {
+ StringTokenizer st = new StringTokenizer(line, " :=?");
+ if (!st.hasMoreTokens())
+ continue lines;
+ String key = st.nextToken();
+ if (!st.hasMoreTokens())
+ continue lines;
+ String value = st.nextToken();
+ if (st.hasMoreTokens()) // probably not a simple variable assignment
+ continue lines;
+ context.put(key, value);
+ }
+ return context;
+ }
+