diff options
| author | Alexandru Croitor <alexandru.croitor@qt.io> | 2025-02-11 13:30:02 +0100 |
|---|---|---|
| committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2025-02-11 16:02:32 +0100 |
| commit | d7a739bde116116ec6cacdb99c3a235705017529 (patch) | |
| tree | 0a3e187bf9833e5902083852257d318cee4d5e0d /util/cmake/json_parser.py | |
| parent | a5d896d70afbdc16c22429dbbb17a3ca0a255239 (diff) | |
CMake: Remove pro2cmake and configurejson2cmake
Most qt repos and modules are now ported from qmake to CMake. The
CMake API for internal Qt modules has evolved, and these tools have
not been kept up-to-date. It's time to remove them. Developers can
still use qmake2cmake for their own user projects, which is hosted in
a different repo.
If we do end up needing the scripts again, they can be used from one
of the older branches like 6.9.
Fixes: QTBUG-133678
Change-Id: I8d9a765f2575a6c0fcfe9a0346a06a7eec302914
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'util/cmake/json_parser.py')
| -rw-r--r-- | util/cmake/json_parser.py | 76 |
1 files changed, 0 insertions, 76 deletions
diff --git a/util/cmake/json_parser.py b/util/cmake/json_parser.py deleted file mode 100644 index f8e0fa6017f..00000000000 --- a/util/cmake/json_parser.py +++ /dev/null @@ -1,76 +0,0 @@ -#!/usr/bin/env python3 -# Copyright (C) 2019 The Qt Company Ltd. -# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 - -import pyparsing as pp # type: ignore -import json -import re -from helper import _set_up_py_parsing_nicer_debug_output - -_set_up_py_parsing_nicer_debug_output(pp) - - -class QMakeSpecificJSONParser: - def __init__(self, *, debug: bool = False) -> None: - self.debug = debug - self.grammar = self.create_py_parsing_grammar() - - def create_py_parsing_grammar(self): - # Keep around all whitespace. - pp.ParserElement.setDefaultWhitespaceChars("") - - def add_element(name: str, value: pp.ParserElement): - nonlocal self - if self.debug: - value.setName(name) - value.setDebug() - return value - - # Our grammar is pretty simple. We want to remove all newlines - # inside quoted strings, to make the quoted strings JSON - # compliant. So our grammar should skip to the first quote while - # keeping everything before it as-is, process the quoted string - # skip to the next quote, and repeat that until the end of the - # file. - - EOF = add_element("EOF", pp.StringEnd()) - SkipToQuote = add_element("SkipToQuote", pp.SkipTo('"')) - SkipToEOF = add_element("SkipToEOF", pp.SkipTo(EOF)) - - def remove_newlines_and_whitespace_in_quoted_string(tokens): - first_string = tokens[0] - replaced_string = re.sub(r"\n[ ]*", " ", first_string) - return replaced_string - - QuotedString = add_element( - "QuotedString", pp.QuotedString(quoteChar='"', multiline=True, unquoteResults=False) - ) - QuotedString.setParseAction(remove_newlines_and_whitespace_in_quoted_string) - - QuotedTerm = add_element("QuotedTerm", pp.Optional(SkipToQuote) + QuotedString) - Grammar = add_element("Grammar", pp.OneOrMore(QuotedTerm) + SkipToEOF) - - return Grammar - - def parse_file_using_py_parsing(self, file: str): - print(f'Pre processing "{file}" using py parsing to remove incorrect newlines.') - try: - with open(file, "r") as file_fd: - contents = file_fd.read() - - parser_result = self.grammar.parseString(contents, parseAll=True) - token_list = parser_result.asList() - joined_string = "".join(token_list) - - return joined_string - except pp.ParseException as pe: - print(pe.line) - print(" " * (pe.col - 1) + "^") - print(pe) - raise pe - - def parse(self, file: str): - pre_processed_string = self.parse_file_using_py_parsing(file) - print(f'Parsing "{file}" using json.loads().') - json_parsed = json.loads(pre_processed_string) - return json_parsed |
