void LinkToTarget(BuildResult br, bool modificationsDone) { // The target file to which all objects will be linked to var LinkTargetFile = Project.GetOutputFileName(BuildConfig.Selector); if (!modificationsDone && File.Exists(LinkTargetFile)) { monitor.ReportSuccess("Build successful! - No new linkage needed"); monitor.Step(1); return; } // b.Build linker argument string // Build argument preparation var linkArgs = FillInMacros(BuildArguments(BuildConfig).LinkerArguments.Trim() + (string.IsNullOrEmpty(BuildConfig.ExtraLinkerArguments) ? string.Empty : (" " + BuildConfig.ExtraLinkerArguments.Trim())), new DLinkerMacroProvider { ObjectsStringPattern = Compiler.ArgumentPatterns.ObjectFileLinkPattern, Objects = BuiltObjects.ToArray(), TargetFile = LinkTargetFile, RelativeTargetDirectory = BuildConfig.OutputDirectory.ToRelative(Project.BaseDirectory), Libraries = GetLibraries(BuildConfig, Compiler) }, commonMacros); var linkerOutput = ""; var linkerErrorOutput = ""; var linkCfg = LinkTargetCfg(BuildConfig); var linkerExecutable = linkCfg.Linker; if (!Path.IsPathRooted(linkerExecutable) && !string.IsNullOrEmpty(Compiler.BinPath)) { linkerExecutable = Path.Combine(Compiler.BinPath, linkCfg.Linker); if (!File.Exists(linkerExecutable)) { linkerExecutable = linkCfg.Linker; } } string cmdLineFile; HandleOverLongArgumentStrings(monitor, Compiler, true, ref linkArgs, out cmdLineFile); int exitCode = ExecuteCommand(linkerExecutable, linkArgs, Project.BaseDirectory, monitor, out linkerErrorOutput, out linkerOutput); ErrorExtracting.HandleOptLinkOutput(Project, br, linkerOutput); ErrorExtracting.HandleLdOutput(Project, br, linkerOutput); ErrorExtracting.HandleReturnCode(monitor, br, exitCode); if (cmdLineFile != null && !br.Failed) { File.Delete(cmdLineFile); } }
BuildResult DoOneStepBuild() { var br = new BuildResult(); bool filesModified = false; // Enum files & build resource files foreach (var pf in Project.Files) { if (pf.BuildAction != BuildAction.Compile || pf.Subtype == Subtype.Directory) { continue; } DateTime dt; if (Project.LastModificationTimes.TryGetValue(pf, out dt)) { filesModified |= File.GetLastWriteTime(pf.FilePath) != dt; } else { filesModified = true; } Project.LastModificationTimes[pf] = File.GetLastWriteTime(pf.FilePath); if (pf.FilePath.Extension.EndsWith(".rc", StringComparison.OrdinalIgnoreCase)) { if (!CompileResourceScript(br, pf)) { return(br); } } else { BuiltObjects.Add(MakeRelativeToPrjBase(pf.FilePath)); } } // Build argument string var target = Project.GetOutputFileName(BuildConfig.Selector); if (!filesModified && Project.EnableIncrementalLinking && File.Exists(target)) { monitor.ReportSuccess("Build successful! - No new linkage needed"); monitor.Step(1); return(br); } var rawArgumentString = new StringBuilder(); if (!string.IsNullOrEmpty(AdditionalCompilerAttributes)) { rawArgumentString.Append(AdditionalCompilerAttributes.Trim()).Append(' '); } rawArgumentString.Append(BuildArguments.OneStepBuildArguments.Trim()); if (!string.IsNullOrEmpty(BuildConfig.ExtraCompilerArguments)) { rawArgumentString.Append(' ').Append(BuildConfig.ExtraCompilerArguments.Trim()); } if (!string.IsNullOrEmpty(BuildConfig.ExtraLinkerArguments)) { rawArgumentString.Append(' ').Append(PrefixedExtraLinkerFlags); } var argumentString = FillInMacros(rawArgumentString.ToString(), new OneStepBuildArgumentMacroProvider { ObjectsStringPattern = Compiler.ArgumentPatterns.ObjectFileLinkPattern, IncludesStringPattern = Compiler.ArgumentPatterns.IncludePathPattern, SourceFiles = BuiltObjects, Includes = FillCommonMacros(Project.IncludePaths), Libraries = GetLibraries(BuildConfig, Compiler), RelativeTargetDirectory = BuildConfig.OutputDirectory, ObjectsDirectory = ObjectDirectory, TargetFile = target, }, commonMacros); // Execute the compiler var stdOut = ""; var stdError = ""; var linkerExecutable = Compiler.SourceCompilerCommand; if (!Path.IsPathRooted(linkerExecutable) && !string.IsNullOrEmpty(Compiler.BinPath)) { linkerExecutable = Path.Combine(Compiler.BinPath, LinkTargetCfg.Linker); if (!File.Exists(linkerExecutable)) { linkerExecutable = LinkTargetCfg.Linker; } } monitor.Log.WriteLine("Current dictionary: " + Project.BaseDirectory); string cmdLineFile; HandleOverLongArgumentStrings(Compiler, true, ref argumentString, out cmdLineFile); int exitCode = ExecuteCommand(linkerExecutable, argumentString, Project.BaseDirectory, monitor, out stdError, out stdOut); ErrorExtracting.HandleCompilerOutput(Project, br, stdError); ErrorExtracting.HandleCompilerOutput(Project, br, stdOut); ErrorExtracting.HandleOptLinkOutput(Project, br, stdOut); ErrorExtracting.HandleReturnCode(monitor, br, exitCode); if (cmdLineFile != null) { File.Delete(cmdLineFile); } return(br); }
BuildResult DoOneStepBuild() { var br = new BuildResult(); bool filesModified = false; // Enum files & build resource files foreach (var pf in Project.Files) { if (pf.BuildAction != BuildAction.Compile || pf.Subtype == Subtype.Directory) { continue; } DateTime dt; if (Project.LastModificationTimes.TryGetValue(pf, out dt)) { filesModified |= File.GetLastWriteTime(pf.FilePath) != dt; } else { filesModified = true; } Project.LastModificationTimes[pf] = File.GetLastWriteTime(pf.FilePath); if (pf.FilePath.Extension.EndsWith(".rc", StringComparison.OrdinalIgnoreCase)) { if (!CompileResourceScript(br, pf)) { return(br); } } else { BuiltObjects.Add(MakeRelativeToPrjBase(Project, pf.FilePath)); } } // Build argument string var target = Project.GetOutputFileName(BuildConfig.Selector); if (!Project.NeedsFullRebuild && !filesModified && Project.EnableIncrementalLinking && File.Exists(target)) { monitor.ReportSuccess("Build successful! - No new linkage needed"); monitor.Step(1); return(br); } var argumentString = BuildOneStepBuildString(Project, BuiltObjects, BuildConfig.Selector); // Execute the compiler var stdOut = ""; var stdError = ""; var linkCfg = LinkTargetCfg(BuildConfig); var linkerExecutable = Compiler.SourceCompilerCommand; if (!Path.IsPathRooted(linkerExecutable) && !string.IsNullOrEmpty(Compiler.BinPath)) { linkerExecutable = Path.Combine(Compiler.BinPath, linkCfg.Linker); if (!File.Exists(linkerExecutable)) { linkerExecutable = linkCfg.Linker; } } monitor.Log.WriteLine("Current dictionary: " + Project.BaseDirectory); string cmdLineFile; HandleOverLongArgumentStrings(monitor, Compiler, true, ref argumentString, out cmdLineFile); int exitCode = ExecuteCommand(linkerExecutable, argumentString, Project.BaseDirectory, monitor, out stdError, out stdOut); ErrorExtracting.HandleCompilerOutput(Project, br, stdError); ErrorExtracting.HandleCompilerOutput(Project, br, stdOut); ErrorExtracting.HandleOptLinkOutput(Project, br, stdOut); ErrorExtracting.HandleLdOutput(Project, br, stdOut); ErrorExtracting.HandleReturnCode(monitor, br, exitCode); if (cmdLineFile != null) { File.Delete(cmdLineFile); } if (!br.Failed) { Project.CopySupportFiles(monitor, this.BuildConfig.Selector); Project.NeedsFullRebuild = false; } return(br); }