Include file normalization

This commit is contained in:
Ruben Perez 2022-10-11 12:19:18 +02:00
parent 4d57d2db08
commit 996172dc3a
26 changed files with 97 additions and 92 deletions

View File

@ -7,7 +7,7 @@
//[example_metadata
#include "boost/mysql/connection.hpp"
#include <boost/mysql/connection.hpp>
#include <boost/asio/ssl/context.hpp>
#include <boost/mysql.hpp>
#include <boost/asio/io_context.hpp>

View File

@ -7,8 +7,8 @@
//[example_query_async_callbacks
#include "boost/mysql/connection.hpp"
#include "boost/mysql/error.hpp"
#include <boost/mysql/connection.hpp>
#include <boost/mysql/error.hpp>
#include <boost/asio/ssl/context.hpp>
#include <boost/mysql.hpp>
#include <boost/asio/io_context.hpp>

View File

@ -5,7 +5,7 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#include "boost/mysql/connection.hpp"
#include <boost/mysql/connection.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/asio/ssl/context.hpp>
#include <boost/mysql.hpp>

View File

@ -5,7 +5,7 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#include "boost/mysql/detail/protocol/constants.hpp"
#include <boost/mysql/detail/protocol/constants.hpp>
#include "integration_test_common.hpp"
#include "network_test.hpp"

View File

@ -5,7 +5,7 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#include "boost/mysql/tcp.hpp"
#include <boost/mysql/tcp.hpp>
#include "tcp_network_fixture.hpp"
#include "metadata_validator.hpp"
#include "test_common.hpp"

View File

@ -9,7 +9,7 @@
#include <boost/asio/ssl/verify_mode.hpp>
#include <boost/mysql/handshake_params.hpp>
#include <boost/mysql/tcp_ssl.hpp>
#include "boost/mysql/errc.hpp"
#include <boost/mysql/errc.hpp>
#include "er_network_variant.hpp"
#include "get_endpoint.hpp"
#include "integration_test_common.hpp"

View File

@ -9,8 +9,8 @@
#include <boost/mysql/connection.hpp>
#include <boost/test/tools/interface.hpp>
#include <boost/test/unit_test_suite.hpp>
#include "boost/mysql/handshake_params.hpp"
#include "boost/mysql/errc.hpp"
#include <boost/mysql/handshake_params.hpp>
#include <boost/mysql/errc.hpp>
#include "integration_test_common.hpp"
using namespace boost::mysql::test;

View File

@ -8,7 +8,7 @@
#ifndef BOOST_MYSQL_TEST_INTEGRATION_UTILS_INCLUDE_ER_CONNECTION_HPP
#define BOOST_MYSQL_TEST_INTEGRATION_UTILS_INCLUDE_ER_CONNECTION_HPP
#include "boost/mysql/error.hpp"
#include <boost/mysql/error.hpp>
#include "network_result.hpp"
#include "er_endpoint.hpp"
#include "er_resultset.hpp"

View File

@ -12,7 +12,7 @@
#include <boost/asio/io_context.hpp>
#include <boost/test/unit_test.hpp>
#include <thread>
#include "boost/mysql/handshake_params.hpp"
#include <boost/mysql/handshake_params.hpp>
#include "test_common.hpp"
#include "metadata_validator.hpp"
#include "network_test.hpp"

View File

@ -14,12 +14,12 @@
#include "er_impl_common.hpp"
#include "get_endpoint.hpp"
#include "handler_call_tracker.hpp"
#include "boost/mysql/handshake_params.hpp"
#include "boost/mysql/errc.hpp"
#include "boost/mysql/error.hpp"
#include "boost/mysql/execute_params.hpp"
#include "boost/mysql/statement_base.hpp"
#include "boost/mysql/row.hpp"
#include <boost/mysql/handshake_params.hpp>
#include <boost/mysql/errc.hpp>
#include <boost/mysql/error.hpp>
#include <boost/mysql/execute_params.hpp>
#include <boost/mysql/statement_base.hpp>
#include <boost/mysql/row.hpp>
#include <boost/mysql/resultset_base.hpp>
#include <boost/mysql/connection.hpp>
#include <memory>

View File

