#241 Synchronise sdcclib commands with ar

closed
nobody
None
5
2008-03-05
2008-03-05
Maarten Brock
No

I think it would be nice if the command line options for sdcclib were compatible with those from GNU ar.

Current available options for sdcclib:
a - Adds relfile(s) to library. If relfile exists, replaces it.
l - Adds relfile list to library.
d - Deletes relfile(s) from library.
e - Extracts relfile(s) from library.
s - Dumps symbols of library.
m - Dumps modules of library.
v - Displays program version.
h - This help.

But ar uses:
r - Add/replace a member
x - Extract a member

I think duplicating a to r and e to x is the preferred solution.

Discussion

    • status: open --> closed
     
  • Logged In: YES
    user_id=603650
    Originator: NO

    Done in revision 5071.

     
  • Maarten Brock
    Maarten Brock
    2008-03-05

    Logged In: YES
    user_id=888171
    Originator: YES

    Oops, I spoke too soon. ar does not use -options but commands. E.g.

    ar r mylib.a myfile.o
    sdcclib -a mylib.lib myfile.rel

    Maybe it's possible to recognize if the first argument is 'r' or 'x' or 'd'? That would be illegal library names then.

     
  • Maarten Brock
    Maarten Brock
    2008-03-05

    Logged In: YES
    user_id=888171
    Originator: YES

    How about this patch (against #5070)? And also please replace TAB's with spaces.

    --- C:/Documents and Settings/Maarten/Local Settings/Temp/sdcclib.c-revBASE.svn001.tmp.c Wed Mar 05 17:12:34 2008
    +++ C:/Lokaal/sdcc/support/librarian/sdcclib.c Wed Mar 05 17:15:29 2008
    @@ -94,16 +94,16 @@
    {
    int rvalue=0, unknown=0;
    static char Help[] =
    - "Usage: %s [-options] library relfile1 relfile2 relfile3 ...\n\n"
    + "Usage: %s [option|-options] library relfile1 relfile2 relfile3 ...\n\n"
    "available options:\n"
    - "a - Adds relfile(s) to library. If relfile exists, replaces it.\n"
    + "a,r - Adds relfile(s) to library. If relfile exists, replaces it.\n"
    "l - Adds relfile list to library.\n"
    "d - Deletes relfile(s) from library.\n"
    - "e - Extracts relfile(s) from library.\n"
    + "e,x - Extracts relfile(s) from library.\n"
    "s - Dumps symbols of library.\n"
    "m - Dumps modules of library.\n"
    "v - Displays program version.\n"
    - "h - This help.\n";
    + "h,? - This help.\n";

    switch (opt[0])
    {
    @@ -120,12 +120,14 @@
    exit(1);
    break;
    case 'a':
    + case 'r':
    action=OPT_ADD_REL;
    break;
    case 'l':
    action=OPT_ADD_LIST;
    break;
    case 'e':
    + case 'x':
    action=OPT_EXT_REL;
    break;
    case 'd':
    @@ -151,7 +153,7 @@

    for (j=1; j<argc; j++)
    {
    - if(argv[j][0]=='-')
    + if (argv[j][0]=='-')
    {
    for(i=1; argv[j][i]!=0 ; i++)
    if (set_options(&argv[j][i])) break;
    @@ -161,8 +163,13 @@
    switch(cont_par)
    {
    case 0:
    + if (argv[j][1]=='\0')
    + set_options(&argv[j][0]);
    + else
    + {
    cont_par++;
    strcpy(LibName, argv[j]);
    + }
    break;

    case 1:

     
  • Logged In: YES
    user_id=603650
    Originator: NO

    Revision 5072 should implement the desired functionality. For example if there is a library named 's' (without extension), to dump its symbols:

    sdcclib s s

    The first 's' is the dump symbols command while the second 's' is the library name.