add multi-architecture support for MacOS
This commit is contained in:
20
bin/README.md
vendored
20
bin/README.md
vendored
@@ -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
20
bin/README_EN.md
vendored
@@ -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>
|
||||
```
|
||||
|
||||
19
bin/builders/MacBuilder.ts
vendored
19
bin/builders/MacBuilder.ts
vendored
@@ -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
3
bin/cli.ts
vendored
@@ -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
1
bin/defaults.ts
vendored
@@ -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
3
bin/types.ts
vendored
@@ -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 {
|
||||
|
||||
23
dist/cli.js
vendored
23
dist/cli.js
vendored
@@ -48,6 +48,7 @@ const DEFAULT_PAKE_OPTIONS = {
|
||||
resizable: true,
|
||||
transparent: false,
|
||||
debug: false,
|
||||
multi_arch: false,
|
||||
};
|
||||
|
||||
const tlds = [
|
||||
@@ -2016,9 +2017,22 @@ class MacBuilder {
|
||||
log.debug('PakeAppOptions', options);
|
||||
const { name } = options;
|
||||
yield mergeTauriConfig(url, options, tauriConf);
|
||||
//这里直接使用 universal-apple-darwin 的打包,而非当前系统的包
|
||||
yield shellExec(`cd ${npmDirectory} && npm install && npm run build:mac`);
|
||||
const dmgName = `${name}_${tauriConf.package.version}_universal.dmg`;
|
||||
let dmgName;
|
||||
if (options.multi_arch) {
|
||||
yield shellExec(`cd ${npmDirectory} && npm install && npm run build:mac`);
|
||||
dmgName = `${name}_${tauriConf.package.version}_universal.dmg`;
|
||||
}
|
||||
else {
|
||||
yield shellExec(`cd ${npmDirectory} && npm install && npm run build`);
|
||||
let arch;
|
||||
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`);
|
||||
yield fs.copyFile(appPath, distPath);
|
||||
@@ -2263,7 +2277,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((url, options) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
yield checkUpdateTips();
|
||||
if (!url) {
|
||||
|
||||
Reference in New Issue
Block a user