summaryrefslogtreecommitdiff
path: root/src/bin/main.c
diff options
context:
space:
mode:
authorYakov Goldberg <yakov.g@samsung.com>2014-06-30 11:20:35 +0300
committerYakov Goldberg <yakov.g@samsung.com>2014-06-30 18:39:12 +0300
commit0927d55c146f83014f798f10bb2ac8f20d725c2a (patch)
tree1f1da028d72d7416b78833afce08da100e4f25ef /src/bin/main.c
parentdb05b2f5dd0c3c013fa594e8d4e55cb184c65db8 (diff)
use flags "-e c" and "--json" in order to generate only c, only json, or both
- if both: "-e c --json" are used, NAME.c and NAME.h files will be generated with JSON descriptions in it - if only: "--json" is used, NAME.json with JSON description file will be generated - redesign command line options, add "-h" falg for help - TODO update
Diffstat (limited to 'src/bin/main.c')
-rw-r--r--src/bin/main.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/bin/main.c b/src/bin/main.c
index 595d058..3df94d9 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -87,11 +87,12 @@ _help()
87 " -f FILENAME\n" 87 " -f FILENAME\n"
88 " -s - simulate\n" 88 " -s - simulate\n"
89 " -e - export format. (-e c)\n" 89 " -e - export format. (-e c)\n"
90#if 0 90 " --json - generate JSON descriptions\n"
91 " --json - insert JSON descriptions into code\n" 91 " - if both: \"-e c --json\" are used, NAME.c and NAME.h files will be generated with JSON descriptions in it.\n"
92#endif 92 " - if only: \"--json\" is used, NAME.json JSON description file will be generated.\n"
93 " -p PATH in generate mode. Current dir by default\n" 93 " -p PATH in generate mode. Current dir by default\n"
94 " -o NAME in generate mode\n"); 94 " -o NAME in generate mode\n"
95 " -h print this help\n");
95} 96}
96 97
97/* Declare only this function, 98/* Declare only this function,
@@ -136,6 +137,11 @@ main(int argc, char **argv)
136 goto end; 137 goto end;
137 } 138 }
138 } 139 }
140 else if (!strcmp(argv[i], "-h"))
141 {
142 mode = "-h";
143 break;
144 }
139 else if (!strcmp(argv[i], "-s")) 145 else if (!strcmp(argv[i], "-s"))
140 { 146 {
141 mode = "-s"; 147 mode = "-s";
@@ -151,8 +157,6 @@ main(int argc, char **argv)
151 i++; 157 i++;
152 const char* format = argv[i]; 158 const char* format = argv[i];
153 export_mode = export_mode | GENERATE_CODE; 159 export_mode = export_mode | GENERATE_CODE;
154 /* FIXME: remove this when ready t ogenerate JSON separately. */
155 export_mode = export_mode | GENERATE_JSON;
156 if (!strcmp(format, "cpp")) 160 if (!strcmp(format, "cpp"))
157 { 161 {
158 export_format = GENERATION_CPP; 162 export_format = GENERATION_CPP;
@@ -163,8 +167,8 @@ main(int argc, char **argv)
163 } 167 }
164 else 168 else
165 { 169 {
166 _help(); 170 mode = "-h";
167 return 1; 171 break;
168 } 172 }
169 } 173 }
170 else if ((!strcmp(argv[i], "-t")) && (i < (argc - 1))) 174 else if ((!strcmp(argv[i], "-t")) && (i < (argc - 1)))
@@ -179,8 +183,6 @@ main(int argc, char **argv)
179 } 183 }
180 else if (!strcmp(argv[i], "--json")) 184 else if (!strcmp(argv[i], "--json"))
181 { 185 {
182 _help();
183 return 1;
184 mode = "-e"; 186 mode = "-e";
185 export_mode = export_mode | GENERATE_JSON; 187 export_mode = export_mode | GENERATE_JSON;
186 } 188 }
@@ -225,6 +227,10 @@ main(int argc, char **argv)
225 _generate(filename, path, new_filename, export_format, export_mode); 227 _generate(filename, path, new_filename, export_format, export_mode);
226 } 228 }
227 } 229 }
230 else if (!strcmp(mode, "-h"))
231 {
232 _help();
233 }
228 234
229end: 235end:
230 if (filename) free(filename); 236 if (filename) free(filename);