nmake: can a batch file run as part of a make command block, affect the environment of the nmake.exe process?
I 开发者_StackOverflow中文版think in nmake if I do this:
example :
set value=77
echo %%value%%
The result will display 77 on the console.
Is there a way for me to invoke a .cmd or .bat file that will affect the environment of the nmake.exe process? Suppose I put the statement set value=77
in a file called "setvalue.cmd". Then change the makefile to this:
example :
setvalue
echo %%value%%
I get:
%value%
Alternatively, if there's a way to set a macro within a command block, that would also work. Or, a way to set the value of a macro from a batch file, even outside a command block.
You can create an nmake snippet during makefile pre-processing, and read that in. Assuming batch.cmd
outputs valid nmake syntax, then
!if [batch.cmd >makefile.auto]
!error *** Could not create makefile.auto
!endif
!include makefile.auto
You should ensure batch.cmd
sets %errorlevel%
appropriately (e.g., exit /b 22
).
makefile.auto
can contain anything, but you would probably want stuff like value=77
. A couple of points:
- Dereference
value
using nmake syntax ($(value)
) - You can pass parameters to
batch.cmd
if necessary ([batch.cmd $(OBJECTS) >makefile.auto]
)
No, I don't think so.
精彩评论