-
Notifications
You must be signed in to change notification settings - Fork 511
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for Windows builds of Xamarin.Mac
- Loading branch information
Showing
13 changed files
with
618 additions
and
429 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("Xamarin.Mac.Tasks.Core")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("Xamarin.Mac.Tasks.Core")] | ||
[assembly: AssemblyCopyright("Copyright © 2016")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("af1ac7c3-f6dd-4e46-b897-9dbb90b158ec")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
145 changes: 145 additions & 0 deletions
145
msbuild/Xamarin.Mac.Tasks.Core/Tasks/DetectSdkLocations.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
using System; | ||
using System.IO; | ||
using System.Linq; | ||
|
||
using Microsoft.Build.Framework; | ||
using Microsoft.Build.Utilities; | ||
|
||
using Xamarin.MacDev.Tasks; | ||
using Xamarin.MacDev; | ||
|
||
namespace Xamarin.Mac.Tasks | ||
{ | ||
public class DetectSdkLocationsTaskBase : Task | ||
{ | ||
#region Inputs | ||
|
||
public string SessionId { get; set; } | ||
|
||
// This is also an input | ||
[Output] | ||
public string SdkVersion { | ||
get; set; | ||
} | ||
|
||
public string XamarinSdkRoot { | ||
get; set; | ||
} | ||
|
||
#endregion Inputs | ||
|
||
#region Outputs | ||
|
||
[Output] | ||
public string SdkRoot { | ||
get; set; | ||
} | ||
|
||
[Output] | ||
public string SdkBinPath { | ||
get; set; | ||
} | ||
|
||
[Output] | ||
public string SdkDevPath { | ||
get; set; | ||
} | ||
|
||
[Output] | ||
public string SdkUsrPath { | ||
get; set; | ||
} | ||
|
||
#endregion Outputs | ||
|
||
public override bool Execute () | ||
{ | ||
Log.LogTaskName ("DetectSdkLocations"); | ||
Log.LogTaskProperty ("SdkVersion", SdkVersion); | ||
Log.LogTaskProperty ("XamarinSdkRoot", XamarinSdkRoot); | ||
|
||
EnsureAppleSdkRoot (); | ||
EnsureXamarinSdkRoot (); | ||
EnsureSdkPath (); | ||
|
||
return !Log.HasLoggedErrors; | ||
} | ||
|
||
void EnsureSdkPath () | ||
{ | ||
MacOSXSdkVersion requestedSdkVersion; | ||
if (string.IsNullOrEmpty (SdkVersion)) { | ||
requestedSdkVersion = MacOSXSdkVersion.UseDefault; | ||
} else if (!MacOSXSdkVersion.TryParse (SdkVersion, out requestedSdkVersion)) { | ||
Log.LogError ("Could not parse the SDK version '{0}'", SdkVersion); | ||
return; | ||
} | ||
|
||
var sdkVersion = requestedSdkVersion.ResolveIfDefault (MacOSXSdks.Native); | ||
if (!MacOSXSdks.Native.SdkIsInstalled (sdkVersion)) { | ||
sdkVersion = MacOSXSdks.Native.GetClosestInstalledSdk (sdkVersion); | ||
|
||
if (sdkVersion.IsUseDefault || !MacOSXSdks.Native.SdkIsInstalled (sdkVersion)) { | ||
if (requestedSdkVersion.IsUseDefault) { | ||
Log.LogError ("The Apple MacOSX SDK is not installed."); | ||
} else { | ||
Log.LogError ("The MacOSX SDK version '{0}' is not installed, and no newer version was found.", requestedSdkVersion.ToString ()); | ||
} | ||
return; | ||
} | ||
Log.LogWarning ("The MacOSX SDK version '{0}' is not installed. Using newer version '{1}' instead'.", requestedSdkVersion, sdkVersion); | ||
} | ||
|
||
SdkVersion = sdkVersion.ToString (); | ||
|
||
SdkRoot = MacOSXSdks.Native.GetSdkPath (sdkVersion); | ||
if (string.IsNullOrEmpty (SdkRoot)) | ||
Log.LogError ("Could not locate the MacOSX '{0}' SDK at path '{1}'", SdkVersion, SdkRoot); | ||
|
||
SdkUsrPath = DirExists ("SDK usr directory", Path.Combine (MacOSXSdks.Native.DeveloperRoot, "usr")); | ||
if (string.IsNullOrEmpty (SdkUsrPath)) | ||
Log.LogError ("Could not locate the MacOSX '{0}' SDK usr path at '{1}'", SdkVersion, SdkRoot); | ||
|
||
SdkBinPath = DirExists ("SDK bin directory", Path.Combine (SdkUsrPath, "bin")); | ||
if (string.IsNullOrEmpty (SdkBinPath)) | ||
Log.LogError ("Could not locate SDK bin directory"); | ||
} | ||
|
||
void EnsureAppleSdkRoot () | ||
{ | ||
if (!MacOSXSdks.Native.IsInstalled) { | ||
Log.LogError (" Could not find valid a usable Xcode app bundle"); | ||
} else { | ||
Log.LogMessage (MessageImportance.Low, " DeveloperRoot: {0}", MacOSXSdks.Native.DeveloperRoot); | ||
Log.LogMessage (MessageImportance.Low, " GetPlatformPath: {0}", MacOSXSdks.Native.GetPlatformPath ()); | ||
|
||
SdkDevPath = MacOSXSdks.Native.DeveloperRoot; | ||
if (string.IsNullOrEmpty (SdkDevPath)) | ||
Log.LogError (" Could not find valid a usable Xcode developer path"); | ||
} | ||
} | ||
|
||
void EnsureXamarinSdkRoot () | ||
{ | ||
if (string.IsNullOrEmpty (XamarinSdkRoot)) | ||
XamarinSdkRoot = MacOSXSdks.XamMac.FrameworkDirectory; | ||
|
||
if (string.IsNullOrEmpty (XamarinSdkRoot) || !Directory.Exists (XamarinSdkRoot)) | ||
Log.LogError (" Could not find 'Xamarin.Mac'"); | ||
} | ||
|
||
string DirExists (string checkingFor, params string[] paths) | ||
{ | ||
try { | ||
if (paths.Any (p => string.IsNullOrEmpty (p))) | ||
return null; | ||
|
||
var path = Path.GetFullPath (Path.Combine (paths)); | ||
Log.LogMessage (MessageImportance.Low, " Searching for '{0}' in '{1}'", checkingFor, path); | ||
return Directory.Exists (path) ? path : null; | ||
} catch { | ||
return null; | ||
} | ||
} | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
msbuild/Xamarin.Mac.Tasks.Core/Tasks/EmbedProvisionProfile.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using System; | ||
using System.IO; | ||
using System.Linq; | ||
|
||
using Microsoft.Build.Framework; | ||
using Microsoft.Build.Utilities; | ||
|
||
using Xamarin.MacDev.Tasks; | ||
using Xamarin.MacDev; | ||
|
||
namespace Xamarin.Mac.Tasks | ||
{ | ||
public class EmbedProvisionProfileTaskBase : Task | ||
{ | ||
#region Inputs | ||
|
||
public string SessionId { get; set; } | ||
|
||
[Required] | ||
public string AppBundleDir { get; set; } | ||
|
||
[Required] | ||
public string ProvisioningProfile { get; set; } | ||
|
||
#endregion | ||
|
||
static MobileProvision GetMobileProvision (MobileProvisionPlatform platform, string uuid) | ||
{ | ||
var extension = MobileProvision.GetFileExtension (platform); | ||
var path = Path.Combine (MobileProvision.ProfileDirectory, uuid + extension); | ||
|
||
if (File.Exists (path)) | ||
return MobileProvision.LoadFromFile (path); | ||
|
||
return MobileProvision.GetAllInstalledProvisions (platform, true).FirstOrDefault (x => x.Uuid == uuid); | ||
} | ||
|
||
public override bool Execute () | ||
{ | ||
Log.LogTaskName ("EmbedProvisionProfile"); | ||
Log.LogTaskProperty ("AppBundleDir", AppBundleDir); | ||
Log.LogTaskProperty ("ProvisioningProfile", ProvisioningProfile); | ||
|
||
var profile = GetMobileProvision (MobileProvisionPlatform.MacOS, ProvisioningProfile); | ||
|
||
if (profile == null) { | ||
Log.LogError ("Could not locate the provisioning profile with a UUID of {0}.", ProvisioningProfile); | ||
return false; | ||
} | ||
|
||
var embedded = Path.Combine (AppBundleDir, "Contents", "embedded.provisionprofile"); | ||
|
||
Directory.CreateDirectory (AppBundleDir); | ||
profile.Save (embedded); | ||
|
||
return true; | ||
} | ||
} | ||
} |
Oops, something went wrong.