makeit.bat

Started by Mark Jones, July 25, 2006, 07:31:15 PM

Previous topic - Next topic

Mark Jones

Hi, here is a general-purpose makeit.bat. You can edit the first three lines to fit most projects, and it detects wether or not to compile the resources. I believe it should work on all windows versions but this is untested.


@echo off
set name=myProject
set subsys=console
set build=release
set err=0

if not exist %name%.rc goto compile
echo  Building:   %name%.res from %name%.rc
\genesys\bin\rc %name%.rc
if errorlevel 1 set err=1

echo  Converting: %name%.res to rsrc.obj
\genesys\bin\cvtres /nologo /machine:IX86 %name%.res /out:rsrc.obj
if errorlevel 1 set err=1

:compile
\genesys\bin\ml /c /coff /Cp /nologo /I"\Genesys\include" %name%.asm
if errorlevel 1 set err=1

if not exist rsrc.obj goto norsrc
echo  Linking:    %name%.obj and rsrc.obj
\genesys\bin\link /nologo /%build% /subsystem:%subsys% %name%.obj rsrc.obj
if errorlevel 1 set err=1
goto done

:norsrc
echo  Linking:    %name%.obj
\genesys\bin\link /nologo /%build% /subsystem:%subsys% %name%.obj
if errorlevel 1 set err=1

:done
echo  Deleting...
if exist %name%.res del %name%.res
if exist %name%.obj del %name%.obj
if exist rsrc.obj del rsrc.obj
if %err%==1 pause
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

jdoe

Hi,

Some ideas to be more "general-purpose".

The build and subsys variable could be merged and used like build=/subsystem:console /release /dll
The "done" section could include .lib and .exp in case of DLL building.



@echo off
set name=myProject
set build=/nologo /subsystem:console /release /dll
set err=0

if not exist %name%.rc goto compile
echo  Building : %name%.res from %name%.rc
\genesys\bin\rc %name%.rc
if errorlevel 1 set err=1

echo  Converting : %name%.res to rsrc.obj
\genesys\bin\cvtres /nologo /machine:IX86 %name%.res /out:rsrc.obj
if errorlevel 1 set err=1

:compile
\genesys\bin\ml /c /coff /Cp /nologo /I"\Genesys\include" %name%.asm
if errorlevel 1 set err=1

if not exist rsrc.obj goto norsrc
echo  Linking : %name%.obj and rsrc.obj
\genesys\bin\link %build% %name%.obj rsrc.obj
if errorlevel 1 set err=1
goto done

:norsrc
echo  Linking : %name%.obj
\genesys\bin\link %build% %name%.obj
if errorlevel 1 set err=1

:done
echo  Deleting...
if exist %name%.res del %name%.res
if exist %name%.obj del %name%.obj
if exist %name%.exp del %name%.exp
if exist %name%.lib del %name%.lib
if exist rsrc.obj del rsrc.obj
if %err%==1 pause




And BTW why is it cvtres /machine:IX86 and not cvtres /machine:X86 like cvtres /? tell to use ?

PBrennick

#2
Mark,
This is what I use, it is a variant of yours that you posted last year.  I made a few changes to it via my Rifleman account so that is why the credits at the bottom look the way they do. I wonder if there any way to get the good ideas from each one of them into one excellent file!


@echo off
set appname="SendMail"
set debug=0
set console=0
set run=0
set pack=0

set BIN=\GeneSys\bin

if not exist %bin%\ml.exe goto patherror
if not exist %bin%\polink.exe goto patherror

if %console%==1 goto console
if %debug%==1 goto windebugver

:winreleasever
    %bin%\ml /c /coff /Cp %appname%.asm >trash.can
    if not exist %appname%.obj goto errorout
    del trash.can

    if not exist %appname%.rc goto noresources
    %bin%\porc.exe /v %appname%.rc
    if not exist %appname%.res goto reserror
    ren %appname%.RES %appname%.res

    %bin%\polink /SUBSYSTEM:WINDOWS /RELEASE /VERSION:4.0 %appname%.obj %appname%.res
    goto finish

:noresources
    %bin%\polink /SUBSYSTEM:WINDOWS /RELEASE /VERSION:4.0 %appname%.obj
    goto finish

:windebugver
    %bin%\ml /c /coff /Cp /Fm /Zi /Zd %appname%.asm >trash.can
    if not exist %appname%.obj goto errorout
    del trash.can

    if not exist %appname%.rc goto noresfile
    %bin%\porc.exe /v %appname%.rc
    if not exist %appname%.res goto reserror
    ren %file%.RES %appname%.res

    %bin%\polink /SUBSYSTEM:WINDOWS /DEBUG /DEBUGTYPE:CV /VERSION:4.0 /INCREMENTAL:NO %appname%.obj %appname%.res
    goto finish

:noresfile
    %bin%\polink /SUBSYSTEM:WINDOWS /DEBUG /DEBUGTYPE:CV /VERSION:4.0 /INCREMENTAL:NO %appname%.obj
    goto finish

:console
    if %debug%==1 goto consoledebugver

:consolereleasever
    %bin%\ml /c /coff /Cp %appname%.asm >trash.can
    if not exist %appname%.obj goto errorout
    del trash.can
    echo.
    %bin%\polink /SUBSYSTEM:CONSOLE /RELEASE /VERSION:4.0 %appname%.obj
    goto finish

