diff --git a/CMakeLists.txt b/CMakeLists.txt index 801f39b71..b186375f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -197,7 +197,6 @@ endif() get_directory_property(HAS_PARENT PARENT_DIRECTORY) if (HAS_PARENT) - set(TL_TD_API_TLO ${TL_TD_API_TLO} PARENT_SCOPE) # was used in standalone binding generators set(TL_TD_JSON_AUTO ${TL_TD_JSON_AUTO_SOURCE} PARENT_SCOPE) # used in tdbot set(TD_TEST_SOURCE ${TD_TEST_SOURCE} PARENT_SCOPE) # used to build tests endif() diff --git a/td/generate/CMakeLists.txt b/td/generate/CMakeLists.txt index adbaa2660..f7a93d8f6 100644 --- a/td/generate/CMakeLists.txt +++ b/td/generate/CMakeLists.txt @@ -6,6 +6,7 @@ endif() file(MAKE_DIRECTORY auto/td/telegram) file(MAKE_DIRECTORY auto/td/mtproto) +file(MAKE_DIRECTORY auto/tlo) set(TL_TD_AUTO_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/auto PARENT_SCOPE) @@ -37,9 +38,6 @@ set(TL_TD_JSON_AUTO_SOURCE PARENT_SCOPE ) -set(TL_TD_API_TLO ${CMAKE_CURRENT_SOURCE_DIR}/scheme/td_api.tlo) -set(TL_TD_API_TLO ${TL_TD_API_TLO} PARENT_SCOPE) - set(TL_C_AUTO_SOURCE ${TD_AUTO_INCLUDE_DIR}/telegram/td_tdc_api.cpp ${TD_AUTO_INCLUDE_DIR}/telegram/td_tdc_api.h @@ -106,13 +104,25 @@ if (NOT CMAKE_CROSSCOMPILING) set(GENERATE_COMMON_CMD generate_common) endif() + add_subdirectory(tl-parser) + + add_custom_target(tl_generate_tlo + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMAND tl-parser -e auto/tlo/mtproto_api.tlo scheme/mtproto_api.tl + COMMAND tl-parser -e auto/tlo/secret_api.tlo scheme/secret_api.tl + COMMAND tl-parser -e auto/tlo/td_api.tlo scheme/td_api.tl + COMMAND tl-parser -e auto/tlo/telegram_api.tlo scheme/telegram_api.tl + COMMENT "Generate tlo files" + DEPENDS tl-parser scheme/mtproto_api.tl scheme/secret_api.tl scheme/td_api.tl scheme/telegram_api.tl + ) + 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} COMMAND ${GENERATE_COMMON_CMD} - COMMENT "Generate common tl source files" - DEPENDS generate_common scheme/mtproto_api.tlo scheme/telegram_api.tlo scheme/secret_api.tlo ${TL_TD_API_TLO} DoxygenTlDocumentationGenerator.php + COMMENT "Generate common TL source files" + DEPENDS generate_common tl_generate_tlo auto/tlo/mtproto_api.tlo auto/tlo/secret_api.tlo auto/tlo/td_api.tlo auto/tlo/telegram_api.tlo scheme/td_api.tl DoxygenTlDocumentationGenerator.php ) if (TD_ENABLE_JNI) target_compile_definitions(generate_common PRIVATE TD_ENABLE_JNI=1) @@ -126,8 +136,8 @@ if (NOT CMAKE_CROSSCOMPILING) add_custom_target(tl_generate_c WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND generate_c - COMMENT "Generate C tl source files" - DEPENDS generate_c ${TL_TD_API_TLO} + COMMENT "Generate C TL source files" + DEPENDS generate_c tl_generate_tlo auto/tlo/td_api.tlo scheme/td_api.tl ) add_executable(td_generate_java_api ${TL_GENERATE_JAVA_SOURCE}) @@ -138,30 +148,30 @@ if (NOT CMAKE_CROSSCOMPILING) add_custom_target(tl_generate_json WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND generate_json - COMMENT "Generate JSON tl source files" - DEPENDS generate_json ${TL_TD_API_TLO} + COMMENT "Generate JSON TL source files" + DEPENDS generate_json tl_generate_tlo auto/tlo/td_api.tlo scheme/td_api.tl ) if (TD_ENABLE_JNI) install(TARGETS td_generate_java_api RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") install(FILES JavadocTlDocumentationGenerator.php TlDocumentationGenerator.php DESTINATION "${CMAKE_INSTALL_BINDIR}/td/generate") - install(FILES scheme/td_api.tlo scheme/td_api.tl DESTINATION "${CMAKE_INSTALL_BINDIR}/td/generate/scheme") + install(FILES auto/tlo/td_api.tlo scheme/td_api.tl DESTINATION "${CMAKE_INSTALL_BINDIR}/td/generate/scheme") endif() if (TD_ENABLE_DOTNET) if (PHP_EXECUTABLE) - set(GENERATE_DOTNET_API_CMD td_generate_dotnet_api ${TL_TD_API_TLO} && ${PHP_EXECUTABLE} DotnetTlDocumentationGenerator.php scheme/td_api.tl auto/td/telegram/TdDotNetApi.h) + set(GENERATE_DOTNET_API_CMD td_generate_dotnet_api ${CMAKE_CURRENT_SOURCE_DIR}/auto/tlo/td_api.tlo && ${PHP_EXECUTABLE} DotnetTlDocumentationGenerator.php scheme/td_api.tl auto/td/telegram/TdDotNetApi.h) else() - set(GENERATE_DOTNET_API_CMD td_generate_dotnet_api ${TL_TD_API_TLO}) + set(GENERATE_DOTNET_API_CMD td_generate_dotnet_api ${CMAKE_CURRENT_SOURCE_DIR}/auto/tlo/td_api.tlo) endif() 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} - COMMAND ${GENERATE_DOTNET_API_CMD} ${TL_TD_API_TLO} + COMMAND ${GENERATE_DOTNET_API_CMD} COMMENT "Generate .NET API files" - DEPENDS td_generate_dotnet_api ${TL_TD_API_TLO} DotnetTlDocumentationGenerator.php + DEPENDS td_generate_dotnet_api tl_generate_tlo auto/tlo/td_api.tlo scheme/td_api.tl DotnetTlDocumentationGenerator.php ) endif() diff --git a/td/generate/generate_c.cpp b/td/generate/generate_c.cpp index ac38a2df7..01831e72d 100644 --- a/td/generate/generate_c.cpp +++ b/td/generate/generate_c.cpp @@ -10,7 +10,7 @@ #include "td/tl/tl_generate.h" int main() { - td::tl::tl_config config_td = td::tl::read_tl_config_from_file("scheme/td_api.tlo"); + 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, "#include \"td/telegram/td_api.h\"\n")); td::tl::write_tl_to_file(config_td, "auto/td/telegram/td_tdc_api_inner.h", diff --git a/td/generate/generate_common.cpp b/td/generate/generate_common.cpp index 11f507138..8fcdc8e2c 100644 --- a/td/generate/generate_common.cpp +++ b/td/generate/generate_common.cpp @@ -22,7 +22,7 @@ static void generate_cpp(const std::string &directory, const std::string &tl_nam const std::string &bytes_type, const std::vector &ext_cpp_includes, const std::vector &ext_h_includes) { std::string path = directory + "/" + tl_name; - td::tl::tl_config config = td::tl::read_tl_config_from_file("scheme/" + tl_name + ".tlo"); + td::tl::tl_config config = td::tl::read_tl_config_from_file("auto/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)); diff --git a/td/generate/generate_json.cpp b/td/generate/generate_json.cpp index 993fa2933..b1e47add3 100644 --- a/td/generate/generate_json.cpp +++ b/td/generate/generate_json.cpp @@ -10,6 +10,6 @@ #include "td/tl/tl_generate.h" int main() { - td::gen_json_converter(td::tl::read_tl_config_from_file("scheme/td_api.tlo"), "td/telegram/td_api_json", + td::gen_json_converter(td::tl::read_tl_config_from_file("auto/tlo/td_api.tlo"), "td/telegram/td_api_json", td::tl::TL_writer::Server); } diff --git a/td/generate/scheme/mtproto_api.tlo b/td/generate/scheme/mtproto_api.tlo deleted file mode 100644 index 2e00490e5..000000000 Binary files a/td/generate/scheme/mtproto_api.tlo and /dev/null differ diff --git a/td/generate/scheme/secret_api.tlo b/td/generate/scheme/secret_api.tlo deleted file mode 100644 index d265dbfc9..000000000 Binary files a/td/generate/scheme/secret_api.tlo and /dev/null differ diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo deleted file mode 100644 index e594e6fd1..000000000 Binary files a/td/generate/scheme/td_api.tlo and /dev/null differ diff --git a/td/generate/scheme/telegram_api.tlo b/td/generate/scheme/telegram_api.tlo deleted file mode 100644 index 4c7daf5e9..000000000 Binary files a/td/generate/scheme/telegram_api.tlo and /dev/null differ diff --git a/td/generate/scheme/update-tlo.sh b/td/generate/scheme/update-tlo.sh deleted file mode 100755 index cfcb71f35..000000000 --- a/td/generate/scheme/update-tlo.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -cd $(dirname $0) -tl-parser -e td_api.tlo td_api.tl -tl-parser -e telegram_api.tlo telegram_api.tl -tl-parser -e mtproto_api.tlo mtproto_api.tl -tl-parser -e secret_api.tlo secret_api.tl