Skip to content

Commit

Permalink
Install h3 from cmake (#927)
Browse files Browse the repository at this point in the history
  • Loading branch information
andarut authored Nov 2, 2023
1 parent 51cf776 commit b8b74b7
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 28 deletions.
10 changes: 0 additions & 10 deletions .github/workflows/Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,6 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Get polyfills repo
uses: actions/checkout@v3
with:
repository: 'uber/h3'
path: 'h3'
ref: stable-3.x

# because of https://github.com/orgs/Homebrew/discussions/4612
- name: Check Environment
run: |
Expand All @@ -151,9 +144,6 @@ jobs:
brew link --overwrite --force shivammathur/php/[email protected]
/usr/local/Frameworks/Python.framework/Versions/3.11/bin/pip3 install jsonschema
- name: Build Uber h3
run: cmake -DCMAKE_CXX_COMPILER=${{matrix.compiler}} -DCMAKE_CXX_STANDARD=${{matrix.cpp}} -S $GITHUB_WORKSPACE/h3 -B ${{runner.workspace}}/h3/build && make install -C ${{runner.workspace}}/h3/build -j$(nproc) all

- name: Run cmake
run: cmake -DCMAKE_CXX_COMPILER=${{matrix.compiler}} -DCMAKE_CXX_STANDARD=${{matrix.cpp}} -DDOWNLOAD_MISSING_LIBRARIES=On -S $GITHUB_WORKSPACE -B ${{runner.workspace}}/build

Expand Down
17 changes: 17 additions & 0 deletions cmake/external-libraries.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,23 @@ else()
add_link_options(-L${kphp-timelib_SOURCE_DIR}/objs)
endif()

find_library(KPHP_H3 h3)
if(KPHP_H3)
add_library(h3 STATIC IMPORTED ${KPHP_H3})
else()
handle_missing_library("h3")
FetchContent_Declare(
h3
GIT_REPOSITORY https://github.com/VKCOM/uber-h3.git
GIT_TAG fetch_content
)
message(STATUS "---------------------")
FetchContent_MakeAvailable(h3)
include_directories(${h3_BINARY_DIR}/src/include)
add_definitions(-DKPHP_H3_LIB_DIR="${h3_BINARY_DIR}/lib")
add_link_options(-L${h3_BINARY_DIR}/lib)
endif()

if(APPLE)
if (DEFINED ENV{EPOLL_SHIM_REPO})
FetchContent_Declare(
Expand Down
9 changes: 9 additions & 0 deletions compiler/compiler-settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,15 @@ void CompilerSettings::init() {
ld_flags.value_ += " -L /usr/local/lib";
#endif

#ifdef KPHP_H3_LIB_DIR
ld_flags.value_ += " -L" KPHP_H3_LIB_DIR;
#else
// kphp-h3 is usually installed in /usr/local/lib;
// LDD may not find a library in /usr/local/lib if we don't add it here
// TODO: can we avoid this hardcoded library path?
ld_flags.value_ += " -L /usr/local/lib";
#endif

std::vector<vk::string_view> external_libs{"pthread", "m", "dl"};

#ifdef PDO_DRIVER_MYSQL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,32 +79,21 @@ apt install git cmake make g++ gperf python3-minimal python3-jsonschema \
```


##### MacOS with Intel chipset
##### MacOS
Make sure you have `brew` and `clang` (at least `Apple clang version 10.0.0`)
```bash
# Install dependencies
brew tap shivammathur/php
brew update
brew install re2c cmake coreutils openssl libiconv re2 pcre yaml-cpp zstd googletest shivammathur/php/[email protected]
brew link --overwrite shivammathur/php/[email protected]
pip3 install jsonschema
```
Clone somewhere local [epoll-shim from GitHub]({{site.url_package_epoll_shim}}) and switch to *osx-platform* branch.
Add env variable `EPOLL_SHIM_REPO` to your bash profile. It allows to avoid of cloning `epoll-shim` on each clean cmake call.
```bash
git clone https://github.com/VKCOM/epoll-shim.git
cd epoll-shim
git checkout osx-platform
echo 'export "EPOLL_SHIM_REPO=$(pwd)" >> ~/.bash_profile'
```

Clone somewhere local [h3 from GitHub]({{site.url_package_h3_mac}}) and switch to *stable-3.x* branch.
```bash
git clone https://github.com/uber/h3.git
git checkout stable-3.x
mkdir build
cd build
cmake ..
sudo make install
# Build kphp
git clone https://github.com/VKCOM/kphp.git && cd kphp
mkdir build && cd build
cmake .. -DDOWNLOAD_MISSING_LIBRARIES=On
make -j$(nproc)
```

##### Other Linux
Expand Down

0 comments on commit b8b74b7

Please sign in to comment.