The MASM Forum

Microsoft 64 bit MASM => MASM64 SDK => Topic started by: hutch-- on October 11, 2018, 03:46:07 PM

Title: A general purpose makelib.bat file.
Post by: hutch-- on October 11, 2018, 03:46:07 PM
Should be easy enough to use, put your library source files into a directory, add this batch file and run the batch file from the command line with the name of the library with NO extension and it will build your source files into a library of your name choice.
@echo off
  if "%1" == "" goto quit
  if "%1" == "?" goto help
  dir /b *.asm > src.txt
  \masm32\bin64\ml64 /c @src.txt
  dir /b *.obj > obj.txt
  @echo.
  \masm32\bin64\lib /MACHINE:X64 /OUT:%1.lib @obj.txt
  del *.obj
  del obj.txt
  del src.txt
  dir *.lib
  pause
  goto theend
:help
  @echo.
  @echo ****************************
  @echo SYNTAX : makelib YourLibName
  @echo ****************************
  @echo.
  pause
  goto theend
:quit
  %echo --------------------------------------------------------------------------------------------
  %echo Missing library name, run the batch file with the library name you require with NO extension
  %echo --------------------------------------------------------------------------------------------
  goto help
:theend
Title: Re: A general purpose makelib.bat file.
Post by: Vortex on October 13, 2018, 09:53:30 PM
Hi Hutch,

Thanks. Here is another version using a FOR loop to process all the source files :

Code: [Select]
@echo off

  if "%1" == "" goto quit
  if "%1" == "?" goto help

  for /r %%v IN (*.asm) do \masm32\bin64\ml64 /c %%v
 
  \masm32\bin64\lib /MACHINE:X64 /OUT:%1.lib *.obj

  @echo.

  del *.obj
  dir *.lib
  pause

  goto theend
:help
  @echo.
  @echo ****************************
  @echo SYNTAX : makelib YourLibName
  @echo ****************************
  @echo.
  pause
  goto theend
:quit
  %echo --------------------------------------------------------------------------------------------
  %echo Missing library name, run the batch file with the library name you require with NO extension
  %echo --------------------------------------------------------------------------------------------
  goto help
:theend
Title: Re: A general purpose makelib.bat file.
Post by: hutch-- on October 13, 2018, 11:06:03 PM
Thanks Erol,

The FOR - IN - DO loop is a good design.  :t