How can I add NSIS to a Windows build environment?
From NSIS Wiki
Jump to navigationJump to search
If you develop Windows software with the DDK or PSDK it might be a nice idea to generate the NSIS executable(s) directly after you have compiled your software. I'll show you a quick and dirty way. I presume that you have already setup your build environment.
Steps
- Create a new directory on top of your development tree. I call it installer
- Put your NSIS script(s) in this directory and make sure that the paths are setup correctly.
- Copy makefile from your %DDK% or %PSDK% directory
- Create a new source file. Let's say dummy.c. This file is required because the build environment expect at least one source (*.c or *.cpp) file:
int __cdecl main( void ) { return 0; }
- Create a new source file. For example with this content:
TARGETNAME=dummy TARGETPATH=. TARGETTYPE=PROGRAM NTTARGETFILE1=create-packages.h UMTYPE=console SOURCES=dummy.c
If you need more information about the source file go to MSDN. The important line in this file is: "NTTARGETFILE1=create-packages.h". The build environment will try to create create-packages.h before the compiler starts.
- How the build environment can create create-packages.h is explained in makefile.inc. So create a new makefile.inc:
create-packages.h: C:\Program Files\NSIS\makensis.exe /V1 <your_software>.nsi
The build environment does not check if the create-packages.h exists after the command has been finished. :)
- Go to the parent directory of installer and add installer as last entry of the dirs file:
DIRS= \ dir1 \ dir2 \ dir3 \ installer
- That's all... :)
What happens?
- After the build environment has compiled the file(s) in dir1, dir2 and dir3 it change to the installer directory.
- The build environment reads source and sees that it has to create create-packages.h before it can compile. It executes the command "C:\Program Files\NSIS\makensis.exe /V1 <your_software>.nsi"
- Then it compiles dummy.c. Anyway, our NSIS installer package has been created and that is what we want. :)
- The only disadvantage of this quick and dirty way is, that we have generated a useless executable. But I don't care... ;)