-
Notifications
You must be signed in to change notification settings - Fork 7.4k
thrift: module integration, samples, and tests #54013
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
stephanosio
merged 5 commits into
zephyrproject-rtos:main
from
cfriedt:merge-thrift-into-zephyr
Feb 9, 2023
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
bf81498
manifest: add entry for zephyrproject-rtos/thrift
cfriedt 276f632
MAINTAINERS: add thrift west project
cfriedt 699f736
modules: add thrift module
cfriedt 9fc1cc7
tests: lib: thrift: add tests for the thrift module
cfriedt 64c102b
samples: modules: thrift: add samples for thrift module
cfriedt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Copyright 2022 Meta | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
if(CONFIG_THRIFT) | ||
|
||
set(THRIFT_UPSTREAM ${ZEPHYR_THRIFT_MODULE_DIR}) | ||
|
||
zephyr_library() | ||
|
||
zephyr_include_directories(src) | ||
zephyr_include_directories(include) | ||
zephyr_include_directories(${THRIFT_UPSTREAM}/lib/cpp/src) | ||
|
||
zephyr_library_sources( | ||
src/_stat.c | ||
src/thrift/server/TFDServer.cpp | ||
${THRIFT_UPSTREAM}/lib/cpp/src/thrift/protocol/TProtocol.cpp | ||
${THRIFT_UPSTREAM}/lib/cpp/src/thrift/server/TConnectedClient.cpp | ||
${THRIFT_UPSTREAM}/lib/cpp/src/thrift/server/TSimpleServer.cpp | ||
${THRIFT_UPSTREAM}/lib/cpp/src/thrift/transport/SocketCommon.cpp | ||
${THRIFT_UPSTREAM}/lib/cpp/src/thrift/transport/TBufferTransports.cpp | ||
${THRIFT_UPSTREAM}/lib/cpp/src/thrift/transport/TFDTransport.cpp | ||
${THRIFT_UPSTREAM}/lib/cpp/src/thrift/transport/TTransportException.cpp | ||
${THRIFT_UPSTREAM}/lib/cpp/src/thrift/transport/TServerSocket.cpp | ||
${THRIFT_UPSTREAM}/lib/cpp/src/thrift/transport/TSocket.cpp | ||
${THRIFT_UPSTREAM}/lib/cpp/src/thrift/TApplicationException.cpp | ||
${THRIFT_UPSTREAM}/lib/cpp/src/thrift/TOutput.cpp | ||
|
||
# Replace with upstream equivalents when Zephyr's std::thread, etc, are fixed | ||
src/thrift/concurrency/Mutex.cpp | ||
src/thrift/server/TServerFramework.cpp | ||
) | ||
|
||
zephyr_library_sources_ifdef(CONFIG_THRIFT_SSL_SOCKET | ||
# Replace with upstream equivalents when Zephyr's std::thread, etc, are fixed | ||
src/thrift/transport/TSSLSocket.cpp | ||
src/thrift/transport/TSSLServerSocket.cpp | ||
) | ||
|
||
# needed because std::iterator was deprecated with -std=c++17 | ||
zephyr_library_compile_options(-Wno-deprecated-declarations) | ||
|
||
endif(CONFIG_THRIFT) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Copyright 2022 Meta | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
config ZEPHYR_THRIFT_MODULE | ||
bool | ||
|
||
menuconfig THRIFT | ||
bool "Support for Thrift [EXPERIMENTAL]" | ||
select EXPERIMENTAL | ||
depends on CPP | ||
depends on STD_CPP17 | ||
depends on CPP_EXCEPTIONS | ||
depends on POSIX_API | ||
help | ||
Enable this option to support Apache Thrift | ||
|
||
if THRIFT | ||
|
||
config THRIFT_SSL_SOCKET | ||
bool "TSSLSocket support for Thrift" | ||
depends on MBEDTLS | ||
depends on MBEDTLS_PEM_CERTIFICATE_FORMAT | ||
depends on NET_SOCKETS_SOCKOPT_TLS | ||
help | ||
Enable this option to support TSSLSocket for Thrift | ||
|
||
module = THRIFT | ||
module-str = THRIFT | ||
source "subsys/logging/Kconfig.template.log_config" | ||
|
||
endif # THRIFT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Copyright 2022 Meta | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
find_program(THRIFT_EXECUTABLE thrift) | ||
if(NOT THRIFT_EXECUTABLE) | ||
message(FATAL_ERROR "The 'thrift' command was not found") | ||
endif() | ||
|
||
function(thrift | ||
target # CMake target (for dependencies / headers) | ||
lang # The language for generated sources | ||
lang_opts # Language options (e.g. ':no_skeleton') | ||
out_dir # Output directory for generated files | ||
# (do not include 'gen-cpp', etc) | ||
source_file # The .thrift source file | ||
options # Additional thrift options | ||
|
||
# Generated files in ${ARGN} | ||
) | ||
file(MAKE_DIRECTORY ${out_dir}) | ||
add_custom_command( | ||
OUTPUT ${ARGN} | ||
COMMAND | ||
${THRIFT_EXECUTABLE} | ||
--gen ${lang}${lang_opts} | ||
-o ${out_dir} | ||
${source_file} | ||
${options} | ||
DEPENDS ${source_file} | ||
) | ||
|
||
target_include_directories(${target} PRIVATE ${out_dir}/gen-${lang}) | ||
endfunction() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright 2022 Meta | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <errno.h> | ||
#include <sys/stat.h> | ||
|
||
#include <zephyr/kernel.h> | ||
|
||
int stat(const char *restrict path, struct stat *restrict buf) | ||
{ | ||
ARG_UNUSED(path); | ||
ARG_UNUSED(buf); | ||
|
||
errno = ENOTSUP; | ||
|
||
return -1; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright 2022 Meta | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <thrift/concurrency/Mutex.h> | ||
|
||
namespace apache | ||
{ | ||
namespace thrift | ||
{ | ||
namespace concurrency | ||
{ | ||
stephanosio marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Mutex::Mutex() | ||
{ | ||
} | ||
|
||
void Mutex::lock() const | ||
{ | ||
} | ||
|
||
bool Mutex::trylock() const | ||
{ | ||
return false; | ||
} | ||
|
||
bool Mutex::timedlock(int64_t milliseconds) const | ||
{ | ||
return false; | ||
} | ||
|
||
void Mutex::unlock() const | ||
{ | ||
} | ||
|
||
void *Mutex::getUnderlyingImpl() const | ||
{ | ||
return nullptr; | ||
} | ||
} // namespace concurrency | ||
} // namespace thrift | ||
} // namespace apache |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
/* | ||
* Copyright (c) 2023 Meta | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
/* config.h. Generated from config.hin by configure. */ | ||
/* config.hin. Generated from configure.ac by autoheader. */ | ||
|
||
#ifndef ZEPHYR_MODULES_THRIFT_SRC_THRIFT_CONFIG_H_ | ||
#define ZEPHYR_MODULES_THRIFT_SRC_THRIFT_CONFIG_H_ | ||
|
||
/* Possible value for SIGNED_RIGHT_SHIFT_IS */ | ||
#define ARITHMETIC_RIGHT_SHIFT 1 | ||
|
||
/* Define to 1 if you have the <arpa/inet.h> header file. */ | ||
#define HAVE_ARPA_INET_H 1 | ||
|
||
/* Define to 1 if you have the `clock_gettime' function. */ | ||
#define HAVE_CLOCK_GETTIME 1 | ||
|
||
/* define if the compiler supports basic C++11 syntax */ | ||
#define HAVE_CXX11 1 | ||
|
||
/* Define to 1 if you have the <fcntl.h> header file. */ | ||
#define HAVE_FCNTL_H 1 | ||
|
||
/* Define to 1 if you have the `gethostbyname' function. */ | ||
#define HAVE_GETHOSTBYNAME 1 | ||
|
||
/* Define to 1 if you have the `gettimeofday' function. */ | ||
#define HAVE_GETTIMEOFDAY 1 | ||
|
||
/* Define to 1 if you have the `inet_ntoa' function. */ | ||
#define HAVE_INET_NTOA 1 | ||
|
||
/* Define to 1 if you have the <inttypes.h> header file. */ | ||
#define HAVE_INTTYPES_H 1 | ||
|
||
/* Define to 1 if you have the <limits.h> header file. */ | ||
#define HAVE_LIMITS_H 1 | ||
|
||
/* Define to 1 if your system has a GNU libc compatible `malloc' function, and to 0 otherwise. */ | ||
#define HAVE_MALLOC 1 | ||
|
||
/* Define to 1 if you have the `memmove' function. */ | ||
#define HAVE_MEMMOVE 1 | ||
|
||
/* Define to 1 if you have the <memory.h> header file. */ | ||
#define HAVE_MEMORY_H 1 | ||
|
||
/* Define to 1 if you have the `memset' function. */ | ||
#define HAVE_MEMSET 1 | ||
|
||
/* Define to 1 if you have the `mkdir' function. */ | ||
#define HAVE_MKDIR 1 | ||
|
||
/* Define to 1 if you have the <netdb.h> header file. */ | ||
#define HAVE_NETDB_H 1 | ||
|
||
/* Define to 1 if you have the <netinet/in.h> header file. */ | ||
#define HAVE_NETINET_IN_H 1 | ||
|
||
/* Define to 1 if you have the <poll.h> header file. */ | ||
#define HAVE_POLL_H 1 | ||
|
||
/* Define to 1 if you have the <pthread.h> header file. */ | ||
#define HAVE_PTHREAD_H 1 | ||
|
||
/* Define to 1 if the system has the type `ptrdiff_t'. */ | ||
#define HAVE_PTRDIFF_T 1 | ||
|
||
/* Define to 1 if your system has a GNU libc compatible `realloc' function, and to 0 otherwise. */ | ||
#define HAVE_REALLOC 1 | ||
|
||
/* Define to 1 if you have the <sched.h> header file. */ | ||
#define HAVE_SCHED_H 1 | ||
|
||
/* Define to 1 if you have the `select' function. */ | ||
#define HAVE_SELECT 1 | ||
|
||
/* Define to 1 if you have the `socket' function. */ | ||
#define HAVE_SOCKET 1 | ||
|
||
/* Define to 1 if stdbool.h conforms to C99. */ | ||
#define HAVE_STDBOOL_H 1 | ||
|
||
/* Define to 1 if you have the <stddef.h> header file. */ | ||
#define HAVE_STDDEF_H 1 | ||
|
||
/* Define to 1 if you have the <stdint.h> header file. */ | ||
#define HAVE_STDINT_H 1 | ||
|
||
/* Define to 1 if you have the <stdlib.h> header file. */ | ||
#define HAVE_STDLIB_H 1 | ||
|
||
/* Define to 1 if you have the `strchr' function. */ | ||
#define HAVE_STRCHR 1 | ||
|
||
/* Define to 1 if you have the `strdup' function. */ | ||
#define HAVE_STRDUP 1 | ||
|
||
/* Define to 1 if you have the `strerror' function. */ | ||
#define HAVE_STRERROR 1 | ||
|
||
/* Define to 1 if you have the `strerror_r' function. */ | ||
#define HAVE_STRERROR_R 1 | ||
|
||
/* Define to 1 if you have the `strftime' function. */ | ||
#define HAVE_STRFTIME 1 | ||
|
||
/* Define to 1 if you have the <strings.h> header file. */ | ||
#define HAVE_STRINGS_H 1 | ||
|
||
/* Define to 1 if you have the <string.h> header file. */ | ||
#define HAVE_STRING_H 1 | ||
|
||
/* Define to 1 if you have the `strstr' function. */ | ||
#define HAVE_STRSTR 1 | ||
|
||
/* Define to 1 if you have the `strtol' function. */ | ||
#define HAVE_STRTOL 1 | ||
|
||
/* Define to 1 if you have the `strtoul' function. */ | ||
#define HAVE_STRTOUL 1 | ||
|
||
/* Define to 1 if you have the <sys/ioctl.h> header file. */ | ||
#define HAVE_SYS_IOCTL_H 1 | ||
|
||
/* Define to 1 if you have the <sys/resource.h> header file. */ | ||
#define HAVE_SYS_RESOURCE_H 1 | ||
|
||
/* Define to 1 if you have the <sys/select.h> header file. */ | ||
#define HAVE_SYS_SELECT_H 1 | ||
|
||
/* Define to 1 if you have the <sys/socket.h> header file. */ | ||
#define HAVE_SYS_SOCKET_H 1 | ||
|
||
/* Define to 1 if you have the <sys/stat.h> header file. */ | ||
#define HAVE_SYS_STAT_H 1 | ||
|
||
/* Define to 1 if you have the <sys/time.h> header file. */ | ||
#define HAVE_SYS_TIME_H 1 | ||
|
||
/* Define to 1 if you have the <sys/types.h> header file. */ | ||
#define HAVE_SYS_TYPES_H 1 | ||
|
||
/* Define to 1 if you have the <unistd.h> header file. */ | ||
#define HAVE_UNISTD_H 1 | ||
|
||
/* Define to 1 if you have the `vprintf' function. */ | ||
#define HAVE_VPRINTF 1 | ||
|
||
/* define if zlib is available */ | ||
/* #undef HAVE_ZLIB */ | ||
|
||
/* Possible value for SIGNED_RIGHT_SHIFT_IS */ | ||
#define LOGICAL_RIGHT_SHIFT 2 | ||
|
||
/* Define as the return type of signal handlers (`int' or `void'). */ | ||
#define RETSIGTYPE void | ||
|
||
/* Define to the type of arg 1 for `select'. */ | ||
#define SELECT_TYPE_ARG1 int | ||
|
||
/* Define to the type of args 2, 3 and 4 for `select'. */ | ||
#define SELECT_TYPE_ARG234 (fd_set *) | ||
|
||
/* Define to the type of arg 5 for `select'. */ | ||
#define SELECT_TYPE_ARG5 (struct timeval *) | ||
|
||
/* Indicates the effect of the right shift operator on negative signed integers */ | ||
#define SIGNED_RIGHT_SHIFT_IS 1 | ||
|
||
/* Define to 1 if you have the ANSI C header files. */ | ||
#define STDC_HEADERS 1 | ||
|
||
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */ | ||
#define TIME_WITH_SYS_TIME 1 | ||
|
||
/* Possible value for SIGNED_RIGHT_SHIFT_IS */ | ||
#define UNKNOWN_RIGHT_SHIFT 3 | ||
|
||
#endif /* ZEPHYR_MODULES_THRIFT_SRC_THRIFT_CONFIG_H_ */ |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.