diff --git a/.cargo/config.toml b/.cargo/config.toml index 3ff0588..cfb0188 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -2,5 +2,3 @@ # In theory, your system GCC and libstdc++ should be able to compile everything here. In practice, # you probably want these overrides, so they're enabled by default. CXX = "clang++" -# CXXSTDLIB = "libc++" -#CXXFLAGS = "-std=gnu++2a -fcoroutines -stdlib=libc++" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6431e20..9dd599c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,4 @@ name: CI - on: push: branches: @@ -9,7 +8,7 @@ on: - main concurrency: - group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} + group: '${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}' cancel-in-progress: true jobs: @@ -18,24 +17,38 @@ jobs: steps: - uses: actions/checkout@v4 - # - name: Install deps - # run: sudo apt-get install libfmt-dev libgflags-dev - + - name: Cache cargo registry + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + key: cargo-registry-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + cargo-registry-${{ runner.os }}- + + - name: Cache cargo build + uses: actions/cache@v4 + with: + path: target + key: cargo-build-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + cargo-build-${{ runner.os }}- + - name: Format run: cargo fmt --all -- --check - + - name: Clippy working-directory: cxx-async run: cargo clippy -- -D warnings - build: - runs-on: ${{ matrix.os }} + build_and_test_with_folly: + runs-on: ubuntu-latest strategy: matrix: os: - ubuntu-latest - # - macos-latest - # - windows-latest + steps: - uses: actions/checkout@v4 @@ -48,17 +61,17 @@ jobs: make \ gcc \ g++ \ + clang \ autoconf \ automake \ libtool \ python3-pip \ ninja-build \ libgflags-dev \ - libboost-all-dev \ libdouble-conversion-dev \ libevent-dev \ - libgflags-dev \ libgoogle-glog-dev \ + libboost-all-dev \ libssl-dev \ libunwind-dev \ liblz4-dev \ @@ -68,53 +81,113 @@ jobs: binutils-dev \ libjemalloc-dev \ libiberty-dev + + - name: Add environment variables + run: | + echo "PATH=$HOME/.local/bin:$PATH" >> $GITHUB_ENV + echo "CMAKE_PREFIX_PATH=$HOME/.local:$CMAKE_PREFIX_PATH" >> $GITHUB_ENV + echo "C_INCLUDE_PATH=$HOME/.local/include:$C_INCLUDE_PATH" >> $GITHUB_ENV + echo "CPLUS_INCLUDE_PATH=$HOME/.local/include:$CPLUS_INCLUDE_PATH" >> $GITHUB_ENV + echo "LIBRARY_PATH=$HOME/.local/lib:$LIBRARY_PATH" >> $GITHUB_ENV + echo "LD_LIBRARY_PATH=$HOME/.local/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV + echo "PKG_CONFIG_PATH=$HOME/.local/lib/pkgconfig:$PKG_CONFIG_PATH" >> $GITHUB_ENV + + # Cache fmt + - name: Cache fmt + id: cache-fmt + uses: actions/cache@v4 + with: + path: | + ~/.local/include/fmt/** + ~/.local/lib/libfmt* + key: fmt-${{ runner.os }}-v10.1.1 - - name: Build fmt + - name: Build fmt if not cached + if: steps.cache-fmt.outputs.cache-hit != 'true' run: | - git clone https://github.com/fmtlib/fmt.git && cd fmt - rm _build -rf; mkdir _build -p && cd _build - cmake .. -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DCMAKE_C_COMPILER=/usr/bin/clang -DFMT_TEST=OFF + cd /tmp/ + git clone https://github.com/fmtlib/fmt.git + cd fmt + mkdir -p _build && cd _build + cmake .. \ + -DFMT_TEST=OFF \ + -DCMAKE_INSTALL_PREFIX=$HOME/.local \ + -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE make -j$(nproc) - sudo make install + make install sudo ldconfig - - - name: Build fast_float + cd ../../ + rm -rf /tmp/fmt + + # Cache fast_float + - name: Cache fast_float + id: cache-fast_float + uses: actions/cache@v4 + with: + path: | + ~/.local/lib/libfast_float* + ~/.local/include/fast_float/** + key: fast_float-${{ runner.os }}-v3.9.0 + + - name: Build fast_float if not cached + if: steps.cache-fast_float.outputs.cache-hit != 'true' run: | + cd /tmp git clone https://github.com/fastfloat/fast_float.git && cd fast_float - rm _build -rf; mkdir _build -p && cd _build + rm -rf _build; mkdir -p _build && cd _build cmake .. -DCMAKE_CXX_COMPILER=/usr/bin/clang++ \ -DCMAKE_C_COMPILER=/usr/bin/clang \ + -DCMAKE_INSTALL_PREFIX=$HOME/.local \ -DCMAKE_CXX_FLAGS="-O3" \ -DBUILD_SHARED_LIBS=TRUE \ -DBUILD_BENCHMARKS=OFF make -j$(nproc) - sudo make install + make install sudo ldconfig + cd ../../ + rm -rf /tmp/fast_float + + # Cache Folly + - name: Cache Folly + id: cache-folly + uses: actions/cache@v4 + with: + path: | + ~/.local/lib/libfolly** + ~/.local/include/folly/** + key: folly-${{ runner.os }}-20241104 - - name: Build Folly + - name: Build Folly if not cached + if: steps.cache-folly.outputs.cache-hit != 'true' run: | - git clone https://github.com/facebook/folly.git - cd folly - rm _build -rf - mkdir _build && cd _build - cmake .. -DBUILD_SHARED_LIBS=ON \ - -DCMAKE_CXX_COMPILER=/usr/bin/clang++ \ - -DCMAKE_C_COMPILER=/usr/bin/clang \ - -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ - -DBUILD_BENCHMARKS=OFF \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_CXX_STANDARD=20 \ - -DCMAKE_CXX_STANDARD_REQUIRED=ON + cd /tmp + git clone https://github.com/facebook/folly.git && cd folly + git checkout v2024.11.04.00 + rm -rf _build; mkdir _build && cd _build + cmake .. \ + -DBUILD_SHARED_LIBS=ON \ + -DCMAKE_INSTALL_PREFIX=$HOME/.local \ + -DCMAKE_CXX_COMPILER=/usr/bin/clang++ \ + -DCMAKE_C_COMPILER=/usr/bin/clang \ + -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ + -DBUILD_TESTS=OFF \ + -DBUILD_BENCHMARKS=OFF \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_CXX_STANDARD=20 \ + -DCMAKE_CXX_STANDARD_REQUIRED=ON make -j$(nproc) - sudo make install + make install sudo ldconfig + cd ../ + rm -rf /tmp/folly/ - # - name: Install dependencies on linux - # if: matrix.os == 'ubuntu-latest' - # run: sudo apt-get install libfmt-dev libgflags-dev - + - name: Copy dependencies to sys + run: | + sudo cp -r $HOME/.local/include/* /usr/include/ + sudo cp -r $HOME/.local/lib/* /usr/lib/ + sudo ldconfig + - name: Build working-directory: cxx-async - run: | - cargo build - + run: | + cargo build \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index dbedf90..5ff0a01 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -76,6 +76,19 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "cxx-async-example-cppcoro" +version = "0.1.0" +dependencies = [ + "async-recursion 0.3.2", + "cxx", + "cxx-async", + "cxx-build", + "futures", + "once_cell", + "pkg-config", +] + [[package]] name = "cxx-async-example-folly" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index aaebfad..1ba634f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,6 @@ resolver = "2" members = [ "cxx-async", "macro", - # "examples/cppcoro", + "examples/cppcoro", "examples/folly", ] diff --git a/cxx-async/Cargo.toml b/cxx-async/Cargo.toml index ff2ae8b..5df0621 100644 --- a/cxx-async/Cargo.toml +++ b/cxx-async/Cargo.toml @@ -34,7 +34,6 @@ features = ["thread-pool"] [dependencies.link-cplusplus] version = "1" -# features = ["libc++"] [build-dependencies] cxx-build = "1"