add example for building against 3rd party packages
This is an example people can use for building against 3rd party libs.
BUG=24611334
TEST=built packages and they worked in qemu
Change-Id: I962cddf36d57450c8ed752b219b9e3ce2e2ededf
diff --git a/3rd-party-binary.mk b/3rd-party-binary.mk
new file mode 100644
index 0000000..76a4902
--- /dev/null
+++ b/3rd-party-binary.mk
@@ -0,0 +1,5 @@
+LOCAL_CC := $(HOST_OUT_EXECUTABLES)/3rd-party-compiler
+LOCAL_CXX := $(LOCAL_CC)
+LOCAL_ADDITIONAL_DEPENDENCIES := 3rd-party-packages
+
+include $(BUILD_EXECUTABLE)
diff --git a/tests/Android.mk b/tests/Android.mk
new file mode 100644
index 0000000..648619c
--- /dev/null
+++ b/tests/Android.mk
@@ -0,0 +1,9 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := 3rd-party-test
+LOCAL_SRC_FILES := hello.c
+LOCAL_LDLIBS := -liniparser
+
+include external/gentoo/integration/3rd-party-binary.mk
diff --git a/tests/hello.c b/tests/hello.c
new file mode 100644
index 0000000..a4bf6fe
--- /dev/null
+++ b/tests/hello.c
@@ -0,0 +1,44 @@
+/* Simple test program for using libiniparser. */
+
+#undef NDEBUG
+#include <assert.h>
+#include <err.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <iniparser.h>
+
+int main(int argc, char *argv[])
+{
+ /* mktemp modifies the arg, so string has to be on the stack. */
+ char tmp[] = "foo.XXXXXX";
+ const char *file;
+ FILE *fp;
+ dictionary *dict;
+ const char *val;
+
+ file = mktemp(tmp);
+ fp = fopen(file, "we");
+ if (!fp)
+ err(1, "could not open %s", file);
+ fputs(
+ "[section]\n"
+ "key = value\n",
+ fp);
+ fclose(fp);
+
+ dict = iniparser_load(file);
+ if (!dict)
+ err(1, "could not read %s", file);
+ val = iniparser_getstring(dict, "section:key", NULL);
+ if (strcmp(val, "value") != 0)
+ errx(1, "section.key is '%s' but should be '%s'",
+ val, "value");
+ iniparser_freedict(dict);
+
+ unlink(file);
+
+ puts("success!");
+
+ return 0;
+}