[generator] Use --target-framework to specify which XM profile to target. (#1339)

This commit is contained in:
Rolf Bjarne Kvinge 2016-12-20 11:33:56 +01:00 коммит произвёл GitHub
Родитель 86fcbbe715
Коммит ffe3184345
7 изменённых файлов: 56 добавлений и 5 удалений

Просмотреть файл

@ -2,6 +2,7 @@ using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

using Xamarin.MacDev.Tasks;
using Microsoft.Build.Framework;
@ -38,7 +39,17 @@ namespace Xamarin.Mac.Tasks
"MONO_PATH=" + string.Format ("{0}/lib/mono/{1}", FrameworkRoot, isMobile ? "Xamarin.Mac" : "4.5")
};
return string.Format ("{0}/lib/bmac/bmac-{1}.exe ", FrameworkRoot, isMobile ? "mobile" : "full") + "-nostdlib " + base.GenerateCommandLineCommands ();
var sb = new StringBuilder ();
if (isMobile) {
sb.Append (Path.Combine (FrameworkRoot, "lib", "bmac", "bmac-mobile.exe"));
sb.Append (" --target-framework=Xamarin.Mac,Version=v2.0,Profile=Mobile ");
} else {
sb.Append (Path.Combine (FrameworkRoot, "lib", "bmac", "bmac-full.exe"));
sb.Append (" --target-framework=Xamarin.Mac,Version=v4.5,Profile=Full ");
}
sb.Append ("-nostdlib ");
sb.Append (base.GenerateCommandLineCommands ());
return sb.ToString ();
}
}
}

Просмотреть файл

