Changeset 2986 for trunk


Ignore:
Timestamp:
Apr 2, 2007, 12:48:39 AM (18 years ago)
Author:
bird
Message:

dllar.cmd enhancements from Yuri. Fixes #39.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/emx/src/misc/dllar.cmd

    r800 r2986  
    6363    cmdLine = cmdLine||" "||value('DLLAR_CMDLINE',,'OS2ENVIRONMENT');
    6464    outFile = '';
     65    useDefFile = '';
    6566    inputFiles.0 = 0;
    6667    description = '';
    6768    CC = 'gcc.exe';
    68     CFLAGS = '-s -Zcrtdll';
     69    CFLAGS = '-Zcrtdll';
    6970    EXTRA_CFLAGS = '';
    7071    EXPORT_BY_ORDINALS = 0;
    7172    exclude_symbols = '';
    7273    library_flags = '';
     74    library_data = '';
     75    flag_omf = 0;
     76    AR='ar'
    7377    curDir = directory();
    7478    curDirS = curDir;
     
    8690                outFile = word(cmdLine, i);
    8791            end;
     92            when abbrev('def', substr(tmp, 2), 3) then
     93                useDefFile = GetLongArg();
    8894            when abbrev('description', substr(tmp, 2), 1) then
    8995                description = GetLongArg();
     
    100106            when abbrev('libflags', substr(tmp, 2), 4) then
    101107                library_flags = library_flags||GetLongArg()' ';
     108            when abbrev('libdata', substr(tmp, 2), 4) then
     109                library_data = library_data||GetLongArg()' ';
    102110            when abbrev('nocrtdll', substr(tmp, 2), 5) then
    103                 CFLAGS = '-s';
     111                CFLAGS = '';
    104112            when abbrev('nolxlite', substr(tmp, 2), 5) then
    105113                flag_USE_LXLITE = 0;
     114            when abbrev('omf', substr(tmp, 2), 3) then
     115                flag_omf = 1;
    106116            otherwise
    107117                EXTRA_CFLAGS = EXTRA_CFLAGS' 'tmp;
     
    128138    end; /* iterate cmdline words */
    129139
     140    if (flag_omf = 1) then
     141    do
     142        AR = 'emxomfar';
     143        CFLAGS = CFLAGS || ' -Zomf';
     144    end
     145
    130146    /* check arg sanity */
    131147    if (inputFiles.0 = 0) then
     
    154170            /* Prefix with '!' to indicate archive */
    155171            inputFiles.I = '!'inputFiles.I;
    156             call doCommand('cd 'substr(inputFiles.I, 2)' && ar x 'fullname);
     172            call doCommand('cd 'substr(inputFiles.I, 2)' && 'AR' x 'fullname);
    157173            call directory(curDir);
    158174            rc = SysFileTree(substr(inputFiles.I, 2)'\*.o', 'files', 'FO');
     
    208224    dllFile = outFile'.dll';
    209225    arcFile = outFile'.a';
     226    arcFileOmf = outFile'.lib';
    210227
    211228    if (do_backup & stream(arcFile, 'C', 'query exists') \= '') then
    212229        call doCommand('ren 'arcFile' 'outFile'_s.a');
    213230
    214     /*
    215      * Extract public symbols from all the object files.
    216      */
    217     tmpdefFile = '$_'filespec('NAME', defFile);
    218     call SysFileDelete(tmpdefFile);
    219     do I = 1 to inputFiles.0
    220         if (left(inputFiles.I, 1) \= '!') then
    221             call doCommand('emxexp -u' inputFiles.I' >>'tmpdefFile);
    222     end;
    223 
    224     /*
    225      * Create the def file.
    226      */
    227     call SysFileDelete(defFile);
    228     call stream defFile, 'c', 'open write';
    229     call lineOut defFile, 'LIBRARY 'filespec('NAME', outFile)' 'library_flags;
    230     if (length(description) > 0) then
    231         call lineOut defFile, 'DESCRIPTION "'description'"';
    232     call lineOut defFile, 'EXPORTS';
    233 
    234     queTmp = RxQueue('Create');
    235     queOld = RxQueue('Set', queTmp);
    236     call doCommand('cat 'tmpdefFile' | sort.exe | uniq.exe | rxqueue.exe' queTmp);
    237 
    238     ordinal = 1;
    239     do while queued() > 0
    240         parse pull line;
    241         if (length(line) > 0) & (word(line, 1) \= ';') & (export_ok(line)) then
    242         do
    243             if (EXPORT_BY_ORDINALS) then
    244             do
    245                 iPos = pos(';', line);
    246                 if (iPos > 1) then
    247                     line = strip(substr(line, 1, iPos - 1), 'T');
    248                 line = line||' @'||ordinal||' NONAME';
    249                 ordinal = ordinal + 1;
    250             end;
    251             call lineOut defFile, line;
    252         end;
    253     end;
    254     call RxQueue 'Delete', RxQueue('Set', queOld);
    255     call stream defFile, 'C', 'CLOSE';
    256     call SysFileDelete(tmpdefFile);
    257     drop line ordinal tmpdefFile;          /* try prevent running out of memory... */
     231   if useDefFile = '' then
     232   do
     233       /*
     234        * Extract public symbols from all the object files.
     235        */
     236       tmpdefFile = '$_'filespec('NAME', defFile);
     237       call SysFileDelete(tmpdefFile);
     238       do I = 1 to inputFiles.0
     239           if (left(inputFiles.I, 1) \= '!') then
     240               call doCommand('emxexp -u' inputFiles.I' >>'tmpdefFile);
     241       end;
     242   
     243       /*
     244        * Create the def file.
     245        */
     246       call SysFileDelete(defFile);
     247       call stream defFile, 'c', 'open write';
     248       call lineOut defFile, 'LIBRARY 'filespec('NAME', outFile)' 'library_flags;
     249       if (length(library_data) > 0) then
     250           call lineOut defFile, 'DATA 'library_data;
     251       if (length(description) > 0) then
     252           call lineOut defFile, 'DESCRIPTION "'description'"';
     253       call lineOut defFile, 'EXPORTS';
     254   
     255       queTmp = RxQueue('Create');
     256       queOld = RxQueue('Set', queTmp);
     257       call doCommand('cat 'tmpdefFile' | sort.exe | uniq.exe | rxqueue.exe' queTmp);
     258   
     259       ordinal = 1;
     260       do while queued() > 0
     261           parse pull line;
     262           if (length(line) > 0) & (word(line, 1) \= ';') & (export_ok(line)) then
     263           do
     264               if (EXPORT_BY_ORDINALS) then
     265               do
     266                   iPos = pos(';', line);
     267                   if (iPos > 1) then
     268                       line = strip(substr(line, 1, iPos - 1), 'T');
     269                   line = line||' @'||ordinal||' NONAME';
     270                   ordinal = ordinal + 1;
     271               end;
     272               call lineOut defFile, line;
     273           end;
     274       end;
     275       call RxQueue 'Delete', RxQueue('Set', queOld);
     276       call stream defFile, 'C', 'CLOSE';
     277       call SysFileDelete(tmpdefFile);
     278       drop line ordinal tmpdefFile;          /* try prevent running out of memory... */
     279   
     280   end
     281   else
     282   do
     283       defFile = useDefFile;
     284   end
    258285
    259286
     
    293320
    294321    call doCommand('emximp -o 'arcFile defFile);
     322    call doCommand('emximp -o 'arcFileOmf defFile);
    295323    if (flag_USE_LXLITE) then
    296324    do
     
    314342 say '       [-cc "CC"] [-f[lags] "CFLAGS"] [-ord[inals]] -ex[clude] "symbol(s)"'
    315343 say '       [-libf[lags] "{INIT|TERM}{GLOBAL|INSTANCE}"] [-nocrt[dll]]'
     344 say '       [-libd[ata] "DATA"] [-omf]'
     345 say '       [-nolxlite] [-def def_file]"'
    316346 say '       [*.o] [*.a]'
    317347 say '*> "output_file" should have no extension.'
     
    319349 say '   The import library name is derived from this and is set to "name".a.'
    320350 say '*> "cc" is used to use another GCC executable.   (default: gcc.exe)'
    321  say '*> "flags" should be any set of valid GCC flags. (default: -s -Zcrtdll)'
     351 say '*> "flags" should be any set of valid GCC flags. (default: -Zcrtdll)'
    322352 say '   These flags will be put at the start of GCC command line.'
    323353 say '*> -ord[inals] tells dllar to export entries by ordinals. Be careful.'
     
    328358 say '*> -libf[lags] can be used to add INITGLOBAL/INITINSTANCE and/or'
    329359 say '   TERMGLOBAL/TERMINSTANCE flags to the dynamically-linked library.'
     360 say '*> -libd[ata] can be used to add data segment attributes flags to the '
     361 say '   dynamically-linked library.'
    330362 say '*> -nocrtdll switch will disable linking the library against emx''s'
    331363 say '   C runtime DLLs.'
     364 say '*> -nolxlite does not compress executable'
     365 say '*> -def def_file do not generate .def file, use def_file instead.'
     366 say '*> -omf will use OMF tools to extract the static library objects.'
    332367 say '*> All other switches (for example -L./ or -lmylib) will be passed'
    333368 say '   unchanged to GCC at the end of command line.'
Note: See TracChangeset for help on using the changeset viewer.