问题
According to Delphi's help file, when I open the dialog box to add build events to my project's options, the dialog box should show a list of macros (placeholders) that I can use on the command line for the build event. When I try this in Delphi XE, the list of macros is empty. The help file doesn't say which macros are available either (that I could find).
So, which macros are available? Right now I need a macro for the full path to the compiled .exe
file (post-build), and the full path to the .dproj
file. But I'd like to have a complete list of the available macros for future reference.
回答1:
I had to go back to D2010 to come up with this list:
BDS The environment variable $(BDS)
DEFINES The project's conditional defines
DIR The environment variable $(DIR)
INCLUDEPATH The project's include path
INPUTDIR The input file's directory
INPUTEXT The input file's extension
INPUTFILENAME The input file's name, with extension
INPUTPATH The input file's full path
LOCALCOMMAND Local command entered by user in project manager
OUTPUTDIR The output file's directory
OUTPUTEXT The output file's extension
OUTPUTFILENAME The output file's name, with extension
OUTPUTNAME The output file's name, without extension
OUTPUTPATH The output file's full path
Path The environment variable $(PATH)
PROJECTDIR The project's directory
PROJECTEXT The project's extension
PROJECTFILENAME The project file's name, with extension
PROJECTNAME The project's name
PROJECTPATH The project file's full path
SAVE Save the input file to disk before it's compiled
SystemRoot The environment variable $(SYSTEMROOT)
WINDIR The environment variable $(WINDIR)
回答2:
For starters, I think the one you want is $(PROJECTPATH) which will be the full name of the DPROJ file including its path.
This is a Bug in RAD XE. I have seen this too. It went away for me on Update 1. Wait. I mean, it's a regression in Update 1, that wasn't in RTM.
This is a screengrab from Delphi 2009:
回答3:
I have Update 1 installed, but still can't see them, however...
For the Output File use "$(OUTPUTDIR)$(OUTPUTFILENAME)" and the Project File use "$(ProjectDir)$(ProjectFileName)"
You can find a list of the available macros (if they aren't showing up in the IDE) in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Borland.Delphi.Targets (sourced from What are the MSBuild project level properties for Delphi?)
Inside that file is the following area on my machine...
<!-- Build event properties settable in the IDE -->
<ProjectName>$(MSBuildProjectName)</ProjectName>
<ProjectFilename>$(MSBuildProjectFile)</ProjectFilename>
<ProjectExt>$(MSBuildProjectExtension)</ProjectExt>
<ProjectDir>$(MSBuildProjectDirectory)</ProjectDir>
<ProjectPath>$(MSBuildProjectFullPath)</ProjectPath>
<InputPath>@(DelphiCompile->'%(FullPath)')</InputPath>
<InputDir>@(DelphiCompile->'%(RootDir)%(Directory)')</InputDir>
<InputName>@(DelphiCompile->'%(Filename)')</InputName>
<InputExt>@(DelphiCompile->'%(Extension)')</InputExt>
<InputFilename>@(DelphiCompile->'%(Filename)%(Extension)')</InputFilename>
<OutputPath>@(_DependencyCheckOutputName->'%(FullPath)')</OutputPath>
<OutputDir>@(_DependencyCheckOutputName->'%(RootDir)%(Directory)')</OutputDir>
<OutputName>@(_DependencyCheckOutputName->'%(Filename)')</OutputName>
<OutputExt>@(_DependencyCheckOutputName->'%(Extension)')</OutputExt>
<OutputFilename>@(_DependencyCheckOutputName->'%(Filename)%(Extension)')</OutputFilename>
HTH
来源:https://stackoverflow.com/questions/5533718/build-event-macros-in-delphi-xe