Skip to content

Commit

Permalink
Try replacing setup-mono.ps1 with C# script
Browse files Browse the repository at this point in the history
  • Loading branch information
nike4613 committed Jun 18, 2024
1 parent f06c6a1 commit bb8d1ce
Show file tree
Hide file tree
Showing 9 changed files with 351 additions and 61 deletions.
116 changes: 58 additions & 58 deletions .github/gen-test-matrix.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ param (
)

$ErrorActionPreference = "Stop";

$nugetOrgPkgSrc = "nuget.org";

$nugetOrgPkgSrc = "nuget.org";

$operatingSystems = @(
[pscustomobject]@{
Expand All @@ -16,7 +16,7 @@ $operatingSystems = @(
runnerArch = 1;
hasFramework = $true;
unityMonoArch = @("win32", "win64", "win_arm64");
unityMonoDll = "mono-2.0-bdwgc.dll";
unityMonoDll = "mono-2.0-bdwgc.dll";
dllSuffix = ".dll";
},
[pscustomobject]@{
Expand All @@ -27,8 +27,8 @@ $operatingSystems = @(
runnerArch = 0;
hasMono = $true;
unityMonoArch = @("linux64");
unityMonoDll = "limonobdwgc-2.0.so"; # TODO
dllPrefix = "lib";
unityMonoDll = "limonobdwgc-2.0.so"; # TODO
dllPrefix = "lib";
dllSuffix = ".so";
},
[pscustomobject]@{
Expand All @@ -39,8 +39,8 @@ $operatingSystems = @(
runnerArch = 0;
hasMono = $true;
unityMonoArch = @("macos_x64");
unityMonoDll = "limonobdwgc-2.0.dylib";
dllPrefix = "lib";
unityMonoDll = "limonobdwgc-2.0.dylib";
dllPrefix = "lib";
dllSuffix = ".dylib";
},
[pscustomobject]@{
Expand All @@ -52,8 +52,8 @@ $operatingSystems = @(
runnerArch = 1;
hasMono = $true;
unityMonoArch = @("macos_x64", "macos_arm64");
unityMonoDll = "limonobdwgc-2.0.dylib";
dllPrefix = "lib";
unityMonoDll = "limonobdwgc-2.0.dylib";
dllPrefix = "lib";
dllSuffix = ".dylib";
}
);
Expand Down Expand Up @@ -96,43 +96,43 @@ $dotnetVersions = @(
sdk = "6.0";
tfm = "net6.0";
rids = @("win-x86","win-x64","win-arm64","linux-x64","linux-arm","linux-arm64","osx-x64","osx-arm64");
pgo = $true;
netMonoPkgVer = "6.0.31"
pgo = $true;
netMonoPkgVer = "6.0.31"
netMonoNugetSrc = $nugetOrgPkgSrc;
},
[pscustomobject]@{
name = ".NET 7.0";
sdk = "7.0";
tfm = "net7.0";
rids = @("win-x86","win-x64","win-arm64","linux-x64","linux-arm","linux-arm64","osx-x64","osx-arm64");
pgo = $true;
netMonoPkgVer = "7.0.20"
pgo = $true;
netMonoPkgVer = "7.0.20"
netMonoNugetSrc = $nugetOrgPkgSrc;
},
[pscustomobject]@{
name = ".NET 8.0";
sdk = "8.0";
tfm = "net8.0";
rids = @("win-x86","win-x64","win-arm64","linux-x64","linux-arm","linux-arm64","osx-x64","osx-arm64");
pgo = $true;
netMonoPkgVer = "8.0.6"
pgo = $true;
netMonoPkgVer = "8.0.6"
netMonoNugetSrc = $nugetOrgPkgSrc;
}
);

$netMonoPackageName = "Microsoft.NETCore.App.Runtime.Mono.{RID}";
$netMonoLibPath = "runtimes/{RID}/lib/{TFM}/";
$netMonoDllPath = "runtimes/{RID}/native/{DllPre}coreclr{DllSuf}";

function Fill-Template($template, $obj)
{
$result = $template;
foreach ($kvp in $obj.GetEnumerator())
{

$netMonoPackageName = "Microsoft.NETCore.App.Runtime.Mono.{RID}";
$netMonoLibPath = "runtimes/{RID}/lib/{TFM}/";
$netMonoDllPath = "runtimes/{RID}/native/{DllPre}coreclr{DllSuf}";

function Fill-Template($template, $obj)
{
$result = $template;
foreach ($kvp in $obj.GetEnumerator())
{
$result = $result -replace "{$($kvp.Key)}",$kvp.Value;
}
}
return $result;
}
}

$monoTfm = "net462";

Expand Down Expand Up @@ -172,7 +172,7 @@ function Remove-NullProperties {
$obj
}

}
}

foreach ($os in $operatingSystems)
{
Expand Down Expand Up @@ -253,38 +253,38 @@ foreach ($os in $operatingSystems)
arch = $arch;
}
);
}

