Skip to content

Commit

Permalink
Add osx-arm64 support
Browse files Browse the repository at this point in the history
  • Loading branch information
liesauer committed Jan 10, 2024
1 parent 847e935 commit 6fab958
Show file tree
Hide file tree
Showing 16 changed files with 37 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Build/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ dotnet pack -c Release /p:PackageOutputPath=${nupkgdir}

# 打包nbeauty
mkdir ${archivedir}
"win-x86", "win-x64", "linux-x64", "osx-x64" | ForEach-Object -Process {
"win-x86", "win-x64", "linux-x64", "osx-x64", "osx-arm64" | ForEach-Object -Process {
$rid = $_
cd "${tooldir}/${rid}"
Compress-Archive -Force -Path * -DestinationPath "${archivedir}/${rid}.zip"
Expand Down
2 changes: 1 addition & 1 deletion Common/Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PackageOutputPath>.nupkg</PackageOutputPath>
<Version>2.1.4.1</Version>
<Version>2.1.4.2</Version>

<Company>nulastudio</Company>
<Authors>LiesAuer</Authors>
Expand Down
6 changes: 5 additions & 1 deletion NetBeauty/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ BINARY_WIN_X86 = win-x86/nbeauty2.exe
BINARY_WIN_X64 = win-x64/nbeauty2.exe
BINARY_LINUX_X64 = linux-x64/nbeauty2
BINARY_MAC_X64 = osx-x64/nbeauty2
BINARY_MAC_ARM64 = osx-arm64/nbeauty2
BUILD_FLAGS = -ldflags="-s -w"
PACKAGE = "github.com/nulastudio/NetBeauty/src/main"

build-all: build-win-x86 build-win-x64 build-linux-x64 build-osx-x64
build-all: build-win-x86 build-win-x64 build-linux-x64 build-osx-x64 build-osx-arm64

build-win-x86:
CGO_ENABLED=0 GOOS=windows GOARCH=386 go build $(BUILD_FLAGS) -o ./$(OUTPUT)/$(BINARY_WIN_X86) $(PACKAGE)
Expand All @@ -19,3 +20,6 @@ build-linux-x64:

build-osx-x64:
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build $(BUILD_FLAGS) -o ./$(OUTPUT)/$(BINARY_MAC_X64) $(PACKAGE)

build-osx-arm64:
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build $(BUILD_FLAGS) -o ./$(OUTPUT)/$(BINARY_MAC_ARM64) $(PACKAGE)
5 changes: 5 additions & 0 deletions NetBeauty/make.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ $BINARY_WIN_X86 = "win-x86/nbeauty2.exe"
$BINARY_WIN_X64 = "win-x64/nbeauty2.exe"
$BINARY_LINUX_X64 = "linux-x64/nbeauty2"
$BINARY_MAC_X64 = "osx-x64/nbeauty2"
$BINARY_MAC_ARM64 = "osx-arm64/nbeauty2"
$BUILD_FLAGS = '-ldflags="-s -w"'
$PACKAGE = "github.com/nulastudio/NetBeauty/src/main"

Expand All @@ -23,3 +24,7 @@ go build ${BUILD_FLAGS} -o ./${OUTPUT}/${BINARY_LINUX_X64} $PACKAGE
$Env:GOOS = "darwin"
$Env:GOARCH = "amd64"
go build ${BUILD_FLAGS} -o ./${OUTPUT}/${BINARY_MAC_X64} $PACKAGE

$Env:GOOS = "darwin"
$Env:GOARCH = "arm64"
go build ${BUILD_FLAGS} -o ./${OUTPUT}/${BINARY_MAC_ARM64} $PACKAGE
4 changes: 2 additions & 2 deletions NetBeauty/src/main/bindata.go

Large diffs are not rendered by default.

Binary file modified NetBeauty/src/nbloader/nbloader.dll
Binary file not shown.
10 changes: 9 additions & 1 deletion NetBeautyGlobalTool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Program
["win-x64"] = "/nbeauty2/win-x64/nbeauty2.exe",
["linux-x64"] = "/nbeauty2/linux-x64/nbeauty2",
["osx-x64"] = "/nbeauty2/osx-x64/nbeauty2",
["osx-arm64"] = "/nbeauty2/osx-arm64/nbeauty2",
};

static void Main(string[] args)
Expand All @@ -32,7 +33,14 @@ static void Main(string[] args)
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
nbeautyBin = platform["osx-x64"];
if (RuntimeInformation.ProcessArchitecture == Architecture.X64)
{
nbeautyBin = platform["osx-x64"];
}
else if (RuntimeInformation.ProcessArchitecture == Architecture.Arm64)
{
nbeautyBin = platform["osx-arm64"];
}
}
var psi = new ProcessStartInfo(rootDir + nbeautyBin)
{
Expand Down
6 changes: 5 additions & 1 deletion NetBeautyNuget/Beauty.targets
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
<IsWindows Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">True</IsWindows>
<IsLinux Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">True</IsLinux>
<IsOSX Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">True</IsOSX>
<RuntimeArch>$([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture)</RuntimeArch>
<RuntimeOS Condition="$(IsWindows) == 'True'">win-x86</RuntimeOS>
<RuntimeOS Condition="$(IsLinux) == 'True'">linux-x64</RuntimeOS>
<RuntimeOS Condition="$(IsOSX) == 'True'">osx-x64</RuntimeOS>
<RuntimeOS Condition="$(IsOSX) == 'True' And $(RuntimeArch) == 'X64'">osx-x64</RuntimeOS>
<RuntimeOS Condition="$(IsOSX) == 'True' And $(RuntimeArch) == 'Arm64'">osx-arm64</RuntimeOS>
<BeautyBinExt Condition="$(IsWindows) == 'True'">.exe</BeautyBinExt>
<BeautyBin>"$(MSBuildThisFileDirectory)../tools/$(RuntimeOS)/nbeauty2$(BeautyBinExt)"</BeautyBin>
<BeautyLibsDir Condition="$(BeautyLibsDir) == ''">libraries</BeautyLibsDir>
Expand Down Expand Up @@ -81,6 +83,8 @@ Args = string.Join(" ", CommandLineArgs);
<_BeautyIsPublishing>True</_BeautyIsPublishing>
</PropertyGroup>

<!-- <Message Text="RuntimeOS: $(RuntimeOS)" Importance="High" /> -->
<!-- <Message Text="RuntimeArch: $(RuntimeArch)" Importance="High" /> -->
<!-- <Message Text="Running inside Visual Studio: $(_BeautyDetermineIsInsideVS)" Importance="High" /> -->
<!-- <Message Text="PublishProtocol: $(PublishProtocol)" Importance="High" /> -->
<!-- <Message Text="Running is publish task: $(_BeautyIsPublishing)" Importance="High" /> -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="nulastudio.NetBeauty" Version="2.1.4.1" />
<PackageReference Include="nulastudio.NetBeauty" Version="2.1.4.2" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion NetBeautyTest/ChromelyTest/ChromelyTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="nulastudio.NetBeauty" Version="2.1.4.1" />
<PackageReference Include="nulastudio.NetBeauty" Version="2.1.4.2" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion NetBeautyTest/NetFxTest/NetFxTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<PackageReference Include="nulastudio.NetBeauty" Version="2.1.4.1" />
<PackageReference Include="nulastudio.NetBeauty" Version="2.1.4.2" />
<PackageReference Include="SixLabors.ImageSharp">
<Version>2.1.3</Version>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion NetBeautyTest/SharedRuntimeTest/WsClient/WsClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

<ItemGroup>
<PackageReference Include="WatsonWebsocket" Version="2.3.2.5" />
<PackageReference Include="nulastudio.NetBeauty" Version="2.1.4.1" />
<PackageReference Include="nulastudio.NetBeauty" Version="2.1.4.2" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion NetBeautyTest/SharedRuntimeTest/WsServer/WsServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

<ItemGroup>
<PackageReference Include="WatsonWebsocket" Version="2.3.2.5" />
<PackageReference Include="nulastudio.NetBeauty" Version="2.1.4.1" />
<PackageReference Include="nulastudio.NetBeauty" Version="2.1.4.2" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion NetBeautyTest/WPFTest/WPFTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="nulastudio.NetBeauty" Version="2.1.4.1" />
<PackageReference Include="nulastudio.NetBeauty" Version="2.1.4.2" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="7.0.0" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion NetBeautyTest/WebAppTest/WebAppTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="nulastudio.NetBeauty" Version="2.1.4.1" />
<PackageReference Include="nulastudio.NetBeauty" Version="2.1.4.2" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ see [`--hiddens`](#use-the-binary-application-if-your-project-has-already-been-p
| ---- | ---- | ---- |
| Supported Framework | `.Net Framework`<br/>`.Net Core 3.0+` | `.Net Core 2.0+` |
| Supported Deployment Model | Framework-dependent deployment (`FDD`)<br/>Self-contained deployment (`SCD`)<br/>Framework-dependent executables (`FDE`) | Self-contained deployment (`SCD`) |
| Supported System | All | `win-x64` `win-x86`<br/>`linux-x64` `linux-arm` `linux-arm64`<br/>`osx-x64` |
| Supported System | All | `win-x64` `win-x86`<br/>`linux-x64` `linux-arm` `linux-arm64`<br/>`osx-x64`<br/>`osx-arm64`(.NET 6+) |
| Need Patched HostFXR | No<br />Yes(if use patch) | Yes |
| Minimum Structure | ~20 Files<br />~8 Files(if use patch) | ~8 Files |
| How It Works | [`STARTUP_HOOKS`](https://github.com/dotnet/runtime/blob/main/docs/design/features/host-startup-hook.md)<br/>[`AssemblyLoadContext.Resolving`](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.loader.assemblyloadcontext.resolving?view=netcore-3.0)<br/>[`AssemblyLoadContext.ResolvingUnmanagedDll`](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.loader.assemblyloadcontext.resolvingunmanageddll?view=netcore-3.0)<br />+<br />[`patched libhostfxr`](https://github.com/nulastudio/HostFXRPatcher)(if use patch)<br/>[`additionalProbingPaths`](https://github.com/dotnet/toolset/blob/master/Documentation/specs/runtime-configuration-file.md#runtimeoptions-section-runtimeconfigjson)(if use patch) | [`patched libhostfxr`](https://github.com/nulastudio/HostFXRPatcher)<br/>[`additionalProbingPaths`](https://github.com/dotnet/toolset/blob/master/Documentation/specs/runtime-configuration-file.md#runtimeoptions-section-runtimeconfigjson) |
Expand Down Expand Up @@ -84,7 +84,7 @@ Your `*.csproj` should be like:
</PropertyGroup>

<ItemGroup>
<PackageReference Include="nulastudio.NetBeauty" Version="2.1.4.1" />
<PackageReference Include="nulastudio.NetBeauty" Version="2.1.4.2" />
</ItemGroup>

</Project>
Expand Down

0 comments on commit 6fab958

Please sign in to comment.