Skip to content

Commit

Permalink
Rename TdWindows to TdDotNet.
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 0bfff62c224dcbd316534649b119917280b3b398
  • Loading branch information
levlam committed Feb 27, 2018
1 parent 9874d08 commit 6eadf47
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 47 deletions.
34 changes: 15 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)

project(TDLib VERSION 1.1.3 LANGUAGES CXX C)

if ("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
set(UWP 1)
endif()

option(TD_ENABLE_JNI "Use \"ON\" to enable JNI-compatible TDLib API.")
option(TD_ENABLE_DOTNET "Use \"ON\" to enable generation of C++/CLI or C++/CX TDLib API bindings.")

Expand Down Expand Up @@ -53,7 +49,6 @@ In FAST mode stack is unwinded only using frame pointers, which may fail. \
In SAFE mode stack is unwinded using backtrace function from execinfo.h, which may be very slow. \
By default both methods are used to achieve maximum speed and accuracy")

# LIBRARIES
if (EMSCRIPTEN)
# use prebuilt zlib
set(ZLIB_FOUND 1)
Expand Down Expand Up @@ -283,7 +278,7 @@ set(TL_C_SCHEME_SOURCE
set_source_files_properties(${TL_DOTNET_AUTO} PROPERTIES GENERATED TRUE)
set(TL_DOTNET_SCHEME_SOURCE
${TL_TD_DOTNET_AUTO}
td/tl/tl_win_object.h
td/tl/tl_dotnet_object.h
)

set(TDLIB_SOURCE
Expand Down Expand Up @@ -595,27 +590,25 @@ if (TD_ENABLE_JNI AND NOT ANDROID) # jni is available by default on Android
endif()

if (TD_ENABLE_DOTNET)
add_library(TdWindows SHARED
td/telegram/ClientWindows.cpp
td/telegram/LogWindows.cpp
add_library(TdDotNet SHARED
td/telegram/ClientDotNet.cpp
td/telegram/LogDotNet.cpp
${TL_DOTNET_SCHEME_SOURCE}
)
target_link_libraries(TdWindows PRIVATE tdclient tdutils)
target_include_directories(TdWindows PUBLIC
target_link_libraries(TdDotNet PRIVATE tdclient tdutils)
target_include_directories(TdDotNet PUBLIC
$<BUILD_INTERFACE:${TL_TD_AUTO_INCLUDES}>
)
if (NOT CMAKE_CROSSCOMPILING)
add_dependencies(TdWindows generate_td_windows_api)
add_dependencies(TdDotNet generate_dotnet_api)
endif()
if (UWP)
set_target_properties(TdWindows PROPERTIES VS_WINRT_COMPONENT "true")
target_compile_options(TdWindows PUBLIC "/ZW")
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
set_target_properties(TdDotNet PROPERTIES VS_WINRT_COMPONENT "true")
target_compile_options(TdDotNet PUBLIC "/ZW")
else()
set_target_properties(TdWindows PROPERTIES COMPILE_FLAGS "/GR /clr")
target_compile_options(TdWindows PUBLIC "/EHa")
set_target_properties(TdDotNet PROPERTIES COMPILE_FLAGS "/GR /clr")
target_compile_options(TdDotNet PUBLIC "/EHa")
endif()

target_compile_options(TdWindows PUBLIC "/bigobj")
endif()

# tdc - TDLib interface in pure c.
Expand Down Expand Up @@ -669,6 +662,9 @@ if (BIGOBJ)
target_compile_options(tdclient PUBLIC ${BIGOBJ})
target_compile_options(tdjson PUBLIC ${BIGOBJ})
target_compile_options(tdjson_static PUBLIC ${BIGOBJ})
if (TD_ENABLE_DOTNET)
target_compile_options(TdDotNet PUBLIC "/bigobj")
endif()
endif()

if (EMSCRIPTEN)
Expand Down
4 changes: 2 additions & 2 deletions sqlite/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ elseif (MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4996")
endif()

if (UWP)
target_compile_options(tdsqlite PRIVATE /DSQLITE_OS_WINRT=1)
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
target_compile_definitions(tdsqlite PRIVATE -DSQLITE_OS_WINRT=1)
endif()

install(TARGETS tdsqlite EXPORT TdTargets
Expand Down
28 changes: 15 additions & 13 deletions td/generate/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ set(TL_C_AUTO
)

set(TL_TD_DOTNET_AUTO
${CMAKE_CURRENT_SOURCE_DIR}/auto/td/telegram/TdWindowsApi.cpp
${CMAKE_CURRENT_SOURCE_DIR}/auto/td/telegram/TdWindowsApi.h
${CMAKE_CURRENT_SOURCE_DIR}/auto/td/telegram/TdDotNetApi.cpp
${CMAKE_CURRENT_SOURCE_DIR}/auto/td/telegram/TdDotNetApi.h
PARENT_SCOPE
)

Expand Down Expand Up @@ -98,7 +98,7 @@ if (NOT CMAKE_CROSSCOMPILING)
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 scheme/td_api.tlo
DEPENDS generate_common scheme/mtproto_api.tlo scheme/telegram_api.tlo scheme/secret_api.tlo ${TL_TD_API_TLO}
)
if (TD_ENABLE_JNI)
target_compile_definitions(generate_common PRIVATE TD_ENABLE_JNI=1)
Expand All @@ -110,7 +110,7 @@ if (NOT CMAKE_CROSSCOMPILING)
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND generate_c
COMMENT "Generate C tl source files"
DEPENDS generate_c scheme/td_api.tlo
DEPENDS generate_c ${TL_TD_API_TLO}
)

add_executable(td_generate_java_api ${TL_GENERATE_JAVA_SOURCE})
Expand All @@ -122,7 +122,7 @@ if (NOT CMAKE_CROSSCOMPILING)
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND generate_json
COMMENT "Generate JSON tl source files"
DEPENDS generate_json scheme/td_api.tlo
DEPENDS generate_json ${TL_TD_API_TLO}
)

if (TD_ENABLE_JNI)
Expand All @@ -131,12 +131,14 @@ if (NOT CMAKE_CROSSCOMPILING)
install(FILES scheme/td_api.tlo scheme/td_api.tl DESTINATION bin/td/generate/scheme)
endif()

add_executable(generate_td_windows_api_exe generate_td_windows_api.cpp tl_writer_win.h)
target_link_libraries(generate_td_windows_api_exe PRIVATE tdtl)
add_custom_target(generate_td_windows_api
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND generate_td_windows_api_exe ${TL_TD_API_TLO}
COMMENT "Generate tl-files"
DEPENDS generate_td_windows_api_exe ${TL_TD_API_TLO}
)
if (TD_ENABLE_DOTNET)
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 td_generate_dotnet_api ${TL_TD_API_TLO}
COMMENT "Generate .Net API files"
DEPENDS td_generate_dotnet_api ${TL_TD_API_TLO}
)
endif()
endif()
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,20 @@
// 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_dotnet.h"

#include "td/tl/tl_config.h"
#include "td/tl/tl_generate.h"

#include "tl_writer_win.h"

int main(int argc, char *argv[]) {
if (argc < 2) {
return 1;
}

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/TdWindowsApi.cpp",
td::tl::TlWriterWinCommon("TdApi", false, "#include \"td/telegram/TdWindowsApi.h\"\n"));
td::tl::write_tl_to_file(config_td, "auto/td/telegram/TdWindowsApi.h",
td::tl::TlWriterWinCommon("TdApi", true, "#include \"td/telegram/td_api.h\"\n"));

return 0;
td::tl::write_tl_to_file(config_td, "auto/td/telegram/TdDotNetApi.cpp",
td::tl::TlWriterDotNet("TdApi", false, "#include \"td/telegram/TdDotNetApi.h\"\n"));
td::tl::write_tl_to_file(config_td, "auto/td/telegram/TdDotNetApi.h",
td::tl::TlWriterDotNet("TdApi", true, "#include \"td/telegram/td_api.h\"\n"));
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
namespace td {
namespace tl {

class TlWriterWinCommon : public TL_writer {
class TlWriterDotNet : public TL_writer {
public:
bool is_header_;
std::string prefix_;
TlWriterWinCommon(const std::string &name, bool is_header, const std::string &prefix = "")
TlWriterDotNet(const std::string &name, bool is_header, const std::string &prefix = "")
: TL_writer(name), is_header_(is_header), prefix_(prefix) {
}
int get_max_arity(void) const override {
Expand Down Expand Up @@ -179,7 +179,7 @@ class TlWriterWinCommon : public TL_writer {
std::string gen_output_begin(void) const override {
return prefix_ +
"#include \"td/utils/port/CxCli.h\"\n"
"#include \"td/tl/tl_win_object.h\"\n\n"
"#include \"td/tl/tl_dotnet_object.h\"\n\n"
"namespace TdWindows {\n";
}
std::string gen_output_end() const override {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
// 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 "td/telegram/TdWindowsApi.h"
#include "td/telegram/TdDotNetApi.h"

#include "td/telegram/Client.h"

#include "td/utils/port/CxCli.h"

namespace TdWindows {

using namespace CxCli;

public interface class ClientResultHandler {
Expand Down
3 changes: 3 additions & 0 deletions td/telegram/LogWindows.cpp → td/telegram/LogDotNet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
#include "td/utils/port/CxCli.h"

namespace TdWindows {

using namespace CxCli;

public ref class Log sealed {
public:
static void SetFilePath(String^ filePath) {
Expand All @@ -24,4 +26,5 @@ public ref class Log sealed {
::td::Log::set_verbosity_level(verbosityLevel);
}
};

} // namespace TdWindows
1 change: 0 additions & 1 deletion td/tl/tl_win_object.h → td/tl/tl_dotnet_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#include "td/utils/misc.h"
#include "td/utils/port/CxCli.h"
#include "td/utils/tl_storers.h"

#include "td/telegram/td_api.h"
#include "td/telegram/td_api.hpp"
Expand Down

0 comments on commit 6eadf47

Please sign in to comment.