mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-20 23:52:40 +08:00
d375996c3d
* 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
61 lines
1.5 KiB
TypeScript
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();
|