Changeset 31cd205d in rtems


Ignore:
Timestamp:
Apr 12, 2018, 4:12:06 AM (15 months ago)
Author:
Chris Johns <chrisj@…>
Branches:
master
Children:
86e79d7
Parents:
2a61542
git-author:
Chris Johns <chrisj@…> (04/12/18 04:12:06)
git-committer:
Chris Johns <chrisj@…> (04/12/18 07:54:59)
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/build/rtems-bin2c.c

    r2a61542 r31cd205d  
    5353}
    5454
    55 void process(const char *ifname, const char *ofname)
     55void process(const char *ifname, const char *ofname, const char *forced_name)
    5656{
    5757  FILE *ifile, *ocfile, *ohfile;
     
    120120
    121121  /* find basename */
    122   char *ifbasename_to_free = strdup(ifname);
     122  char *ifbasename_to_free =
     123    forced_name != NULL ? strdup(forced_name) : strdup(ifname);
    123124  if ( ifbasename_to_free == NULL ) {
    124125    fprintf(stderr, "cannot allocate memory\n" );
     
    261262  fprintf(
    262263     stderr,
    263      "usage: bin2c [-csvzCH] <input_file> <output_file>\n"
     264     "usage: bin2c [-csvzCH] [-N name] <input_file> <output_file>\n"
    264265     "  <input_file> is the binary file to convert\n"
    265266     "  <output_file> should not have a .c or .h extension\n"
     
    271272     "  -H - create c-header only\n"
    272273     "  -C - create c-source file only\n"
     274     "  -N - force name of data array\n"
    273275    );
    274276  exit(1);
     
    277279int main(int argc, char **argv)
    278280{
     281  const char *name = NULL;
    279282  while (argc > 3) {
    280283    if (!strcmp(argv[1], "-c")) {
     
    304307      --argc;
    305308      ++argv;
     309    } else if (!strcmp(argv[1], "-N")) {
     310      --argc;
     311      ++argv;
     312      if (argc <= 1) {
     313        fprintf(stderr, "error: -N needs a name\n");
     314        usage();
     315      }
     316      name = argv[1];
     317      --argc;
     318      ++argv;
    306319    } else {
    307320      usage();
     
    313326
    314327  /* process( input_file, output_basename ) */
    315   process(argv[1], argv[2]);
     328  process(argv[1], argv[2], name);
    316329  return 0;
    317330}
    318 
Note: See TracChangeset for help on using the changeset viewer.