@ -14,12 +14,12 @@
#include "er_impl_common.hpp"
#include "get_endpoint.hpp"
#include "handler_call_tracker.hpp"
#include "boost/mysql/handshake_params.hpp"
#include "boost/mysql/errc.hpp"
#include "boost/mysql/error.hpp"
#include "boost/mysql/execute_params.hpp"
#include "boost/mysql/statement_base.hpp"
#include "boost/mysql/row.hpp"
#include <boost/mysql/handshake_params.hpp>
#include <boost/mysql/errc.hpp>
#include <boost/mysql/error.hpp>
#include <boost/mysql/execute_params.hpp>
#include <boost/mysql/statement_base.hpp>
#include <boost/mysql/row.hpp>
#include <boost/mysql/resultset_base.hpp>
#include <boost/mysql/connection.hpp>
#include <memory>

View File

@ -14,12 +14,12 @@
#include "er_impl_common.hpp"
#include "get_endpoint.hpp"
#include "handler_call_tracker.hpp"
#include "boost/mysql/handshake_params.hpp"
#include "boost/mysql/errc.hpp"
#include "boost/mysql/error.hpp"
#include "boost/mysql/execute_params.hpp"
#include "boost/mysql/statement_base.hpp"
#include "boost/mysql/row.hpp"
#include <boost/mysql/handshake_params.hpp>
#include <boost/mysql/errc.hpp>
#include <boost/mysql/error.hpp>
#include <boost/mysql/execute_params.hpp>
#include <boost/mysql/statement_base.hpp>
#include <boost/mysql/row.hpp>
#include <boost/mysql/resultset_base.hpp>
#include <boost/mysql/connection.hpp>
#include <boost/asio/spawn.hpp>

View File

@ -15,12 +15,12 @@
#include "er_impl_common.hpp"
#include "get_endpoint.hpp"
#include "handler_call_tracker.hpp"
#include "boost/mysql/handshake_params.hpp"
#include "boost/mysql/errc.hpp"
#include "boost/mysql/error.hpp"
#include "boost/mysql/execute_params.hpp"
#include "boost/mysql/statement_base.hpp"
#include "boost/mysql/row.hpp"
#include <boost/mysql/handshake_params.hpp>
#include <boost/mysql/errc.hpp>
#include <boost/mysql/error.hpp>
#include <boost/mysql/execute_params.hpp>
#include <boost/mysql/statement_base.hpp>
#include <boost/mysql/row.hpp>
#include <boost/mysql/resultset_base.hpp>
#include <boost/mysql/connection.hpp>
#include <boost/asio/co_spawn.hpp>

View File

@ -14,12 +14,12 @@
#include "er_impl_common.hpp"
#include "get_endpoint.hpp"
#include "handler_call_tracker.hpp"
#include "boost/mysql/handshake_params.hpp"
#include "boost/mysql/errc.hpp"
#include "boost/mysql/error.hpp"
#include "boost/mysql/execute_params.hpp"
#include "boost/mysql/statement_base.hpp"
#include "boost/mysql/row.hpp"
#include <boost/mysql/handshake_params.hpp>
#include <boost/mysql/errc.hpp>
#include <boost/mysql/error.hpp>
#include <boost/mysql/execute_params.hpp>
#include <boost/mysql/statement_base.hpp>
#include <boost/mysql/row.hpp>
#include <boost/mysql/resultset_base.hpp>
#include <boost/mysql/connection.hpp>
#include <memory>

View File

@ -14,12 +14,12 @@
#include "er_impl_common.hpp"
#include "get_endpoint.hpp"
#include "handler_call_tracker.hpp"
#include "boost/mysql/handshake_params.hpp"
#include "boost/mysql/errc.hpp"
#include "boost/mysql/error.hpp"
#include "boost/mysql/execute_params.hpp"
#include "boost/mysql/statement_base.hpp"
#include "boost/mysql/row.hpp"
#include <boost/mysql/handshake_params.hpp>
#include <boost/mysql/errc.hpp>
#include <boost/mysql/error.hpp>
#include <boost/mysql/execute_params.hpp>
#include <boost/mysql/statement_base.hpp>
#include <boost/mysql/row.hpp>
#include <boost/mysql/resultset_base.hpp>
#include <boost/mysql/connection.hpp>
#include <memory>

View File

@ -8,8 +8,8 @@
#ifndef BOOST_MYSQL_TEST_INTEGRATION_UTILS_SRC_ER_IMPL_COMMON_HPP
#define BOOST_MYSQL_TEST_INTEGRATION_UTILS_SRC_ER_IMPL_COMMON_HPP
#include "boost/mysql/error.hpp"
#include "boost/mysql/statement_base.hpp"
#include <boost/mysql/error.hpp>
#include <boost/mysql/statement_base.hpp>
#include "er_connection.hpp"
#include "er_network_variant.hpp"
#include "er_resultset.hpp"

