Skip to content
This repository was archived by the owner on Aug 11, 2021. It is now read-only.

Commit eb607a1

Browse files
committed
[Bam|Core] Fixes #182. When the C# assembly for all the packages in a build fails to compile, an improved error message is now displayed, hinting at using the command line option in bam for enabling debug symbols, and the option to generate a debuggable project in one of the applicable IDEs (VisualStudio/Xamarin Studio/MonoDevelop).
1 parent c67027b commit eb607a1

File tree

4 files changed

+25
-18
lines changed

4 files changed

+25
-18
lines changed

Bam.Core/EntryPoint.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,7 @@ public static void
9999
}
100100
else
101101
{
102-
var compiledSuccessfully = PackageUtilities.CompilePackageAssembly();
103-
if (!compiledSuccessfully)
104-
{
105-
throw new Exception("Package compilation failed");
106-
}
102+
PackageUtilities.CompilePackageAssembly();
107103
PackageUtilities.LoadPackageAssembly();
108104
}
109105

Bam.Core/Package/PackageUtilities.cs

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -487,11 +487,11 @@ private static string
487487

488488
/// <summary>
489489
/// Compile the package assembly, using all the source files from the dependent packages.
490+
/// Throws Bam.Core.Exceptions if package compilation fails.
490491
/// </summary>
491-
/// <returns><c>true</c>, if package assembly was compiled, <c>false</c> otherwise.</returns>
492492
/// <param name="enforceBamAssemblyVersions">If set to <c>true</c> enforce bam assembly versions. Default is true.</param>
493493
/// <param name="enableClean">If set to <c>true</c> cleaning the build root is allowed. Default is true.</param>
494-
public static bool
494+
public static void
495495
CompilePackageAssembly(
496496
bool enforceBamAssemblyVersions = true,
497497
bool enableClean = true)
@@ -616,8 +616,7 @@ public static bool
616616
Graph.Instance.ScriptAssemblyPathname = cachedAssemblyPathname;
617617

618618
assemblyCompileProfile.StopProfile();
619-
620-
return true;
619+
return;
621620
}
622621
else
623622
{
@@ -723,12 +722,26 @@ public static bool
723722

724723
if (results.Errors.HasErrors || results.Errors.HasWarnings)
725724
{
726-
Log.ErrorMessage("Failed to compile package '{0}'. There are {1} errors.", Graph.Instance.MasterPackage.FullName, results.Errors.Count);
725+
var message = new System.Text.StringBuilder();
726+
message.AppendFormat("Failed to compile package '{0}'. There are {1} errors.", Graph.Instance.MasterPackage.FullName, results.Errors.Count);
727+
message.AppendLine();
727728
foreach (System.CodeDom.Compiler.CompilerError error in results.Errors)
728729
{
729-
Log.ErrorMessage("\t{0}({1}): {2} {3}", error.FileName, error.Line, error.ErrorNumber, error.ErrorText);
730+
message.AppendFormat("\t{0}({1}): {2} {3}", error.FileName, error.Line, error.ErrorNumber, error.ErrorText);
731+
message.AppendLine();
732+
}
733+
if (!Graph.Instance.CompileWithDebugSymbols)
734+
{
735+
message.AppendLine();
736+
ICommandLineArgument debugOption = new Options.UseDebugSymbols();
737+
message.AppendFormat("Use the {0}/{1} command line option with bam for more accurate error messages.", debugOption.LongName, debugOption.ShortName);
738+
message.AppendLine();
730739
}
731-
return false;
740+
message.AppendLine();
741+
ICommandLineArgument createDebugProjectOption = new Options.CreateDebugProject();
742+
message.AppendFormat("Use the {0}/{1} command line option with bam to create an editable IDE project containing the build scripts.", createDebugProjectOption.LongName, createDebugProjectOption.ShortName);
743+
message.AppendLine();
744+
throw new Exception(message.ToString());
732745
}
733746

734747
if (!Graph.Instance.CompileWithDebugSymbols)
@@ -752,8 +765,6 @@ public static bool
752765
}
753766

754767
assemblyCompileProfile.StopProfile();
755-
756-
return true;
757768
}
758769

759770
/// <summary>

Bam/CommandLineArgumentHelper.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,8 @@ public static void
8888
if (Core.PackageUtilities.IsPackageDirectory(Core.Graph.Instance.ProcessState.WorkingDirectory))
8989
{
9090
Core.Graph.Instance.BuildRoot = System.IO.Path.GetTempPath();
91-
if (Core.PackageUtilities.CompilePackageAssembly(enforceBamAssemblyVersions: false, enableClean: false))
92-
{
93-
Core.PackageUtilities.LoadPackageAssembly();
94-
}
91+
Core.PackageUtilities.CompilePackageAssembly(enforceBamAssemblyVersions: false, enableClean: false);
92+
Core.PackageUtilities.LoadPackageAssembly();
9593
}
9694
}
9795
catch (Core.Exception)

Changelog.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
25-Mar-2016 Fixes #182. When the C# assembly for all the packages in a build fails to compile, an improved error message is now displayed, hinting at using the command line option in bam for enabling debug symbols, and the option to generate a debuggable project in one of the applicable IDEs (VisualStudio/Xamarin Studio/MonoDevelop).
2+
13
25-Mar-2016 Fixes #180. C.DynamicLibrary and C.Cxx.DynamicLibrary that identify dynamic library dependencies with CompilePubliclyAndLinkAgainst now forward those dependencies on, just like how StaticLibraries already do. If the public API in dynamic library D is exposed in the public API of dynamic library E, then it is legal for a compilation step dependent on D to invoke calls in E that were not resolved during D's link. This change simplifies writing build scripts in that transient dynamic dependencies no longer need to be manually specified.
24

35
24-Mar-2016 Fixes #179. Removed the 'frameworks' argument from the C.ILinkingPolicy.Link function, as it is never used. Passing OSX frameworks to the linker is performed via the setting in C.ICommonLinkerSettingsOSX.

0 commit comments

Comments
 (0)