From 455fca63d822cd61f2e64f4d245585be12701b6f Mon Sep 17 00:00:00 2001 From: codeimp Date: Fri, 16 Jan 2009 12:25:47 +0000 Subject: [PATCH] fixed problem with compiler paths --- Build/Scripting/ZDoom_ACS.cfg | 2 +- Documents/compilerinterfaces.txt | 13 +++++++++---- Source/Compilers/AccCompiler.cs | 12 +++--------- Source/Compilers/Compiler.cs | 2 ++ Source/Controls/ScriptFileDocumentTab.cs | 3 ++- Source/General/MapManager.cs | 24 +++++++++++++++++++----- 6 files changed, 36 insertions(+), 20 deletions(-) diff --git a/Build/Scripting/ZDoom_ACS.cfg b/Build/Scripting/ZDoom_ACS.cfg index 9a567a6c..b6dd4b3d 100644 --- a/Build/Scripting/ZDoom_ACS.cfg +++ b/Build/Scripting/ZDoom_ACS.cfg @@ -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 diff --git a/Documents/compilerinterfaces.txt b/Documents/compilerinterfaces.txt index 80a41f1e..dfce4c04 100644 --- a/Documents/compilerinterfaces.txt +++ b/Documents/compilerinterfaces.txt @@ -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! diff --git a/Source/Compilers/AccCompiler.cs b/Source/Compilers/AccCompiler.cs index 52dc3f5f..49b16ab9 100644 --- a/Source/Compilers/AccCompiler.cs +++ b/Source/Compilers/AccCompiler.cs @@ -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(); diff --git a/Source/Compilers/Compiler.cs b/Source/Compilers/Compiler.cs index 289e3bb1..234452a9 100644 --- a/Source/Compilers/Compiler.cs +++ b/Source/Compilers/Compiler.cs @@ -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; } } diff --git a/Source/Controls/ScriptFileDocumentTab.cs b/Source/Controls/ScriptFileDocumentTab.cs index 7eceb000..92d334c5 100644 --- a/Source/Controls/ScriptFileDocumentTab.cs +++ b/Source/Controls/ScriptFileDocumentTab.cs @@ -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()) { diff --git a/Source/General/MapManager.cs b/Source/General/MapManager.cs index 3701f0bf..29dfb5cc 100644 --- a/Source/General/MapManager.cs +++ b/Source/General/MapManager.cs @@ -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(); @@ -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()) {