Run TL class generators from auto/ directory.

This commit is contained in:
levlam 2023-06-26 15:33:02 +03:00
parent 496dc3284e
commit 8f9a4dcaa0
6 changed files with 20 additions and 21 deletions

View File

@ -101,7 +101,7 @@ if (NOT CMAKE_CROSSCOMPILING)
endif()
if (PHP_EXECUTABLE AND NOT TD_ENABLE_DOTNET)
set(GENERATE_COMMON_CMD generate_common && ${PHP_EXECUTABLE} DoxygenTlDocumentationGenerator.php scheme/td_api.tl auto/td/telegram/td_api.h)
set(GENERATE_COMMON_CMD generate_common && ${PHP_EXECUTABLE} ../DoxygenTlDocumentationGenerator.php ../scheme/td_api.tl td/telegram/td_api.h)
else()
set(GENERATE_COMMON_CMD generate_common)
endif()
@ -132,7 +132,7 @@ if (NOT CMAKE_CROSSCOMPILING)
add_executable(generate_common ${TL_GENERATE_COMMON_SOURCE})
target_link_libraries(generate_common PRIVATE tdtl)
add_custom_target(tl_generate_common
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/auto
COMMAND ${GENERATE_COMMON_CMD}
COMMENT "Generate common TL source files"
DEPENDS generate_common tl_generate_tlo ${TLO_FILES} ${CMAKE_CURRENT_SOURCE_DIR}/scheme/td_api.tl ${CMAKE_CURRENT_SOURCE_DIR}/DoxygenTlDocumentationGenerator.php
@ -147,7 +147,7 @@ if (NOT CMAKE_CROSSCOMPILING)
add_executable(generate_c ${TL_GENERATE_C_SOURCE})
target_link_libraries(generate_c PRIVATE tdtl)
add_custom_target(tl_generate_c
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/auto
COMMAND generate_c
COMMENT "Generate C TL source files"
DEPENDS generate_c tl_generate_tlo ${TD_API_TLO_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/scheme/td_api.tl
@ -159,7 +159,7 @@ if (NOT CMAKE_CROSSCOMPILING)
add_executable(generate_json ${TL_GENERATE_JSON_SOURCE})
target_link_libraries(generate_json PRIVATE tdtl tdutils)
add_custom_target(tl_generate_json
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/auto
COMMAND generate_json
COMMENT "Generate JSON TL source files"
DEPENDS generate_json tl_generate_tlo ${TD_API_TLO_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/scheme/td_api.tl
@ -173,7 +173,7 @@ if (NOT CMAKE_CROSSCOMPILING)
if (TD_ENABLE_DOTNET)
if (PHP_EXECUTABLE)
set(GENERATE_DOTNET_API_CMD td_generate_dotnet_api ${TD_API_TLO_FILE} && ${PHP_EXECUTABLE} DotnetTlDocumentationGenerator.php scheme/td_api.tl auto/td/telegram/TdDotNetApi.h)
set(GENERATE_DOTNET_API_CMD td_generate_dotnet_api ${TD_API_TLO_FILE} && ${PHP_EXECUTABLE} ../DotnetTlDocumentationGenerator.php ../scheme/td_api.tl td/telegram/TdDotNetApi.h)
else()
set(GENERATE_DOTNET_API_CMD td_generate_dotnet_api ${TD_API_TLO_FILE})
endif()
@ -181,7 +181,7 @@ if (NOT CMAKE_CROSSCOMPILING)
add_executable(td_generate_dotnet_api generate_dotnet.cpp tl_writer_dotnet.h)
target_link_libraries(td_generate_dotnet_api PRIVATE tdtl)
add_custom_target(generate_dotnet_api
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/auto
COMMAND ${GENERATE_DOTNET_API_CMD}
COMMENT "Generate .NET API files"
DEPENDS td_generate_dotnet_api tl_generate_tlo ${TD_API_TLO_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/scheme/td_api.tl ${CMAKE_CURRENT_SOURCE_DIR}/DotnetTlDocumentationGenerator.php

View File

@ -10,8 +10,8 @@
#include "td/tl/tl_generate.h"
int main() {
td::tl::tl_config config_td = td::tl::read_tl_config_from_file("auto/tlo/td_api.tlo");
td::tl::write_tl_to_file(config_td, "auto/td/telegram/td_tdc_api.h", td::TlWriterCCommon("TdApi", 1));
td::tl::write_tl_to_file(config_td, "auto/td/telegram/td_tdc_api_inner.h", td::TlWriterCCommon("TdApi", -1));
td::tl::write_tl_to_file(config_td, "auto/td/telegram/td_tdc_api.cpp", td::TlWriterCCommon("TdApi", 0));
td::tl::tl_config config_td = td::tl::read_tl_config_from_file("tlo/td_api.tlo");
td::tl::write_tl_to_file(config_td, "td/telegram/td_tdc_api.h", td::TlWriterCCommon("TdApi", 1));
td::tl::write_tl_to_file(config_td, "td/telegram/td_tdc_api_inner.h", td::TlWriterCCommon("TdApi", -1));
td::tl::write_tl_to_file(config_td, "td/telegram/td_tdc_api.cpp", td::TlWriterCCommon("TdApi", 0));
}

View File

@ -22,27 +22,27 @@ static void generate_cpp(const std::string &directory, const std::string &tl_nam
const std::string &bytes_type, const std::vector<std::string> &ext_cpp_includes,
const std::vector<std::string> &ext_h_includes) {
std::string path = directory + "/" + tl_name;
td::tl::tl_config config = td::tl::read_tl_config_from_file("auto/tlo/" + tl_name + ".tlo");
td::tl::tl_config config = td::tl::read_tl_config_from_file("tlo/" + tl_name + ".tlo");
td::tl::write_tl_to_file(config, path + ".cpp", WriterCpp(tl_name, string_type, bytes_type, ext_cpp_includes));
td::tl::write_tl_to_file(config, path + ".h", WriterH(tl_name, string_type, bytes_type, ext_h_includes));
td::tl::write_tl_to_file(config, path + ".hpp", WriterHpp(tl_name, string_type, bytes_type));
}
int main() {
generate_cpp<>("auto/td/telegram", "telegram_api", "std::string", "BufferSlice",
generate_cpp<>("td/telegram", "telegram_api", "std::string", "BufferSlice",
{"\"td/tl/tl_object_parse.h\"", "\"td/tl/tl_object_store.h\""}, {"\"td/utils/buffer.h\""});
generate_cpp<>("auto/td/telegram", "secret_api", "std::string", "BufferSlice",
generate_cpp<>("td/telegram", "secret_api", "std::string", "BufferSlice",
{"\"td/tl/tl_object_parse.h\"", "\"td/tl/tl_object_store.h\""}, {"\"td/utils/buffer.h\""});
generate_cpp<>("auto/td/mtproto", "mtproto_api", "Slice", "Slice",
generate_cpp<>("td/mtproto", "mtproto_api", "Slice", "Slice",
{"\"td/tl/tl_object_parse.h\"", "\"td/tl/tl_object_store.h\""},
{"\"td/utils/Slice.h\"", "\"td/utils/UInt.h\""});
#ifdef TD_ENABLE_JNI
generate_cpp<td::TD_TL_writer_jni_cpp, td::TD_TL_writer_jni_h>(
"auto/td/telegram", "td_api", "std::string", "std::string", {"\"td/tl/tl_jni_object.h\""}, {"<string>"});
generate_cpp<td::TD_TL_writer_jni_cpp, td::TD_TL_writer_jni_h>("td/telegram", "td_api", "std::string", "std::string",
{"\"td/tl/tl_jni_object.h\""}, {"<string>"});
#else
generate_cpp<>("auto/td/telegram", "td_api", "std::string", "std::string", {}, {"<string>"});
generate_cpp<>("td/telegram", "td_api", "std::string", "std::string", {}, {"<string>"});
#endif
}

View File

@ -16,7 +16,7 @@ int main(int argc, char *argv[]) {
td::tl::tl_config config_td = td::tl::read_tl_config_from_file(argv[1]);
td::tl::write_tl_to_file(config_td, "auto/td/telegram/TdDotNetApi.cpp",
td::tl::write_tl_to_file(config_td, "td/telegram/TdDotNetApi.cpp",
td::tl::TlWriterDotNet("TdApi", false, "#include \"td/telegram/TdDotNetApi.h\"\n\n"));
td::tl::write_tl_to_file(config_td, "auto/td/telegram/TdDotNetApi.h", td::tl::TlWriterDotNet("TdApi", true, ""));
td::tl::write_tl_to_file(config_td, "td/telegram/TdDotNetApi.h", td::tl::TlWriterDotNet("TdApi", true, ""));
}

View File

@ -10,6 +10,6 @@
#include "td/tl/tl_generate.h"
int main() {
td::gen_json_converter(td::tl::read_tl_config_from_file("auto/tlo/td_api.tlo"), "td/telegram/td_api_json",
td::gen_json_converter(td::tl::read_tl_config_from_file("tlo/td_api.tlo"), "td/telegram/td_api_json",
td::tl::TL_writer::Server);
}

View File

@ -187,7 +187,6 @@ void gen_tl_constructor_from_string(StringBuilder &sb, const tl::simple::Schema
void gen_json_converter_file(const tl::simple::Schema &schema, const std::string &file_name_base, bool is_header,
Mode mode) {
auto file_name = is_header ? file_name_base + ".h" : file_name_base + ".cpp";
file_name = "auto/" + file_name;
auto old_file_content = [&] {
auto r_content = read_file(file_name);
if (r_content.is_error()) {