diff --git a/projects/facebook.com/folly/package.yml b/projects/facebook.com/folly/package.yml index fe7755f0..af9c9da9 100644 --- a/projects/facebook.com/folly/package.yml +++ b/projects/facebook.com/folly/package.yml @@ -18,6 +18,9 @@ dependencies: google.github.io/snappy: '*' google.com/double-conversion: ^3 fmt.dev: ^9 + darwin: + sourceware.org/bzip2: '*' + zlib.net: '*' build: dependencies: @@ -35,8 +38,14 @@ build: script: - test -d xyz.tea.srcs && rm -rf xyz.tea.srcs - mv $SRCROOT xyz.tea.srcs - - cmake $ARGS -S xyz.tea.srcs -B . - - make --jobs {{hw.concurrency}} install + - cmake $ARGS -DBUILD_SHARED_LIBS=ON -S xyz.tea.srcs -B shared + - cmake --build shared + - cmake --install shared + + - cmake $ARGS -DBUILD_SHARED_LIBS=OFF -S xyz.tea.srcs -B static + - cmake --build static + - run: cp /tmp/xyz.tea.folly/static/libfolly.a libfollybenchmark.a + working-directory: ${{prefix}}/static/folly - run: | sed -E -i.bak \ diff --git a/projects/facebook.com/wangle/EchoClient.cpp b/projects/facebook.com/wangle/EchoClient.cpp new file mode 100644 index 00000000..42ecd545 --- /dev/null +++ b/projects/facebook.com/wangle/EchoClient.cpp @@ -0,0 +1,95 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include + +#include +#include +#include +#include +#include +#include + +using namespace folly; +using namespace wangle; + +DEFINE_int32(port, 8080, "echo server port"); +DEFINE_string(host, "::1", "echo server address"); + +typedef Pipeline EchoPipeline; + +// the handler for receiving messages back from the server +class EchoHandler : public HandlerAdapter { + public: + void read(Context*, std::string msg) override { + std::cout << "received back: " << msg; + } + void readException(Context* ctx, exception_wrapper e) override { + std::cout << exceptionStr(e) << std::endl; + close(ctx); + } + void readEOF(Context* ctx) override { + std::cout << "EOF received :(" << std::endl; + close(ctx); + } +}; + +// chains the handlers together to define the response pipeline +class EchoPipelineFactory : public PipelineFactory { + public: + EchoPipeline::Ptr newPipeline(std::shared_ptr sock) override { + auto pipeline = EchoPipeline::create(); + pipeline->addBack(AsyncSocketHandler(sock)); + pipeline->addBack( + EventBaseHandler()); // ensure we can write from any thread + pipeline->addBack(LineBasedFrameDecoder(8192, false)); + pipeline->addBack(StringCodec()); + pipeline->addBack(EchoHandler()); + pipeline->finalize(); + return pipeline; + } +}; + +int main(int argc, char** argv) { + folly::Init init(&argc, &argv); + + ClientBootstrap client; + client.group(std::make_shared(1)); + client.pipelineFactory(std::make_shared()); + auto pipeline = client.connect(SocketAddress(FLAGS_host, FLAGS_port)).get(); + + try { + while (true) { + std::string line; + std::getline(std::cin, line); + if (line == "") { + break; + } + + pipeline->write(line + "\r\n").get(); + if (line == "bye") { + pipeline->close(); + break; + } + } + } catch (const std::exception& e) { + std::cout << exceptionStr(e) << std::endl; + } + + return 0; +} diff --git a/projects/facebook.com/wangle/EchoServer.cpp b/projects/facebook.com/wangle/EchoServer.cpp new file mode 100644 index 00000000..2c860938 --- /dev/null +++ b/projects/facebook.com/wangle/EchoServer.cpp @@ -0,0 +1,65 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include +#include +#include +#include +#include + +using namespace folly; +using namespace wangle; + +DEFINE_int32(port, 8080, "echo server port"); + +typedef Pipeline EchoPipeline; + +// the main logic of our echo server; receives a string and writes it straight +// back +class EchoHandler : public HandlerAdapter { + public: + void read(Context* ctx, std::string msg) override { + std::cout << "handling " << msg << std::endl; + write(ctx, msg + "\r\n"); + } +}; + +// where we define the chain of handlers for each messeage received +class EchoPipelineFactory : public PipelineFactory { + public: + EchoPipeline::Ptr newPipeline(std::shared_ptr sock) override { + auto pipeline = EchoPipeline::create(); + pipeline->addBack(AsyncSocketHandler(sock)); + pipeline->addBack(LineBasedFrameDecoder(8192)); + pipeline->addBack(StringCodec()); + pipeline->addBack(EchoHandler()); + pipeline->finalize(); + return pipeline; + } +}; + +int main(int argc, char** argv) { + folly::Init init(&argc, &argv); + + ServerBootstrap server; + server.childPipeline(std::make_shared()); + server.bind(FLAGS_port); + server.waitForStop(); + + return 0; +} diff --git a/projects/facebook.com/wangle/package.yml b/projects/facebook.com/wangle/package.yml new file mode 100644 index 00000000..1ad98bb3 --- /dev/null +++ b/projects/facebook.com/wangle/package.yml @@ -0,0 +1,108 @@ +distributable: + url: https://github.com/facebook/wangle/archive/refs/tags/v{{version.raw}}.tar.gz + strip-components: 1 + +versions: + github: facebook/wangle + strip: /v/ + +dependencies: + boost.org: '*' + google.com/double-conversion: ^3 + github.com/facebookincubator/fizz: '*' + fmt.dev: ^9 + facebook.com/folly: '*' + gflags.github.io: '*' + google.com/glog: '*' + libevent.org: '*' + libsodium.org: '*' + lz4.org: ^1 + openssl.org: ^1.1 + google.github.io/snappy: '*' + facebook.com/zstd: ^1 + darwin: + sourceware.org/bzip2: '*' + zlib.net: '*' + +build: + dependencies: + tea.xyz/gx/cc: c99 + tea.xyz/gx/make: '*' + cmake.org: ^3 + working-directory: wangle + script: + - cmake . -DBUILD_SHARED_LIBS=ON $ARGS + - make install + - make clean + + - cmake . -DBUILD_SHARED_LIBS=OFF $ARGS + - make + - cp lib/libwangle.a {{prefix}}/lib + + - sed -i.bak "s:$(tea --prefix):\$\{_IMPORT_PREFIX\}/../../../..:g" "{{prefix}}"/lib/cmake/wangle/wangle-targets.cmake + - rm "{{prefix}}"/lib/cmake/wangle/wangle-targets.cmake.bak + env: + ARGS: + - -DCMAKE_INSTALL_PREFIX={{prefix}} + - -DCMAKE_BUILD_TYPE=Release + - -DBUILD_TESTS=OFF + +test: + dependencies: + tea.xyz/gx/cc: c99 + curl.se: '*' + script: + - c++ $CXXFLAGS 'EchoClient.cpp' -o EchoClient + - c++ $CXXFLAGS 'EchoServer.cpp' -o EchoServer + + # This should all work; but it doesn't in GHA. + # We should FIXME. + # # Find a free port + # - FREE_PORT=0 + # - run: | + # FREE_PORT=49152 + # while lsof -i:$FREE_PORT >/dev/null 2>&1; do + # ((FREE_PORT++)) + # done + + # # Start the EchoServer + # - run: | + # ./EchoServer -port "${FREE_PORT}" & + # SERVER_PID=$! + # - sleep 10 + + # # Send test lines to the EchoClient + # - run: | + # ./EchoClient -port "${FREE_PORT}" > out << EOF || true + # Hello from tea! + # Another test line. + # EOF + # CLIENT_BACKGROUND_PID=$! + + # - sleep 20 + + # # Check the output for the test lines + # - grep "Hello from tea!" out + # - grep "Another test line." out + env: + CXXFLAGS: + - -std=c++17 + - -lgflags + - -lglog + - -lfolly + - -lfizz + - -lwangle + - -lssl + - -lcrypto + - -lfmt + - -ldouble-conversion + - -levent + - -lboost_context + darwin: + CXXFLAGS: + - -lc++abi + linux: + CXXFLAGS: + - -ldl + - -lpthread + - -latomic diff --git a/projects/github.com/facebookincubator/fizz/package.yml b/projects/github.com/facebookincubator/fizz/package.yml index e98ed42a..e1c36dcd 100644 --- a/projects/github.com/facebookincubator/fizz/package.yml +++ b/projects/github.com/facebookincubator/fizz/package.yml @@ -33,6 +33,9 @@ build: cmake -S fizz -B build $ARGS cmake --build build cmake --install build + + sed -i.bak "s:$(tea --prefix):\$\{_IMPORT_PREFIX\}/../../../..:g" "{{prefix}}"/lib/cmake/fizz/fizz-targets.cmake + rm "{{prefix}}"/lib/cmake/fizz/fizz-targets.cmake.bak env: ARGS: - -GNinja diff --git a/projects/google.github.io/snappy/package.yml b/projects/google.github.io/snappy/package.yml index dd65d6d0..c7262a22 100644 --- a/projects/google.github.io/snappy/package.yml +++ b/projects/google.github.io/snappy/package.yml @@ -12,19 +12,24 @@ build: freedesktop.org/pkg-config: '*' cmake.org: '*' gnu.org/patch: '*' - script: | + script: # disable -Werror (because there are warnings lol) - patch -p1