Skip to content

Commit

Permalink
add libs
Browse files Browse the repository at this point in the history
  • Loading branch information
karol-bisztyga committed Sep 1, 2021
1 parent 70f8bc0 commit 710183c
Show file tree
Hide file tree
Showing 25 changed files with 193 additions and 85 deletions.
48 changes: 47 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,33 @@ find_package(folly REQUIRED)
find_package(gflags REQUIRED)
find_package(glog REQUIRED)

# find_package(thriftcpp2 REQUIRED PATHS /Users/karolbisztyga/Desktop/workspace/tmp/fbthrift-test/fbthrift)
find_library(LIBASYNC async ../fbthrift/lib/libasync.a)
find_library(LIBCOMPILER async ../fbthrift/lib/libcompiler_generators.a)
find_library(LIBMUSTACHE async ../fbthrift/lib/libmustache_lib.a)
find_library(LIBTHRIFTCPP2 async ../fbthrift/lib/libthriftcpp2.a)
find_library(LIBTHRIFTPROTOCOL async ../fbthrift/lib/libthriftprotocol.a)
find_library(LIBCOMPILERAST async ../fbthrift/lib/libcompiler_ast.a)
find_library(LIBCOMPILERLIB async ../fbthrift/lib/libcompiler_lib.a)
find_library(LIBRPCMETADATA async ../fbthrift/lib/librpcmetadata.a)
find_library(LIBTHRIFTFROZEN2 async ../fbthrift/lib/libthriftfrozen2.a)
find_library(LIBTRANSPORT async ../fbthrift/lib/libtransport.a)
find_library(LIBCOMPILERBASE async ../fbthrift/lib/libcompiler_base.a)
find_library(LIBCOCNCURRENCY async ../fbthrift/lib/libconcurrency.a)
find_library(LIBTHRIFTCORE async ../fbthrift/lib/libthrift-core.a)
find_library(LIBTHRIFTMETADATA async ../fbthrift/lib/libthriftmetadata.a)

include_directories(
../fbthrift
./gen-cpp2
)

add_library(thriftcpp2 SHARED IMPORTED)
set_property(TARGET thriftcpp2 PROPERTY IMPORTED_LOCATION "/Users/karolbisztyga/Desktop/workspace/tmp/fbthrift/lib/libthriftcpp2.a")

file(GLOB SERVER_CODE "./server/*.cpp")
file(GLOB GENERATED_CODE "./gen-cpp2/*.cpp")

#[[
add_executable(
karol_server

Expand All @@ -30,11 +52,35 @@ install(
TARGETS karol_server
RUNTIME DESTINATION bin/
)
]]

