Commit e8b99155 authored by Daniel Bovensiepen's avatar Daniel Bovensiepen

Change build process to create meaningful Archive file instead of gem.a

parent e162f6d2
...@@ -24,6 +24,8 @@ ifeq ($(strip $(LIBR)),) ...@@ -24,6 +24,8 @@ ifeq ($(strip $(LIBR)),)
LIBR := $(MRUBY_ROOT)lib/libmruby.a LIBR := $(MRUBY_ROOT)lib/libmruby.a
endif endif
GEM_PACKAGE := mrb-$(GEM)-gem.a
# Default rules which are calling the # Default rules which are calling the
# gem specific gem-all and gem-clean # gem specific gem-all and gem-clean
# implementations of a gem # implementations of a gem
...@@ -36,7 +38,7 @@ gem-info: ...@@ -36,7 +38,7 @@ gem-info:
# Building target for C and Ruby files # Building target for C and Ruby files
gem-c-and-rb-files : gem_mixlib.o gem-c-and-rb-files : gem_mixlib.o
$(AR) rs gem.a $(GEM_OBJECTS) $^ $(AR) rs $(GEM_PACKAGE) $(GEM_OBJECTS) $^
gem_mixlib.c : gem_mrblib_header.ctmp gem_mrblib_irep.ctmp gem_mixlib_init.ctmp gem_mixlib.c : gem_mrblib_header.ctmp gem_mrblib_irep.ctmp gem_mixlib_init.ctmp
cat $^ > $@ cat $^ > $@
...@@ -46,14 +48,14 @@ gem_mixlib_init.ctmp : ...@@ -46,14 +48,14 @@ gem_mixlib_init.ctmp :
# Building target for C files # Building target for C files
gem-c-files : gem_srclib.o gem-c-files : gem_srclib.o
$(AR) rs gem.a $(GEM_OBJECTS) $< $(AR) rs $(GEM_PACKAGE) $(GEM_OBJECTS) $<
gem_srclib.c : gem_srclib.c :
$(MRUBY_ROOT)mrbgems/generator gem_srclib $(GEM) > $@ $(MRUBY_ROOT)mrbgems/generator gem_srclib $(GEM) > $@
# Building target for Ruby Files # Building target for Ruby Files
gem-rb-files : gem_mrblib.o gem-rb-files : gem_mrblib.o
$(AR) rs gem.a $< $(AR) rs $(GEM_PACKAGE) $<
gem_mrblib.c : gem_mrblib_header.ctmp gem_mrblib_irep.ctmp gem_mrblib_init.ctmp gem_mrblib.c : gem_mrblib_header.ctmp gem_mrblib_irep.ctmp gem_mrblib_init.ctmp
cat $^ > $@ cat $^ > $@
...@@ -71,13 +73,13 @@ gem_mrblib.rbtmp : ...@@ -71,13 +73,13 @@ gem_mrblib.rbtmp :
cat $(GEM_RB_FILES) > $@ cat $(GEM_RB_FILES) > $@
gem-clean-c-and-rb-files : gem-clean-c-and-rb-files :
-$(RM) gem.a gem_mixlib.o gem_mixlib.c gem_mrblib_header.ctmp gem_mrblib_irep.ctmp gem_mixlib_init.ctmp gem_mrblib.rbtmp -$(RM) $(GEM_PACKAGE) gem_mixlib.o gem_mixlib.c gem_mrblib_header.ctmp gem_mrblib_irep.ctmp gem_mixlib_init.ctmp gem_mrblib.rbtmp
gem-clean-c-files : gem-clean-c-files :
-$(RM) gem.a gem_srclib.c gem_srclib.o $(GEM_OBJECTS) -$(RM) $(GEM_PACKAGE) gem_srclib.c gem_srclib.o $(GEM_OBJECTS)
gem-clean-rb-files : gem-clean-rb-files :
-$(RM) gem.a gem_mrblib.o gem_mrblib.c gem_mrblib_header.ctmp gem_mrblib_init.ctmp gem_mrblib_irep.ctmp gem_mrblib.rbtmp -$(RM) $(GEM_PACKAGE) gem_mrblib.o gem_mrblib.c gem_mrblib_header.ctmp gem_mrblib_init.ctmp gem_mrblib_irep.ctmp gem_mrblib.rbtmp
.PHONY : clean .PHONY : clean
clean : gem-clean clean : gem-clean
......
...@@ -13,6 +13,39 @@ char *get_file_name(char *path) ...@@ -13,6 +13,39 @@ char *get_file_name(char *path)
return base ? base+1 : path; return base ? base+1 : path;
} }
char *replace(const char *s, const char *old, const char *new)
{
char *ret;
int i, count = 0;
size_t newlen = strlen(new);
size_t oldlen = strlen(old);
for (i = 0; s[i] != '\0'; i++) {
if (strstr(&s[i], old) == &s[i]) {
count++;
i += oldlen - 1;
}
}
ret = malloc(i + count * (newlen - oldlen));
if (ret == NULL)
exit(EXIT_FAILURE);
i = 0;
while (*s) {
if (strstr(s, old) == s) {
strcpy(&ret[i], new);
i += newlen;
s += oldlen;
}
else
ret[i++] = *s++;
}
ret[i] = '\0';
return ret;
}
/* /*
* Template generator for each active GEM * Template generator for each active GEM
* *
...@@ -25,8 +58,8 @@ char *get_file_name(char *path) ...@@ -25,8 +58,8 @@ char *get_file_name(char *path)
* String at the start of the template * String at the start of the template
* end: * end:
* String at the end of the template * String at the end of the template
* dir_to_skip: * full_path
* Name of a directory which will be skipped * Should the full path of the GEM be used?
* *
*/ */
static char* static char*
...@@ -76,7 +109,7 @@ for_each_gem (char before[1024], char after[1024], ...@@ -76,7 +109,7 @@ for_each_gem (char before[1024], char after[1024],
strcat(complete_line, gem_list[i]); strcat(complete_line, gem_list[i]);
else else
strcat(complete_line, get_file_name(gem_list[i])); strcat(complete_line, get_file_name(gem_list[i]));
strcat(complete_line, after); strcat(complete_line, replace(after, "#GEMNAME#", get_file_name(gem_list[i])));
} }
strcat(complete_line, end); strcat(complete_line, end);
...@@ -161,10 +194,10 @@ void ...@@ -161,10 +194,10 @@ void
make_gem_makefile_list() make_gem_makefile_list()
{ {
printf("%s", printf("%s",
for_each_gem(" ", "", "GEM_LIST := ", "\n", TRUE) for_each_gem(" ", "/mrb-#GEMNAME#-gem.a", "GEM_LIST := ", "\n", TRUE)
); );
printf("GEM_ARCHIVE_FILES := $(addsuffix /gem.a, $(GEM_LIST))\n" printf("GEM_ARCHIVE_FILES := $(GEM_LIST)\n"
"GEM_ARCHIVE_FILES += $(MRUBY_ROOT)/mrbgems/gem_init.a\n\n"); "GEM_ARCHIVE_FILES += $(MRUBY_ROOT)/mrbgems/gem_init.a\n\n");
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment