summaryrefslogtreecommitdiffstats
path: root/tools/build
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2018-04-12 14:12:06 +1000
committerChris Johns <chrisj@rtems.org>2018-04-12 17:54:59 +1000
commit31cd205d2b349d49099c7c2eff33365378c97529 (patch)
tree87e664839694d77627267f6205c0352120db6ead /tools/build
parentlibdl: RAP format fixes. (diff)
downloadrtems-31cd205d2b349d49099c7c2eff33365378c97529.tar.bz2
tools: Add a -N option to force a name on the array.
This can be used to have a different file name for the same data name. Update #2769
Diffstat (limited to 'tools/build')
-rw-r--r--tools/build/rtems-bin2c.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/tools/build/rtems-bin2c.c b/tools/build/rtems-bin2c.c
index 7674389740..53caf27aa2 100644
--- a/tools/build/rtems-bin2c.c
+++ b/tools/build/rtems-bin2c.c
@@ -52,7 +52,7 @@ int myfgetc(FILE *f)
return c;
}
-void process(const char *ifname, const char *ofname)
+void process(const char *ifname, const char *ofname, const char *forced_name)
{
FILE *ifile, *ocfile, *ohfile;
char buf[PATH_MAX+1], *p;
@@ -119,7 +119,8 @@ void process(const char *ifname, const char *ofname)
}
/* find basename */
- char *ifbasename_to_free = strdup(ifname);
+ char *ifbasename_to_free =
+ forced_name != NULL ? strdup(forced_name) : strdup(ifname);
if ( ifbasename_to_free == NULL ) {
fprintf(stderr, "cannot allocate memory\n" );
fclose(ifile);
@@ -260,7 +261,7 @@ void usage(void)
{
fprintf(
stderr,
- "usage: bin2c [-csvzCH] <input_file> <output_file>\n"
+ "usage: bin2c [-csvzCH] [-N name] <input_file> <output_file>\n"
" <input_file> is the binary file to convert\n"
" <output_file> should not have a .c or .h extension\n"
"\n"
@@ -270,12 +271,14 @@ void usage(void)
" -z - add zero terminator\n"
" -H - create c-header only\n"
" -C - create c-source file only\n"
+ " -N - force name of data array\n"
);
exit(1);
}
int main(int argc, char **argv)
{
+ const char *name = NULL;
while (argc > 3) {
if (!strcmp(argv[1], "-c")) {
useconst = 0;
@@ -303,6 +306,16 @@ int main(int argc, char **argv)
createH = 1;
--argc;
++argv;
+ } else if (!strcmp(argv[1], "-N")) {
+ --argc;
+ ++argv;
+ if (argc <= 1) {
+ fprintf(stderr, "error: -N needs a name\n");
+ usage();
+ }
+ name = argv[1];
+ --argc;
+ ++argv;
} else {
usage();
}
@@ -312,7 +325,6 @@ int main(int argc, char **argv)
}
/* process( input_file, output_basename ) */
- process(argv[1], argv[2]);
+ process(argv[1], argv[2], name);
return 0;
}
-