add_executable(
karol_client
${GENERATED_CODE}
client/client.cpp
)
target_link_libraries(
karol_client

${LIBASYNC}
${LIBCOMPILER}
${LIBMUSTACHE}
${LIBTHRIFTCPP2}
${LIBTHRIFTPROTOCOL}
${LIBCOMPILERAST}
${LIBCOMPILERLIB}
${LIBRPCMETADATA}
${LIBTHRIFTFROZEN2}
${LIBTRANSPORT}
${LIBCOMPILERBASE}
${LIBCOCNCURRENCY}
${LIBTHRIFTCORE}
${LIBTHRIFTCORE}
${thriftcpp2}
gflags
glog::glog
Folly::folly
)
install(
TARGETS karol_client
RUNTIME DESTINATION bin/
Expand Down
37 changes: 37 additions & 0 deletions check_deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

set -e

echo -n "."
brew list folly > /dev/null
echo -n "."
brew list bison > /dev/null
echo -n "."
brew list boost > /dev/null
echo -n "."
brew list cmake > /dev/null
echo -n "."
brew list flex > /dev/null
echo -n "."
brew list openssl > /dev/null
echo -n "."

brew list zlib > /dev/null
echo -n "."
brew list fmt > /dev/null
echo -n "."
brew list gflags > /dev/null
echo -n "."

brew list glog > /dev/null
echo -n "."
brew list fizz > /dev/null
echo -n "."
brew list folly > /dev/null
echo -n "."
brew list wangle > /dev/null
echo -n "."
brew list zstd > /dev/null
echo -n "."

echo -n "ALL GOOD"
4 changes: 2 additions & 2 deletions gen-cpp2/Example_constants.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Autogenerated by Thrift for ../Example.thrift
* Autogenerated by Thrift for Example.thrift
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
* @generated @nocommit
*/
6 changes: 3 additions & 3 deletions gen-cpp2/Example_constants.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/**
* Autogenerated by Thrift for ../Example.thrift
* Autogenerated by Thrift for Example.thrift
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
* @generated @nocommit
*/
#pragma once

#include <thrift/lib/cpp2/gen/module_constants_h.h>

#include "../gen-cpp2/Example_types.h"
#include "Example_types.h"

namespace cpp2 {

Expand Down
6 changes: 3 additions & 3 deletions gen-cpp2/Example_data.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/**
* Autogenerated by Thrift for ../Example.thrift
* Autogenerated by Thrift for Example.thrift
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
* @generated @nocommit
*/

#include "../gen-cpp2/Example_data.h"
#include "Example_data.h"

#include <thrift/lib/cpp2/gen/module_data_cpp.h>

Expand Down
6 changes: 3 additions & 3 deletions gen-cpp2/Example_data.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/**
* Autogenerated by Thrift for ../Example.thrift
* Autogenerated by Thrift for Example.thrift
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
* @generated @nocommit
*/
#pragma once

#include <thrift/lib/cpp2/gen/module_data_h.h>

#include "../gen-cpp2/Example_types.h"
#include "Example_types.h"

namespace apache { namespace thrift {

Expand Down
6 changes: 3 additions & 3 deletions gen-cpp2/Example_for_each_field.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* Autogenerated by Thrift for ../Example.thrift
* Autogenerated by Thrift for Example.thrift
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
* @generated @nocommit
*/
#pragma once

#include "../gen-cpp2/Example_metadata.h"
#include "Example_metadata.h"
#include <thrift/lib/cpp2/visitation/for_each.h>

namespace apache {
Expand Down
26 changes: 21 additions & 5 deletions gen-cpp2/Example_metadata.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/**
* Autogenerated by Thrift for ../Example.thrift
* Autogenerated by Thrift for Example.thrift
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
* @generated @nocommit
*/
#include <thrift/lib/cpp2/gen/module_metadata_cpp.h>
#include "../gen-cpp2/Example_metadata.h"
#include "Example_metadata.h"

namespace apache {
namespace thrift {
Expand All @@ -30,7 +30,17 @@ void ServiceMetadata<::cpp2::KarolServiceSvIf>::gen_ping(ThriftMetadata& metadat
service.functions_ref()->push_back(std::move(func));
}

void ServiceMetadata<::cpp2::KarolServiceSvIf>::gen(ThriftMetadata& metadata, ThriftServiceContext& context) {
void ServiceMetadata<::cpp2::KarolServiceSvIf>::gen(::apache::thrift::metadata::ThriftServiceMetadataResponse& response) {
const ::apache::thrift::metadata::ThriftServiceContextRef* self = genRecurse(*response.metadata_ref(), *response.services_ref());
DCHECK(self != nullptr);
// TODO(praihan): Remove ThriftServiceContext from response. But in the meantime, we need to fill the field with the result of looking up in ThriftMetadata.
::apache::thrift::metadata::ThriftServiceContext context;
context.module_ref() = *self->module_ref();
context.service_info_ref() = response.metadata_ref()->services_ref()->at(*self->service_name_ref());
response.context_ref() = std::move(context);
}

const ThriftServiceContextRef* ServiceMetadata<::cpp2::KarolServiceSvIf>::genRecurse(ThriftMetadata& metadata, std::vector<ThriftServiceContextRef>& services) {
(void) metadata;
::apache::thrift::metadata::ThriftService Example_KarolService;
Example_KarolService.name_ref() = "Example.KarolService";
Expand All @@ -40,10 +50,16 @@ void ServiceMetadata<::cpp2::KarolServiceSvIf>::gen(ThriftMetadata& metadata, Th
for (auto& function_gen : functions) {
function_gen(metadata, Example_KarolService);
}
context.service_info_ref() = std::move(Example_KarolService);
// We need to keep the index around because a reference or iterator could be invalidated.
auto selfIndex = services.size();
services.emplace_back();
ThriftServiceContextRef& context = services[selfIndex];
metadata.services_ref()->emplace("Example.KarolService", std::move(Example_KarolService));
context.service_name_ref() = "Example.KarolService";
::apache::thrift::metadata::ThriftModuleContext module;
module.name_ref() = "Example";
context.module_ref() = std::move(module);
return &context;
}
} // namespace md
} // namespace detail
Expand Down
15 changes: 11 additions & 4 deletions gen-cpp2/Example_metadata.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
/**
* Autogenerated by Thrift for ../Example.thrift
* Autogenerated by Thrift for Example.thrift
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
* @generated @nocommit
*/
#pragma once

#include <vector>

#include <thrift/lib/cpp2/gen/module_metadata_h.h>
#include "../gen-cpp2/Example_types.h"
#include "Example_types.h"

namespace cpp2 {
class KarolServiceSvIf;
Expand All @@ -21,8 +23,13 @@ namespace md {
template <>
class ServiceMetadata<::cpp2::KarolServiceSvIf> {
public:
static void gen(ThriftMetadata& metadata, ThriftServiceContext& context);
static void gen(ThriftServiceMetadataResponse& response);
private:
static const ThriftServiceContextRef* genRecurse(ThriftMetadata& metadata, std::vector<ThriftServiceContextRef>& services);

template <typename T>
friend class ServiceMetadata;

static void gen_ping(ThriftMetadata& metadata, ThriftService& context);
};
} // namespace md
Expand Down
10 changes: 5 additions & 5 deletions gen-cpp2/Example_types.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/**
* Autogenerated by Thrift for ../Example.thrift
* Autogenerated by Thrift for Example.thrift
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
* @generated @nocommit
*/
#include "../gen-cpp2/Example_types.h"
#include "../gen-cpp2/Example_types.tcc"
#include "Example_types.h"
#include "Example_types.tcc"

#include <thrift/lib/cpp2/gen/module_types_cpp.h>

#include "../gen-cpp2/Example_data.h"
#include "Example_data.h"

4 changes: 2 additions & 2 deletions gen-cpp2/Example_types.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* Autogenerated by Thrift for ../Example.thrift
* Autogenerated by Thrift for Example.thrift
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
* @generated @nocommit
*/
#pragma once

Expand Down
6 changes: 3 additions & 3 deletions gen-cpp2/Example_types.tcc
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* Autogenerated by Thrift for ../Example.thrift
* Autogenerated by Thrift for Example.thrift
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
* @generated @nocommit
*/
#pragma once

#include "../gen-cpp2/Example_types.h"
#include "Example_types.h"

#include <thrift/lib/cpp2/gen/module_types_tcc.h>

Expand Down
6 changes: 3 additions & 3 deletions gen-cpp2/Example_types_custom_protocol.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* Autogenerated by Thrift for ../Example.thrift
* Autogenerated by Thrift for Example.thrift
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
* @generated @nocommit
*/
#pragma once

Expand All @@ -14,5 +14,5 @@
* VirtualProtocol) to read/write thrift structs.
*/

#include "../gen-cpp2/Example_types.tcc"
#include "Example_types.tcc"

6 changes: 3 additions & 3 deletions gen-cpp2/Example_visit_by_thrift_field_metadata.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/**
* Autogenerated by Thrift for ../Example.thrift
* Autogenerated by Thrift for Example.thrift
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
* @generated @nocommit
*/
#pragma once

#include <thrift/lib/cpp2/visitation/visit_by_thrift_field_metadata.h>
#include "../gen-cpp2/Example_metadata.h"
#include "Example_metadata.h"

namespace apache {
namespace thrift {
Expand Down
6 changes: 3 additions & 3 deletions gen-cpp2/Example_visit_union.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* Autogenerated by Thrift for ../Example.thrift
* Autogenerated by Thrift for Example.thrift
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
* @generated @nocommit
*/
#pragma once

#include "../gen-cpp2/Example_metadata.h"
#include "Example_metadata.h"
#include <thrift/lib/cpp2/visitation/visit_union.h>

namespace apache {
Expand Down
9 changes: 5 additions & 4 deletions gen-cpp2/Example_visitation.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/**
* Autogenerated by Thrift for ../Example.thrift
* Autogenerated by Thrift for Example.thrift
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
* @generated @nocommit
*/
#pragma once
#include "../gen-cpp2/Example_for_each_field.h"
#include "../gen-cpp2/Example_visit_union.h"
#include "Example_for_each_field.h"
#include "Example_visit_union.h"
#include "Example_visit_by_thrift_field_metadata.h"

0 comments on commit 710183c

Please sign in to comment.