[msbuild] Added EnableOnDemandResources option (#2133)

* [msbuild] Added EnableOnDemandResources option

Disabling this option causes the ACTool task to pass
--enable-on-demand-resources NO (instead of YES) to actool.

It will also cause the ResourceTags property on BundleResource
and InterfaceBuilder items to be ignored.

* Fixed unit tests
This commit is contained in:
Jeffrey Stedfast 2017-05-26 14:52:07 -04:00 коммит произвёл GitHub
Родитель a69c85bae7
Коммит 7facec2a70
7 изменённых файлов: 33 добавлений и 12 удалений

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

@ -563,6 +563,7 @@ Copyright (C) 2014 Xamarin. All rights reserved.
ToolExe="$(ACToolExe)"
ToolPath="$(ACToolPath)"
AppManifest="$(_AppManifest)"
EnableOnDemandResources="false"
ImageAssets="@(ImageAsset)"
OptimizePngs="false"
OutputPath="$(OutputPath)"
@ -611,6 +612,7 @@ Copyright (C) 2014 Xamarin. All rights reserved.
ToolExe="$(IBToolExe)"
ToolPath="$(IBToolPath)"
AppManifest="$(_AppManifest)"
EnableOnDemandResources="false"
InterfaceDefinitions="@(InterfaceDefinition)"
IntermediateOutputPath="$(IntermediateOutputPath)"
SdkPlatform="MacOSX"

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

@ -26,6 +26,8 @@ namespace Xamarin.MacDev.Tasks
public string DeviceOSVersion { get; set; }
public bool EnableOnDemandResources { get; set; }
[Required]
public ITaskItem[] ImageAssets { get; set; }
@ -156,7 +158,7 @@ namespace Xamarin.MacDev.Tasks
if (AppleSdkSettings.XcodeVersion.Major >= 7) {
if (!string.IsNullOrEmpty (outputSpecs))
args.Add ("--enable-on-demand-resources", "YES");
args.Add ("--enable-on-demand-resources", EnableOnDemandResources ? "YES" : "NO");
if (!string.IsNullOrEmpty (DeviceModel))
args.Add ("--filter-for-device-model", DeviceModel);
@ -258,6 +260,7 @@ namespace Xamarin.MacDev.Tasks
Log.LogTaskProperty ("AppManifest", AppManifest);
Log.LogTaskProperty ("DeviceModel", DeviceModel);
Log.LogTaskProperty ("DeviceOSVersion", DeviceOSVersion);
Log.LogTaskProperty ("EnableOnDemandResources", EnableOnDemandResources);
Log.LogTaskProperty ("ImageAssets", ImageAssets);
Log.LogTaskProperty ("IntermediateOutputPath", IntermediateOutputPath);
Log.LogTaskProperty ("IsWatchApp", IsWatchApp);

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

@ -21,6 +21,8 @@ namespace Xamarin.MacDev.Tasks
public ITaskItem[] BundleResources { get; set; }
public bool EnableOnDemandResources { get; set; }
[Required]
public string IntermediateOutputPath { get; set; }
@ -36,6 +38,7 @@ namespace Xamarin.MacDev.Tasks
Log.LogTaskProperty ("AppBundleDir", AppBundleDir);
Log.LogTaskProperty ("BundleIdentifier", BundleIdentifier);
Log.LogTaskProperty ("BundleResources", BundleResources);
Log.LogTaskProperty ("EnableOnDemandResources", EnableOnDemandResources);
Log.LogTaskProperty ("IntermediateOutputPath", IntermediateOutputPath);
Log.LogTaskProperty ("OutputPath", OutputPath);
@ -47,10 +50,10 @@ namespace Xamarin.MacDev.Tasks
foreach (var item in BundleResources) {
var logicalName = item.GetMetadata ("LogicalName");
var outputPath = item.GetMetadata ("OutputPath");
var tags = AssetPackUtils.GetResourceTags (item);
IList<string> tags;
string hash;
if (tags != null) {
if (EnableOnDemandResources && (tags = AssetPackUtils.GetResourceTags (item)) != null) {
var assetpack = AssetPackUtils.GetAssetPackDirectory (OutputPath, BundleIdentifier, tags, out hash);
if (packs.Add (hash)) {

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

@ -16,7 +16,9 @@ namespace Xamarin.MacDev.Tasks
PDictionary plist;
#region Inputs
public bool EnableOnDemandResources { get; set; }
[Required]
public ITaskItem[] InterfaceDefinitions { get; set; }
@ -208,7 +210,7 @@ namespace Xamarin.MacDev.Tasks
expected.SetMetadata ("LogicalName", bundleName);
expected.SetMetadata ("Optimize", "false");
if (!string.IsNullOrEmpty (resourceTags))
if (EnableOnDemandResources && !string.IsNullOrEmpty (resourceTags))
expected.SetMetadata ("ResourceTags", resourceTags);
if (UseCompilationDirectory) {
@ -398,6 +400,7 @@ namespace Xamarin.MacDev.Tasks
{
Log.LogTaskName ("IBTool");
Log.LogTaskProperty ("AppManifest", AppManifest);
Log.LogTaskProperty ("EnableOnDemandResources", EnableOnDemandResources);
Log.LogTaskProperty ("InterfaceDefinitions", InterfaceDefinitions);
Log.LogTaskProperty ("IntermediateOutputPath", IntermediateOutputPath);
Log.LogTaskProperty ("IsWatchApp", IsWatchApp);

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

@ -85,8 +85,9 @@ Copyright (C) 2013-2016 Xamarin. All rights reserved.
<MtouchArch Condition="'$(MtouchArch)' == '' And '$(_Platform)' == 'iPhone'">ARMv7</MtouchArch>
<!-- On-Demand Resources -->
<OnDemandResourcesInitialInstallTags Condition="'$(OnDemandResourcesInitialInstallTags)' == ''"></OnDemandResourcesInitialInstallTags>
<OnDemandResourcesPrefetchOrder Condition="'$(OnDemandResourcesPrefetchOrder)' == ''"></OnDemandResourcesPrefetchOrder>
<EnableOnDemandResources Condition="'$(EnableOnDemandResources)' == ''">true</EnableOnDemandResources>
<OnDemandResourcesInitialInstallTags Condition="'$(OnDemandResourcesInitialInstallTags)' == '' Or '$(EnableOnDemandResources)' != 'true'"></OnDemandResourcesInitialInstallTags>
<OnDemandResourcesPrefetchOrder Condition="'$(OnDemandResourcesPrefetchOrder)' == '' Or '$(EnableOnDemandResources)' != 'true'"></OnDemandResourcesPrefetchOrder>
<EmbedOnDemandResources Condition="'$(EmbedOnDemandResources)' == ''">true</EmbedOnDemandResources>
<!-- Device-Specific Builds -->
@ -98,7 +99,7 @@ Copyright (C) 2013-2016 Xamarin. All rights reserved.
<ItemGroup>
<AvailableItemName Include="BundleResource" />
</ItemGroup>
<Import Project="$(MSBuildThisFileDirectory)$(MSBuildThisFileName).After.props"
Condition="Exists('$(MSBuildThisFileDirectory)$(MSBuildThisFileName).After.props')"/>

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

@ -438,6 +438,7 @@ Copyright (C) 2013-2016 Xamarin. All rights reserved.
AppBundleDir="$(AppBundleDir)"
BundleIdentifier="$(_BundleIdentifier)"
BundleResources="@(_BundleResourceWithLogicalName)"
EnableOnDemandResources="$(EnableOnDemandResources)"
IntermediateOutputPath="$(DeviceSpecificIntermediateOutputPath)"
OutputPath="$(DeviceSpecificOutputPath)"
>
@ -1163,7 +1164,7 @@ Copyright (C) 2013-2016 Xamarin. All rights reserved.
Inputs="@(ImageAsset);$(_AppManifest)"
Outputs="$(_ACTool_PartialAppManifestCache);$(_ACTool_BundleResourceCache)"
DependsOnTargets="_DetectAppManifest;_DetectSdkLocations;_BeforeCoreCompileImageAssets">
<ACTool
SessionId="$(BuildSessionId)"
Condition="'$(IsMacEnabled)' == 'true' And '@(ImageAsset)' != ''"
@ -1172,6 +1173,7 @@ Copyright (C) 2013-2016 Xamarin. All rights reserved.
AppManifest="$(_AppManifest)"
DeviceModel="$(TargetDeviceModel)"
DeviceOSVersion="$(TargetDeviceOSVersion)"
EnableOnDemandResources="$(EnableOnDemandResources)"
ImageAssets="@(ImageAsset)"
OptimizePNGs="$(OptimizePNGs)"
OutputPath="$(DeviceSpecificOutputPath)"
@ -1275,13 +1277,14 @@ Copyright (C) 2013-2016 Xamarin. All rights reserved.
Inputs="@(InterfaceDefinition)"
Outputs="$(_IBToolCache)"
DependsOnTargets="_BeforeCoreCompileInterfaceDefinitions">
<IBTool
SessionId="$(BuildSessionId)"
Condition="'$(IsMacEnabled)' == 'true'"
ToolExe="$(IBToolExe)"
ToolPath="$(IBToolPath)"
AppManifest="$(_AppManifest)"
EnableOnDemandResources="$(EnableOnDemandResources)"
InterfaceDefinitions="@(InterfaceDefinition)"
IntermediateOutputPath="$(DeviceSpecificIntermediateOutputPath)"
IsWatchApp="$(IsWatchApp)"
@ -1299,7 +1302,7 @@ Copyright (C) 2013-2016 Xamarin. All rights reserved.
<!-- Local items to be persisted to items files -->
<Output TaskParameter="BundleResources" ItemName="_IBTool_BundleResources" />
</IBTool>
<!-- Cached the generated outputs items for incremental build support -->
<WriteItemsToFile Items="@(_IBTool_BundleResources)" ItemName="_BundleResourceWithLogicalName" File="$(_IBToolCache)" Overwrite="true" IncludeMetadata="true" />
<ItemGroup>
@ -1969,7 +1972,7 @@ Copyright (C) 2013-2016 Xamarin. All rights reserved.
</PropertyGroup>
</Target>
<Target Name="_PackageOnDemandResources" Condition="'$(BuildIpa)' == 'true' And ('$(_DistributionType)' == 'AppStore' Or '$(_DistributionType)' == 'AdHoc')" >
<Target Name="_PackageOnDemandResources" Condition="'$(BuildIpa)' == 'true' And '$(EnableOnDemandResources)' == 'true' And ('$(_DistributionType)' == 'AppStore' Or '$(_DistributionType)' == 'AdHoc')" >
<PropertyGroup>
<_PayloadDir>$(DeviceSpecificIntermediateOutputPath)ipa\Payload\</_PayloadDir>
<_IpaAppBundleDir>$(_PayloadDir)$(_AppBundleName).app\</_IpaAppBundleDir>

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

@ -125,6 +125,8 @@ namespace Xamarin.iOS.Tasks
storyboard.SetMetadata ("ResourceTags", tag);
}
ibtool.EnableOnDemandResources = true;
Assert.IsTrue (ibtool.Execute (), "Execution of IBTool task failed.");
foreach (var bundleResource in ibtool.BundleResources) {
@ -141,6 +143,8 @@ namespace Xamarin.iOS.Tasks
bundleResources.Add (bundleName);
}
ibtool.EnableOnDemandResources = true;
string[] expected = {
"Base.lproj/LaunchScreen.storyboardc/01J-lp-oVM-view-Ze5-6b-2t3.nib",
"Base.lproj/LaunchScreen.storyboardc/Info.plist",
@ -200,6 +204,8 @@ namespace Xamarin.iOS.Tasks
storyboard.SetMetadata ("ResourceTags", tag);
}
ibtool.EnableOnDemandResources = true;
Assert.IsTrue (ibtool.Execute (), "Execution of IBTool task failed.");
foreach (var bundleResource in ibtool.BundleResources) {