-
Notifications
You must be signed in to change notification settings - Fork 569
Expand file tree
/
Copy pathGenerateRtxt.cs
More file actions
45 lines (34 loc) · 1.42 KB
/
GenerateRtxt.cs
File metadata and controls
45 lines (34 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright (C) 2022 Microsoft Ltd, Inc. All rights reserved.
#nullable enable
using System;
using System.IO;
using Microsoft.Build.Framework;
using Microsoft.Android.Build.Tasks;
namespace Xamarin.Android.Tasks
{
public class GenerateRtxt : AndroidTask
{
public override string TaskPrefix => "GR";
[Required]
public string RTxtFile { get; set; } = "";
[Required]
public string ResourceDirectory { get; set; } = "";
public string[]? AdditionalResourceDirectories { get; set; }
public string[]? AarLibraries { get; set; }
public string? JavaPlatformJarPath { get; set; }
public string? ResourceFlagFile { get; set; }
public string? CaseMapFile { get; set; }
public override bool RunTask ()
{
// Parse the Resource files and then generate an R.txt file
var writer = new RtxtWriter ();
var resource_fixup = MonoAndroidHelper.LoadMapFile (BuildEngine4, Path.GetFullPath (CaseMapFile), StringComparer.OrdinalIgnoreCase);
var javaPlatformDirectory = JavaPlatformJarPath.IsNullOrEmpty () ? "" : Path.GetDirectoryName (JavaPlatformJarPath);
var parser = new FileResourceParser (Log) { JavaPlatformDirectory = javaPlatformDirectory, ResourceFlagFile = ResourceFlagFile};
var resources = parser.Parse (ResourceDirectory, AdditionalResourceDirectories ?? [], AarLibraries ?? [], resource_fixup);
// only update if it changed.
writer.Write (RTxtFile, resources);
return !Log.HasLoggedErrors;
}
}
}