From 0e7d5a2e4bcca01a41ea00324261818440808e6f Mon Sep 17 00:00:00 2001 From: Daniel Bovensiepen Date: Sat, 22 Sep 2012 01:16:26 +0800 Subject: Move Gem Tests into the main Test target --- test/Makefile | 7 +++++-- test/init_mrbtest.c | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/Makefile b/test/Makefile index 18bc79b5a..efabdc367 100644 --- a/test/Makefile +++ b/test/Makefile @@ -68,13 +68,16 @@ $(OBJS) : %.o : %.c $(CC) $(ALL_CFLAGS) -MMD $(INCLUDES) -c $< -o $@ # Compile C source from merged mruby source -$(CLIB) : $(RLIB) $(MRBC) $(INIT) - $(MRBC) -Bmrbtest_irep -o$(DLIB) $(RLIB); $(CAT) $(INIT) $(DLIB) > $@ +$(CLIB) : ../mrbgems/g/mrbgemtest.ctmp $(RLIB) $(MRBC) $(INIT) + $(MRBC) -Bmrbtest_irep -o$(DLIB) $(RLIB); $(CAT) $(INIT) $(DLIB) ../mrbgems/g/mrbgemtest.ctmp > $@ # merge mruby sources $(RLIB) : $(ASSLIB) $(MRBS) $(CAT) $(ASSLIB) $(MRBS) > $@ +../mrbgems/g/mrbgemtest.ctmp : + @$(MAKE) prepare-test -C ../mrbgems + # clean up .PHONY : clean clean : diff --git a/test/init_mrbtest.c b/test/init_mrbtest.c index b9f09dd2f..2bc2f2e4b 100644 --- a/test/init_mrbtest.c +++ b/test/init_mrbtest.c @@ -5,13 +5,16 @@ #include "mruby/proc.h" extern const char mrbtest_irep[]; +extern const char mrbgemtest_irep[]; void mrb_init_mrbtest(mrb_state *mrb) { int n = mrb_read_irep(mrb, mrbtest_irep); + int m = mrb_read_irep(mrb, mrbgemtest_irep); mrb_run(mrb, mrb_proc_new(mrb, mrb->irep[n]), mrb_top_self(mrb)); + mrb_run(mrb, mrb_proc_new(mrb, mrb->irep[m]), mrb_top_self(mrb)); if (mrb->exc) { mrb_p(mrb, mrb_obj_value(mrb->exc)); exit(0); -- cgit v1.2.3 From df91989bf760d206a3b3d035f2425caa65d35d60 Mon Sep 17 00:00:00 2001 From: Daniel Bovensiepen Date: Sat, 22 Sep 2012 02:07:15 +0800 Subject: Optimize Makefiles --- mrbgems/Makefile | 35 ++++++++++++++++++++++------------- mrbgems/generator.c | 8 ++++++++ test/Makefile | 22 +++++++++++++--------- 3 files changed, 43 insertions(+), 22 deletions(-) (limited to 'test') diff --git a/mrbgems/Makefile b/mrbgems/Makefile index d12e85ab4..466ac18e1 100644 --- a/mrbgems/Makefile +++ b/mrbgems/Makefile @@ -5,29 +5,37 @@ LIBR := ../lib/libmruby.a INIT := init_gems RM_F := rm -f CC_FLAGS := -Wall -Werror-implicit-function-declaration -g -O3 -MMD -I. -I./../include -MMAKER := ./generator -MMAKER_BIN := $(MMAKER) + export CC = gcc export LL = gcc export AR = ar +GENERATOR := ./generator +ifeq ($(OS),Windows_NT) + GENERATOR_BIN := $(GENERATOR).exe +else + GENERATOR_BIN := $(GENERATOR) +endif +GEM_MAKEFILE := g/Makefile +GEMDLIB := g/mrbgemtest.ctmp + ############################## # generic build targets, rules .PHONY : all all : $(INIT).o all_gems -all_gems : g/Makefile +all_gems : GEM_MAKEFILE @echo "Build all gems" $(MAKE) -C g -g/Makefile : $(MMAKER_BIN) +GEM_MAKEFILE : $(GENERATOR_BIN) @echo "Generate Gem Makefile" - $(MMAKER_BIN) makefile > $@ + $(GENERATOR_BIN) makefile > $@ -$(INIT).c : $(MMAKER_BIN) +$(INIT).c : $(GENERATOR_BIN) @echo "Generate Gem driver" - $(MMAKER_BIN) $(INIT) > $@ + $(GENERATOR_BIN) $(INIT) > $@ $(INIT).o : $(INIT).c @echo "Build the driver which initializes all gems" @@ -36,21 +44,22 @@ $(INIT).o : $(INIT).c # Generator -$(MMAKER_BIN) : $(MMAKER).o +$(GENERATOR_BIN) : $(GENERATOR).o @echo "Build the generator which creates the driver and Gem Makefile" $(LL) -o $@ $(CC_FLAGS) $< -$(MMAKER).o : $(MMAKER).c +$(GENERATOR).o : $(GENERATOR).c $(CC) $(CC_FLAGS) -MMD -c $< -o $@ .PHONY : prepare-test -prepare-test : +prepare-test : $(GEMDLIB) + +$(GEMDLIB) : @$(MAKE) prepare-test -C g # clean driver and all gems .PHONY : clean -clean : $(MMAKER_BIN) +clean : GEM_MAKEFILE @echo "Cleanup Gems" - $(MMAKER_BIN) makefile > g/Makefile $(MAKE) clean -C g - -$(RM_F) $(INIT).c *.o *.d $(MMAKER_BIN) g/Makefile + -$(RM_F) $(INIT).c *.o *.d $(GENERATOR_BIN) GEM_MAKEFILE diff --git a/mrbgems/generator.c b/mrbgems/generator.c index 8d8bee0cf..7015f5a4d 100644 --- a/mrbgems/generator.c +++ b/mrbgems/generator.c @@ -102,6 +102,10 @@ for_each_gem (char before[1024], char after[1024], puts(complete_line); } +/* + * Gem Makefile Generator + * + */ void make_gem_makefile() { @@ -156,6 +160,10 @@ make_gem_makefile() for_each_gem("\t@$(MAKE) clean -C ", " $(MAKE_FLAGS)\n", "", "", ""); } +/* + * init_gems.c Generator + * + */ void make_init_gems() { diff --git a/test/Makefile b/test/Makefile index efabdc367..04722e2d1 100644 --- a/test/Makefile +++ b/test/Makefile @@ -10,6 +10,8 @@ MLIB := $(TARGET).o CLIB := $(TARGET).c INIT := init_$(TARGET).c DLIB := $(TARGET).ctmp +GEMDIR := ../mrbgems +GEMDLIB := $(GEMDIR)/g/mrbgemtest.ctmp RLIB := $(TARGET).rbtmp DEPLIB := $(TARGET).d driver.d ASSLIB := $(BASEDIR)/assert.rb @@ -42,14 +44,13 @@ endif # mruby compiler and test driver ifeq ($(OS),Windows_NT) -MRBC = ../bin/mrbc.exe -EXE := $(TARGET).exe + MRBC = ../bin/mrbc.exe + EXE := $(TARGET).exe else -MRBC = ../bin/mrbc -EXE := $(TARGET) + MRBC = ../bin/mrbc + EXE := $(TARGET) endif - ############################## # generic build targets, rules @@ -68,15 +69,18 @@ $(OBJS) : %.o : %.c $(CC) $(ALL_CFLAGS) -MMD $(INCLUDES) -c $< -o $@ # Compile C source from merged mruby source -$(CLIB) : ../mrbgems/g/mrbgemtest.ctmp $(RLIB) $(MRBC) $(INIT) - $(MRBC) -Bmrbtest_irep -o$(DLIB) $(RLIB); $(CAT) $(INIT) $(DLIB) ../mrbgems/g/mrbgemtest.ctmp > $@ +$(CLIB) : $(DLIB) $(GEMDLIB) $(INIT) + $(CAT) $(INIT) $(DLIB) $(GEMDLIB) > $@ + +$(DLIB) : $(RLIB) $(MRBC) + $(MRBC) -Bmrbtest_irep -o$@ $(RLIB) # merge mruby sources $(RLIB) : $(ASSLIB) $(MRBS) $(CAT) $(ASSLIB) $(MRBS) > $@ -../mrbgems/g/mrbgemtest.ctmp : - @$(MAKE) prepare-test -C ../mrbgems +$(GEMDLIB) : + @$(MAKE) prepare-test -C $(GEMDIR) # clean up .PHONY : clean -- cgit v1.2.3 From 0832e26f20882ad6eb10a27ff32d48f1ed6cac04 Mon Sep 17 00:00:00 2001 From: Daniel Bovensiepen Date: Mon, 24 Sep 2012 00:12:16 +0800 Subject: Fix initializing of generator and beautify generator --- mrbgems/Makefile | 11 ++++------- mrbgems/generator.c | 26 ++++++++++---------------- test/Makefile | 6 ++---- 3 files changed, 16 insertions(+), 27 deletions(-) (limited to 'test') diff --git a/mrbgems/Makefile b/mrbgems/Makefile index 29d71d586..a30f804d7 100644 --- a/mrbgems/Makefile +++ b/mrbgems/Makefile @@ -25,13 +25,12 @@ GEMDLIB := g/mrbgemtest.ctmp .PHONY : all all : $(INIT).o all_gems -all_gems : $(GEM_MAKEFILE) +all_gems : $(GENERATOR_BIN) + @echo "Generate Gem Makefile" + $(GENERATOR_BIN) makefile > $(GEM_MAKEFILE) @echo "Build all gems" $(MAKE) -C g -$(GEM_MAKEFILE) : $(GENERATOR_BIN) - @echo "Generate Gem Makefile" - $(GENERATOR_BIN) makefile > $@ $(INIT).c : $(GENERATOR_BIN) @echo "Generate Gem driver" @@ -52,9 +51,7 @@ $(GENERATOR).o : $(GENERATOR).c $(CC) $(CC_FLAGS) -MMD -c $< -o $@ .PHONY : prepare-test -prepare-test : $(GEMDLIB) - -$(GEMDLIB) : +prepare-test : @$(MAKE) prepare-test -C g # clean driver and all gems diff --git a/mrbgems/generator.c b/mrbgems/generator.c index 430dcb354..bc1acdaef 100644 --- a/mrbgems/generator.c +++ b/mrbgems/generator.c @@ -53,14 +53,14 @@ for_each_gem (char before[1024], char after[1024], { struct dirent **eps; int n; - char gemname[1024] = ""; - char gemname_path[4096] = ""; - char src_path[4096] = ""; + char gemname[1024] = { 0 }; + char gemname_path[4096] = { 0 }; + char src_path[4096] = { 0 }; struct stat attribut; // return value char* complete_line = malloc(4096 + sizeof(char)); - + strcpy(complete_line, ""); strcat(complete_line, start); n = scandir("./g", &eps, one, alphasort); @@ -114,7 +114,7 @@ for_each_gem (char before[1024], char after[1024], void make_gem_makefile() { - char *gem_check = ""; + char *gem_check = { 0 }; int gem_empty; int gem_c_empty; int gem_ruby_empty; @@ -190,25 +190,19 @@ make_gem_makefile() } printf("\n.PHONY : prepare-test\n" - "prepare-test : mrbgemtest.ctmp\n\n" - - "mrbgemtest.ctmp : mrbgemtest.rbtmp\n" - "\t../../bin/mrbc -Bmrbgemtest_irep -omrbgemtest.ctmp mrbgemtest.rbtmp\n\n" - - "mrbgemtest.rbtmp :\n" + "prepare-test :\n" ); - if (!gem_empty) printf("%s", for_each_gem(" ", "/test/*.rb ", "\tcat", " > mrbgemtest.rbtmp", "") ); else - printf("\t../generator rbtmp > mrbgemtest.rbtmp\n"); + printf("\t../generator rbtmp > mrbgemtest.rbtmp"); + printf("\n\t../../bin/mrbc -Bmrbgemtest_irep -omrbgemtest.ctmp mrbgemtest.rbtmp\n\n"); - printf("\n\n.PHONY : clean\n" + printf(".PHONY : clean\n" "clean :\n" "\t$(RM) *.c *.d *.rbtmp *.ctmp *.o mrbtest\n"); - if (!gem_empty) printf("%s", for_each_gem("\t@$(MAKE) clean -C ", " $(MAKE_FLAGS)\n", "", "", "") @@ -222,7 +216,7 @@ make_gem_makefile() void make_init_gems() { - char *gem_check = ""; + char *gem_check = { 0 }; int gem_empty; int gem_c_empty; int gem_ruby_empty; diff --git a/test/Makefile b/test/Makefile index 04722e2d1..183e03438 100644 --- a/test/Makefile +++ b/test/Makefile @@ -69,7 +69,8 @@ $(OBJS) : %.o : %.c $(CC) $(ALL_CFLAGS) -MMD $(INCLUDES) -c $< -o $@ # Compile C source from merged mruby source -$(CLIB) : $(DLIB) $(GEMDLIB) $(INIT) +$(CLIB) : $(DLIB) $(INIT) + @$(MAKE) prepare-test -C $(GEMDIR) $(CAT) $(INIT) $(DLIB) $(GEMDLIB) > $@ $(DLIB) : $(RLIB) $(MRBC) @@ -79,9 +80,6 @@ $(DLIB) : $(RLIB) $(MRBC) $(RLIB) : $(ASSLIB) $(MRBS) $(CAT) $(ASSLIB) $(MRBS) > $@ -$(GEMDLIB) : - @$(MAKE) prepare-test -C $(GEMDIR) - # clean up .PHONY : clean clean : -- cgit v1.2.3 From fcaeec554a9aac77463f1460b469ea5f34a6f2a0 Mon Sep 17 00:00:00 2001 From: Daniel Bovensiepen Date: Thu, 8 Nov 2012 17:36:39 +0900 Subject: Fix merge --- test/Makefile | 8 -------- 1 file changed, 8 deletions(-) (limited to 'test') diff --git a/test/Makefile b/test/Makefile index b06343084..a4d8b7c0b 100644 --- a/test/Makefile +++ b/test/Makefile @@ -51,13 +51,6 @@ endif # mruby compiler and test driver ifeq ($(OS),Windows_NT) -<<<<<<< HEAD - MRBC = ../bin/mrbc.exe - EXE := $(TARGET).exe -else - MRBC = ../bin/mrbc - EXE := $(TARGET) -======= MRBC = ../bin/mrbc.exe MRUBY= ../bin/mruby.exe EXE := $(TARGET).exe @@ -65,7 +58,6 @@ else MRBC = ../bin/mrbc MRUBY= ../bin/mruby EXE := $(TARGET) ->>>>>>> upstream/master endif ############################## -- cgit v1.2.3 From a9513c1d1dd89bd23f3220e3dab37e52a6ed0ae1 Mon Sep 17 00:00:00 2001 From: Daniel Bovensiepen Date: Wed, 21 Nov 2012 15:57:24 +0800 Subject: Include dynamically GEMs into mrbtest --- test/Makefile | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/Makefile b/test/Makefile index a4d8b7c0b..1cadd90a2 100644 --- a/test/Makefile +++ b/test/Makefile @@ -3,9 +3,18 @@ # project-specific macros # extension of the executable-file is modifiable(.exe .out ...) +MRUBY_ROOT := .. BASEDIR = . TARGET := mrbtest LIBR := ../lib/libmruby.a + +MAKEFILE_GEM_LIST := $(MRUBY_ROOT)/mrbgems/g/MakefileGemList +ifeq ($(wildcard $(MAKEFILE_GEM_LIST)),) + GEM_ARCHIVE_FILES = +else + include $(MAKEFILE_GEM_LIST) +endif + MLIB := $(TARGET).o CLIB := $(TARGET).c INIT := init_$(TARGET).c @@ -77,7 +86,7 @@ all : $(EXE) $(MRUBY) $(TESTRB) $(TESTMRB) # executable constructed using linker from object files $(EXE) : $(OBJS) $(LIBR) - $(LL) -o $@ $(CFLAGS) $(OBJS) $(LIBR) $(LIBS) + $(LL) -o $@ $(CFLAGS) $(OBJS) $(LIBR) $(GEM_ARCHIVE_FILES) $(LIBS) -include $(OBJS:.o=.d) -- cgit v1.2.3 From 2a2e20680966c674786011450eb59abb595147fd Mon Sep 17 00:00:00 2001 From: Daniel Bovensiepen Date: Thu, 22 Nov 2012 19:00:39 +0800 Subject: Deactivate / Activate GEMs Flag introduced into mrbtest --- test/Makefile | 21 ++++++++++++++++----- test/init_mrbtest.c | 4 ++++ 2 files changed, 20 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/Makefile b/test/Makefile index 1cadd90a2..dfbcd8ce2 100644 --- a/test/Makefile +++ b/test/Makefile @@ -8,19 +8,28 @@ BASEDIR = . TARGET := mrbtest LIBR := ../lib/libmruby.a -MAKEFILE_GEM_LIST := $(MRUBY_ROOT)/mrbgems/g/MakefileGemList -ifeq ($(wildcard $(MAKEFILE_GEM_LIST)),) +ifeq ($(strip $(ENABLE_GEMS)),) + # by default GEMs are deactivated + ENABLE_GEMS = false +endif + +ifeq ($(ENABLE_GEMS),false) GEM_ARCHIVE_FILES = else - include $(MAKEFILE_GEM_LIST) + GEMDIR := ../mrbgems + GEMDLIB := $(GEMDIR)/g/mrbgemtest.ctmp + MAKEFILE_GEM_LIST := $(MRUBY_ROOT)/mrbgems/g/MakefileGemList + ifeq ($(wildcard $(MAKEFILE_GEM_LIST)),) + GEM_ARCHIVE_FILES = + else + include $(MAKEFILE_GEM_LIST) + endif endif MLIB := $(TARGET).o CLIB := $(TARGET).c INIT := init_$(TARGET).c DLIB := $(TARGET).ctmp -GEMDIR := ../mrbgems -GEMDLIB := $(GEMDIR)/g/mrbgemtest.ctmp RLIB := $(TARGET).rbtmp DEPLIB := $(TARGET).d driver.d ASSLIB := $(BASEDIR)/assert.rb @@ -96,7 +105,9 @@ $(OBJS) : %.o : %.c # Compile C source from merged mruby source $(CLIB) : $(DLIB) $(INIT) +ifeq ($(ENABLE_GEMS),true) @$(MAKE) prepare-test -C $(GEMDIR) +endif $(CAT) $(INIT) $(DLIB) $(GEMDLIB) > $@ $(DLIB) : $(RLIB) $(MRBC) diff --git a/test/init_mrbtest.c b/test/init_mrbtest.c index 2bc2f2e4b..ce9dd4cdd 100644 --- a/test/init_mrbtest.c +++ b/test/init_mrbtest.c @@ -11,10 +11,14 @@ void mrb_init_mrbtest(mrb_state *mrb) { int n = mrb_read_irep(mrb, mrbtest_irep); +#ifdef ENABLE_GEMS int m = mrb_read_irep(mrb, mrbgemtest_irep); +#endif mrb_run(mrb, mrb_proc_new(mrb, mrb->irep[n]), mrb_top_self(mrb)); +#ifdef ENABLE_GEMS mrb_run(mrb, mrb_proc_new(mrb, mrb->irep[m]), mrb_top_self(mrb)); +#endif if (mrb->exc) { mrb_p(mrb, mrb_obj_value(mrb->exc)); exit(0); -- cgit v1.2.3