add multi-architecture support for MacOS

This commit is contained in:
Tlntin
2023-01-26 11:42:54 +08:00
parent e238d242db
commit 7c07d3f227
7 changed files with 79 additions and 10 deletions

20
bin/README.md vendored
View File

@@ -124,3 +124,23 @@ url 为你需要打包的网页链接 🔗,必须提供。
# 或者
-f <value>
```
#### [multi-arch]
打包结果同时支持英特尔和m1芯片仅适用于MacOS默认为 `false`。
##### 准备工作
- 注意开启该选项后需要用rust官网的rustup安装rust不支持brew安装。
- 对于intel芯片用户需要安装arm64跨平台包使安装包支持m1芯片使用下面命令安装。
```shell
rustup target add aarch64-apple-darwin
```
- 对于M1芯片用户需要安装x86跨平台包使安装包支持interl芯片使用下面的命令安装。
```shell
rustup target add x86_64-apple-darwin
```
##### 使用方法
```shell
--multi-arch <value>
# 或者
-m <value>
```

20
bin/README_EN.md vendored
View File

@@ -123,3 +123,23 @@ Indicates if the window should be full screen on application launch. The default
# or
-f <value>
```
#### [multi-arch]
Package results support both Intel and m1 chips, only for MacOS. The default is `false`.
##### Preparation
- Note: After enabling this option, you need to use rustup on the rust official website to install rust, brew installation is not supported.
- For intel chip users, you need to install the arm64 cross-platform package to make the installation package support the m1 chip, and use the following command to install.
```shell
rustup target add aarch64-apple-darwin
```
- For M1 chip users, you need to install the x86 cross-platform package to make the installation package support the interl chip, and use the following command to install.
```shell
rustup target add x86_64-apple-darwin
```
##### Instructions
```shell
--multi-arch <value>
# or
-m <value>
```

View File

@@ -39,11 +39,20 @@ export default class MacBuilder implements IBuilder {
const { name } = options;
await mergeTauriConfig(url, options, tauriConf);
//这里直接使用 universal-apple-darwin 的打包,而非当前系统的包
await shellExec(`cd ${npmDirectory} && npm install && npm run build:mac`);
const dmgName = `${name}_${tauriConf.package.version}_universal.dmg`;
let dmgName: string;
if (options.multi_arch) {
await shellExec(`cd ${npmDirectory} && npm install && npm run build:mac`);
dmgName = `${name}_${tauriConf.package.version}_universal.dmg`;
} else {
await shellExec(`cd ${npmDirectory} && npm install && npm run build`);
let arch: string;
if (process.arch === "x64") {
arch = "amd64";
} else {
arch = process.arch;
}
dmgName = `${name}_${tauriConf.package.version}_${arch}.deb`;
}
const appPath = this.getBuildAppPath(npmDirectory, dmgName);
const distPath = path.resolve(`${name}.dmg`);
await fs.copyFile(appPath, distPath);

3
bin/cli.ts vendored
View File

@@ -21,7 +21,8 @@ program
.option('--no-resizable', 'whether the window can be resizable', DEFAULT_PAKE_OPTIONS.resizable)
.option('-f, --fullscreen', 'makes the packaged app start in full screen', DEFAULT_PAKE_OPTIONS.fullscreen)
.option('-t, --transparent', 'transparent title bar', DEFAULT_PAKE_OPTIONS.transparent)
.option('-d, --debug', 'debug', DEFAULT_PAKE_OPTIONS.transparent)
.option('-d, --debug', 'debug', DEFAULT_PAKE_OPTIONS.debug)
.option('-m, --multi-arch', "Supports both Intel and m1 chips, only for Mac.", DEFAULT_PAKE_OPTIONS.multi_arch)
.action(async (url: string, options: PakeCliOptions) => {
await checkUpdateTips();

1
bin/defaults.ts vendored
View File

@@ -8,6 +8,7 @@ export const DEFAULT_PAKE_OPTIONS: PakeCliOptions = {
resizable: true,
transparent: false,
debug: false,
multi_arch: false,
};
export const DEFAULT_APP_NAME = 'Pake';

3
bin/types.ts vendored
View File

@@ -22,6 +22,9 @@ export interface PakeCliOptions {
/** 调试模式,会输出更多日志 */
debug: boolean;
/** mutli arch, Supports both Intel and m1 chips, only for Mac */
multi_arch: boolean;
}
export interface PakeAppOptions extends PakeCliOptions {