This commit is contained in:
Joao Matos 2017-04-25 19:28:11 +01:00
Родитель cf8b4d952e
Коммит 24fc9d2bba
8 изменённых файлов: 56 добавлений и 41 удалений

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

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@ -149,8 +149,8 @@ namespace MonoEmbeddinator4000
options.Verbose = Verbose; options.Verbose = Verbose;
options.OutputDir = OutputDir; options.OutputDir = OutputDir;
options.CompileCode = CompileCode; options.CompileCode = CompileCode;
options.Target = Target; options.Compilation.Target = Target;
options.DebugMode = DebugMode; options.Compilation.DebugMode = DebugMode;
if (options.OutputDir == null) if (options.OutputDir == null)
options.OutputDir = Directory.GetCurrentDirectory(); options.OutputDir = Directory.GetCurrentDirectory();
@ -171,10 +171,10 @@ namespace MonoEmbeddinator4000
} }
var targetPlatform = ConvertToTargetPlatform(Platform); var targetPlatform = ConvertToTargetPlatform(Platform);
options.Platform = targetPlatform; options.Compilation.Platform = targetPlatform;
var vsVersion = ConvertToVsVersion(VsVersion); var vsVersion = ConvertToVsVersion(VsVersion);
options.VsVersion = vsVersion; options.Compilation.VsVersion = vsVersion;
return true; return true;
} }

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

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
@ -231,13 +231,13 @@ namespace MonoEmbeddinator4000
void AotAssemblies() void AotAssemblies()
{ {
switch (Options.Platform) switch (Options.Compilation.Platform)
{ {
case TargetPlatform.iOS: case TargetPlatform.iOS:
case TargetPlatform.TVOS: case TargetPlatform.TVOS:
case TargetPlatform.WatchOS: case TargetPlatform.WatchOS:
{ {
string aotCompiler = GetAppleAotCompiler(Options.Platform, string aotCompiler = GetAppleAotCompiler(Options.Compilation.Platform,
XamarinSdkRoot, is64bits: false); XamarinSdkRoot, is64bits: false);
// Call the Mono AOT cross compiler for all input assemblies. // Call the Mono AOT cross compiler for all input assemblies.
@ -255,7 +255,7 @@ namespace MonoEmbeddinator4000
case TargetPlatform.Android: case TargetPlatform.Android:
throw new NotSupportedException(string.Format( throw new NotSupportedException(string.Format(
"AOT cross compilation to target platform '{0}' is not supported.", "AOT cross compilation to target platform '{0}' is not supported.",
Options.Platform)); Options.Compilation.Platform));
case TargetPlatform.MacOS: case TargetPlatform.MacOS:
break; break;
} }
@ -266,7 +266,7 @@ namespace MonoEmbeddinator4000
get get
{ {
var detectAppleSdks = new Xamarin.iOS.Tasks.DetectIPhoneSdks { var detectAppleSdks = new Xamarin.iOS.Tasks.DetectIPhoneSdks {
TargetFrameworkIdentifier = GetXamarinTargetFrameworkName(Options.Platform) TargetFrameworkIdentifier = GetXamarinTargetFrameworkName(Options.Compilation.Platform)
}; };
if (!detectAppleSdks.Execute()) if (!detectAppleSdks.Execute())
@ -300,13 +300,13 @@ namespace MonoEmbeddinator4000
{ {
var appName = $"{OutputName}.app"; var appName = $"{OutputName}.app";
switch (Options.Platform) switch (Options.Compilation.Platform)
{ {
case TargetPlatform.iOS: case TargetPlatform.iOS:
case TargetPlatform.TVOS: case TargetPlatform.TVOS:
case TargetPlatform.WatchOS: case TargetPlatform.WatchOS:
var sdkName = App.Abi.IsSimulator() ? "Simulator" : string.Empty; var sdkName = App.Abi.IsSimulator() ? "Simulator" : string.Empty;
return Path.Combine(Options.OutputDir, $"{Options.Platform}{sdkName}", return Path.Combine(Options.OutputDir, $"{Options.Compilation.Platform}{sdkName}",
appName); appName);
case TargetPlatform.Windows: case TargetPlatform.Windows:
case TargetPlatform.Android: case TargetPlatform.Android:
@ -314,7 +314,7 @@ namespace MonoEmbeddinator4000
break; break;
} }
return Path.Combine(Options.OutputDir, Options.Platform.ToString(), return Path.Combine(Options.OutputDir, Options.Compilation.Platform.ToString(),
App.Abi.ToString(), appName); App.Abi.ToString(), appName);
} }
@ -332,13 +332,13 @@ namespace MonoEmbeddinator4000
$"--assembly-build-target=@all=framework={OutputName}.framework" $"--assembly-build-target=@all=framework={OutputName}.framework"
}; };
if (Options.DebugMode) if (Options.Compilation.DebugMode)
args.Add("--debug"); args.Add("--debug");
var targetArg = App.Abi.IsSimulator() ? "--sim" : "--dev"; var targetArg = App.Abi.IsSimulator() ? "--sim" : "--dev";
args.Add($"{targetArg} {GetOutputFolder()}"); args.Add($"{targetArg} {GetOutputFolder()}");
var xamarinAppleFramework = GetXamarinTargetFrameworkName(Options.Platform); var xamarinAppleFramework = GetXamarinTargetFrameworkName(Options.Compilation.Platform);
var references = new List<string> { var references = new List<string> {
Path.Combine(MonoTouchSdk.LibDir, "mono", xamarinAppleFramework, $"{xamarinAppleFramework}.dll"), Path.Combine(MonoTouchSdk.LibDir, "mono", xamarinAppleFramework, $"{xamarinAppleFramework}.dll"),
Path.Combine(MonoTouchSdk.LibDir, "mono", xamarinAppleFramework, "mscorlib.dll") Path.Combine(MonoTouchSdk.LibDir, "mono", xamarinAppleFramework, "mscorlib.dll")
@ -408,7 +408,7 @@ namespace MonoEmbeddinator4000
string.Join(" ", files.Select(file => Path.GetFullPath(file))) string.Join(" ", files.Select(file => Path.GetFullPath(file)))
}; };
if (Options.DebugMode) if (Options.Compilation.DebugMode)
args.Add("-g"); args.Add("-g");
var invocation = string.Join(" ", args); var invocation = string.Join(" ", args);
@ -437,14 +437,14 @@ namespace MonoEmbeddinator4000
throw new Exception("Visual Studio SDK was not found on your system."); throw new Exception("Visual Studio SDK was not found on your system.");
ToolchainVersion vsSdk; ToolchainVersion vsSdk;
if (Options.VsVersion == VisualStudioVersion.Latest) if (Options.Compilation.VsVersion == VisualStudioVersion.Latest)
vsSdk = vsSdks.LastOrDefault(); vsSdk = vsSdks.LastOrDefault();
else else
{ {
var exactVersion = vsSdks.Where(vs => (int)vs.Version == (int)Options.VsVersion) var exactVersion = vsSdks.Where(vs => (int)vs.Version == (int)Options.Compilation.VsVersion)
.Cast<ToolchainVersion?>().SingleOrDefault(); .Cast<ToolchainVersion?>().SingleOrDefault();
if (!exactVersion.HasValue) if (!exactVersion.HasValue)
throw new Exception($"Visual Studio SDK version {Options.VsVersion} was not found on your system."); throw new Exception($"Visual Studio SDK version {Options.Compilation.VsVersion} was not found on your system.");
vsSdk = exactVersion.Value; vsSdk = exactVersion.Value;
} }
@ -462,7 +462,7 @@ namespace MonoEmbeddinator4000
$"-I\"{monoPath}\\include\\mono-2.0\"", $"-I\"{monoPath}\\include\\mono-2.0\"",
string.Join(" ", files.Select(file => "\""+ Path.GetFullPath(file) + "\"")), string.Join(" ", files.Select(file => "\""+ Path.GetFullPath(file) + "\"")),
$"\"{monoPath}\\lib\\monosgen-2.0.lib\"", $"\"{monoPath}\\lib\\monosgen-2.0.lib\"",
Options.CompileSharedLibrary ? "/LD" : string.Empty, Options.Compilation.CompileSharedLibrary ? "/LD" : string.Empty,
$"/Fe{output}" $"/Fe{output}"
}; };
@ -502,7 +502,7 @@ namespace MonoEmbeddinator4000
var sysroot = Path.Combine (XcodeToolchain.GetXcodeIncludesFolder (), "../.."); var sysroot = Path.Combine (XcodeToolchain.GetXcodeIncludesFolder (), "../..");
args.Add ($"-isysroot {sysroot}"); args.Add ($"-isysroot {sysroot}");
if (Options.Target == CompilationTarget.SharedLibrary) if (Options.Compilation.Target == CompilationTarget.SharedLibrary)
{ {
var name = Path.GetFileNameWithoutExtension(Project.Assemblies[0]); var name = Path.GetFileNameWithoutExtension(Project.Assemblies[0]);
var libName = $"lib{name}.dylib"; var libName = $"lib{name}.dylib";
@ -535,7 +535,7 @@ namespace MonoEmbeddinator4000
} }
else if (Platform.IsMacOS) else if (Platform.IsMacOS)
{ {
switch (Options.Platform) switch (Options.Compilation.Platform)
{ {
case TargetPlatform.iOS: case TargetPlatform.iOS:
case TargetPlatform.TVOS: case TargetPlatform.TVOS:
@ -545,7 +545,7 @@ namespace MonoEmbeddinator4000
case TargetPlatform.Windows: case TargetPlatform.Windows:
case TargetPlatform.Android: case TargetPlatform.Android:
throw new NotSupportedException( throw new NotSupportedException(
$"Cross compilation to target platform '{Options.Platform}' is not supported."); $"Cross compilation to target platform '{Options.Compilation.Platform}' is not supported.");
case TargetPlatform.MacOS: case TargetPlatform.MacOS:
CompileClang(files); CompileClang(files);
break; break;

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

@ -87,6 +87,8 @@ namespace MonoEmbeddinator4000.Generators
{ {
public TranslationUnit Unit; public TranslationUnit Unit;
Options EmbedOptions => Context.Options as Options;
public CCodeGenerator(BindingContext context, public CCodeGenerator(BindingContext context,
TranslationUnit unit) : base(context, unit) TranslationUnit unit) : base(context, unit)
{ {
@ -113,7 +115,7 @@ namespace MonoEmbeddinator4000.Generators
public void WriteInclude(string include) public void WriteInclude(string include)
{ {
if (Options.GenerateSupportFiles) if (EmbedOptions.GenerateSupportFiles)
WriteLine("#include \"{0}\"", include); WriteLine("#include \"{0}\"", include);
else else
WriteLine("#include <{0}>", include); WriteLine("#include <{0}>", include);

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

@ -4,5 +4,12 @@ namespace MonoEmbeddinator4000
{ {
public class Options : DriverOptions public class Options : DriverOptions
{ {
// If true, will use unmanaged->managed thunks to call managed methods.
// In this mode the JIT will generate specialized wrappers for marshaling
// which will be faster but also lead to higher memory consumption.
public bool UseUnmanagedThunks;
// If true, will generate support files alongside generated binding code.
public bool GenerateSupportFiles = true;
} }
} }

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

@ -179,11 +179,8 @@
<Compile Include="../../external/CppSharp/src/Generator/Passes/GenerateAnonymousDelegatesPass.cs"> <Compile Include="../../external/CppSharp/src/Generator/Passes/GenerateAnonymousDelegatesPass.cs">
<Link>Passes/GenerateAnonymousDelegatesPass.cs</Link> <Link>Passes/GenerateAnonymousDelegatesPass.cs</Link>
</Compile> </Compile>
<Compile Include="../../external/CppSharp/src/Generator/Passes/GenerateInlinesPass.cs"> <Compile Include="../../external/CppSharp/src/Generator/Passes/GenerateSymbolsPass.cs">
<Link>Passes/GenerateInlinesPass.cs</Link> <Link>Passes/GenerateSymbolsPass.cs</Link>
</Compile>
<Compile Include="../../external/CppSharp/src/Generator/Passes/GenerateTemplatesCodePass.cs">
<Link>Passes/GenerateTemplatesCodePass.cs</Link>
</Compile> </Compile>
<Compile Include="../../external/CppSharp/src/Generator/Passes/GetterSetterToPropertyPass.cs"> <Compile Include="../../external/CppSharp/src/Generator/Passes/GetterSetterToPropertyPass.cs">
<Link>Passes/GetterSetterToPropertyPass.cs</Link> <Link>Passes/GetterSetterToPropertyPass.cs</Link>
@ -194,9 +191,6 @@
<Compile Include="../../external/CppSharp/src/Generator/Passes/IgnoreSystemDeclarationsPass.cs"> <Compile Include="../../external/CppSharp/src/Generator/Passes/IgnoreSystemDeclarationsPass.cs">
<Link>Passes/IgnoreSystemDeclarationsPass.cs</Link> <Link>Passes/IgnoreSystemDeclarationsPass.cs</Link>
</Compile> </Compile>
<Compile Include="../../external/CppSharp/src/Generator/Passes/InlinesCodeGenerator.cs">
<Link>Passes/InlinesCodeGenerator.cs</Link>
</Compile>
<Compile Include="../../external/CppSharp/src/Generator/Passes/MarkSupportedClassTemplateSpecializationsPass.cs"> <Compile Include="../../external/CppSharp/src/Generator/Passes/MarkSupportedClassTemplateSpecializationsPass.cs">
<Link>Passes/MarkSupportedClassTemplateSpecializationsPass.cs</Link> <Link>Passes/MarkSupportedClassTemplateSpecializationsPass.cs</Link>
</Compile> </Compile>
@ -236,6 +230,9 @@
<Compile Include="../../external/CppSharp/src/Generator/Passes/StripUnusedSystemTypesPass.cs"> <Compile Include="../../external/CppSharp/src/Generator/Passes/StripUnusedSystemTypesPass.cs">
<Link>Passes/StripUnusedSystemTypesPass.cs</Link> <Link>Passes/StripUnusedSystemTypesPass.cs</Link>
</Compile> </Compile>
<Compile Include="../../external/CppSharp/src/Generator/Passes/SymbolsCodeGenerator.cs">
<Link>Passes/SymbolsCodeGenerator.cs</Link>
</Compile>
<Compile Include="../../external/CppSharp/src/Generator/Passes/TrimSpecializationsPass.cs"> <Compile Include="../../external/CppSharp/src/Generator/Passes/TrimSpecializationsPass.cs">
<Link>Passes/TrimSpecializationsPass.cs</Link> <Link>Passes/TrimSpecializationsPass.cs</Link>
</Compile> </Compile>
@ -245,11 +242,14 @@
<Compile Include="../../external/CppSharp/src/Generator/Types/Std/Stdlib.cs"> <Compile Include="../../external/CppSharp/src/Generator/Types/Std/Stdlib.cs">
<Link>Types/Std/Stdlib.cs</Link> <Link>Types/Std/Stdlib.cs</Link>
</Compile> </Compile>
<Compile Include="../../external/CppSharp/src/Generator/Types/TypeIgnoreChecker.cs">
<Link>Types/TypeIgnoreChecker.cs</Link>
</Compile>
<Compile Include="../../external/CppSharp/src/Generator/Types/TypeMap.cs"> <Compile Include="../../external/CppSharp/src/Generator/Types/TypeMap.cs">
<Link>Types/TypeMap.cs</Link> <Link>Types/TypeMap.cs</Link>
</Compile> </Compile>
<Compile Include="../../external/CppSharp/src/Generator/Types/Types.cs"> <Compile Include="../../external/CppSharp/src/Generator/Types/TypeMapDatabase.cs">
<Link>Types/Types.cs</Link> <Link>Types/TypeMapDatabase.cs</Link>
</Compile> </Compile>
<Compile Include="../../external/CppSharp/src/Generator/Utils/BlockGenerator.cs"> <Compile Include="../../external/CppSharp/src/Generator/Utils/BlockGenerator.cs">
<Link>Utils/BlockGenerator.cs</Link> <Link>Utils/BlockGenerator.cs</Link>

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

@ -41,15 +41,15 @@
<ItemGroup> <ItemGroup>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="../../external/CppSharp/src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/CppSharp.CppParser.cs">
<Link>i686-apple-darwin12.4.0/CppSharp.CppParser.cs</Link>
</Compile>
<Compile Include="../../external/CppSharp/src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/Std.cs">
<Link>i686-apple-darwin12.4.0/Std.cs</Link>
</Compile>
<None Include="../../external/CppSharp/src/CppParser/Bindings/CSharp/premake5.lua"> <None Include="../../external/CppSharp/src/CppParser/Bindings/CSharp/premake5.lua">
<Link>premake5.lua</Link> <Link>premake5.lua</Link>
</None> </None>
<Compile Include="../../external/CppSharp/src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/CppSharp.CppParser.cs">
<Link>x86_64-apple-darwin12.4.0/CppSharp.CppParser.cs</Link>
</Compile>
<Compile Include="../../external/CppSharp/src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/Std.cs">
<Link>x86_64-apple-darwin12.4.0/Std.cs</Link>
</Compile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="CppSharp.Runtime.csproj"> <ProjectReference Include="CppSharp.Runtime.csproj">

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

@ -41,8 +41,14 @@
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="Microsoft.VisualStudio.Setup.Configuration.Interop">
<HintPath>../../external/CppSharp/deps/vs2017/Microsoft.VisualStudio.Setup.Configuration.Interop.dll</HintPath>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="../../external/CppSharp/src/Core/Compilation.cs">
<Link>Compilation.cs</Link>
</Compile>
<Compile Include="../../external/CppSharp/src/Core/Diagnostics.cs"> <Compile Include="../../external/CppSharp/src/Core/Diagnostics.cs">
<Link>Diagnostics.cs</Link> <Link>Diagnostics.cs</Link>
</Compile> </Compile>

2
external/CppSharp поставляемый

@ -1 +1 @@
Subproject commit df9666d6c46800496e79286c9adfa681ffc16ce9 Subproject commit 3ac96ac8f29bcbeec7126a5c8e98f9182a113935