[libzip] Add check for `cmake`. (#100)

If `cmake` isn't available in `$PATH`, the error is less than ideal:

	.../xamarin-android/build-tools/libzip/libzip.targets: error :
	Command 'cmake -DCMAKE_OSX_ARCHITECTURES="i386;x86_64" .../xamarin-android/external/libzip'
	exited with code: 127.

Whereby "less than ideal" I mean "wat?"

This is why we have the `<Which/>` task (commit 0c073f67), to provide
a better error messages.

Refactor out the `<Which/>` task execution into
`build-tools/scripts/RequiredPrograms.targets`, and change the
`@(_RequiredProgram)` item group to `@(RequiredProgram)` so that use
can be more consistent across projects, and add a check for `cmake` to
`build-tools/libzip` so that if `cmake` isn't installed we can get a
better error message:

	error : Could not find required program 'cmake'.
This commit is contained in:
Jonathan Pryor 2016-06-30 17:48:40 -04:00 коммит произвёл Dean Ellis
Родитель 16dbf3e9f8
Коммит 8aa18fc9e8
10 изменённых файлов: 128 добавлений и 117 удалений

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

@ -1,40 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ItemType>GenericProject</ItemType>
<ProjectGuid>{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}</ProjectGuid>
</PropertyGroup>
<Import Project="android-toolchain.targets" />
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>$(AndroidToolchainDirectory)</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>$(AndroidToolchainDirectory)</OutputPath>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<BuildDependsOn>
ResolveReferences;
_CopyBootstrapTasksAssembly;
_CheckForRequiredPrograms;
_DownloadItems;
_UnzipFiles;
_CreateNdkToolchains;
_CreateMxeToolchains;
</BuildDependsOn>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Xamarin.Android.Tools.BootstrapTasks\Xamarin.Android.Tools.BootstrapTasks.csproj">
<Project>{E8492EFB-D14A-4F32-AA28-88848322ECEA}</Project>
<Name>Xamarin.Android.Tools.BootstrapTasks</Name>
<ReferenceOutputAssembly>False</ReferenceOutputAssembly>
<OutputItemType>Content</OutputItemType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ItemType>GenericProject</ItemType>
<ProjectGuid>{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}</ProjectGuid>
</PropertyGroup>
<Import Project="android-toolchain.targets" />
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>$(AndroidToolchainDirectory)</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>$(AndroidToolchainDirectory)</OutputPath>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<BuildDependsOn>
ResolveReferences;
_CopyBootstrapTasksAssembly;
CheckForRequiredPrograms;
_DownloadItems;
_UnzipFiles;
_CreateNdkToolchains;
_CreateMxeToolchains;
</BuildDependsOn>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Xamarin.Android.Tools.BootstrapTasks\Xamarin.Android.Tools.BootstrapTasks.csproj">
<Project>{E8492EFB-D14A-4F32-AA28-88848322ECEA}</Project>
<Name>Xamarin.Android.Tools.BootstrapTasks</Name>
<ReferenceOutputAssembly>False</ReferenceOutputAssembly>
<OutputItemType>Content</OutputItemType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
</Project>

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

@ -62,41 +62,41 @@
</_NdkToolchain>
</ItemGroup>
<ItemGroup>
<_RequiredProgram Include="$(ManagedRuntime)" Condition=" '$(ManagedRuntime)' != '' " />
<_RequiredProgram Include="$(HostCc)" />
<_RequiredProgram Include="$(HostCxx)" />
<_RequiredProgram Include="7za" Condition="$(AndroidSupportedHostJitAbisForConditionalChecks.Contains (':mxe-Win64:'))">
<RequiredProgram Include="$(ManagedRuntime)" Condition=" '$(ManagedRuntime)' != '' " />
<RequiredProgram Include="$(HostCc)" />
<RequiredProgram Include="$(HostCxx)" />
<RequiredProgram Include="7za" Condition="$(AndroidSupportedHostJitAbisForConditionalChecks.Contains (':mxe-Win64:'))">
<Homebrew>p7zip</Homebrew>
</_RequiredProgram>
<_RequiredProgram Include="autoconf" />
<_RequiredProgram Include="automake" />
<_RequiredProgram Include="cmake" Condition="$(AndroidSupportedHostJitAbisForConditionalChecks.Contains (':mxe-Win64:'))" />
<_RequiredProgram Include="gdk-pixbuf-csource" Condition="$(AndroidSupportedHostJitAbisForConditionalChecks.Contains (':mxe-Win64:'))">
</RequiredProgram>
<RequiredProgram Include="autoconf" />
<RequiredProgram Include="automake" />
<RequiredProgram Include="cmake" Condition="$(AndroidSupportedHostJitAbisForConditionalChecks.Contains (':mxe-Win64:'))" />
<RequiredProgram Include="gdk-pixbuf-csource" Condition="$(AndroidSupportedHostJitAbisForConditionalChecks.Contains (':mxe-Win64:'))">
<Homebrew>gdk-pixbuf</Homebrew>
</_RequiredProgram>
<_RequiredProgram Include="gettext" Condition="$(AndroidSupportedHostJitAbisForConditionalChecks.Contains (':mxe-Win64:'))" />
<_RequiredProgram Include="glibtool" Condition="$(AndroidSupportedHostJitAbisForConditionalChecks.Contains (':mxe-Win64:'))">
</RequiredProgram>
<RequiredProgram Include="gettext" Condition="$(AndroidSupportedHostJitAbisForConditionalChecks.Contains (':mxe-Win64:'))" />
<RequiredProgram Include="glibtool" Condition="$(AndroidSupportedHostJitAbisForConditionalChecks.Contains (':mxe-Win64:'))">
<Homebrew>libtool</Homebrew>
</_RequiredProgram>
<_RequiredProgram Include="gsed" Condition="$(AndroidSupportedHostJitAbisForConditionalChecks.Contains (':mxe-Win64:'))">
</RequiredProgram>
<RequiredProgram Include="gsed" Condition="$(AndroidSupportedHostJitAbisForConditionalChecks.Contains (':mxe-Win64:'))">
<Homebrew>gnu-sed</Homebrew>
</_RequiredProgram>
<_RequiredProgram Include="intltoolize" Condition="$(AndroidSupportedHostJitAbisForConditionalChecks.Contains (':mxe-Win64:'))">
</RequiredProgram>
<RequiredProgram Include="intltoolize" Condition="$(AndroidSupportedHostJitAbisForConditionalChecks.Contains (':mxe-Win64:'))">
<Homebrew>intltool</Homebrew>
</_RequiredProgram>
<_RequiredProgram Include="make" />
<_RequiredProgram Include="pkg-config" Condition="$(AndroidSupportedHostJitAbisForConditionalChecks.Contains (':mxe-Win64:'))">
</RequiredProgram>
<RequiredProgram Include="make" />
<RequiredProgram Include="pkg-config" Condition="$(AndroidSupportedHostJitAbisForConditionalChecks.Contains (':mxe-Win64:'))">
<Homebrew>pkg-config</Homebrew>
</_RequiredProgram>
<_RequiredProgram Include="ruby" Condition="$(AndroidSupportedHostJitAbisForConditionalChecks.Contains (':mxe-Win64:'))" />
<_RequiredProgram Include="scons" Condition="$(AndroidSupportedHostJitAbisForConditionalChecks.Contains (':mxe-Win64:'))">
</RequiredProgram>
<RequiredProgram Include="ruby" Condition="$(AndroidSupportedHostJitAbisForConditionalChecks.Contains (':mxe-Win64:'))" />
<RequiredProgram Include="scons" Condition="$(AndroidSupportedHostJitAbisForConditionalChecks.Contains (':mxe-Win64:'))">
<Homebrew>scons</Homebrew>
</_RequiredProgram>
<_RequiredProgram Include="wget" Condition="$(AndroidSupportedHostJitAbisForConditionalChecks.Contains (':mxe-Win64:'))">
</RequiredProgram>
<RequiredProgram Include="wget" Condition="$(AndroidSupportedHostJitAbisForConditionalChecks.Contains (':mxe-Win64:'))">
<Homebrew>wget</Homebrew>
</_RequiredProgram>
<_RequiredProgram Include="xz" Condition="$(AndroidSupportedHostJitAbisForConditionalChecks.Contains (':mxe-Win64:'))">
</RequiredProgram>
<RequiredProgram Include="xz" Condition="$(AndroidSupportedHostJitAbisForConditionalChecks.Contains (':mxe-Win64:'))">
<Homebrew>xz</Homebrew>
</_RequiredProgram>
</RequiredProgram>
</ItemGroup>
</Project>

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

@ -2,6 +2,7 @@
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\Configuration.props" />
<Import Project="android-toolchain.projitems" />
<Import Project="..\scripts\RequiredPrograms.targets" />
<Target Name="_CopyBootstrapTasksAssembly"
Outputs="$(OutputPath)\Xamarin.Android.Tools.BootstrapTasks.dll">
<MSBuild
@ -13,21 +14,6 @@
<UsingTask AssemblyFile="$(OutputPath)\Xamarin.Android.Tools.BootstrapTasks.dll" TaskName="Xamarin.Android.Tools.BootstrapTasks.DownloadUri" />
<UsingTask AssemblyFile="$(OutputPath)\Xamarin.Android.Tools.BootstrapTasks.dll" TaskName="Xamarin.Android.Tools.BootstrapTasks.UnzipDirectoryChildren" />
<UsingTask AssemblyFile="$(OutputPath)\Xamarin.Android.Tools.BootstrapTasks.dll" TaskName="Xamarin.Android.Tools.BootstrapTasks.Which" />
<Target Name="_CheckForRequiredPrograms">
<Which Program="%(_RequiredProgram.Identity)" Required="True" />
<OnError ExecuteTargets="_PrintRequiredPrograms" />
</Target>
<Target Name="_PrintRequiredPrograms">
<Error
ContinueOnError="True"
Text="The following programs are required: @(_RequiredProgram->'%(Identity)', ' ')"
/>
<Error
Condition=" '$(HostOS)' == 'Darwin' "
ContinueOnError="True"
Text="Please try running: brew install @(_RequiredProgram->'%(Homebrew)', ' ')`"
/>
</Target>
<Target Name="_DetermineItems">
<CreateItem
Include="@(AndroidSdkItem)"

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

@ -1,34 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ItemType>GenericProject</ItemType>
<ProjectGuid>{900A0F71-BAAD-417A-8D1A-8D330297CDD0}</ProjectGuid>
</PropertyGroup>
<Import Project="..\..\Configuration.props" />
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>..\..\bin\$(Configuration)</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>..\..\bin\$(Configuration)</OutputPath>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.Common.targets" />
<PropertyGroup>
<BuildDependsOnLocal Condition="'$(HostOS)' == 'Windows' OR '$(HostOS)' == 'Darwin'">
ResolveReferences;
_Configure;
_Make
</BuildDependsOnLocal>
</PropertyGroup>
<Import Project="libzip.targets" />
<ItemGroup>
<ProjectReference Include="..\android-toolchain\android-toolchain.mdproj">
<Project>{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}</Project>
<Name>android-toolchain</Name>
<ReferenceOutputAssembly>False</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
<Target Name="Build" DependsOnTargets="$(BuildDependsOnLocal)" />
<Target Name="Clean" />
</Project>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ItemType>GenericProject</ItemType>
<ProjectGuid>{900A0F71-BAAD-417A-8D1A-8D330297CDD0}</ProjectGuid>
</PropertyGroup>
<Import Project="..\..\Configuration.props" />
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>..\..\bin\$(Configuration)</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>..\..\bin\$(Configuration)</OutputPath>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.Common.targets" />
<PropertyGroup>
<BuildDependsOnLocal Condition="'$(HostOS)' == 'Windows' OR '$(HostOS)' == 'Darwin'">
ResolveReferences;
CheckForRequiredPrograms;
_Configure;
_Make
</BuildDependsOnLocal>
</PropertyGroup>
<Import Project="libzip.targets" />
<ItemGroup>
<ProjectReference Include="..\android-toolchain\android-toolchain.mdproj">
<Project>{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}</Project>
<Name>android-toolchain</Name>
<ReferenceOutputAssembly>False</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
<Target Name="Build" DependsOnTargets="$(BuildDependsOnLocal)" />
<Target Name="Clean" />
</Project>

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

@ -20,4 +20,7 @@
<OutputLibraryPath>libzip.so</OutputLibraryPath>
</_LibZipTarget>
</ItemGroup>
<ItemGroup>
<RequiredProgram Include="cmake" />
</ItemGroup>
</Project>

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

@ -6,6 +6,7 @@
<UsingTask AssemblyFile="$(_SourceTopDir)\bin\Build$(Configuration)\Xamarin.Android.Tools.BootstrapTasks.dll" TaskName="Xamarin.Android.Tools.BootstrapTasks.GetNugetPackageBasePath" />
<Import Project="libzip.props" />
<Import Project="libzip.projitems" />
<Import Project="..\scripts\RequiredPrograms.targets" />
<Target Name="_SetCMakeListsTxtTimeToLastCommitTimestamp">
<Exec
Command="touch -m -t `git log -1 --format=%25cd --date=format-local:%25Y%25m%25d%25H%25M.%25S` CMakeLists.txt"

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

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask AssemblyFile="$(MSBuildThisFileDirectory)..\..\bin\Build$(Configuration)\Xamarin.Android.Tools.BootstrapTasks.dll" TaskName="Xamarin.Android.Tools.BootstrapTasks.Which" />
<Target Name="CheckForRequiredPrograms">
<Which Program="%(RequiredProgram.Identity)" Required="True" />
<OnError ExecuteTargets="_PrintRequiredPrograms" />
</Target>
<Target Name="_PrintRequiredPrograms">
<Error
ContinueOnError="True"
Text="The following programs are required: @(RequiredProgram->'%(Identity)', ' ')"
/>
<Error
Condition=" '$(HostOS)' == 'Darwin' "
ContinueOnError="True"
Text="Please try running: brew install @(RequiredProgram->'%(Homebrew)', ' ')`"
/>
</Target>
</Project>

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

@ -17,6 +17,7 @@
<PropertyGroup>
<BuildDependsOn>
ResolveReferences;
CheckForRequiredPrograms;
_BuildRuntimes;
</BuildDependsOn>
</PropertyGroup>

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

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<_RequiredProgram Include="xxd" />
<RequiredProgram Include="xxd" />
</ItemGroup>
</Project>

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

@ -3,6 +3,7 @@
<UsingTask AssemblyFile="..\..\bin\Build$(Configuration)\Xamarin.Android.Tools.BootstrapTasks.dll" TaskName="Xamarin.Android.Tools.BootstrapTasks.ValueToItems" />
<UsingTask AssemblyFile="..\..\bin\Build$(Configuration)\Xamarin.Android.Tools.BootstrapTasks.dll" TaskName="Xamarin.Android.Tools.BootstrapTasks.Which" />
<Import Project="monodroid.projitems" />
<Import Project="..\..\build-tools\scripts\RequiredPrograms.targets" />
<PropertyGroup>
<_Conf>$(Configuration.ToLowerInvariant())</_Conf>
</PropertyGroup>
@ -12,7 +13,6 @@
<Target Name="_BuildRuntimes"
Inputs="@(CFiles);jni\Android.mk"
Outputs="@(AndroidSupportedTargetJitAbi->'$(OutputPath)\%(Identity)\libmono-android.$(_Conf).so')">
<Which Program="%(_RequiredProgram.Identity)" Required="True" />
<PropertyGroup>
<_AppAbi>@(AndroidSupportedTargetJitAbi->'%(Identity)', ' ')</_AppAbi>
</PropertyGroup>