Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[windows] now can build android-toolchain.mdproj #743

Merged
merged 2 commits into from
Aug 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ packages
.nuget
TestResult.xml
TestResult-*.xml
.vs/
19 changes: 19 additions & 0 deletions build-tools/android-toolchain/android-toolchain.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,25 @@
<HostOS>Darwin</HostOS>
<DestDir>emulator</DestDir>
</AndroidSdkItem>
<AndroidNdkItem Include="android-ndk-r14b-windows-x86_64.zip">
<HostOS>Windows</HostOS>
</AndroidNdkItem>
<AndroidSdkItem Include="build-tools_r$(XABuildToolsVersion)-windows.zip">
<HostOS>Windows</HostOS>
<DestDir>build-tools\$(XABuildToolsFolder)</DestDir>
</AndroidSdkItem>
<AndroidSdkItem Include="platform-tools_r26.0.0-windows.zip">
<HostOS>Windows</HostOS>
<DestDir>platform-tools</DestDir>
</AndroidSdkItem>
<AndroidSdkItem Include="sdk-tools-windows-3952940.zip">
<HostOS>Windows</HostOS>
<DestDir>tools</DestDir>
</AndroidSdkItem>
<AndroidSdkItem Include="emulator-windows-3965150.zip">
<HostOS>Windows</HostOS>
<DestDir>emulator</DestDir>
</AndroidSdkItem>
<AndroidSdkItem Include="android-2.3.3_r02-linux.zip">
<HostOS></HostOS>
<DestDir>platforms\android-10</DestDir>
Expand Down
2 changes: 1 addition & 1 deletion build-tools/bundle/bundle.mdproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<Name>mono-runtimes</Name>
<ReferenceOutputAssembly>False</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\libzip\libzip.mdproj">
<ProjectReference Include="..\libzip\libzip.mdproj" Condition=" '$(HostOS)' != 'Windows' ">
<Project>{900A0F71-BAAD-417A-8D1A-8D330297CDD0}</Project>
<Name>libzip</Name>
<ReferenceOutputAssembly>False</ReferenceOutputAssembly>
Expand Down
13 changes: 7 additions & 6 deletions build-tools/dependencies/dependencies.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
<_AptGetInstall>apt-get -f -u install</_AptGetInstall>
</PropertyGroup>
<ItemGroup>
<RequiredProgram Include="$(HostCcName)" />
<RequiredProgram Include="$(HostCxxName)" />
<RequiredProgram Include="$(HostCcName)" Condition=" '$(HostOS)' != 'Windows' " />
<RequiredProgram Include="$(HostCxxName)" Condition=" '$(HostOS)' != 'Windows' " />
<RequiredProgram Include="7za" Condition=" '$(NeedMxe)' == 'true' And $(AndroidSupportedHostJitAbisForConditionalChecks.Contains (':mxe-Win64:'))">
<Homebrew>p7zip</Homebrew>
</RequiredProgram>
<RequiredProgram Include="autoconf">
<RequiredProgram Include="autoconf" Condition=" '$(HostOS)' != 'Windows' ">
<Homebrew>autoconf</Homebrew>
</RequiredProgram>
<RequiredProgram Include="automake">
<RequiredProgram Include="automake" Condition=" '$(HostOS)' != 'Windows' ">
<Homebrew>automake</Homebrew>
</RequiredProgram>
<RequiredProgram Include="cmake" Condition=" '$(NeedMxe)' == 'true' And $(AndroidSupportedHostJitAbisForConditionalChecks.Contains (':mxe-Win64:'))">
Expand All @@ -36,10 +36,11 @@
</RequiredProgram>
<RequiredProgram Include="javac">
<MinimumVersion>1.8</MinimumVersion>
<CurrentVersionCommand>$(MSBuildThisFileDirectory)..\scripts\javac-version</CurrentVersionCommand>
<CurrentVersionCommand Condition=" '$(HostOS)' != 'Windows' ">$(MSBuildThisFileDirectory)..\scripts\javac-version</CurrentVersionCommand>
<CurrentVersionCommand Condition=" '$(HostOS)' == 'Windows' ">javac -version 2&gt;&amp;1</CurrentVersionCommand>
<UbuntuInstall>$(_AptGetInstall) openjdk-8-jdk</UbuntuInstall>
</RequiredProgram>
<RequiredProgram Include="make" />
<RequiredProgram Include="make" Condition=" '$(HostOS)' != 'Windows' " />
<RequiredProgram Include="pkg-config" Condition=" '$(NeedMxe)' == 'true' And $(AndroidSupportedHostJitAbisForConditionalChecks.Contains (':mxe-Win64:'))">
<Homebrew>pkg-config</Homebrew>
</RequiredProgram>
Expand Down
2 changes: 1 addition & 1 deletion build-tools/libzip/libzip.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
</ItemGroup>
<ItemGroup>
<RequiredProgram Include="cmake" />
<RequiredProgram Include="make" />
<RequiredProgram Include="make" Condition=" '$(HostOS)' != 'Windows' " />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ public override bool Execute ()
var licdir = Path.Combine (Path.Combine (AndroidSdkDirectory, "licenses"));
Directory.CreateDirectory (licdir);

