• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3# Copyright (C) 2023 Huawei Device Co., Ltd.
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#     http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16import os
17import subprocess
18import sys
19import platform
20
21THIS_DIR = os.path.dirname(os.path.abspath(__file__))
22PROJECT_TOP = os.path.realpath(os.path.join(THIS_DIR, ".."))
23TAIL_DIR = "."
24
25if "developtools" in sys.argv[3]:
26    TAIL_DIR = "developtools/profiler"
27    PROJECT_TOP = os.path.realpath(os.path.join(THIS_DIR, ".."))
28
29OHOS_X64_OUT = os.path.join(PROJECT_TOP, sys.argv[2])
30LIBCXX_X64_OUT = os.path.join(PROJECT_TOP, sys.argv[1], "ndk/libcxx/linux_x86_64")
31SUBSYS_X64_OUT = os.path.join(PROJECT_TOP, sys.argv[2], TAIL_DIR)
32PROTOC_NAME = "protoc"
33PROTOCREADER_PLUGIN = "protoreader_plugin"
34current_os = platform.system()
35if current_os == "Windows":
36    PROTOC_NAME = "protoc.exe"
37    PROTOCREADER_PLUGIN = "protoreader_plugin.exe"
38PROTOC = os.path.join(PROJECT_TOP, sys.argv[2], TAIL_DIR, PROTOC_NAME)
39OPT_PLUGIN_PROTOREADER_PATH = os.path.join(PROJECT_TOP, sys.argv[2], TAIL_DIR, PROTOCREADER_PLUGIN)
40OPT_PLUGIN_PROTOREADER = "--plugin=protoc-gen-plugin=" + os.path.join(PROJECT_TOP, sys.argv[2], TAIL_DIR, PROTOCREADER_PLUGIN)
41PLUGINOUT = "--plugin_out=wrapper_namespace=ProtoReader"
42
43PARAMS = sys.argv[1:]
44print("PARAMS =", PARAMS)
45PARAMS_FILTER = " ".join(sys.argv[1:4])
46
47PARAMS_SRC = " ".join(PARAMS).replace(PARAMS_FILTER, "")
48PARAMS_ALL = f"{PARAMS_SRC}"
49
50if not sys.argv[4].startswith("--plugin"):
51    if os.path.isfile(OPT_PLUGIN_PROTOREADER_PATH):
52        cmd=[PROTOC, OPT_PLUGIN_PROTOREADER, f"{PLUGINOUT}:{sys.argv[5]}", *PARAMS_ALL.split()]
53        print("执行参数:--------------- ", cmd, " --------------------------")
54        subprocess.run(cmd)
55subprocess.run([PROTOC, *PARAMS_ALL.split()])
56