News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Universal makeit.bat

Started by Mark Jones, May 30, 2005, 05:13:26 AM

Previous topic - Next topic

Mark Jones

This is a windows batch file to assist in building MASM apps. Edit the app name and booleans for quick 'n easy compilation. Tested only on XP, might blow up on 9x... it's a work in progress. Feedback much appreciated. :)


@echo off
@rem ***** Ultimate MASM32 MakeIt.bat v1.26 by Mark Jones 2005 *****
@rem   appname="My App" [name of executable, minus extension]
@rem   rsrcname=rsrc  [name of rsrc.rc file, minus extension]
@rem   console=0 for GUI app, 1=console app
@rem   polink=0 use MS LINK, 1=use POLINK
@rem   debug=1=generate debug data
@rem   debugtype=[CV|COFF|BOTH]
@rem   verbose=0 suppresses POLINK messages
@rem   dll=0 makes .exe, 1 makes.dll
@rem   run=0 does not run .exe after compilation
@rem
@rem   Pauses only on error - no waiting
@rem   .obj and .res files are deleted
@
@rem ------------------ Only edit these values ---------------------
set appname="3d frames"
set rsrcname=rsrc
set console=0
set polink=1
set debug=0
set debugtype=BOTH
set verbose=0
set dll=0
set run=1
@rem ---------------------------------------------------------------
@
@cls
set bin=\masm32\bin
set lib=\masm32\lib
set include=\masm32\include
set err=0
@
if exist %appname%.obj del %appname%.obj
if exist %appname%.exe del %appname%.exe
@
if not exist %bin%\ml.exe goto patherror
@
if %rsrcname%=="" goto skip_rc
    %bin%\rc /v %rsrcname%.rc
    if errorlevel 1 set err=1
@   echo.
    %bin%\cvtres /machine:ix86 %rsrcname%.res
    if errorlevel 1 set err=1
    set rc=%rsrcname%.res
:skip_rc
    set rc=
@
if %dll%==1 set dll=/DLL
if %dll%==0 set dll=
@
if %verbose%==1 set verbose=/VERBOSE
if %verbose%==0 set verbose=
@
if %console%==1 goto console
if %debug%==1 goto windebugver
@
:winreleasever
    %bin%\ml /c /coff /Cp %appname%.asm
    if errorlevel 1 set err=1
@   echo.
    if %polink%==1 goto polink1
    %bin%\link /SUBSYSTEM:WINDOWS %dll% /RELEASE /VERSION:4.0 %appname%.obj %rc%
    if errorlevel 1 set err=1
    goto finish
@   :polink1
    echo  Linking: %appname%.obj
    echo.
    %bin%\polink /SUBSYSTEM:WINDOWS %dll% /RELEASE /VERSION:4.0 %verbose% %appname%.obj %rc%
    if errorlevel 1 set err=1
    goto finish
@
:windebugver
    %bin%\ml /c /coff /Cp /Fm /Zi /Zd %appname%.asm
    if errorlevel 1 set err=1
@   echo.
    if %polink%==1 goto polink2
    %bin%\link /SUBSYSTEM:WINDOWS %dll% /DEBUG /DEBUGTYPE:%debugtype% /VERSION:4.0 %appname%.obj %rc%
    if errorlevel 1 set err=1
    goto finish
@   :polink2
    echo  Linking: %appname%.obj
    echo.
    %bin%\polink /SUBSYSTEM:WINDOWS %dll% /DEBUG /DEBUGTYPE:%debugtype% /VERSION:4.0 %verbose% %appname%.obj %rc%
    if errorlevel 1 set err=1
    goto finish
@
@
:console
if %debug%==1 goto consoledebugver
@
:consolereleasever
    %bin%\ml /c /coff /Cp %appname%.asm
    if errorlevel 1 set err=1
@   echo.
    if %polink%==1 goto polink3
    %bin%\link /SUBSYSTEM:CONSOLE %dll% /RELEASE /VERSION:4.0 %appname%.obj %rc%
    if errorlevel 1 set err=1
    goto finish