View File

@ -13,12 +13,12 @@
#include "streams.hpp"
#include "er_impl_common.hpp"
#include "get_endpoint.hpp"
#include "boost/mysql/handshake_params.hpp"
#include "boost/mysql/errc.hpp"
#include "boost/mysql/error.hpp"
#include "boost/mysql/execute_params.hpp"
#include "boost/mysql/statement_base.hpp"
#include "boost/mysql/row.hpp"
#include <boost/mysql/handshake_params.hpp>
#include <boost/mysql/errc.hpp>
#include <boost/mysql/error.hpp>
#include <boost/mysql/execute_params.hpp>
#include <boost/mysql/statement_base.hpp>
#include <boost/mysql/row.hpp>
#include <boost/mysql/resultset_base.hpp>
#include <boost/mysql/connection.hpp>
#include <memory>

View File

@ -13,12 +13,12 @@
#include "streams.hpp"
#include "er_impl_common.hpp"
#include "get_endpoint.hpp"
#include "boost/mysql/handshake_params.hpp"
#include "boost/mysql/errc.hpp"
#include "boost/mysql/error.hpp"
#include "boost/mysql/execute_params.hpp"
#include "boost/mysql/statement_base.hpp"
#include "boost/mysql/row.hpp"
#include <boost/mysql/handshake_params.hpp>
#include <boost/mysql/errc.hpp>
#include <boost/mysql/error.hpp>
#include <boost/mysql/execute_params.hpp>
#include <boost/mysql/statement_base.hpp>
#include <boost/mysql/row.hpp>
#include <boost/mysql/resultset_base.hpp>
#include <boost/mysql/connection.hpp>
#include <memory>

View File

@ -12,8 +12,8 @@
#include <boost/test/unit_test.hpp>
#include <boost/test/unit_test_suite.hpp>
#include <boost/mysql/detail/channel/message_reader.hpp>
#include "boost/mysql/errc.hpp"
#include "boost/mysql/error.hpp"
#include <boost/mysql/errc.hpp>
#include <boost/mysql/error.hpp>
#include "assert_buffer_equals.hpp"
#include "test_stream.hpp"
#include "create_message.hpp"

View File

@ -6,10 +6,10 @@
//
#include <boost/mysql/detail/network_algorithms/read_all_rows.hpp>
#include "boost/mysql/detail/protocol/resultset_encoding.hpp"
#include "boost/mysql/error.hpp"
#include "boost/mysql/resultset_base.hpp"
#include "boost/mysql/row_view.hpp"
#include <boost/mysql/detail/protocol/resultset_encoding.hpp>
#include <boost/mysql/error.hpp>
#include <boost/mysql/resultset_base.hpp>
#include <boost/mysql/row_view.hpp>
#include <boost/asio/buffer.hpp>
#include <boost/asio/bind_executor.hpp>
#include <boost/asio/io_context.hpp>

View File

@ -6,10 +6,10 @@
//
#include <boost/mysql/detail/network_algorithms/read_one_row.hpp>
#include "boost/mysql/detail/protocol/resultset_encoding.hpp"
#include "boost/mysql/error.hpp"
#include "boost/mysql/resultset_base.hpp"
#include "boost/mysql/row_view.hpp"
#include <boost/mysql/detail/protocol/resultset_encoding.hpp>
#include <boost/mysql/error.hpp>
#include <boost/mysql/resultset_base.hpp>
#include <boost/mysql/row_view.hpp>
#include <boost/asio/buffer.hpp>
#include <boost/asio/bind_executor.hpp>
#include <boost/asio/io_context.hpp>

View File

@ -6,10 +6,10 @@
//
#include <boost/mysql/detail/network_algorithms/read_some_rows.hpp>
#include "boost/mysql/detail/protocol/resultset_encoding.hpp"
#include "boost/mysql/error.hpp"
#include "boost/mysql/resultset_base.hpp"
#include "boost/mysql/row_view.hpp"
#include <boost/mysql/detail/protocol/resultset_encoding.hpp>
#include <boost/mysql/error.hpp>
#include <boost/mysql/resultset_base.hpp>
#include <boost/mysql/row_view.hpp>
#include <boost/asio/buffer.hpp>
#include <boost/asio/bind_executor.hpp>
#include <boost/asio/io_context.hpp>

