Add separate tl_generate_mtproto target.
This commit is contained in:
parent
61a879e91a
commit
f013f47e7b
@ -168,13 +168,13 @@ add_subdirectory(tdutils)
|
||||
add_subdirectory(td/generate)
|
||||
|
||||
if (NOT CMAKE_CROSSCOMPILING)
|
||||
add_custom_target(prepare_cross_compiling DEPENDS tl_generate_common tdmime_auto tl_generate_json)
|
||||
add_custom_target(prepare_cross_compiling DEPENDS tl_generate_mtproto tl_generate_common tdmime_auto tl_generate_json)
|
||||
if (TD_ENABLE_DOTNET)
|
||||
add_custom_target(remove_cpp_documentation
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
COMMAND remove_documentation ${TL_TD_API_AUTO_SOURCE} td/telegram/Client.h td/telegram/Log.h td/tl/TlObject.h
|
||||
COMMENT "Remove C++ documentation from sources"
|
||||
DEPENDS remove_documentation tl_generate_common generate_dotnet_api ${TL_TD_API_AUTO_SOURCE} td/telegram/Client.h td/telegram/Log.h td/tl/TlObject.h
|
||||
DEPENDS remove_documentation tl_generate_mtproto tl_generate_common generate_dotnet_api ${TL_TD_API_AUTO_SOURCE} td/telegram/Client.h td/telegram/Log.h td/tl/TlObject.h
|
||||
)
|
||||
|
||||
add_dependencies(prepare_cross_compiling generate_dotnet_api remove_cpp_documentation)
|
||||
@ -1085,6 +1085,9 @@ if (WIN32)
|
||||
target_link_libraries(tdmtproto PRIVATE ws2_32 Mswsock Crypt32)
|
||||
endif()
|
||||
endif()
|
||||
if (NOT CMAKE_CROSSCOMPILING)
|
||||
add_dependencies(tdmtproto tl_generate_mtproto)
|
||||
endif()
|
||||
|
||||
# tdcore - mostly internal TDLib interface. One should use tdactor for interactions with it.
|
||||
if (MSVC AND TD_ENABLE_LTO)
|
||||
|
@ -57,9 +57,7 @@ set(TL_DOTNET_AUTO_SOURCE
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
||||
set(TL_GENERATE_COMMON_SOURCE
|
||||
generate_common.cpp
|
||||
|
||||
set(TL_WRITER_CPP_SOURCE
|
||||
tl_writer_cpp.cpp
|
||||
tl_writer_h.cpp
|
||||
tl_writer_hpp.cpp
|
||||
@ -75,6 +73,14 @@ set(TL_GENERATE_COMMON_SOURCE
|
||||
tl_writer_td.h
|
||||
)
|
||||
|
||||
set(TL_GENERATE_MTPROTO_SOURCE
|
||||
generate_mtproto.cpp
|
||||
)
|
||||
|
||||
set(TL_GENERATE_COMMON_SOURCE
|
||||
generate_common.cpp
|
||||
)
|
||||
|
||||
set(TL_GENERATE_C_SOURCE
|
||||
generate_c.cpp
|
||||
|
||||
@ -133,8 +139,21 @@ if (NOT CMAKE_CROSSCOMPILING)
|
||||
DEPENDS tl-parser ${CMAKE_CURRENT_SOURCE_DIR}/scheme/mtproto_api.tl ${CMAKE_CURRENT_SOURCE_DIR}/scheme/secret_api.tl ${CMAKE_CURRENT_SOURCE_DIR}/scheme/td_api.tl ${CMAKE_CURRENT_SOURCE_DIR}/scheme/telegram_api.tl
|
||||
)
|
||||
|
||||
add_library(tl_writer_cpp STATIC ${TL_WRITER_CPP_SOURCE})
|
||||
target_link_libraries(tl_writer_cpp PRIVATE tdtl)
|
||||
target_include_directories(tl_writer_cpp PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
|
||||
|
||||
add_executable(generate_mtproto ${TL_GENERATE_MTPROTO_SOURCE})
|
||||
target_link_libraries(generate_mtproto PRIVATE tdtl tl_writer_cpp)
|
||||
add_custom_target(tl_generate_mtproto
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/auto
|
||||
COMMAND generate_mtproto
|
||||
COMMENT "Generate MTProto API source files"
|
||||
DEPENDS generate_mtproto tl_generate_tlo ${TLO_FILES}
|
||||
)
|
||||
|
||||
add_executable(generate_common ${TL_GENERATE_COMMON_SOURCE})
|
||||
target_link_libraries(generate_common PRIVATE tdtl)
|
||||
target_link_libraries(generate_common PRIVATE tdtl tl_writer_cpp)
|
||||
add_custom_target(tl_generate_common
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/auto
|
||||
COMMAND ${GENERATE_COMMON_CMD}
|
||||
|
@ -39,10 +39,6 @@ int main() {
|
||||
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<>("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<false, 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>"});
|
||||
|
27
td/generate/generate_mtproto.cpp
Normal file
27
td/generate/generate_mtproto.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
//
|
||||
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
#include "tl_writer_cpp.h"
|
||||
#include "tl_writer_h.h"
|
||||
#include "tl_writer_hpp.h"
|
||||
|
||||
#include "td/tl/tl_config.h"
|
||||
#include "td/tl/tl_generate.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
int main() {
|
||||
std::string tl_name = "mtproto_api";
|
||||
std::string path = "td/mtproto/" + tl_name;
|
||||
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",
|
||||
td::TD_TL_writer_cpp(tl_name, "Slice", "Slice", {"\"td/tl/tl_object_parse.h\"", "\"td/tl/tl_object_store.h\""}));
|
||||
td::tl::write_tl_to_file(
|
||||
config, path + ".h",
|
||||
td::TD_TL_writer_h(tl_name, "Slice", "Slice", {"\"td/utils/Slice.h\"", "\"td/utils/UInt.h\""}));
|
||||
td::tl::write_tl_to_file(config, path + ".hpp", td::TD_TL_writer_hpp(tl_name, "Slice", "Slice"));
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user