@   :polink3
    echo  Linking: %appname%.obj
    echo.
    %bin%\polink /SUBSYSTEM:CONSOLE %dll% /RELEASE /VERSION:4.0 %verbose% %appname%.obj %rc%
    if errorlevel 1 set err=1
    goto finish
@
:consoledebugver
    %bin%\ml /c /coff /Cp /Fm /Zi /Zd %appname%.asm
    if errorlevel 1 set err=1
@   echo.
    if %polink%==1 goto polink4
    %bin%\link /SUBSYSTEM:CONSOLE %dll% /DEBUG /DEBUGTYPE:%debugtype% /VERSION:4.0 %appname%.obj %rc%
    if errorlevel 1 set err=1
    goto finish
@   :polink4
    echo  Linking: %appname%.obj
    echo.
    %bin%\polink /SUBSYSTEM:CONSOLE %dll% /DEBUG /DEBUGTYPE:%debugtype% /VERSION:4.0 %verbose% %appname%.obj %rc%
    if errorlevel 1 set err=1
@
:finish
    if %err%==1 pause
    if exist %appname%.obj del .\*.obj
    if not %rsrcname%=="" del %rsrcname%.res
@
if %run%==0 goto end
@
:runafter
    echo * Running application *
@   echo.
    %appname%.exe
@   goto end
@
:patherror
@   echo.
    echo  ML.EXE was not found in the path - compilation terminated!
@
:end

[attachment deleted by admin]
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

James Ladd

Mark,
Since you declare variables like BIN why not use them in the script ?
Then if the paths change, you can change in one place and not all through the script.
An example call would be good too. Yes I can work this out but others might like it.
Ill test the script out on the FASt stuff.
Rgs striker.

Mark Jones

#2
Oh Striker you are right! Maybe I should learn to check my code in the morning, then post...  :wink

Attached an example and added a "run" boolean in case the app makes a .dll, no sense in trying to run that!  :lol
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

James Ladd

Mark,
Thanks for the update.
Maybe for the un-initiated you could add a REM about the flag being passed in each case to ML and LINK ?
Rgs striker.

Mark Jones

Thanks Striker. I'm curious, anyone know if it is possible to make a RAM drive from any WinXX command prompt? It would be nice to do all the compiling in ram to minimize HD fragmentation. :wink

Vew version at top! Adds resource.rc support, deletes .obj and .res after compile, and only pauses on error. :)
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

hutch--

Mark,

In the DOS days there were some very good on the fly ram disks but with Windows you need a device driver to get one going. I had a quick play with a DDK sample some time ago that would handle a 20 meg ramdisk but it had to be set up at boot.

There may be a way to do what you had in mind with a memory mapped file.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

MichaelW

Franck Uberto's XMSDSK worked well under Windows 9x. Under DOS you could load, resize, or unload it from the command line, but for Windows you had to load it from autoexec.bat. Testing just now, I could not make it work for Windows 2000. It is still available here (and probably other places too):

ftp://gatekeeper.dec.com/pub/micro/pc/simtelnet/msdos/ramdisk/furd19_i.zip


eschew obfuscation

hutch--

That was my favourite as well, worked well and was easy to use. Franck was also a nice guy.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

GregL

I haven't tried this, but I have seen favorable reviews for it. It's called RAMDisk XP, works with 2000/XP, there are also versions for 9x, ME & NT4:

    http://www.cenatek.com/product_ramdisk.cfm

This one is free, but it sounds dangerous on NTFS and/or XP:

    http://support.microsoft.com/default.aspx?scid=kb;en-us;257405


Mark Jones

Hehe, yes that sounds quite scary for XP. :)

New version at top, includes POLINK support. I wonder if it works on 9x? 
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

James Ladd

Mark,

The make is coming along nicely.
How about checking a command line argument to see if the user wants to go into debug rather than just a run
after the build ?
Also, goASM support would be nice.

If the user specifies a debug "makeit debug" then set the other flags accordingly. ie: generate debug output.

Rgs, S