diff options
author | Mike Frysinger <vapier@google.com> | 2015-10-02 17:05:57 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@google.com> | 2015-10-03 00:38:15 -0400 |
commit | 96c7072d8a75d4977537c075ce504156a2d91756 (patch) | |
tree | d15d2069e097cbabf5b730dba616db98396918a5 | |
parent | 021bca0c657545290975e71d01622d97d1cbb6a3 (diff) | |
download | integration-96c7072d8a75d4977537c075ce504156a2d91756.tar.gz |
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
-rw-r--r-- | 3rd-party-binary.mk | 5 | ||||
-rw-r--r-- | tests/Android.mk | 9 | ||||
-rw-r--r-- | tests/hello.c | 44 |
3 files changed, 58 insertions, 0 deletions
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; +} |