diff options
| author | Daniel Bovensiepen <[email protected]> | 2012-11-22 16:13:16 +0800 |
|---|---|---|
| committer | Daniel Bovensiepen <[email protected]> | 2012-11-22 16:13:16 +0800 |
| commit | 953cbff65c322eac30b6a766eac2676e9eb67ac6 (patch) | |
| tree | c4175e47702f4c28c7a555a3306b0a865240a038 | |
| parent | 754c853300b8824d1b57e40e86280164bfd1a4dd (diff) | |
| download | mruby-953cbff65c322eac30b6a766eac2676e9eb67ac6.tar.gz mruby-953cbff65c322eac30b6a766eac2676e9eb67ac6.zip | |
Make GEM build choosable. Respect GEMS.active file for choices of which GEM to build
| -rw-r--r-- | mrbgems/GEMS.active | 0 | ||||
| -rw-r--r-- | mrbgems/generator.c | 50 |
2 files changed, 47 insertions, 3 deletions
diff --git a/mrbgems/GEMS.active b/mrbgems/GEMS.active new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/mrbgems/GEMS.active diff --git a/mrbgems/generator.c b/mrbgems/generator.c index 1d5cdd367..f5cd2b76a 100644 --- a/mrbgems/generator.c +++ b/mrbgems/generator.c @@ -50,6 +50,17 @@ for_each_gem (char before[1024], char after[1024], char start[1024], char end[1024], char dir_to_skip[1024]) { + FILE *fp; + char *active_gems = NULL; + char ch; + char gem_name[1024] = { 0 }; + int char_index; + char gem_list[1024][1024] = { { 0 }, { 0 } }; + int gem_index; + int i; + int b; + int cnt; + struct dirent **eps; int n; char gemname[1024] = { 0 }; @@ -57,6 +68,27 @@ for_each_gem (char before[1024], char after[1024], char src_path[4096] = { 0 }; struct stat attribut; + fp = fopen("GEMS.active", "r+"); + if (fp != NULL) { + char_index = 0; + gem_index = 0; + while((ch = fgetc(fp)) != EOF) { + if (ch == '\n') { + gem_name[char_index++] = '\0'; + strcpy(gem_list[gem_index++], gem_name); + + gem_name[0] = '\0'; + char_index = 0; + } + else { + gem_name[char_index++] = ch; + } + } + + fclose(fp); + } + else { /* Error: Active GEM list couldn't be loaded */ } + /* return value */ char* complete_line = malloc(4096 + sizeof(char)); strcpy(complete_line, ""); @@ -64,13 +96,10 @@ for_each_gem (char before[1024], char after[1024], n = scandir("./g", &eps, one, alphasort); if (n >= 0) { - int cnt; for (cnt = 0; cnt < n; ++cnt) { strcpy(gemname, eps[cnt]->d_name); strcpy(gemname_path, "./g/"); strcat(gemname_path, gemname); - strcpy(src_path, gemname_path); - strcat(src_path, "/src"); if (strcmp(gemname, ".") == 0) continue; @@ -84,6 +113,21 @@ for_each_gem (char before[1024], char after[1024], continue; } + b = 0; + for(i = 0; i <= gem_index; i++) { + if (strcmp(gem_list[i], gemname) != 0) + b = 0; + else { + /* Current GEM is active */ + b = 1; + break; + } + } + + /* In case the current GEM isn't active we skip it */ + if (b == 0) + continue; + if (strcmp(dir_to_skip, "") != 0) { strcpy(src_path, gemname_path); strcat(src_path, "/"); |
