Add the multi_arch parameter of the master branch to the pake-cli
This commit is contained in:
36
bin/README.md
vendored
36
bin/README.md
vendored
@@ -128,4 +128,40 @@ url 为你需要打包的网页链接 🔗或者本地html文件,必须提供
|
||||
|
||||
```shell
|
||||
--copy-iter-file
|
||||
```
|
||||
|
||||
|
||||
#### [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
|
||||
# 或者
|
||||
-m
|
||||
```
|
||||
|
||||
#### [targets]
|
||||
|
||||
选择输出的包格式,支持deb/appimage/all,如果选择all,则同时打包deb和appimage,该选项仅支持Linux,默认为`all`。
|
||||
|
||||
```shell
|
||||
--targets xxx
|
||||
```
|
||||
36
bin/README_EN.md
vendored
36
bin/README_EN.md
vendored
@@ -128,3 +128,39 @@ Recursive copy, when the url is a local file path, if this option is enabled, th
|
||||
```shell
|
||||
--copy-iter-file
|
||||
```
|
||||
|
||||
|
||||
#### [multi-arch]
|
||||
|
||||
Package results support both Intel and m1 chips, only for MacOS. The default is `false`.
|
||||
|
||||
```shell
|
||||
--targets xxx
|
||||
```
|
||||
|
||||
##### 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
|
||||
# or
|
||||
-m
|
||||
```
|
||||
|
||||
#### [targets]
|
||||
|
||||
Select the output package format, support deb/appimage/all, if all is selected, deb and appimage will be packaged at the same time, this option only supports Linux, the default is `all`.
|
||||
|
||||
35
bin/builders/MacBuilder.ts
vendored
35
bin/builders/MacBuilder.ts
vendored
@@ -39,16 +39,21 @@ export default class MacBuilder implements IBuilder {
|
||||
const { name } = options;
|
||||
|
||||
await mergeTauriConfig(url, options, tauriConf);
|
||||
|
||||
const _ = await shellExec(`cd ${npmDirectory} && npm install && npm run build`);
|
||||
let arch = "x64";
|
||||
if (process.arch === "arm64") {
|
||||
arch = "aarch64";
|
||||
let dmgName: string;
|
||||
if (options.multiArch) {
|
||||
await shellExec(`cd "${npmDirectory}" && npm install --verbose && npm run build:mac`);
|
||||
dmgName = `${name}_${tauriConf.package.version}_universal.dmg`;
|
||||
} else {
|
||||
arch = process.arch;
|
||||
await shellExec(`cd "${npmDirectory}" && npm install --verbose && npm run build`);
|
||||
let arch = "x64";
|
||||
if (process.arch === "arm64") {
|
||||
arch = "aarch64";
|
||||
} else {
|
||||
arch = process.arch;
|
||||
}
|
||||
dmgName = `${name}_${tauriConf.package.version}_${arch}.dmg`;
|
||||
}
|
||||
const dmgName = `${name}_${tauriConf.package.version}_${arch}.dmg`;
|
||||
const appPath = this.getBuildedAppPath(npmDirectory, dmgName);
|
||||
const appPath = this.getBuildAppPath(npmDirectory, dmgName, options.multiArch);
|
||||
const distPath = path.resolve(`${name}.dmg`);
|
||||
await fs.copyFile(appPath, distPath);
|
||||
await fs.unlink(appPath);
|
||||
@@ -57,11 +62,13 @@ export default class MacBuilder implements IBuilder {
|
||||
logger.success('You can find the app installer in', distPath);
|
||||
}
|
||||
|
||||
getBuildedAppPath(npmDirectory: string, dmgName: string) {
|
||||
return path.join(
|
||||
npmDirectory,
|
||||
'src-tauri/target/release/bundle/dmg',
|
||||
dmgName
|
||||
);
|
||||
getBuildAppPath(npmDirectory: string, dmgName: string, multiArch: boolean) {
|
||||
let dmgPath: string;
|
||||
if (multiArch) {
|
||||
dmgPath = 'src-tauri/target/universal-apple-darwin/release/bundle/dmg';
|
||||
} else {
|
||||
dmgPath = 'src-tauri/target/release/bundle/dmg';
|
||||
}
|
||||
return path.join(npmDirectory, dmgPath, dmgName);
|
||||
}
|
||||
}
|
||||
|
||||
8
bin/cli.ts
vendored
8
bin/cli.ts
vendored
@@ -30,10 +30,16 @@ program
|
||||
.option('--iter-copy-file',
|
||||
'copy all static file to pake app when url is a local file',
|
||||
DEFAULT_PAKE_OPTIONS.iterCopyFile)
|
||||
.option(
|
||||
'-m, --multi-arch',
|
||||
"available for Mac only, and supports both Intel and M1",
|
||||
DEFAULT_PAKE_OPTIONS.multiArch
|
||||
)
|
||||
.option(
|
||||
'--targets <string>',
|
||||
'only for linux, default is "deb", option "appaimge" or "all"(deb & appimage)',
|
||||
DEFAULT_PAKE_OPTIONS.targets)
|
||||
DEFAULT_PAKE_OPTIONS.targets
|
||||
)
|
||||
.option('--debug', 'debug', DEFAULT_PAKE_OPTIONS.transparent)
|
||||
.action(async (url: string, options: PakeCliOptions) => {
|
||||
checkUpdateTips();
|
||||
|
||||
1
bin/defaults.ts
vendored
1
bin/defaults.ts
vendored
@@ -10,6 +10,7 @@ export const DEFAULT_PAKE_OPTIONS: PakeCliOptions = {
|
||||
userAgent: '',
|
||||
showMenu: false,
|
||||
showSystemTray: false,
|
||||
multiArch: false,
|
||||
targets: 'deb',
|
||||
iterCopyFile: false,
|
||||
systemTrayIcon: '',
|
||||
|
||||
3
bin/types.ts
vendored
3
bin/types.ts
vendored
@@ -35,6 +35,9 @@ export interface PakeCliOptions {
|
||||
// /** 递归拷贝,当url为本地文件路径时候,若开启该选项,则将url路径文件所在文件夹以及所有子文件都拷贝到pake静态文件夹,默认不开启 */
|
||||
iterCopyFile: false;
|
||||
|
||||
/** mutli arch, Supports both Intel and m1 chips, only for Mac */
|
||||
multiArch: boolean;
|
||||
|
||||
// 包输出产物,对linux用户有效,默认为deb,可选appimage, 或者all(即同时输出deb和all);
|
||||
targets: string;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user