Files
cocos4/scripts/native-pack-tool/source/base/manager.ts
T
媛媛 d375996c3d [3.6.0] init native pack tools (#11175)
* init native pack tool

* compile -> make

* update command line

* update readme

* update android make

* remove some config

* run all platform

* update install

* fix encrypte script

* fix mac/ios create

* update readme

* fix review

* fix run mac

* fix excuteTemplateTask

* remove linux

* update readme

* update
2022-06-08 15:26:02 +08:00

61 lines
1.5 KiB
TypeScript

import { Paths } from "../utils";
import { CocosParams, NativePackTool } from "./default";
export type ISupportPlatform = 'mac-os' | 'mac' | 'ios' | 'android' | 'ohos';
export class NativePackToolManager {
static Paths: Paths;
private PackToolMap: Record<string, NativePackTool> = {};
private getPackTool(platform: string): NativePackTool {
const handler = this.PackToolMap[platform];
if (!handler) {
throw new Error(`No pack tool for platform ${platform}}`);
}
return handler;
}
register(platform: string, tool: NativePackTool) {
this.PackToolMap[platform] = tool;
}
init(params:any) {
const tool = this.getPackTool(params.platform);
tool.init(params);
}
async create(platform: string) {
const tool = this.getPackTool(platform);
if (!tool) {
throw new Error(`No pack tool for platform ${platform}}`);
}
if (!tool.create) {
// TODO Error
return false;
}
await tool.create();
}
async make(platform: string) {
const tool = this.getPackTool(platform);
if (!tool.make) {
return false;
}
await tool.make();
return true;
}
async run(platform: string) {
const tool = this.getPackTool(platform);
if (!tool.run) {
return false;
}
await tool.run();
return true;
}
}
export const nativePackToolMg = new NativePackToolManager();