@ -456,6 +456,10 @@ $(MAC_BUILD_DIR)/AssemblyInfo.cs: $(TOP)/src/AssemblyInfo.cs.in
@mkdir -p $(MAC_BUILD_DIR)
$(call Q_PROF_GEN,mac) sed < $< > $@ 's|@PRODUCT_NAME@|$(MAC_PRODUCT)|g; s|@PACKAGE_HEAD_REV@|$(PACKAGE_HEAD_REV)|g; s|@PACKAGE_HEAD_BRANCH@|$(CURRENT_BRANCH)|g; s|@PACKAGE_VERSION_MAJOR@|$(MAC_PACKAGE_VERSION_MAJOR)|g; s|@PACKAGE_VERSION_MINOR@|$(MAC_PACKAGE_VERSION_MINOR)|g; s|@PACKAGE_VERSION_REV@|$(MAC_PACKAGE_VERSION_REV)|g; s|@PACKAGE_VERSION_BUILD@|$(MAC_PACKAGE_VERSION_BUILD)|g'
# We can't pass the --target-framework values as parameters to the templates, because the commas interfere with Make's parameter parsing.
xm_full_profile=--target-framework=Xamarin.Mac,Version=v4.5,Profile=Full
xm_mobile_profile=--target-framework=Xamarin.Mac,Version=v2.0,Profile=Mobile
define MAC_GENERATOR_template
$(MAC_BUILD_DIR)/$(1)/pmcs: pmcs.in $(PMCS_EXE) Makefile | $(MAC_BUILD_DIR)/$(1)
$$(call Q_PROF_GEN,mac/$(1)) sed -e 's|@MCS@|$(SYSTEM_MCS) $(4)|g' -e 's|@PMCS@|$(abspath $(PMCS_EXE))|g' < $$< > $$@
@ -490,12 +494,13 @@ $(MAC_BUILD_DIR)/$(1)/generated-sources: $(MAC_BUILD_DIR)/$(1)/_bmac.exe $(MAC_A
-d:NO_SYSTEM_DRAWING \
$(2) \
$(3) \
$(xm_$(1)_profile) \
$(MAC_APIS)
endef
$(eval $(call MAC_GENERATOR_template,compat,--ns=MonoMac.ObjCRuntime,-r:/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5/System.Drawing.dll,,$(SYSTEM_MONO),compat-mac))
$(eval $(call MAC_GENERATOR_template,full,--ns=ObjCRuntime -unified-full-profile,-d:NO_SYSTEM_DRAWING,,$(SYSTEM_MONO),full,-d:NO_SYSTEM_DRAWING))
$(eval $(call MAC_GENERATOR_template,mobile,--ns=ObjCRuntime -unified-mobile-profile,$(SHARED_SYSTEM_DRAWING_SOURCES),-nostdlib -r:mscorlib.dll -lib:$(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/Xamarin.Mac,$(TOP)/builds/install/mono-mac64,mobile))
$(eval $(call MAC_GENERATOR_template,full,--ns=ObjCRuntime,-d:NO_SYSTEM_DRAWING,,$(SYSTEM_MONO),full,-d:NO_SYSTEM_DRAWING))
$(eval $(call MAC_GENERATOR_template,mobile,--ns=ObjCRuntime,$(SHARED_SYSTEM_DRAWING_SOURCES),-nostdlib -r:mscorlib.dll -lib:$(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/Xamarin.Mac,$(TOP)/builds/install/mono-mac64,mobile))
define MAC_TARGETS_template
$(MAC_BUILD_DIR)/$(1)/$(2): $(MAC_BUILD_DIR)/$(3)/generated-sources $(MAC_SOURCES) $(MAC_CFNETWORK_SOURCES) $(MAC_CLASSIC_SOURCES) $(SN_KEY)

Просмотреть файл

@ -6,6 +6,7 @@ GENERATOR_SOURCES = \
$(TOP)/src/generator-enums.cs \
$(TOP)/src/generator-filters.cs \
$(TOP)/src/ObjCRuntime/Stret.cs \
$(TOP)/tools/common/TargetFramework.cs \
$(MONO_PATH)/mcs/class/Mono.Options/Mono.Options/Options.cs \
GENERATOR_DEFINES = -d:GENERATOR -d:NET_4_0

Просмотреть файл

@ -47,11 +47,11 @@ mobile|xamarin.mac|xammac)
export MONO_PATH=$ROOT_DIR/lib/mono
else
if [[ "$full_profile" -eq 1 ]]; then
refs="-baselib:$ROOT_DIR/lib/reference/full/Xamarin.Mac.dll"
refs="-baselib:$ROOT_DIR/lib/reference/full/Xamarin.Mac.dll --target-framework=Xamarin.Mac,Version=v4.5,Profile=Full"
bmac=bmac-full.exe
export MONO_PATH=$ROOT_DIR/lib/reference/full
elif [[ "$mobile_profile" -eq 1 ]]; then
refs="-baselib:$ROOT_DIR/lib/reference/mobile/Xamarin.Mac.dll"
refs="-baselib:$ROOT_DIR/lib/reference/mobile/Xamarin.Mac.dll --target-framework=Xamarin.Mac,Version=v2.0,Profile=Mobile"
bmac=bmac-mobile.exe
export MONO_PATH=$ROOT_DIR/lib/mono/Xamarin.Mac
mono="$ROOT_DIR/bin/bmac-mobile-mono"

Просмотреть файл

@ -36,10 +36,12 @@ using System.Runtime.InteropServices;
using XamCore.ObjCRuntime;
using XamCore.Foundation;
using Xamarin.Utils;
class BindingTouch {
static Type CoreObject = typeof (XamCore.Foundation.NSObject);
static TargetFramework? target_framework;
#if MONOMAC
public static PlatformName CurrentPlatform = PlatformName.MacOSX;
#if XAMCORE_2_0
@ -142,6 +144,17 @@ class BindingTouch {
}
}
static void SetTargetFramework (string fx)
{
TargetFramework tf;
if (!TargetFramework.TryParse (fx, out tf))
throw ErrorHelper.CreateError (68, "Invalid value for target framework: {0}.", fx);
target_framework = tf;
if (Array.IndexOf (TargetFramework.ValidFrameworks, target_framework.Value) == -1)
throw ErrorHelper.CreateError (70, "Invalid target framework: {0}. Valid target frameworks are: {1}.", target_framework.Value, string.Join (" ", TargetFramework.ValidFrameworks.Select ((v) => v.ToString ()).ToArray ()));
}
static int Main2 (string [] args)
{
bool show_help = false;
@ -226,6 +239,7 @@ class BindingTouch {
},
{ "unified-full-profile", "Launches compiler pointing to XM Full Profile", l => { /* no-op*/ }, true },
{ "unified-mobile-profile", "Launches compiler pointing to XM Mobile Profile", l => { /* no-op*/ }, true },
{ "target-framework=", "Specify target framework to use. Only applicable to Xamarin.Mac, and the currently supported values are: 'Xamarin.Mac,Version=v2.0,Profile=Mobile', 'Xamarin.Mac,Version=v4.5,Profile=Full' and 'Xamarin.Mac,Version=v4.5,Profile=System')", v => SetTargetFramework (v) },
};
try {
@ -395,6 +409,11 @@ class BindingTouch {
break;
}
if (CurrentPlatform == PlatformName.MacOSX && Unified) {
if (!target_framework.HasValue)
throw ErrorHelper.CreateError (86, "A target framework (--target-framework) must be specified when building for Xamarin.Mac.");
}
var nsManager = new NamespaceManager (
nsManagerPrefix,
ns == null ? firstApiDefinitionName : ns,

Просмотреть файл

@ -12,9 +12,14 @@
using System;
using System.Collections.Generic;
using ProductException=BindingException;
// Error allocation
//
// BI0xxx the generator itself, e.g. parameters, environment
// BI0068 Invalid value for target framework: {0}. [same error number/message as mtouch/mmp]
// BI0070 Invalid target framework: {0}. Valid target frameworks are: {1}. [same error number/message as mtouch/mmp]
// BI0086 A target framework (--target-framework) must be specified when building for Xamarin.Mac. [same error number/message as mtouch/mmp]
// BI1xxx code generation
// BI10xx errors
// BI1001 Do not know how to make a trampoline for {0}
@ -123,6 +128,11 @@ public static class ErrorHelper {
static public int Verbosity { get; set; }
public static ProductException CreateError (int code, string message, params object[] args)
{
return new ProductException (code, true, message, args);
}
static public void Show (Exception e)
{
List<Exception> exceptions = new List<Exception> ();

Просмотреть файл

@ -38,8 +38,13 @@ namespace Xamarin.Utils
public static readonly TargetFramework Xamarin_WatchOS_1_0 = Parse ("Xamarin.WatchOS,v1.0");
public static readonly TargetFramework Xamarin_TVOS_1_0 = Parse ("Xamarin.TVOS,v1.0");
public static readonly TargetFramework Xamarin_Mac_2_0_Mobile = Parse ("Xamarin.Mac,Version=v2.0,Profile=Mobile");
public static readonly TargetFramework Xamarin_Mac_4_5_Full = Parse ("Xamarin.Mac,Version=v4.5,Profile=Full");
public static readonly TargetFramework Xamarin_Mac_4_5_System = Parse ("Xamarin.Mac,Version=v4.5,Profile=System");
#if MTOUCH
public static readonly TargetFramework [] ValidFrameworks = new TargetFramework[] { Xamarin_iOS_1_0, Xamarin_WatchOS_1_0, Xamarin_TVOS_1_0 };
#elif GENERATOR
public static readonly TargetFramework [] ValidFrameworks = new TargetFramework[] { Xamarin_Mac_2_0_Mobile, Xamarin_Mac_4_5_Full, Xamarin_Mac_4_5_System };
#endif
public static TargetFramework Parse (string targetFrameworkString)