xref: /base/update/packaging_tools/code_yacc.py (revision 40681896)
140681896Sopenharmony_ci#!/usr/bin/env python3
240681896Sopenharmony_ci# -*- coding: utf-8 -*-
340681896Sopenharmony_ci
440681896Sopenharmony_ci# Copyright (c) 2021 Huawei Device Co., Ltd.
540681896Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
640681896Sopenharmony_ci# you may not use this file except in compliance with the License.
740681896Sopenharmony_ci# You may obtain a copy of the License at
840681896Sopenharmony_ci#
940681896Sopenharmony_ci# http://www.apache.org/licenses/LICENSE-2.0
1040681896Sopenharmony_ci#
1140681896Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software
1240681896Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
1340681896Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1440681896Sopenharmony_ci# See the License for the specific language governing permissions and
1540681896Sopenharmony_ci# limitations under the License.
1640681896Sopenharmony_ci
1740681896Sopenharmony_ciimport optparse
1840681896Sopenharmony_ciimport subprocess
1940681896Sopenharmony_ci
2040681896Sopenharmony_ciif __name__ == '__main__':
2140681896Sopenharmony_ci    print("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^")
2240681896Sopenharmony_ci    parser_obj = optparse.OptionParser()
2340681896Sopenharmony_ci    parser_obj.add_option("--scriptname",
2440681896Sopenharmony_ci                      help="generate yacc script name",
2540681896Sopenharmony_ci                      action="store_true", default=True)
2640681896Sopenharmony_ci    parser_obj.add_option("--output",
2740681896Sopenharmony_ci                      help="yacc output path",
2840681896Sopenharmony_ci                      action="store_true", default="")
2940681896Sopenharmony_ci    (option_list, parse_params) = parser_obj.parse_args()
3040681896Sopenharmony_ci
3140681896Sopenharmony_ci    if len(parse_params) < 1:
3240681896Sopenharmony_ci        parser_obj.error("yacc param error.")
3340681896Sopenharmony_ci
3440681896Sopenharmony_ci    gen_script_name = parse_params[0]
3540681896Sopenharmony_ci    output_path = parse_params[1]
3640681896Sopenharmony_ci    parse_scripts = subprocess.check_call(
3740681896Sopenharmony_ci        [gen_script_name], stdout=subprocess.PIPE, cwd=output_path)
3840681896Sopenharmony_ci    print("result:", parse_scripts)
39