fixed problem with compiler paths

This commit is contained in:
codeimp 2009-01-16 12:25:47 +00:00
parent 3e7ad76e9d
commit 455fca63d8
6 changed files with 36 additions and 20 deletions

View file

@ -4,7 +4,7 @@
// Compiler settings
compiler = "acc";
parameters = "-I \"%PT\" -I \"%PW\" %FI %FO";
parameters = "-I \"%PT\" -I \"%PS\" %FI %FO";
resultlump = "BEHAVIOR";
// Editor settings

View file

@ -16,14 +16,19 @@ file contents are not copied into the wad file.
With this interface supports the following placeholders in command-line parameters:
%FI indicates the input path and filename.
%FI indicates the input path and filename (temporary location for compiler).
%FO indicates the output path and filename.
%FO indicates the output path and filename (temporary location for compiler).
%FS indicates the path and filename of the original file.
%PT indicates the temporary directory path where the compiler is located.
%PW indicates the path of the open wad file when compiled as internal script lump.
If compiled as file, or the wad file is not saved, %PW is the same as %PT
%PS indicates the path of the original file.
The 'original file' is the saved location of the WAD file when the script is an
internal lump. If the wad file is not saved, %PW is the same as %PT and %FS is the
path and filename of the temporary wad file.
These placeholders are case-sensitive!

View file

@ -75,22 +75,16 @@ namespace CodeImp.DoomBuilder.Compilers
ProcessStartInfo processinfo;
Process process;
TimeSpan deltatime;
string waddir = null;
int line = 0;
// Find wad directory
if(General.Map.FilePathName.Length > 0)
waddir = Path.GetDirectoryName(General.Map.FilePathName);
// When no luck, use temp path
if(waddir == null) waddir = this.tempdir.FullName;
string sourcedir = Path.GetDirectoryName(sourcefile);
// Create parameters
string args = this.parameters;
args = args.Replace("%FI", inputfile);
args = args.Replace("%FO", outputfile);
args = args.Replace("%FS", sourcefile);
args = args.Replace("%PT", this.tempdir.FullName);
args = args.Replace("%PW", waddir);
args = args.Replace("%PS", sourcedir);
// Setup process info
processinfo = new ProcessStartInfo();

View file

@ -40,6 +40,7 @@ namespace CodeImp.DoomBuilder.Compilers
protected CompilerInfo info;
protected string parameters;
protected string workingdir;
protected string sourcefile;
protected string outputfile;
protected string inputfile;
@ -58,6 +59,7 @@ namespace CodeImp.DoomBuilder.Compilers
public string Parameters { get { return parameters; } set { parameters = value; } }
public string WorkingDirectory { get { return workingdir; } set { workingdir = value; } }
public string SourceFile { get { return sourcefile; } set { sourcefile = value; } }
public string InputFile { get { return inputfile; } set { inputfile = value; } }
public string OutputFile { get { return outputfile; } set { outputfile = value; } }
public string Location { get { return tempdir.FullName; } }

View file

@ -108,11 +108,12 @@ namespace CodeImp.DoomBuilder.Controls
// Make random output filename
outputfile = General.MakeTempFilename(compiler.Location, "tmp");
// Run compiler
compiler.Parameters = config.Parameters;
compiler.InputFile = Path.GetFileName(inputfile);
compiler.OutputFile = Path.GetFileName(outputfile);
compiler.SourceFile = filepathname;
compiler.WorkingDirectory = Path.GetDirectoryName(inputfile);
if(compiler.Run())
{

View file

@ -638,7 +638,7 @@ namespace CodeImp.DoomBuilder
private bool BuildNodes(string nodebuildername, bool failaswarning)
{
NodebuilderInfo nodebuilder;
string tempfile1, tempfile2;
string tempfile1, tempfile2, sourcefile;
bool lumpscomplete = false;
WAD buildwad;
@ -662,7 +662,13 @@ namespace CodeImp.DoomBuilder
// Make the temporary WAD file
General.WriteLogLine("Creating temporary build file: " + tempfile1);
buildwad = new WAD(tempfile1);
// Determine source file
if(filepathname.Length > 0)
sourcefile = filepathname;
else
sourcefile = tempwad.Filename;
// Copy lumps to buildwad
General.WriteLogLine("Copying map lumps to temporary build file...");
CopyLumpsByType(tempwad, TEMP_MAP_HEADER, buildwad, BUILD_MAP_HEADER, true, false, false, true);
@ -687,6 +693,7 @@ namespace CodeImp.DoomBuilder
compiler.Parameters = nodebuilder.Parameters;
compiler.InputFile = Path.GetFileName(tempfile1);
compiler.OutputFile = Path.GetFileName(tempfile2);
compiler.SourceFile = sourcefile;
compiler.WorkingDirectory = Path.GetDirectoryName(tempfile1);
if(compiler.Run())
{
@ -1185,7 +1192,7 @@ namespace CodeImp.DoomBuilder
// Returns true when our code worked properly (even when the compiler returned errors)
internal bool CompileLump(string lumpname, bool clearerrors)
{
string inputfile, outputfile;
string inputfile, outputfile, sourcefile;
Compiler compiler;
byte[] filedata;
string reallumpname = lumpname;
@ -1195,6 +1202,12 @@ namespace CodeImp.DoomBuilder
Lump lump = tempwad.FindLump(reallumpname);
if(lump == null) throw new Exception("No such lump in temporary wad file '" + reallumpname + "'.");
// Determine source file
if(filepathname.Length > 0)
sourcefile = filepathname;
else
sourcefile = tempwad.Filename;
// New list of errors
if(clearerrors || (errors == null))
errors = new List<CompilerError>();
@ -1230,14 +1243,15 @@ namespace CodeImp.DoomBuilder
errors.Add(new CompilerError("Unable to write script to working file. " + e.GetType().Name + ": " + e.Message));
return false;
}
// Make random output filename
outputfile = General.MakeTempFilename(compiler.Location, "tmp");
// Run compiler
compiler.Parameters = scriptconfig.Parameters;
compiler.InputFile = Path.GetFileName(inputfile);
compiler.OutputFile = Path.GetFileName(outputfile);
compiler.SourceFile = sourcefile;
compiler.WorkingDirectory = Path.GetDirectoryName(inputfile);
if(compiler.Run())
{