if ($dotnet.netMonoNugetSrc)
{
# this runtime version has an associated Mono build
$fill = @{
RID = $rid;
TFM = $dotnet.tfm;
DllPre = $os.dllPrefix;
}

if ($dotnet.netMonoNugetSrc)
{
# this runtime version has an associated Mono build
$fill = @{
RID = $rid;
TFM = $dotnet.tfm;
DllPre = $os.dllPrefix;
DllSuf = $os.dllSuffix;
};

# fill the templates, so that we can add the job
$pkgName = Fill-Template $netMonoPackageName $fill
$libPath = Fill-Template $netMonoLibPath $fill
$dllPath = Fill-Template $netMonoDllPath $fill

# We always need to do a restore on Mono
$jobdotnet = $outdotnet | Select-Object -ExcludeProperty sdk,pgo -Property *,`
@{n='isMono';e={$true}},`
@{n='netMonoPkgName';e={$pkgName}},`
@{n='monoLibPath';e={$libPath}},`
@{n='monoDllPath';e={$dllPath}}
$jobdotnet.needsRestore = $true;

$jobs += @(
[pscustomobject]@{
title = ".NET Mono $($dotnet.netMonoPkgVer) $arch on $($os.name)";
os = $outos;
dotnet = $jobdotnet | Remove-NullProperties;
};

# fill the templates, so that we can add the job
$pkgName = Fill-Template $netMonoPackageName $fill
$libPath = Fill-Template $netMonoLibPath $fill
$dllPath = Fill-Template $netMonoDllPath $fill

# We always need to do a restore on Mono
$jobdotnet = $outdotnet | Select-Object -ExcludeProperty sdk,pgo -Property *,`
@{n='isMono';e={$true}},`
@{n='netMonoPkgName';e={$pkgName}},`
@{n='monoLibPath';e={$libPath}},`
@{n='monoDllPath';e={$dllPath}}
$jobdotnet.needsRestore = $true;

$jobs += @(
[pscustomobject]@{
title = ".NET Mono $($dotnet.netMonoPkgVer) $arch on $($os.name)";
os = $outos;
dotnet = $jobdotnet | Remove-NullProperties;
arch = $arch;
}
}
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-mono-tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ $useMdh = $env:USE_MDH -eq "true";
[string[]]$exeargs = if ($useMdh) { @($env:MONO_DLL) } else { @() };

# TODO: this xUnit TFM is incorrect for some targets. We'd really like to use vstest on .NET Mono, as that will keep things somewhat simpler.
&$exe @exeargs "$($env:NUGET_PACKAGES)/xunit.runner.console/$($env:XunitVersion)/tools/$($env:TFM)/xunit.console.exe" `
&$exe @exeargs "$($env:NUGET_PACKAGES)/xunit.runner.console/$($env:XunitVersion)/tools/$($env:RUNNER_TFM)/xunit.console.exe" `
"release_$($env:TFM)/MonoMod.UnitTest.dll" -junit "$($env:LOG_FILE_NAME).xml"
4 changes: 3 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ jobs:
env:
INPUT_JOB: ${{ inputs.matrix }}
run: |
./.github/setup-mono.ps1 $env:INPUT_JOB $env:GITHUB_OUTPUT $env:GITHUB_ENV ${{ runner.os }}
#./.github/setup-mono.ps1 $env:INPUT_JOB $env:GITHUB_OUTPUT $env:GITHUB_ENV ${{ runner.os }}
dotnet run --project ./build/setup-mono/setup-mono.csproj -- $env:INPUT_JOB $env:GITHUB_OUTPUT $env:GITHUB_ENV ${{ runner.os }}
- name: Print SDK info
run: dotnet --info
Expand Down Expand Up @@ -108,6 +109,7 @@ jobs:
if: ${{ fromJSON(inputs.matrix).dotnet.isMono }}
env:
TFM: ${{ fromJSON(inputs.matrix).dotnet.tfm }}
RUNNER_TFM: ${{ steps.setup_mono.outputs.runner_tfm }}
USE_MDH: ${{ steps.setup_mono.outputs.use_mdh }}
MDH: ${{ steps.setup_mono.outputs.mdh }}
MONO_DLL: ${{ steps.setup_mono.outputs.mono_dll }}
Expand Down
17 changes: 17 additions & 0 deletions MonoMod.sln
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "docs", "docs\docs.csproj",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "docfx", "docfx\docfx.csproj", "{0BE9C4EB-1595-49E7-A2AA-09CA7E74C698}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{6C33A700-A18E-45F8-BECD-0DBCCD0AC456}"
ProjectSection(SolutionItems) = preProject
build\Directory.Build.props = build\Directory.Build.props
build\Directory.Build.targets = build\Directory.Build.targets
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "setup-mono", "build\setup-mono\setup-mono.csproj", "{945B8D38-9842-49BC-86E2-5228CF0834E8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -214,6 +222,14 @@ Global
{0BE9C4EB-1595-49E7-A2AA-09CA7E74C698}.Release|Any CPU.Build.0 = Release|Any CPU
{0BE9C4EB-1595-49E7-A2AA-09CA7E74C698}.ReleaseTrace|Any CPU.ActiveCfg = ReleaseTrace|Any CPU
{0BE9C4EB-1595-49E7-A2AA-09CA7E74C698}.ReleaseTrace|Any CPU.Build.0 = ReleaseTrace|Any CPU
{945B8D38-9842-49BC-86E2-5228CF0834E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{945B8D38-9842-49BC-86E2-5228CF0834E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{945B8D38-9842-49BC-86E2-5228CF0834E8}.DebugTrace|Any CPU.ActiveCfg = DebugTrace|Any CPU
{945B8D38-9842-49BC-86E2-5228CF0834E8}.DebugTrace|Any CPU.Build.0 = DebugTrace|Any CPU
{945B8D38-9842-49BC-86E2-5228CF0834E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{945B8D38-9842-49BC-86E2-5228CF0834E8}.Release|Any CPU.Build.0 = Release|Any CPU
{945B8D38-9842-49BC-86E2-5228CF0834E8}.ReleaseTrace|Any CPU.ActiveCfg = ReleaseTrace|Any CPU
{945B8D38-9842-49BC-86E2-5228CF0834E8}.ReleaseTrace|Any CPU.Build.0 = ReleaseTrace|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -224,6 +240,7 @@ Global
{179EC228-CED4-429E-934F-422C96273F74} = {BCABFBF3-BB48-4C21-9A52-E140015570A9}
{4A65448D-466F-4E87-9797-41F43787EFF3} = {BCABFBF3-BB48-4C21-9A52-E140015570A9}
{0BE9C4EB-1595-49E7-A2AA-09CA7E74C698} = {BCABFBF3-BB48-4C21-9A52-E140015570A9}
{945B8D38-9842-49BC-86E2-5228CF0834E8} = {6C33A700-A18E-45F8-BECD-0DBCCD0AC456}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E10A3D07-6D9A-4898-B95F-268636312A67}
Expand Down
31 changes: 31 additions & 0 deletions build/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<Project>

<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />

<PropertyGroup>
<TargetFrameworks></TargetFrameworks>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>

<NoWarn>$(NoWarn);CA2007;CA1308</NoWarn>

<MMReferenceILHelpers>false</MMReferenceILHelpers>
<MMIncludeUnsafeAlias>false</MMIncludeUnsafeAlias>
<MMReferenceSourcePkgs>false</MMReferenceSourcePkgs>
<MMReferenceUtils>false</MMReferenceUtils>
<MMReferenceBackports>false</MMReferenceBackports>
<MMSharedSourceFiles>false</MMSharedSourceFiles>
<MMUseSourceGen>false</MMUseSourceGen>
<MMBannedApis>false</MMBannedApis>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Chell" Version="1.0.0" />
</ItemGroup>

<ItemGroup>
<Using Include="Chell" />
<Using Include="Chell.Exports" Static="true" />
</ItemGroup>

</Project>
5 changes: 5 additions & 0 deletions build/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Project>

<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.targets', '$(MSBuildThisFileDirectory)../'))" />

</Project>

0 comments on commit bb8d1ce

Please sign in to comment.