Skip to content

Commit d8fdbcf

Browse files
grendellojonpryor
authored andcommitted
[Linux] Add submodules to cross-build libmonodroid for Windows (#1729)
Adds two components that are required by libmonodroid but not provided with the packaged mingw on Linux (they are part of the MXE build on macOS): * `dlfcn-win32`: `dlopen()` + friends for Windows * `mman-win32`: `mman.h` (`mmap()` and friends) for Windows This helps allows us to perform a full build of Xamarin.Android with cross build for Windows on Linux.
1 parent 3395dbc commit d8fdbcf

File tree

16 files changed

+350
-6
lines changed

16 files changed

+350
-6
lines changed

.gitmodules

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,11 @@
4141
path = external/xamarin-android-tools
4242
url = https://github.com/xamarin/xamarin-android-tools
4343
branch = master
44+
[submodule "external/dlfcn-win32"]
45+
path = external/dlfcn-win32
46+
url = https://github.com/dlfcn-win32/dlfcn-win32.git
47+
branch = v1.1.1
48+
[submodule "external/mman-win32"]
49+
path = external/mman-win32
50+
url = https://github.com/witwall/mman-win32.git
51+
branch = master

Configuration.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
<AutoProvision Condition=" '$(AutoProvision)' == '' ">False</AutoProvision>
3434
<AutoProvisionUsesSudo Condition=" '$(AutoProvisionUsesSudo)' == '' ">False</AutoProvisionUsesSudo>
3535
<XAInstallPrefix Condition=" '$(XAInstallPrefix)' == '' ">$(MSBuildThisFileDirectory)\bin\$(Configuration)\lib\xamarin.android\</XAInstallPrefix>
36+
<LinuxMingwDependenciesRootDirectory Condition=" '$(LinuxMingwDependenciesRootDirectory)' == '' ">$(MSBuildThisFileDirectory)\bin\Build$(Configuration)\linux-mingw-deps</LinuxMingwDependenciesRootDirectory>
3637
<HostOS Condition=" '$(HostOS)' == '' And '$(OS)' == 'Windows_NT' ">Windows</HostOS>
3738
<HostCc Condition=" '$(HostCc)' == '' ">$(HostCc64)</HostCc>
3839
<HostCxx Condition=" '$(HostCxx)' == '' ">$(HostCxx64)</HostCxx>

Xamarin.Android.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Drawing.Primitives",
8383
EndProject
8484
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "libzip-windows", "src\libzip-windows\libzip-windows.csproj", "{0DE278D6-000F-4001-BB98-187C0AF58A61}"
8585
EndProject
86+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "linux-mingw-dependencies", "build-tools\linux-mingw-dependencies\linux-mingw-dependencies.csproj", "{2C1C68CD-CFED-4DEB-A2D3-61D6932F3E8E}"
87+
EndProject
8688
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "bundle", "build-tools\bundle\bundle.csproj", "{1640725C-4DB8-4D8D-BC96-74E688A06EEF}"
8789
EndProject
8890
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "xa-prep-tasks", "build-tools\xa-prep-tasks\xa-prep-tasks.csproj", "{7CE69551-BD73-4726-ACAA-AAF89C84BAF8}"
@@ -264,6 +266,10 @@ Global
264266
{0DE278D6-000F-4001-BB98-187C0AF58A61}.Debug|AnyCPU.Build.0 = Debug|Any CPU
265267
{0DE278D6-000F-4001-BB98-187C0AF58A61}.Release|AnyCPU.ActiveCfg = Release|Any CPU
266268
{0DE278D6-000F-4001-BB98-187C0AF58A61}.Release|AnyCPU.Build.0 = Release|Any CPU
269+
{2C1C68CD-CFED-4DEB-A2D3-61D6932F3E8E}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
270+
{2C1C68CD-CFED-4DEB-A2D3-61D6932F3E8E}.Debug|AnyCPU.Build.0 = Debug|Any CPU
271+
{2C1C68CD-CFED-4DEB-A2D3-61D6932F3E8E}.Release|AnyCPU.ActiveCfg = Release|Any CPU
272+
{2C1C68CD-CFED-4DEB-A2D3-61D6932F3E8E}.Release|AnyCPU.Build.0 = Release|Any CPU
267273
{1640725C-4DB8-4D8D-BC96-74E688A06EEF}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
268274
{1640725C-4DB8-4D8D-BC96-74E688A06EEF}.Debug|AnyCPU.Build.0 = Debug|Any CPU
269275
{1640725C-4DB8-4D8D-BC96-74E688A06EEF}.Release|AnyCPU.ActiveCfg = Release|Any CPU
@@ -352,6 +358,7 @@ Global
352358
{AFB8F6D1-6EA9-42C3-950B-98F34C669AD2} = {E351F97D-EA4F-4E7F-AAA0-8EBB1F2A4A62}
353359
{3FC3E78B-F7D4-42EA-BBE8-4535DF42BFF8} = {E351F97D-EA4F-4E7F-AAA0-8EBB1F2A4A62}
354360
{C876DA71-8573-4CEF-9149-716D72455ED4} = {E351F97D-EA4F-4E7F-AAA0-8EBB1F2A4A62}
361+
{2C1C68CD-CFED-4DEB-A2D3-61D6932F3E8E} = {E351F97D-EA4F-4E7F-AAA0-8EBB1F2A4A62}
355362
{94BD81F7-B06F-4295-9636-F8A3B6BDC762} = {04E3E11E-B47D-4599-8AFC-50515A95E715}
356363
{D14A1B5C-2060-4930-92BE-F7190256C735} = {04E3E11E-B47D-4599-8AFC-50515A95E715}
357364
{FE789F04-5E95-42C5-AEF1-E33F8DF06B3F} = {04E3E11E-B47D-4599-8AFC-50515A95E715}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProjectGuid>{2C1C68CD-CFED-4DEB-A2D3-61D6932F3E8E}</ProjectGuid>
7+
<ForceBuildProjectFilePath>$(MSBuildThisFileFullPath)</ForceBuildProjectFilePath>
8+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
9+
</PropertyGroup>
10+
<Import Project="..\..\Configuration.props" />
11+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
12+
<OutputPath>$(LinuxMingwDependenciesRootDirectory)</OutputPath>
13+
</PropertyGroup>
14+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
15+
<OutputPath>$(LinuxMingwDependenciesRootDirectory)</OutputPath>
16+
</PropertyGroup>
17+
<Import Project="$(MSBuildBinPath)\Microsoft.Common.targets" />
18+
<PropertyGroup>
19+
<BuildDependsOnLocal Condition=" '$(HostOS)' == 'Linux' And ($(AndroidSupportedHostJitAbisForConditionalChecks.Contains (':mxe-Win64:')) Or $(AndroidSupportedHostJitAbisForConditionalChecks.Contains (':mxe-Win32:')))">
20+
ResolveReferences;
21+
_BuildUnlessCached
22+
</BuildDependsOnLocal>
23+
</PropertyGroup>
24+
<Import Project="linux-mingw-dependencies.props" />
25+
<Import Project="linux-mingw-dependencies.projitems" />
26+
<Import Project="linux-mingw-dependencies.targets" />
27+
<Target Name="Build" DependsOnTargets="$(BuildDependsOnLocal)" />
28+
<Target Name="Clean" />
29+
</Project>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<_CommonCmakeProjectFlags>-DBUILD_SHARED_LIBS=OFF -DBUILD_TESTS=OFF</_CommonCmakeProjectFlags>
5+
</PropertyGroup>
6+
<ItemGroup>
7+
<_LinuxCmakeMingwDependency Include="dlfcn-win32-64" Condition="$(AndroidSupportedHostJitAbisForConditionalChecks.Contains (':mxe-Win64:'))">
8+
<Submodule>dlfcn-win32</Submodule>
9+
<CMakeToolchainFile>mingw-linux-64.cmake</CMakeToolchainFile>
10+
<CMakeExtraFlags>$(_CommonCmakeProjectFlags)</CMakeExtraFlags>
11+
<OutputLibrary>x86_64/lib/libdl.a</OutputLibrary>
12+
<OutputLibraryPath>libdl.a</OutputLibraryPath>
13+
<OutputIncludePath>x86_64/include</OutputIncludePath>
14+
<InstallHeaders>dlfcn.h</InstallHeaders>
15+
</_LinuxCmakeMingwDependency>
16+
17+
<_LinuxCmakeMingwDependency Include="dlfcn-win32-32" Condition="$(AndroidSupportedHostJitAbisForConditionalChecks.Contains (':mxe-Win32:'))">
18+
<Submodule>dlfcn-win32</Submodule>
19+
<CMakeToolchainFile>mingw-linux-32.cmake</CMakeToolchainFile>
20+
<CMakeExtraFlags>$(_CommonCmakeProjectFlags)</CMakeExtraFlags>
21+
<OutputLibrary>x86/lib/libdl.a</OutputLibrary>
22+
<OutputLibraryPath>libdl.a</OutputLibraryPath>
23+
<OutputIncludePath>x86/include</OutputIncludePath>
24+
<InstallHeaders>dlfcn.h</InstallHeaders>
25+
</_LinuxCmakeMingwDependency>
26+
27+
<_LinuxCmakeMingwDependency Include="mman-win32-64" Condition="$(AndroidSupportedHostJitAbisForConditionalChecks.Contains (':mxe-Win64:'))">
28+
<Submodule>mman-win32</Submodule>
29+
<CMakeToolchainFile>mingw-linux-64.cmake</CMakeToolchainFile>
30+
<CMakeExtraFlags>$(_CommonCmakeProjectFlags)</CMakeExtraFlags>
31+
<OutputLibrary>x86_64/lib/libmman.a</OutputLibrary>
32+
<OutputLibraryPath>libmman.a</OutputLibraryPath>
33+
<OutputIncludePath>x86_64/include</OutputIncludePath>
34+
<InstallHeaders>mman.h:sys/mman.h</InstallHeaders>
35+
</_LinuxCmakeMingwDependency>
36+
37+
<_LinuxCmakeMingwDependency Include="mman-win32-32" Condition="$(AndroidSupportedHostJitAbisForConditionalChecks.Contains (':mxe-Win32:'))">
38+
<Submodule>mman-win32</Submodule>
39+
<CMakeToolchainFile>mingw-linux-32.cmake</CMakeToolchainFile>
40+
<CMakeExtraFlags>$(_CommonCmakeProjectFlags)</CMakeExtraFlags>
41+
<OutputLibrary>x86/lib/libmman.a</OutputLibrary>
42+
<OutputLibraryPath>libmman.a</OutputLibraryPath>
43+
<OutputIncludePath>x86/include</OutputIncludePath>
44+
<InstallHeaders>mman.h:sys/mman.h</InstallHeaders>
45+
</_LinuxCmakeMingwDependency>
46+
</ItemGroup>
47+
48+
<ItemGroup>
49+
<RequiredProgram Include="cmake" />
50+
<RequiredProgram Include="make" Condition=" '$(HostOS)' != 'Windows' " />
51+
</ItemGroup>
52+
</Project>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<_SubmoduleTopDir>$(XamarinAndroidSourcePath)\external</_SubmoduleTopDir>
5+
<_CMake>cmake</_CMake>
6+
</PropertyGroup>
7+
</Project>
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="..\..\build-tools\scripts\RequiredPrograms.targets" />
4+
<UsingTask AssemblyFile="$(MSBuildThisFileDirectory)..\..\bin\Build$(Configuration)\xa-prep-tasks.dll" TaskName="Xamarin.Android.BuildTools.PrepTasks.CreateFilePaths" />
5+
<PropertyGroup>
6+
<ForceBuildDependsOn>
7+
CheckForRequiredPrograms;
8+
_Configure;
9+
_Make
10+
</ForceBuildDependsOn>
11+
<_LibZipOutputPath>$(XAInstallPrefix)xbuild\Xamarin\Android\</_LibZipOutputPath>
12+
</PropertyGroup>
13+
<Target Name="Build" DependsOnTargets="$(BuildDependsOn)" />
14+
<Target Name="Clean" />
15+
16+
<Target Name="_SetCMakeListsTxtTimeToLastCommitTimestamp">
17+
<GitCommitTime
18+
WorkingDirectory="$(_SubmoduleTopDir)\%(_LinuxCmakeMingwDependency.Submodule)"
19+
ToolPath="$(GitToolPath)"
20+
ToolExe="$(GitToolExe)">
21+
<Output TaskParameter="Time" PropertyName="_LinuxMingwDepCommitTime" />
22+
</GitCommitTime>
23+
<Touch Files="@(_LinuxCmakeMingwDependency->'$(_SubmoduleTopDir)\%(Submodule)\CMakeLists.txt')" Time="$(_LinuxMingwDepCommitTime)" />
24+
</Target>
25+
26+
<Target Name="_Configure"
27+
Condition=" '@(_LinuxCmakeMingwDependency)' != '' "
28+
DependsOnTargets="_SetCMakeListsTxtTimeToLastCommitTimestamp"
29+
Inputs="@(_LinuxCmakeMingwDependency->'$(_SubmoduleTopDir)\%(Submodule)\CMakeLists.txt')"
30+
Outputs="$(IntermediateOutputPath)\%(_LinuxCmakeMingwDependency.Identity)\Makefile">
31+
<MakeDir Directories="@(_LinuxCmakeMingwDependency->'$(IntermediateOutputPath)\%(Identity)')" />
32+
<Exec
33+
Command="$(_CMake) -DCMAKE_TOOLCHAIN_FILE=$(MSBuildThisFileDirectory)\%(_LinuxCmakeMingwDependency.CMakeToolchainFile) %(_LinuxCmakeMingwDependency.CMakeExtraFlags) $(_SubmoduleTopDir)\%(_LinuxCmakeMingwDependency.Submodule)"
34+
WorkingDirectory="$(IntermediateOutputPath)\%(_LinuxCmakeMingwDependency.Identity)"
35+
/>
36+
</Target>
37+
38+
<ItemGroup>
39+
<_LinuxCmakeMingwDependencyMakefile Include="@(_LinuxCmakeMingwDependency->'$(IntermediateOutputPath)\%(Identity)\Makefile')" />
40+
</ItemGroup>
41+
<ItemGroup>
42+
<Content Include="@(_LinuxCmakeMingwDependency->'$(LinuxMingwDependenciesRootDirectory)\%(OutputLibrary)')" />
43+
</ItemGroup>
44+
45+
<Target Name="GetLinuxMingwDepExtraFiles"
46+
Condition=" '@(_LinuxCmakeMingwDependency)' != '' ">
47+
<CreateFilePaths
48+
SourceFileNames="@(_LinuxCmakeMingwDependency->'%(InstallHeaders)')"
49+
SourceDirectories="@(_LinuxCmakeMingwDependency->'$(_SubmoduleTopDir)\%(Submodule)')"
50+
DestinationDirectories="@(_LinuxCmakeMingwDependency->'$(LinuxMingwDependenciesRootDirectory)\%(OutputIncludePath)')">
51+
<Output TaskParameter="FullSourceFilePaths" ItemName="_LinuxMingwDepSourceFile" />
52+
<Output TaskParameter="FullDestinationFilePaths" ItemName="_LinuxMingwDepDestFile" />
53+
</CreateFilePaths>
54+
<ItemGroup>
55+
<Content Include="@(_LinuxMingwDepDestFile)"/>
56+
</ItemGroup>
57+
</Target>
58+
59+
<Target Name="_Make"
60+
Condition=" '@(_LinuxCmakeMingwDependency)' != '' "
61+
DependsOnTargets="GetLinuxMingwDepExtraFiles"
62+
Inputs="@(_LinuxCmakeMingwDependencyMakefile)"
63+
Outputs="@(Content)">
64+
<Exec
65+
Command="make"
66+
WorkingDirectory="$(IntermediateOutputPath)\%(_LinuxCmakeMingwDependency.Identity)"
67+
/>
68+
<Copy
69+
SourceFiles="@(_LinuxMingwDepSourceFile)"
70+
DestinationFiles="@(_LinuxMingwDepDestFile)"
71+
/>
72+
<Copy
73+
SourceFiles="@(_LinuxCmakeMingwDependency->'$(IntermediateOutputPath)\%(Identity)\%(OutputLibraryPath)')"
74+
DestinationFiles="@(_LinuxCmakeMingwDependency->'$(LinuxMingwDependenciesRootDirectory)\%(OutputLibrary)')"
75+
/>
76+
<Touch Files="@(Content)" />
77+
</Target>
78+
79+
<Target Name="GetLinuxMingwDepsBundleItems">
80+
<ItemGroup>
81+
<BundleItem Include="@(Content)" />
82+
</ItemGroup>
83+
</Target>
84+
85+
<Target Name="ForceBuild"
86+
DependsOnTargets="GetLinuxMingwDepsBundleItems;$(ForceBuildDependsOn)"
87+
Inputs="@(_LinuxCmakeMingwDependency->'$(_SubmoduleTopDir)\%(Submodule)\CMakeLists.txt"
88+
Outputs="@(BundleItem)">
89+
</Target>
90+
91+
<Target Name="_BuildUnlessCached"
92+
DependsOnTargets="_SetCMakeListsTxtTimeToLastCommitTimestamp;GetLinuxMingwDepsBundleItems"
93+
Inputs="@(_LinuxCmakeMingwDependency->'$(_SubmoduleTopDir)\%(Submodule)\CMakeLists.txt"
94+
Outputs="@(BundleItem)">
95+
<PropertyGroup>
96+
<_Now>$([System.DateTime]::Now.Ticks)</_Now>
97+
</PropertyGroup>
98+
<MSBuild
99+
Projects="$(ForceBuildProjectFilePath)"
100+
Properties="_ForceXbuildToNotCacheTargets=$(_Now)"
101+
Targets="ForceBuild"
102+
/>
103+
</Target>
104+
105+
<Target Name="_CleanBinaries"
106+
AfterTargets="Clean">
107+
<RemoveDir Directories="$(IntermediateOutputPath)\%(_LinuxCmakeMingwDependency.Identity)" />
108+
<Delete Files="@(_LinuxCmakeMingwDependency->'$(LinuxMingwDependenciesRootDirectory)\%(OutputLibrary)')" />
109+
</Target>
110+
<Target Name="CoreCompile"
111+
DependsOnTargets="_BuildUnlessCached">
112+
</Target>
113+
</Project>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# the name of the target operating system
2+
SET(CMAKE_SYSTEM_NAME Windows)
3+
4+
# which compilers to use for C and C++
5+
SET(CMAKE_C_COMPILER i686-w64-mingw32-gcc)
6+
SET(CMAKE_CXX_COMPILER i686-w64-mingw32-g++)
7+
SET(CMAKE_RC_COMPILER i686-w64-mingw32-windres)
8+
9+
# here is the target environment located
10+
SET(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32)
11+
12+
# adjust the default behaviour of the FIND_XXX() commands:
13+
# search headers and libraries in the target environment, search
14+
# programs in the host environment
15+
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
16+
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
17+
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# the name of the target operating system
2+
SET(CMAKE_SYSTEM_NAME Windows)
3+
4+
# which compilers to use for C and C++
5+
SET(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
6+
SET(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
7+
SET(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)
8+
9+
# here is the target environment located
10+
SET(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32)
11+
12+
# adjust the default behaviour of the FIND_XXX() commands:
13+
# search headers and libraries in the target environment, search
14+
# programs in the host environment
15+
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
16+
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
17+
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Text;
6+
7+
using Microsoft.Build.Framework;
8+
using Microsoft.Build.Utilities;
9+
10+
namespace Xamarin.Android.BuildTools.PrepTasks
11+
{
12+
public class CreateFilePaths : Task
13+
{
14+
[Required]
15+
public string[] SourceFileNames { get; set; }
16+
17+
[Required]
18+
public string[] SourceDirectories { get; set; }
19+
20+
[Required]
21+
public string[] DestinationDirectories { get; set; }
22+
23+
[Output]
24+
public ITaskItem[] FullSourceFilePaths { get; set; }
25+
26+
[Output]
27+
public ITaskItem[] FullDestinationFilePaths { get; set; }
28+
29+
public override bool Execute ()
30+
{
31+
if (SourceFileNames.Length != SourceDirectories.Length || SourceFileNames.Length != DestinationDirectories.Length)
32+
Log.LogError ("Input paramters must be arrays of the same size");
33+
else
34+
DoExecute ();
35+
36+
return !Log.HasLoggedErrors;
37+
}
38+
39+
void DoExecute ()
40+
{
41+
var sourcePaths = new List<ITaskItem> ();
42+
var destinationPaths = new List<ITaskItem> ();
43+
44+
for (int i = 0; i < SourceFileNames.Length; i++) {
45+
string sourceFile = SourceFileNames [i].Trim ();
46+
string sourceDir = SourceDirectories [i].Trim ();
47+
string destDir = DestinationDirectories [i].Trim ();
48+
bool canContinue = true;
49+
50+
canContinue &= AssertNotEmpty (sourceFile, nameof (SourceFileNames), i);
51+
canContinue &= AssertNotEmpty (sourceDir, nameof (SourceDirectories), i);
52+
canContinue &= AssertNotEmpty (destDir, nameof (DestinationDirectories), i);
53+
54+
if (!canContinue)
55+
continue;
56+
57+
string[] parts = sourceFile.Split (':');
58+
if (parts.Length > 2) {
59+
Log.LogError ($"Too many colons in {sourceFile} (SourceFileNames[{i}]), the format is 'file[:dest/file]'");
60+
continue;
61+
}
62+
63+
sourcePaths.Add (new TaskItem (Path.Combine (sourceDir, parts [0])));
64+
destinationPaths.Add (new TaskItem (Path.Combine (destDir, parts.Length == 1 ? parts [0] : parts [1])));
65+
}
66+
67+
FullSourceFilePaths = sourcePaths.ToArray ();
68+
FullDestinationFilePaths = destinationPaths.ToArray ();
69+
70+
bool AssertNotEmpty (string s, string name, int i)
71+
{
72+
if (String.IsNullOrEmpty (s)) {
73+
Log.LogError ($"Element {i} of input array {name} must not be an empty/whitespace-only string");
74+
return false;
75+
}
76+
77+
return true;
78+
}
79+
}
80+
}
81+
}

0 commit comments

Comments
 (0)