Skip to content
Closed
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Copyright (C) 2011 Xamarin, Inc. All rights reserved.

using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
Expand All @@ -16,21 +18,22 @@ public class GetAndroidDefineConstants : Task
public string ProductVersion { get; set; }

[Output]
public string AndroidDefineConstants { get; set; }
public ITaskItem[] AndroidDefineConstants { get; set; }

public override bool Execute ()
{
var sb = new StringBuilder ();
var items = new List<ITaskItem> ();

if (!string.IsNullOrEmpty (ProductVersion)) {
sb.AppendFormat ("__XAMARIN_ANDROID_{0}__;", Regex.Replace (ProductVersion, "[^A-Za-z0-9]", "_"));
items.Add(new TaskItem ($"__XAMARIN_ANDROID_{Regex.Replace (ProductVersion, "[^A-Za-z0-9]", "_")}__"));
}
sb.Append ("__MOBILE__;__ANDROID__");
items.Add(new TaskItem ("__MOBILE__"));
items.Add(new TaskItem("__ANDROID__"));

for (int i = 1; i <= AndroidApiLevel; ++i)
sb.Append (";__ANDROID_").Append (i).Append ("__");
items.Add(new TaskItem ($"__ANDROID_{i}__"));

AndroidDefineConstants = sb.ToString ();
AndroidDefineConstants = items.ToArray ();

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -822,12 +822,14 @@ because xbuild doesn't support framework reference assemblies.

<!-- Get the defined constants for this API Level -->
<GetAndroidDefineConstants AndroidApiLevel="$(_SupportedApiLevel)" ProductVersion="$(MonoAndroidVersion)">
<Output TaskParameter="AndroidDefineConstants" PropertyName="AndroidDefineConstants" />
<Output TaskParameter="AndroidDefineConstants" ItemName="AndroidDefineConstants" />
</GetAndroidDefineConstants>

<CreateProperty Value="$(DefineConstants);$(AndroidDefineConstants)">
<CreateProperty Value="$(DefineConstants);@(AndroidDefineConstants)">
<Output TaskParameter="Value" PropertyName="DefineConstants" />
</CreateProperty>

<Message Text="DefineConstants : $(DefineConstants)"/>
</Target>

<Target Name="AndroidPrepareForBuild" DependsOnTargets="$(_OnResolveMonoAndroidSdks)" />
Expand Down