Skip to content

Commit

Permalink
Update readme file with more details about building the project. (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
RenfengLiu authored Oct 5, 2023
1 parent c838b8d commit 0f6f71b
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 20 deletions.
84 changes: 71 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,100 @@
### Building Dive host tool in Windows
### Checkout the code

```
git clone --recursive https://github.com/google/dive.git
```

If the code has been checked out without `--recursive` or you're pulling from the main branch later, please run following command to make sure the submodules are retrieved properly.
```
git submodule update --init --recursive
```

### Prerequisite

- The QT framework, can be installed from [QT online installer](https://download.qt.io/archive/online_installers/4.6/). We are currently using QT 5.11.2
- gRPC [dependencies](https://github.com/grpc/grpc/blob/master/BUILDING.md#pre-requisites)
- Android NDK (currently we are using 25.2.9519653). Set the `ANDROID_NDK_HOME` environment variable.
```
export ANDROID_NDK_HOME=~/andriod_sdk/ndk/25.2.9519653
```

### Building Dive host tool on Linux
```
# Assumes QTDIR is set to gcc_64 directory (eg. ~/Qt/5.11.2/gcc_64)
export CMAKE_PREFIX_PATH=$QTDIR
export PATH=$QTDIR:$PATH
cd <dive_path>
git submodule update --init --recursive
mkdir build
cd build
cmake -GNinja ..
ninja
```

You can specify the build type for debug/release as well
with `-DCMAKE_BUILD_TYPE=Debug` or `-DCMAKE_BUILD_TYPE=Release` when running cmake.

### Building Dive host tool on Windows
To build with prebuilt gRPC libraries:
```
REM Assumes QTDIR is set to msvc directory (eg. C:\Qt\5.11.2\msvc2017_64)
set CMAKE_PREFIX_PATH=%QTDIR%
set PATH=%QTDIR%\bin;%PATH%
cd <dive_path>
git submodule update --init
git submodule update --init --recursive
mkdir build
cd build
cmake -G "Visual Studio 17 2022" ..
```
Open `dive.sln` and build in Debug or Release

Open `dive.sln` and build in Debug or Release
Or run:
```
cmake --build . --config Debug
cmake --build . --config Release
```
#### Build without prebuilt libraries

Or you can build without using the prebuilt libraries with `-DBUILD_GRPC=ON`

### Building Dive host tool in Linux (DEBUG)
```
REM Assumes QTDIR is set to gcc_64 directory (eg. ~/Qt/5.11.2/gcc_64)
export CMAKE_PREFIX_PATH=$QTDIR
export PATH=$QTDIR:$PATH
cd <dive_path>
git submodule update --init --recursive
mkdir build
cmake -G "Visual Studio 17 2022" -DBUILD_GRPC=ON ..
```

Or you can build with Ninja, which is much faster:
Open Developer Command Prompt for VS 2022(or 2019) and run:
```
cd build
cmake -DCMAKE_BUILD_TYPE=Debug ..
make -j$(nproc)
cmake -G "Ninja" -DBUILD_GRPC=ON ..
ninja
```

Note this requires build dependencies for gRPC, which requires to install prerequisite listed at [gRPC website](https://github.com/grpc/grpc/blob/master/BUILDING.md#windows). It's mostly about install the [NASM](https://www.nasm.us/). If you don't have `choco` installed, you can download the binary from [NASM website](https://www.nasm.us/) and add its path to the `PATH` environment variable.

#### Update prebuilt libraries
Currently, the gRPC binaries are prebuilt under the folder `prebuild``. In case there's build error with the prebuilt libraries, you can run regenerate the libraries with following steps:
- Open Developer Command Prompt for VS 2022(or 2019)
- Run `scripts/build_grpc.bat`


### Building Android Libraries

- Download the Android NDK (e.g. 25.2.9519653)
- Set the environment variable `ANDROID_NDK_HOME` (e.g. export ANDROID_NDK_HOME=~/andriod_sdk/ndk/25.2.9519653)
Run the script

On Linux, run:
```
./scripts/build_android.sh
```
And on Windows, Open Developer Command Prompt for VS 2022(or 2019) and run

```
scripts\build_android.bat
```



It will build both debug and release version of the libraries.
It will build both debug and release version of the libraries under `build_android` folder.


4 changes: 2 additions & 2 deletions grpc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ if(GRPC_AS_SUBMODULE)
set(_REFLECTION grpc++_reflection)
if(CMAKE_CROSSCOMPILING)
if(CMAKE_HOST_WIN32)
set(_PROTOBUF_PROTOC "${CMAKE_SOURCE_DIR}/bin/protoc.exe")
set(_PROTOBUF_PROTOC "${CMAKE_SOURCE_DIR}/prebuild/grpc/bin/protoc.exe")
else()
find_program(_PROTOBUF_PROTOC protoc PATHS ${CMAKE_SOURCE_DIR}/bin)
endif()
Expand All @@ -81,7 +81,7 @@ if(GRPC_AS_SUBMODULE)
set(_GRPC_GRPCPP grpc++)
if(CMAKE_CROSSCOMPILING)
if(CMAKE_HOST_WIN32)
set(_GRPC_CPP_PLUGIN_EXECUTABLE "${CMAKE_SOURCE_DIR}/bin/grpc_cpp_plugin.exe")
set(_GRPC_CPP_PLUGIN_EXECUTABLE "${CMAKE_SOURCE_DIR}/prebuild/grpc/bin/grpc_cpp_plugin.exe")
else()
find_program(_GRPC_CPP_PLUGIN_EXECUTABLE grpc_cpp_plugin PATHS ${CMAKE_SOURCE_DIR}/bin)
endif()
Expand Down
13 changes: 8 additions & 5 deletions scripts/build_android.bat
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@
:: See the License for the specific language governing permissions and
:: limitations under the License.

@REM @echo off
@echo off

set PROJECT_ROOT=%~dp0\..
set BUILD_TYPE=Debug Release
set SRC_DIR=%PROJECT_ROOT%
set startTime=%time%

(for %%b in (%BUILD_TYPE%) do (
setlocal enabledelayedexpansion
echo %%b
set build=%%b
set BUILD_DIR=%PROJECT_ROOT%\\build_android\\!build!
echo "BUILD_DIR: " !BUILD_DIR!
mkdir !BUILD_DIR!
md !BUILD_DIR!
pushd !BUILD_DIR!
cmake -DCMAKE_TOOLCHAIN_FILE=%ANDROID_NDK_HOME%/build/cmake/android.toolchain.cmake ^
-G "Unix Makefiles"^
-DCMAKE_MAKE_PROGRAM="make" ^
-G "Ninja"^
-DCMAKE_BUILD_TYPE=!build! ^
-DCMAKE_SYSTEM_NAME=Android ^
-DANDROID_ABI=arm64-v8a ^
Expand All @@ -43,4 +43,7 @@ set SRC_DIR=%PROJECT_ROOT%

cmake --build . --config=!build! -j %NUMBER_OF_PROCESSORS%
popd
))
))

echo Start Time: %startTime%
echo Finish Time: %time%

0 comments on commit 0f6f71b

Please sign in to comment.