summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/g/hello_world
diff options
context:
space:
mode:
authorDaniel Bovensiepen <[email protected]>2012-09-19 23:18:35 +0800
committerDaniel Bovensiepen <[email protected]>2012-09-19 23:18:35 +0800
commitab548b1c19a23cb6e8369a67d03f4c60a54f8a54 (patch)
treeea792d474e0536dff15de6e9a619f918a888f231 /mrbgems/g/hello_world
parente7425584e3aebc0295f1b55f7f44c2c5f5583964 (diff)
downloadmruby-ab548b1c19a23cb6e8369a67d03f4c60a54f8a54.tar.gz
mruby-ab548b1c19a23cb6e8369a67d03f4c60a54f8a54.zip
add hello world test program
Diffstat (limited to 'mrbgems/g/hello_world')
-rw-r--r--mrbgems/g/hello_world/Makefile25
-rw-r--r--mrbgems/g/hello_world/README.md6
-rw-r--r--mrbgems/g/hello_world/src/hello_world.c17
3 files changed, 48 insertions, 0 deletions
diff --git a/mrbgems/g/hello_world/Makefile b/mrbgems/g/hello_world/Makefile
new file mode 100644
index 000000000..50a92f03a
--- /dev/null
+++ b/mrbgems/g/hello_world/Makefile
@@ -0,0 +1,25 @@
+GEMNAME := hello_world
+MRUBY_ROOT = ../../../
+
+INCLUDES = -I$(MRUBY_ROOT)include -I$(MRUBY_ROOT)src -I.
+CFLAGS = $(INCLUDES) -O3 -g -Wall -Werror-implicit-function-declaration
+RM_F := rm -f
+AR := ar
+
+ifeq ($(strip $(LIBR)),)
+ # default mruby library
+ LIBR = $(MRUBY_ROOT)lib/libmruby.a
+endif
+
+.PHONY : all
+all : src/hello_world.o
+ @$(AR) rs $(LIBR) src/hello_world.o
+ @echo "Gem '$(GEMNAME)' is done"
+
+src/hello_world.o : src/hello_world.c
+ @gcc -c $(CFLAGS) src/hello_world.c -o src/hello_world.o
+
+.PHONY : clean
+clean :
+ -$(RM_F) src/*.o
+ @echo "Gem '$(GEMNAME)' is clean"
diff --git a/mrbgems/g/hello_world/README.md b/mrbgems/g/hello_world/README.md
new file mode 100644
index 000000000..d84bb9941
--- /dev/null
+++ b/mrbgems/g/hello_world/README.md
@@ -0,0 +1,6 @@
+mruby-md5
+=========
+
+MD5 digest function.
+
+This library comes original from mattn (http://github.com/mattn/mruby-md5)
diff --git a/mrbgems/g/hello_world/src/hello_world.c b/mrbgems/g/hello_world/src/hello_world.c
new file mode 100644
index 000000000..75d353542
--- /dev/null
+++ b/mrbgems/g/hello_world/src/hello_world.c
@@ -0,0 +1,17 @@
+#include <mruby.h>
+#include <stdio.h>
+
+static struct RClass *_class_hw;
+
+static mrb_value
+mrb_hello_world(mrb_state *mrb, mrb_value self)
+{
+ puts("Hello World");
+ return self;
+}
+
+void
+mrb_hello_world_gem_init(mrb_state* mrb) {
+ _class_hw = mrb_define_module(mrb, "HW");
+ mrb_define_class_method(mrb, _class_hw, "say", mrb_hello_world, ARGS_NONE());
+}