• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd.
3* Licensed under the Apache License, Version 2.0 (the "License");
4* you may not use this file except in compliance with the License.
5* You may obtain a copy of the License at
6*
7* http://www.apache.org/licenses/LICENSE-2.0
8*
9* Unless required by applicable law or agreed to in writing, software
10* distributed under the License is distributed on an "AS IS" BASIS,
11* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12* See the License for the specific language governing permissions and
13* limitations under the License.
14*/
15const path = require("path");
16const stdio = require("stdio");
17const { AnalyzeCMake } = require("./src/analyze_cmake");
18const { AnalyzeMake } = require("./src/analyze_make");
19const { GenerateGn } = require("./src/generate_gn");
20const { Logger } = require("./src/logger");
21const { Tool } = require("./src/tool");
22
23if (process.execPath.endsWith("node") || process.execPath.endsWith("node.exe")) {
24    Tool.CURRENT_TOOL_PATH = __dirname;//工具目录,用来找到res内资源
25}
26else {
27    Tool.CURRENT_TOOL_PATH = path.parse(process.execPath).dir;
28}
29
30if (Tool.MOCK_TYPE == Tool.MOCK_ENUM.MOCK_RUN) {
31    GenerateGn.mockGenerate();//通过mock数据运行
32}
33
34let ops = stdio.getopt({
35    'type': { key: 't', args: 1, description: "", default: "cmake" },
36    'filename': {
37        key: 'f', args: 1,
38        description: "The make file's relative path \
39( third_party/opencv/CMakeLists.txt , make file can be Makefile/CMakeLists.txt)"
40    },
41    'ohos_product_output': {
42        key: 'o', args: 1, description: "ohos product output relative path",
43        default: "out/rk3568"
44    },
45    'ohos_project_path': { key: 'p', args: 1, description: "ohos project path ( /home/xxx/ohos_project )" },
46    'cmake_args': { key: 'a', args: 1, description: "like: (-DABC,-DQWE)", default: "" },
47    'subsystem_name': { key: 's', args: 1, description: "subsystem", default: "test_subsystem" },
48    'part_name': { key: 'm', args: 1, description: "part", default: "test_part" },
49    'porting_to': { key: 'd', args: 1, description: "porting to", default: "" },
50});
51
52Tool.OHOS_PROJECT_PATH = ops.ohos_project_path;
53
54Tool.OHOS_PORTING_TO = ops.porting_to;
55
56Tool.OHOS_PRODUCT_OUTPUT_PATH = ops.ohos_product_output;
57
58Tool.OHOS_SUBSYSTEM_NAME = ops.subsystem_name;
59Tool.OHOS_PART_NAME = ops.part_name;
60
61//需要对参数做一些正确性判断
62
63let compileFile = path.parse(path.join(Tool.OHOS_PROJECT_PATH, ops.filename));
64
65if (ops.type == "cmake") {//cmake
66    AnalyzeCMake.analyze(compileFile, ops.cmake_args.substring(1, ops.cmake_args.length - 1));
67}
68else if (ops.type == "make") {//make
69    AnalyzeMake.analyze(compileFile);
70}
71else {
72    Logger.err("not support " + ops.filename);
73}
74