:consoledebugver
    %bin%\ml /c /coff /Cp /Fm /Zi /Zd %appname%.asm >trash.can
    if not exist %appname%.obj goto errorout
    del trash.can
    echo.
    %bin%\polink /SUBSYSTEM:CONSOLE /DEBUG /VERSION:4.0 %appname%.obj

:finish
    if %pack%==0 goto done
    if not exist %bin%\upx.exe goto done
    %bin%\upx.exe %appname%.exe

:done
    if exist %appname%.obj del %appname%.obj
    if exist %appname%.res del %appname%.res
    echo.
    echo The build has completed successfully.
    pause
    cls
    if %run%==0 goto end
    %appname%.exe
    goto end

:reserror
    echo.
    echo Trying to create the resource file generates the above mentioned errors...
    echo.
    pause   
    goto end

:errorout
    echo Trying to create the object file generates the following report...
    echo.
    type trash.can
    echo.
    pause   
    goto end

:patherror
    echo.
    echo ML.EXE was not found in the path - compilation terminated.

:end

: Universal makeit.bat v1.01 by Mark Jones 2005, features added by the Rifleman (Paul E. Brennick)


Paul
The GeneSys Project is available from:
The Repository or My crappy website

James Ladd

Please try 'make' ior 'nmake'.

zooba

#4
Or BUILD.EXE (my own program, attached).

Usage:

    BUILD.EXE <source file> [switches]

The first line of the source file or the command line may contain any of the following switches.

VERBOSE  - Display full command lines
CLEAN    - Delete intermediate files after successful build
NOMAKEIT - Don't use MAKEIT.BAT if there is one available

POASM    - Assemble using Pelle's Assembler
DEBUG    - Create symbolic debugging information (PDB file)
LIST     - Create file listing (LST file)
MAKEALL  - Assemble all ASM files in project directory

LINKNONE - Assemble without linking
POLINK   - Link using Pelle's Linker (uses PORC for resource files)
CONSOLE  - Automatically allocates a console window
RESOURCE - Compiles and links RSRC.RC
DLL      - Creates a dynamic-link library
LIB      - Creates a static-link library
LINKALL  - Link all OBJ files in folder
SWAPRUN  - Copy from network/CD before running

A switch preceeded by an exclamation mark (!) will turn off the option.

Command line switches take precedence over switches contained in the file.


Source included. Requires ASM Runtime to rebuild. Should be stored in the same folder as ML, LINK, LIB, RC, CVTRES, POASM, POLINK, PORC and POLIB. Feel free to make any modifications but make a note of it in the usage message (in rsrc.rc).

Cheers,

Zooba :U

Edit - Have fixed an error where string concatenation would fail. I have updated the executable and source, however, a large part of the fix is in ASM Runtime 0.201 which hasn't been released yet. I'll post another edit here when it is.
Edit - ASM Runtime 0.201 has been uploaded (thread here) and a slightly newer version of the build tool is included in that package and has been uploaded here.

[attachment deleted by admin]

PBrennick

Personally, it would have been more useful without the runtime.  It adds an extra layer to the development process which makes its use in what I am trying to do here problematic.  Don't get me wrong, I have looked at your build program and I like it but it carries more baggage than is needed for what is essentually a tool and should be thin.  The asm runtime has its place just like a library has its place but...

Paul
The GeneSys Project is available from:
The Repository or My crappy website

zooba

The runtime isn't actually required to run it, possibly I chose the wrong name there. It's a static library and once it's compiled into the application it's not needed anymore. I only put the link there for people who wanted to re-build rather than use the EXE. Yes, this makes the executable slightly larger, but it is dwarfed by ML and LINK anyway and practically all the included functionality is used.

The program will work with any source files, as I said, ASM Runtime is not required for anything except rebuilding the tool. Applications which don't use the runtime are fine.

Of course, it's up to you in the end, but I felt you may have had the wrong impression and I wanted to clear it up.

Cheers,

Zooba :U

PBrennick

zooba,
Thank you for taking the time to explain this to me.  You are correct, I was getting the wrong idea, here.  I think this might be something that my users coulb be interested in and with that in mind, I will do some experimentation with it.  I gather that I would add this tool to the \GeneSys\bin\ folder.  Is this correct?  My first experimentation failed.  I probably made a silly mistake.

Paul
The GeneSys Project is available from:
The Repository or My crappy website

PBrennick

zooba,
It is working just fine right now and I think it is a very well thought out and implimented tool.  Very nice job!

Paul
The GeneSys Project is available from:
The Repository or My crappy website

zooba

Excellent.

I would appreciate any feedback and/or suggestions your users may have.

Cheers,

Zooba :U

zooba

I've updated ASM Runtime to version 0.201 (thread here) so the build tool can be modified and rebuilt. There is a slightly newer version included with the library and I've also uploaded it here.

Cheers,

Zooba :U

ToutEnMasm

Hello,
Batchs files are my prefered method to make it work anywhere on any windows system.

You can use PATH in it instead of BIN,so you can call all executables in this directory,by there short name.
SET ML=defaut option of ml     ;is useful also
SET CL= defaut option of cl
SET LINK=defaut option for link
SET USELIB =kernel32.lib comctl32.lib .................... ;for cl
...
cl hello.cpp %USELIB%

                                          ToutEnMasm