Created a sample project that uses many wraps, including a subwrap.
This commit is contained in:
parent
201664b2b8
commit
9c1c5bc209
|
@ -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')
|
|
@ -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;
|
||||||
|
}
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
Loading…
Reference in New Issue