View File

@ -8,15 +8,15 @@
// Tests for both deserialize_binary_row() and deserialize_text_row()
#include <boost/mysql/detail/protocol/deserialize_row.hpp>
#include "boost/mysql/detail/auxiliar/string_view_offset.hpp"
#include "boost/mysql/detail/protocol/capabilities.hpp"
#include "boost/mysql/detail/protocol/common_messages.hpp"
#include "boost/mysql/detail/protocol/constants.hpp"
#include "boost/mysql/detail/protocol/resultset_encoding.hpp"
#include "boost/mysql/error.hpp"
#include "boost/mysql/field_view.hpp"
#include "boost/mysql/metadata.hpp"
#include "boost/mysql/resultset_base.hpp"
#include <boost/mysql/detail/auxiliar/string_view_offset.hpp>
#include <boost/mysql/detail/protocol/capabilities.hpp>
#include <boost/mysql/detail/protocol/common_messages.hpp>
#include <boost/mysql/detail/protocol/constants.hpp>
#include <boost/mysql/detail/protocol/resultset_encoding.hpp>
#include <boost/mysql/error.hpp>
#include <boost/mysql/field_view.hpp>
#include <boost/mysql/metadata.hpp>
#include <boost/mysql/resultset_base.hpp>
#include <boost/test/tools/context.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/asio/buffer.hpp>

View File

@ -9,8 +9,8 @@
#include <boost/mysql/detail/protocol/deserialize_text_field.hpp>
#include <boost/mysql/detail/auxiliar/stringize.hpp>
#include "boost/mysql/detail/auxiliar/string_view_offset.hpp"
#include "boost/mysql/field_view.hpp"
#include <boost/mysql/detail/auxiliar/string_view_offset.hpp>
#include <boost/mysql/field_view.hpp>
#include "test_common.hpp"
#include <boost/test/data/monomorphic/collection.hpp>
#include <boost/test/data/test_case.hpp>

View File

@ -7,10 +7,10 @@
#include <boost/mysql/resultset.hpp>
#include <boost/test/unit_test.hpp>
#include "boost/mysql/detail/protocol/common_messages.hpp"
#include "boost/mysql/detail/protocol/constants.hpp"
#include "boost/mysql/detail/protocol/resultset_encoding.hpp"
#include "boost/mysql/field_type.hpp"
#include <boost/mysql/detail/protocol/common_messages.hpp>
#include <boost/mysql/detail/protocol/constants.hpp>
#include <boost/mysql/detail/protocol/resultset_encoding.hpp>
#include <boost/mysql/field_type.hpp>
#include "create_resultset.hpp"
#include "test_channel.hpp"
#include "test_stream.hpp"

View File

@ -10,6 +10,7 @@ import os
import re
from os import path
from collections import namedtuple
from typing import List
# Script to get file headers (copyright notices
# and include guards) okay and up to date
@ -39,6 +40,7 @@ HEADER_TEMPLATE = '''{begin}
{end}'''
MYSQL_ERROR_HEADER = '/usr/include/mysql/mysqld_error.h'
MYSQL_INCLUDE = re.compile('#include <boost/mysql/(.*)>')
def find_first_blank(lines):
return [i for i, line in enumerate(lines) if line == ''][0]
@ -54,6 +56,9 @@ def write_file(fpath, lines):
def text_to_lines(text):
return [line + '\n' for line in text.split('\n')]
def normalize_includes(lines: List[str]):
return [re.sub(MYSQL_INCLUDE, '#include <boost/mysql/\\1>', line) for line in lines]
def gen_header(linesym, opensym=None, closesym=None, shebang=None, include_guard=None):
opensym = linesym if opensym is None else opensym
closesym = linesym if closesym is None else closesym
@ -75,7 +80,7 @@ class NormalProcessor(object):
def process(self, fpath):
lines = read_file(fpath)
first_blank = find_first_blank(line.replace('\n', '') for line in lines)
lines = self.header + lines[first_blank:]
lines = self.header + normalize_includes(lines[first_blank:])
write_file(fpath, lines)
class HppProcessor(object):
@ -86,7 +91,7 @@ class HppProcessor(object):
first_content = [i for i, line in enumerate(lines) if line.startswith('#define')][0] + 1
iguard = self._gen_include_guard(fpath)
header = gen_header('//', include_guard=iguard)
lines = header + lines[first_content:]
lines = header + normalize_includes(lines[first_content:])
write_file(fpath, lines)