|
| 1 | +class Qcoro6 < Formula |
| 2 | + desc "C++ Coroutines for Qt" |
| 3 | + homepage "https://qcoro.dev" |
| 4 | + url "https://github.com/qcoro/qcoro/archive/refs/tags/v0.12.0.tar.gz" |
| 5 | + sha256 "809afafab61593f994c005ca6e242300e1e3e7f4db8b5d41f8c642aab9450fbc" |
| 6 | + license "MIT" |
| 7 | + |
| 8 | + bottle do |
| 9 | + sha256 cellar: :any, arm64_tahoe: "29e63a82cea7891ef2e9844a57e7836d9c4ebf91db2991432038fa9ce4b971a6" |
| 10 | + sha256 cellar: :any, arm64_sequoia: "c77df01948a62ed7857b568b86ea585018632050d2ba57872205a3ae54eadb76" |
| 11 | + sha256 cellar: :any, arm64_sonoma: "f0d57a2e74521709c59b8c8c13727dcc91127378507b5c43e9757e5aaa4ddc44" |
| 12 | + sha256 cellar: :any, sonoma: "4dcbd1c72b2d23a8a7c870611ac6de0f47d6c473c49da1fd111908b253914a9c" |
| 13 | + sha256 cellar: :any_skip_relocation, x86_64_linux: "28ffddc636d502cc3d763fab6deef4348c4f77c7b8e6d14594cfd30d5cdad1d2" |
| 14 | + end |
| 15 | + |
| 16 | + depends_on "cmake" => [:build, :test] |
| 17 | + depends_on "qtbase" |
| 18 | + depends_on "qtdeclarative" |
| 19 | + depends_on "qtwebsockets" |
| 20 | + |
| 21 | + def install |
| 22 | + system "cmake", "-S", ".", "-B", "build", |
| 23 | + "-DBUILD_SHARED_LIBS=ON", |
| 24 | + "-DCMAKE_INSTALL_RPATH=#{rpath}", |
| 25 | + "-DQCORO_BUILD_EXAMPLES=OFF", |
| 26 | + "-DQCORO_BUILD_TESTING=OFF", |
| 27 | + "-DUSE_QT_VERSION=6", |
| 28 | + *std_cmake_args |
| 29 | + system "cmake", "--build", "build" |
| 30 | + system "cmake", "--install", "build" |
| 31 | + end |
| 32 | + |
| 33 | + test do |
| 34 | + (testpath/"CMakeLists.txt").write <<~CMAKE |
| 35 | + cmake_minimum_required(VERSION 3.16) |
| 36 | + project(QCoroTest LANGUAGES CXX) |
| 37 | + set(CMAKE_CXX_STANDARD 20) |
| 38 | + find_package(QCoro6 REQUIRED COMPONENTS Coro Core Network WebSockets Quick Qml Test) |
| 39 | + find_package(Qt6 REQUIRED COMPONENTS Core Network WebSockets Quick Qml Test) |
| 40 | + add_executable(testapp test.cpp) |
| 41 | + target_link_libraries(testapp PRIVATE |
| 42 | + QCoro6::Coro |
| 43 | + QCoro6::Core Qt6::Core |
| 44 | + QCoro6::Network Qt6::Network |
| 45 | + QCoro6::WebSockets Qt6::WebSockets |
| 46 | + QCoro6::Quick Qt6::Quick |
| 47 | + QCoro6::Qml Qt6::Qml |
| 48 | + QCoro6::Test Qt6::Test) |
| 49 | + qcoro_enable_coroutines() |
| 50 | + CMAKE |
| 51 | + |
| 52 | + (testpath/"test.cpp").write <<~CPP |
| 53 | + #include <QCoroTask> // from QCoroCoro |
| 54 | + #include <QCoroSignal> // from QCoroCore |
| 55 | + #include <QCoroAbstractSocket> // from QCoroNetwork |
| 56 | + #include <QCoroWebSocket> // from QCoroWebSockets |
| 57 | + #include <QCoroImageProvider> // from QCoroQuick |
| 58 | + #include <QCoroQmlTask> // from QCoroQml |
| 59 | + #include <QCoroTest> // from QCoroTest |
| 60 | + int main(int argc, char **argv) { |
| 61 | + QCoro::Task<int> t = []() -> QCoro::Task<int> { co_return 42; }(); |
| 62 | + return 0; |
| 63 | + } |
| 64 | + CPP |
| 65 | + |
| 66 | + system "cmake", "-S", ".", "-B", "build" |
| 67 | + system "cmake", "--build", "build" |
| 68 | + system "./build/testapp" |
| 69 | + end |
| 70 | +end |
0 commit comments