Merge "Add in some more useful MonkeyRunner commands:"
diff --git a/ndk/.gitignore b/ndk/.gitignore
new file mode 100644
index 0000000..48a8878
--- /dev/null
+++ b/ndk/.gitignore
@@ -0,0 +1,6 @@
+samples/*/libs/
+samples/*/obj/
+samples/*/bin/
+samples/*/gen/
+local.properties
+build.xml
diff --git a/ndk/samples/module-exports/README.TXT b/ndk/samples/module-exports/README.TXT
new file mode 100644
index 0000000..abd6c98
--- /dev/null
+++ b/ndk/samples/module-exports/README.TXT
@@ -0,0 +1,9 @@
+This sample is used to demonstrate the usage of module exports
+(i.e. LOCAL_EXPORT_CFLAGS and similar other variables).
+
+Here, three modules are defined: foo, bar, zoo
+
+'foo' exports its include directory and a linker flag
+bar simply uses 'foo', as a static library
+zoo uses bar, is a shared library.
+
diff --git a/ndk/samples/module-exports/jni/Android.mk b/ndk/samples/module-exports/jni/Android.mk
new file mode 100644
index 0000000..a4b594d
--- /dev/null
+++ b/ndk/samples/module-exports/jni/Android.mk
@@ -0,0 +1,23 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := foo
+LOCAL_SRC_FILES := foo/foo.c
+LOCAL_CFLAGS := -DFOO=2
+LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/foo
+LOCAL_EXPORT_CFLAGS := -DFOO=1
+LOCAL_EXPORT_LDLIBS := -llog
+include $(BUILD_STATIC_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := bar
+LOCAL_SRC_FILES := bar/bar.c
+LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/bar
+LOCAL_STATIC_LIBRARIES := foo
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := zoo
+LOCAL_SRC_FILES := zoo/zoo.c
+LOCAL_SHARED_LIBRARIES := bar
+include $(BUILD_SHARED_LIBRARY)
diff --git a/ndk/samples/module-exports/jni/bar/bar.c b/ndk/samples/module-exports/jni/bar/bar.c
new file mode 100644
index 0000000..71b21d2
--- /dev/null
+++ b/ndk/samples/module-exports/jni/bar/bar.c
@@ -0,0 +1,6 @@
+#include "bar.h"
+
+int  bar(int  x)
+{
+    return foo(x)-1;
+}
diff --git a/ndk/samples/module-exports/jni/bar/bar.h b/ndk/samples/module-exports/jni/bar/bar.h
new file mode 100644
index 0000000..a01f5f7
--- /dev/null
+++ b/ndk/samples/module-exports/jni/bar/bar.h
@@ -0,0 +1,15 @@
+#ifndef BAR_H
+#define BAR_H
+
+/* FOO should be defined to '1' here with the magic of LOCAL_EXPORT_CFLAGS */
+#ifndef FOO
+#error FOO should be defined here !
+#endif
+
+#if FOO != 1
+#error FOO is not correctly defined here !
+#endif
+
+extern int  bar(int  x);
+
+#endif /* BAR_H */
diff --git a/ndk/samples/module-exports/jni/foo/foo.c b/ndk/samples/module-exports/jni/foo/foo.c
new file mode 100644
index 0000000..71e8595
--- /dev/null
+++ b/ndk/samples/module-exports/jni/foo/foo.c
@@ -0,0 +1,20 @@
+#include "foo.h"
+#include <android/log.h>
+
+/* FOO should be defined to '2' when building foo.c */
+#ifndef FOO
+#error FOO is not defined here !
+#endif
+
+#if FOO != 2
+#error FOO is incorrectly defined here !
+#endif
+
+#define  LOG_TAG    "libfoo"
+#define  LOGI(...)  __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
+
+int  foo(int  x)
+{
+    LOGI("foo(%d) called !", x);
+    return x+1;
+}
diff --git a/ndk/samples/module-exports/jni/foo/foo.h b/ndk/samples/module-exports/jni/foo/foo.h
new file mode 100644
index 0000000..e061d10
--- /dev/null
+++ b/ndk/samples/module-exports/jni/foo/foo.h
@@ -0,0 +1,6 @@
+#ifndef FOO_H
+#define FOO_H
+
+extern int  foo(int x);
+
+#endif /* FOO_H */
diff --git a/ndk/samples/module-exports/jni/zoo/zoo.c b/ndk/samples/module-exports/jni/zoo/zoo.c
new file mode 100644
index 0000000..24e7209
--- /dev/null
+++ b/ndk/samples/module-exports/jni/zoo/zoo.c
@@ -0,0 +1,6 @@
+#include "bar.h"
+
+int something(void)
+{
+    return bar(42);
+}