News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Bild.bat

Started by dedndave, April 07, 2013, 10:16:03 AM

Previous topic - Next topic

dedndave

i have been playing with this for a little while
i think i have the bugs worked out   :P

next time - it may be easier to write a console mode EXE - lol
i may convert this one, when i have more time to play

QuoteUsage: Bild AsmFile [Type]

AsmFile = AsmFile.asm (extension must be .asm, assumed if not present)

W       = Windows32 EXE, MS Link (default)
C       = Console32 EXE, MS Link
D       = Windows32 DLL, MS Link
S       = Native32  SYS, MS Link
L       = Library32 LIB, MS Link
O       = Object32  OBJ

WP      = Windows32 EXE, PoLink
CP      = Console32 EXE, PoLink
DP      = Windows32 DLL, PoLink
SP      = Native32  SYS, PoLink
LP      = Library32 LIB, PoLib

E16     = 16-bit    EXE, Link16
C16     = 16-bit    COM, Link16
S16     = 16-bit    SYS, Link16
L16     = 16-bit    LIB, Lib16
O16     = 16-bit    OBJ

E16C    = 16-bit    EXE, Link16, Masm 5.1 compatible
C16C    = 16-bit    COM, Link16, Masm 5.1 compatible
S16C    = 16-bit    SYS, Link16, Masm 5.1 compatible
L16C    = 16-bit    LIB, Lib16, Masm 5.1 compatible
O16C    = 16-bit    OBJ, Masm 5.1 compatible

i added the LIB functions for my own edification
they will create a new LIB and add a single OBJ module
LIB operations are probably outside the scope of the intended batch file, actually

if you want to create 16-bit LIB's, you need an old version of LIB.EXE (renamed to Lib16.exe)
some possible sources.....
search terms: lib.exe, mslib.exe, lib16

kip irvine library packages

randy hyde library packages

some editions of DOS 3.3

older DDK's, like 2003, included masm 5.1, link, and lib

EDIT: updated on 4-7-13 to fix OBJ/LIB issue (see reply #6 this thread)

Siekmanski

Thanks Dave.

This is very neat and useful  :t
Creative coders use backward thinking techniques as a strategy.

Gunther

Thank you Dave. It's very sophisticated. Did you burn your midnight oil for that?

Gunther
You have to know the facts before you can distort them.

dedndave

thanks, Marinus and Gunther   :t
no oil - just a little time here - a little time there
probably some improvements to come

by the way, it will handle paths or file names that contain spaces, as long as you enclose it
Bild "My Proj" W

it will link with a DEF file if one is found of the same name ("My Proj.def", etc)

and, it looks for "My Proj.rc", then rsrc.rc, for resources

Vortex

Hi Dave,

Nice work :t

Quick test : I was able to build some applications with the swicthes WP,CP and W.

dedndave

i see i left an ECHO line in there for the MsLink command line
that was for testing - oops   :P

dedndave

ok - i found a small bug.....

when the batch file performs most builds, it will delete the existing file first
for example, if building an EXE, it will delete an existing EXE before linking a new one

for LIB's, i didn't want to do that
you could accidently delete a LIB with several modules in it and replace it with a LIB that has 1   :redface:
so, for LIB's, the batch file displays the message:
Quoteecho %Proj%.lib file already exists.
echo Please move, rename, or delete it and try again.

one of the "modes" is to create just an OBJ file
i did not set the output extension environment variable for OBJ's, because i didn't think i needed to - lol
so - it was still set to "lib"
if you tried to build an OBJ in a folder with a LIB present, it would generate the above message
it was an easy fix

updated the original post

i have tested it with all types of output
and - tried to test it under a variety of conditions
there is no good way to test all the possible conditions, of course (this bug is a good example)
let me know if you see something amiss - thanks   :t

jj2007

Hi Dave,

I was about to complain that (arbitrarily picked) \Masm32\examples\Bill_Cravener\NoAniWindow\AniRightLeft\AniRightLeft.asm doesn't assemble when I remembered that I had the same problem with RichMasm: the resource file is named AniRightLeft_rc.rc - impossible to guess even for a sophisticated batch file like yours ;-)

:t

dedndave

yah - i could allow another filename on the command line
but, the primary end-use for this thing is the right-click context menu
the user right-clicks on an asm file, and selects the mode from the context menu
it's a similar clumsiness for lib files, as you may want to add xyz.obj to abc.lib - lol

question, though...
how did it go with projects that use MasmBasic ?

jj2007

Quote from: dedndave on April 08, 2013, 06:55:37 AM
how did it go with projects that use MasmBasic ?

Good question. Here is one example - it assembles, but the exe looks bloated and doesn't work (100% CPU). On further investigation, it turns out that
a) an unused rsrc.rc was hanging around and got included, hence the 40k extra
b) it assembles as sub windows, and the inkey stops it from working.

RichMasm autodetects console/windows, but doing that in a pure batch file is difficult unless you put a parser in the middle...

dedndave

subsystem:windows is the default
if you want some other type, you must specify it on the command line
see the original post, or run the batch file with no parameters for a list
the parameter can be selected for right-context actions
for example, if i right-click on a console mode asm file, and select Build Console, it is set up to...
Bild "%1" C

as for the resource, the batch first looks for "%Proj%.rc"
if that isn't found, it looks for rsrc.rc
i did that because so many existing masm32 projects use that scheme

jj2007

Quote from: dedndave on April 08, 2013, 10:16:59 AM
subsystem:windows is the default
if you want some other type, you must specify it on the command line

OK, so you need two menu entries. No problem.
I opted for autodetect in RichMasm for my own laziness - it happened too often that I forgot to set console ;-)

Quoteas for the resource, the batch first looks for "%Proj%.rc"
if that isn't found, it looks for rsrc.rc
i did that because so many existing masm32 projects use that scheme

I use exactly the same (plus an autodetect in RM), and it always works except for Bill's examples ;-)

One problem with that is if you have multiple sources in a "miscellaneous" folder, and one of them happens to come along with rsrc.rc, it gets used for other sources; and sometimes the executables hang because of the wrong resource.

dedndave

another possibility is to use an environment variable, then CALL
so - with the proper shell extension, it could be done with one selection
the shell extension would set the variable
then, in a batch file
@echo off
call Bild.bat "%~1" %Var%


eventually, i want to write a shell extension anyways
the plan is to provide a right-click submenu that allows you to select different versions/assemblers/linkers/libs
at that point, the Bild.bat file will probably be replaced with an EXE

jj2007

Quote from: dedndave on April 08, 2013, 11:06:47 AM
eventually, i want to write a shell extension anyways

That is a valid reason ;-)

For assembling. most of the time you are already in an editor, so it would make more sense to launch the batch file from there. Which is what I do in Richmasm, using the \Masm32\RichMasm\Res\b*.ba? templates - and it works fine for almost all cases except, well, Bill Cravener's examples :biggrin:

What about linking your batch file to qEditor?

dedndave

it should plug right into QE, although i haven't tried it