Skip to content

Commit

Permalink
[Packaging] Ensure that when we build from source, the srcs go to the…
Browse files Browse the repository at this point in the history
… correct place. (dotnet#7394)

* [Packaging] Ensure that when we build from source,  the srcs go to the correct plance.

When building from source, the install-sources command was not moving
the files correctly. This change makes sure that, if we build from
source, we do add the mono sources in the correct location.

Fixes: dotnet#7393
  • Loading branch information
mandel-macaque authored Nov 11, 2019
1 parent 452f4dc commit e639470
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ public void SetUp ()
monoPath = "/Users/test/xamarin-macios/external/mono/";
installDir = "/Users/test/xamarin-macios/_ios-build//Library/Frameworks/Xamarin.iOS.framework/Versions/git";
destinationDir = "/Users/test/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git";
mangler = new MonoPathMangler {
mangler = new MonoPathMangler {
InstallDir = installDir,
MonoSourcePath = monoPath,
DestinationDir = destinationDir,
XamarinSourcePath = "/Users/test/xamarin-macios/src",
};
}

Expand Down
22 changes: 21 additions & 1 deletion tools/install-source/MonoPathMangler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ public class MonoPathMangler : IPathMangler
{
public static readonly string iOSFramework = "/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/";
public static readonly string MacFramework = "/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/src/Xamarin.Mac/";
string monoSubmodulePath;
string xamarinSourcePath;

/// <summary>
/// Gets and sets the location of the mono sources.
/// </summary>
Expand All @@ -19,12 +22,29 @@ public class MonoPathMangler : IPathMangler
/// <value>The frame work dir.</value>
public string DestinationDir { get; set; }

/// <summary>
/// Gets and sets the path to the xamarin source.
/// </summary>
/// <value>The xamarin source path.</value>
public string XamarinSourcePath {
get {
return xamarinSourcePath;
}
set {
xamarinSourcePath = value;
monoSubmodulePath = Path.Combine (value.Replace ("src/", ""), "external", "mono") + "/";
}
}

/// <summary>
/// Gets or sets the install dir.
/// </summary>
/// <value>The install dir.</value>
public string InstallDir { get; set; }

bool IsCheckout (string path)
=> path.StartsWith (monoSubmodulePath, StringComparison.Ordinal);

public string GetSourcePath (string path)
{
// we are dealing with a Mono archive assembly
Expand All @@ -40,7 +60,7 @@ public string GetSourcePath (string path)

public string GetTargetPath (string path)
{
var relativePath = path.Substring (MonoSourcePath.Length);
var relativePath = path.Substring (IsCheckout (path) ? monoSubmodulePath.Length : MonoSourcePath.Length);
if (relativePath.StartsWith ("/", StringComparison.Ordinal))
relativePath = relativePath.Remove (0, 1);
var target = Path.Combine (DestinationDir, "src", (InstallDir.Contains("Xamarin.iOS")?"Xamarin.iOS":"Xamarin.Mac"), relativePath);
Expand Down
3 changes: 2 additions & 1 deletion tools/install-source/PathManglerFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ MonoPathMangler MonoPathMangler {
monoMangler = new MonoPathMangler {
InstallDir = InstallDir,
DestinationDir = DestinationDir,
MonoSourcePath = MonoSourcePath
MonoSourcePath = MonoSourcePath,
XamarinSourcePath = XamarinSourcePath,
};
return monoMangler;
}
Expand Down

0 comments on commit e639470

Please sign in to comment.