var psi = new ProcessStartInfo (Path.Combine (AndroidSdkDirectory, "tools", "bin", "sdkmanager"), "--licenses") { UseShellExecute = false, RedirectStandardInput = true };
string _;
var path = Which.GetProgramLocation ("sdkmanager", out _, new [] { Path.Combine (AndroidSdkDirectory, "tools", "bin") });
var psi = new ProcessStartInfo (path, "--licenses") { UseShellExecute = false, RedirectStandardInput = true };
var proc = Process.Start (psi);
for (int i = 0; i < 10; i++)
proc.StandardInput.WriteLine ('y');
Expand Down
2 changes: 1 addition & 1 deletion external/LibZipSharp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<Project>{E248B2CA-303B-4645-ADDC-9D4459D550FD}</Project>
<Name>libZipSharp</Name>
</ProjectReference>
<ProjectReference Include="..\..\build-tools\libzip\libzip.mdproj">
<ProjectReference Include="..\..\build-tools\libzip\libzip.mdproj" Condition=" '$(HostOS)' != 'Windows' ">
<Project>{900A0F71-BAAD-417A-8D1A-8D330297CDD0}</Project>
<Name>libzip</Name>
<ReferenceOutputAssembly>False</ReferenceOutputAssembly>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,42 +84,62 @@ public override bool Execute ()
#pragma warning disable 1998
async TTask ExtractFile (string tempDir, string sourceFile, string relativeDestDir, string destinationFolder, Encoding encoding)
{
var tempName = Path.GetRandomFileName ();
var nestedTemp = Path.Combine (tempDir, tempName);
Directory.CreateDirectory (nestedTemp);

relativeDestDir = relativeDestDir?.Replace ('\\', Path.DirectorySeparatorChar);

if (string.Equals (HostOS, "Windows", StringComparison.OrdinalIgnoreCase)) {
ZipFile.ExtractToDirectory (sourceFile, nestedTemp, encoding);
}
else {
//NOTE: to avoid MAX_PATH, we are not using %TEMP% on Windows
using (var source = File.OpenRead (sourceFile))
using (var zip = new ZipArchive (source)) {
foreach (var entry in zip.Entries) {
//Directory entries have empty names
if (!string.IsNullOrEmpty (entry.Name)) {
//entry.FullName can have / or \ depending on your .NET version
var entryPath = entry.FullName.Replace ('/', Path.DirectorySeparatorChar);
if (!NoSubdirectory) {
entryPath = entryPath.Substring (entryPath.IndexOf (Path.DirectorySeparatorChar) + 1);
}
var destinationPath = Path.Combine (destinationFolder, relativeDestDir, entryPath);
var destinationDir = Path.GetDirectoryName (destinationPath);
if (!Directory.Exists (destinationDir))
Directory.CreateDirectory (destinationDir);

entry.ExtractToFile (destinationPath, overwrite: true);
}
}
}
} else {
var tempName = Path.GetRandomFileName ();
var nestedTemp = Path.Combine (tempDir, tempName);
Directory.CreateDirectory (nestedTemp);

//NOTE: using unzip to preserve file attributes
var start = new ProcessStartInfo ("unzip", $"\"{sourceFile}\" -d \"{nestedTemp}\"") {
CreateNoWindow = true,
UseShellExecute = false,
};
Log.LogMessage (MessageImportance.Low, $"unzip \"{sourceFile}\" -d \"{nestedTemp}\"");
var p = Process.Start (start);
p.WaitForExit ();
}

var dirs = NoSubdirectory ? new string [] { nestedTemp } : Directory.EnumerateDirectories (nestedTemp, "*");

foreach (var dir in dirs) {
foreach (var fse in Directory.EnumerateFileSystemEntries (dir)) {
var name = Path.GetFileName (fse);
var destDir = string.IsNullOrEmpty (relativeDestDir)
? destinationFolder
: Path.Combine (destinationFolder, relativeDestDir);
Directory.CreateDirectory (destDir);
var dest = Path.Combine (destDir, name);
Log.LogMessage (MessageImportance.Low, $"mv '{fse}' '{dest}'");
if (Directory.Exists (fse))
Process.Start ("/bin/mv", $@"""{fse}"" ""{dest}""").WaitForExit ();
else {
if (File.Exists (dest))
File.Delete (dest);
File.Move (fse, dest);

var dirs = NoSubdirectory ? new string [] { nestedTemp } : Directory.EnumerateDirectories (nestedTemp, "*");

foreach (var dir in dirs) {
foreach (var fse in Directory.EnumerateFileSystemEntries (dir)) {
var name = Path.GetFileName (fse);
var destDir = string.IsNullOrEmpty (relativeDestDir)
? destinationFolder
: Path.Combine (destinationFolder, relativeDestDir);
Directory.CreateDirectory (destDir);
var dest = Path.Combine (destDir, name);
Log.LogMessage (MessageImportance.Low, $"mv '{fse}' '{dest}'");
if (Directory.Exists (fse))
Process.Start ("/bin/mv", $@"""{fse}"" ""{dest}""").WaitForExit ();
else {
if (File.Exists (dest))
File.Delete (dest);
File.Move (fse, dest);
}
}
}
}
Expand Down