aboutsummaryrefslogtreecommitdiff
path: root/manual tests/2 multiwrap
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2015-02-06 19:33:26 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2015-02-06 19:33:26 +0200
commit9c1c5bc209a4afd446aae4bd911001ddcf84d8f0 (patch)
tree1ea9e8c0247aa7761d2e8d6a0922f7bba6e93971 /manual tests/2 multiwrap
parent201664b2b8a592675414f87a5445ce1d7297b02e (diff)
downloadmeson-9c1c5bc209a4afd446aae4bd911001ddcf84d8f0.zip
meson-9c1c5bc209a4afd446aae4bd911001ddcf84d8f0.tar.gz
meson-9c1c5bc209a4afd446aae4bd911001ddcf84d8f0.tar.bz2
Created a sample project that uses many wraps, including a subwrap.
Diffstat (limited to 'manual tests/2 multiwrap')
-rw-r--r--manual tests/2 multiwrap/meson.build13
-rw-r--r--manual tests/2 multiwrap/prog.c64
-rw-r--r--manual tests/2 multiwrap/subprojects/libpng.wrap11
-rw-r--r--manual tests/2 multiwrap/subprojects/lua.wrap10
-rw-r--r--manual tests/2 multiwrap/subprojects/zlib.wrap10
5 files changed, 108 insertions, 0 deletions
diff --git a/manual tests/2 multiwrap/meson.build b/manual tests/2 multiwrap/meson.build
new file mode 100644
index 0000000..28f4e2b
--- /dev/null
+++ b/manual tests/2 multiwrap/meson.build
@@ -0,0 +1,13 @@
+project('multiwrap', 'c')
+
+# Using multiple downloaded projects for great justice.
+
+add_global_arguments('-std=c99', language : 'c')
+
+luap = subproject('lua')
+pngp = subproject('libpng')
+
+executable('prog', 'prog.c',
+include_directories : [pngp.get_variable('incdir'), luap.get_variable('incdir')],
+link_with :[pngp.get_variable('libpng'), luap.get_variable('lualib')],
+link_args : '-lm')
diff --git a/manual tests/2 multiwrap/prog.c b/manual tests/2 multiwrap/prog.c
new file mode 100644
index 0000000..13a5e03
--- /dev/null
+++ b/manual tests/2 multiwrap/prog.c
@@ -0,0 +1,64 @@
+#include<lua.h>
+#include<stdio.h>
+#include<stdlib.h>
+#include<png.h>
+#include<unistd.h>
+#include<string.h>
+
+static void *l_alloc (void *ud, void *ptr, size_t osize,
+ size_t nsize) {
+ (void)ud;
+ (void)osize;
+ if (nsize == 0) {
+ free(ptr);
+ return NULL;
+ } else {
+ return realloc(ptr, nsize);
+ }
+}
+
+void open_image(const char *fname) {
+ png_image image;
+
+ memset(&image, 0, (sizeof image));
+ image.version = PNG_IMAGE_VERSION;
+
+ if(png_image_begin_read_from_file(&image, fname) != 0) {
+ png_bytep buffer;
+
+ image.format = PNG_FORMAT_RGBA;
+ buffer = malloc(PNG_IMAGE_SIZE(image));
+
+ if(png_image_finish_read(&image, NULL, buffer, 0, NULL) != 0) {
+ printf("Image %s read failed: %s\n", fname, image.message);
+ }
+// png_free_image(&image);
+ free(buffer);
+ } else {
+ printf("Image %s open failed: %s", fname, image.message);
+ }
+}
+
+int printer(lua_State *l) {
+ if(!lua_isstring(l, 1)) {
+ fprintf(stderr, "Incorrect call.\n");
+ return 0;
+ }
+ open_image(lua_tostring(l, 1));
+ return 0;
+}
+
+
+int main(int argc, char **argv) {
+ lua_State *l = lua_newstate(l_alloc, NULL);
+ if(!l) {
+ printf("Lua state allocation failed.\n");
+ return 1;
+ }
+ lua_register(l, "printer", printer);
+ lua_getglobal(l, "printer");
+ lua_pushliteral(l, "foobar.png");
+ lua_call(l, 1, 0);
+ lua_close(l);
+ return 0;
+}
diff --git a/manual tests/2 multiwrap/subprojects/libpng.wrap b/manual tests/2 multiwrap/subprojects/libpng.wrap
new file mode 100644
index 0000000..710c088
--- /dev/null
+++ b/manual tests/2 multiwrap/subprojects/libpng.wrap
@@ -0,0 +1,11 @@
+[mesonwrap]
+
+directory = libpng-1.6.16
+
+source_url = ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng16/libpng-1.6.16.tar.gz
+source_filename = libpng-1.6.16.tar.gz
+source_hash = 02f96b6bad5a381d36d7ba7a5d9be3b06f7fe6c274da00707509c23592a073ad
+
+patch_url = https://dl.dropboxusercontent.com/u/37517477/libpng-meson.tar.gz
+patch_filename = libpng-meson.tar.gz
+patch_hash = 59366b68ee0b2d60e7fb4aaf570aa3a745052e248b50e1857e23df15e25e0234
diff --git a/manual tests/2 multiwrap/subprojects/lua.wrap b/manual tests/2 multiwrap/subprojects/lua.wrap
new file mode 100644
index 0000000..da2ca14
--- /dev/null
+++ b/manual tests/2 multiwrap/subprojects/lua.wrap
@@ -0,0 +1,10 @@
+[mesonwrap]
+directory = lua-5.3.0
+
+source_url = http://www.lua.org/ftp/lua-5.3.0.tar.gz
+source_filename = lua-5.3.0.tar.gz
+source_hash = ae4a5eb2d660515eb191bfe3e061f2b8ffe94dce73d32cfd0de090ddcc0ddb01
+
+patch_url = https://dl.dropboxusercontent.com/u/37517477/lua53-meson.zip
+patch_filename = lua53-meson.zip
+patch_hash = 076d0d57d33ec996c556722c8eeb624a364c66fe9d2225e590b1bc9ae34fbd6e \ No newline at end of file
diff --git a/manual tests/2 multiwrap/subprojects/zlib.wrap b/manual tests/2 multiwrap/subprojects/zlib.wrap
new file mode 100644
index 0000000..7ea3354
--- /dev/null
+++ b/manual tests/2 multiwrap/subprojects/zlib.wrap
@@ -0,0 +1,10 @@
+[mesonwrap]
+directory = zlib-1.2.8
+
+source_url = http://zlib.net/zlib-1.2.8.tar.gz
+source_filename = zlib-1.2.8.tar.gz
+source_hash = 36658cb768a54c1d4dec43c3116c27ed893e88b02ecfcb44f2166f9c0b7f2a0d
+
+patch_url = https://dl.dropboxusercontent.com/u/37517477/zlib128-meson.tar.gz
+patch_filename = zlib128-meson.tar.gz
+patch_hash = 03c868bf22d7e35c978e8b9572c4aea1181606c15c3dd19f0713a8479fe27edc