Merge pull request #500 from atsushieno/fix-linux-execpath-more
Fix more Linux toolchain paths and compilation support.
This commit is contained in:
Коммит
60be6829ee
|
@ -124,6 +124,8 @@ namespace Embeddinator
|
|||
{
|
||||
switch (platform.ToLowerInvariant())
|
||||
{
|
||||
case "linux":
|
||||
return TargetPlatform.Linux;
|
||||
case "windows":
|
||||
return TargetPlatform.Windows;
|
||||
case "android":
|
||||
|
@ -217,4 +219,4 @@ namespace Embeddinator
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -518,7 +518,7 @@ namespace Embeddinator
|
|||
return File.Exists(sgenPath) ? sgenPath : Path.Combine(libPath, "monosgen-2.0.lib");
|
||||
}
|
||||
|
||||
bool CompileClang(IEnumerable<string> files)
|
||||
bool CompileClangMac(IEnumerable<string> files)
|
||||
{
|
||||
var xcodePath = XcodeToolchain.GetXcodeToolchainPath();
|
||||
var clangBin = Path.Combine(xcodePath, "usr/bin/clang");
|
||||
|
@ -559,6 +559,42 @@ namespace Embeddinator
|
|||
return output.ExitCode == 0;
|
||||
}
|
||||
|
||||
bool CompileClangLinux(IEnumerable<string> files)
|
||||
{
|
||||
var clangBin = Path.Combine("/usr/bin/clang");
|
||||
var monoPath = ManagedToolchain.FindMonoPath();
|
||||
|
||||
var args = new List<string> {
|
||||
$"-D{DLLExportDefine}",
|
||||
$"-D_REENTRANT -I/usr/lib/pkgconfig/../../include/mono-2.0",
|
||||
$"-L/usr/lib/pkgconfig/../../lib -lmono-2.0 -lm -lrt -ldl -lpthread",
|
||||
string.Join(" ", files.ToList())
|
||||
};
|
||||
|
||||
if (Options.Compilation.Target == CompilationTarget.SharedLibrary)
|
||||
{
|
||||
var name = Path.GetFileNameWithoutExtension(Project.Assemblies[0]);
|
||||
var libName = $"lib{name}.so";
|
||||
var outputPath = Path.Combine(Options.OutputDir, libName);
|
||||
args.Add($"-shared -fPIC -install_name {libName} -o {outputPath}");
|
||||
}
|
||||
|
||||
switch (Options.GeneratorKind)
|
||||
{
|
||||
case GeneratorKind.ObjectiveC:
|
||||
args.Add("-ObjC");
|
||||
args.Add("-lobjc");
|
||||
break;
|
||||
case GeneratorKind.CPlusPlus:
|
||||
args.Add("-x c++");
|
||||
break;
|
||||
}
|
||||
|
||||
var invocation = string.Join(" ", args);
|
||||
var output = Invoke(clangBin, invocation);
|
||||
return output.ExitCode == 0;
|
||||
}
|
||||
|
||||
bool CompileNDK(IEnumerable<string> files)
|
||||
{
|
||||
var monoPath = Path.Combine(ManagedToolchain.FindMonoPath(), "include", "mono-2.0");
|
||||
|
@ -646,7 +682,7 @@ namespace Embeddinator
|
|||
throw new NotSupportedException(
|
||||
$"Cross compilation to target platform '{Options.Compilation.Platform}' is not supported.");
|
||||
case TargetPlatform.MacOS:
|
||||
return CompileClang(files);
|
||||
return CompileClangMac(files);
|
||||
case TargetPlatform.Android:
|
||||
return CompileNDK(files);
|
||||
}
|
||||
|
@ -656,6 +692,8 @@ namespace Embeddinator
|
|||
{
|
||||
switch (Options.Compilation.Platform)
|
||||
{
|
||||
case TargetPlatform.Linux:
|
||||
return CompileClangLinux(files);
|
||||
case TargetPlatform.Android:
|
||||
return CompileNDK(files);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<UnixMonoRuntime>/usr/bin/mono --debug</UnixMonoRuntime>
|
||||
<UnixMonoRuntime Condition="Exists('/Library/Frameworks/Mono.framework/Commands/')">/Library/Frameworks/Mono.framework/Commands/mono</UnixMonoRuntime>
|
||||
</PropertyGroup>
|
||||
<Target Name="BeforeBuild" Inputs="$(MSBuildThisFileDirectory)subscripts.tt" Outputs="$(MSBuildThisFileDirectory)subscripts.cs">
|
||||
<Exec Condition=" '$(OS)' == 'Unix' " WorkingDirectory="$(MSBuildThisFileDirectory)" Command="nuget install Mono.TextTransform -OutputDirectory ../../packages/" />
|
||||
<Exec Condition=" '$(OS)' == 'Unix' " WorkingDirectory="$(MSBuildThisFileDirectory)" Command=" /Library/Frameworks/Mono.framework/Commands/mono ../../packages/Mono.TextTransform.1.0.0/tools/TextTransform.exe subscripts.tt -o subscripts.cs" />
|
||||
<Exec Condition=" '$(OS)' == 'Unix' " WorkingDirectory="$(MSBuildThisFileDirectory)" Command=" $(UnixMonoRuntime) ../../packages/Mono.TextTransform.1.0.0/tools/TextTransform.exe subscripts.tt -o subscripts.cs" />
|
||||
<Exec Condition=" '$(OS)' != 'Unix' " WorkingDirectory="$(MSBuildThisFileDirectory)" Command="..\..\.nuget\nuget.exe install Mono.TextTransform -OutputDirectory ..\..\packages\" />
|
||||
<Exec Condition=" '$(OS)' != 'Unix' " WorkingDirectory="$(MSBuildThisFileDirectory)" Command="..\..\packages\Mono.TextTransform.1.0.0\tools\TextTransform.exe subscripts.tt -o subscripts.cs" />
|
||||
</Target>
|
||||
|
|
Загрузка…
Ссылка в новой задаче