Skip to content

Commit

Permalink
*: add workflow in CMakePresets (#9304)
Browse files Browse the repository at this point in the history
ref #6233

*: add workflow in CMakePresets

Signed-off-by: Lloyd-Pottiger <[email protected]>
  • Loading branch information
Lloyd-Pottiger authored Aug 13, 2024
1 parent b4e8599 commit 9d130eb
Show file tree
Hide file tree
Showing 2 changed files with 209 additions and 26 deletions.
198 changes: 197 additions & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": 3,
"version": 6,
"cmakeMinimumRequired": {
"major": 3,
"minor": 23,
Expand Down Expand Up @@ -127,5 +127,201 @@
"cacheVariables": {},
"binaryDir": "${sourceDir}/cmake-build-release"
}
],
"buildPresets": [
{
"name": "dev",
"displayName": "Build tiflash binary with debug info and tests enabled",
"configurePreset": "dev",
"targets": ["tiflash"]
},
{
"name": "unit-tests",
"displayName": "Build dbms unit tests",
"configurePreset": "dev",
"targets": ["gtests_dbms"]
},
{
"name": "unit-tests-all",
"displayName": "Build all unit tests",
"configurePreset": "dev",
"targets": ["gtests_dbms, gtests_libdaemon, gtests_libcommon"]
},
{
"name": "dev-coverage",
"displayName": "Build dbms unit tests with code coverage",
"configurePreset": "dev-coverage",
"targets": ["gtests_dbms"]
},
{
"name": "dev-coverage-all",
"displayName": "Build all unit tests with code coverage",
"configurePreset": "dev-coverage",
"targets": ["gtests_dbms, gtests_libdaemon, gtests_libcommon"]
},
{
"name": "release",
"displayName": "Build tiflash binary without debug info",
"configurePreset": "release",
"targets": ["tiflash"]
},
{
"name": "asan",
"displayName": "Build dbms Address Sanitizer tests",
"configurePreset": "asan",
"targets": ["gtests_dbms"]
},
{
"name": "asan-all",
"displayName": "Build all Address Sanitizer tests",
"configurePreset": "asan",
"targets": ["gtests_dbms, gtests_libdaemon, gtests_libcommon"]
},
{
"name": "tsan",
"displayName": "Build dbms Thread Sanitizer tests",
"configurePreset": "tsan",
"targets": ["gtests_dbms"]
},
{
"name": "tsan-all",
"displayName": "Build all Thread Sanitizer tests",
"configurePreset": "tsan",
"targets": ["gtests_dbms, gtests_libdaemon, gtests_libcommon"]
},
{
"name": "benchmarks",
"displayName": "Build benchmarks",
"configurePreset": "benchmarks",
"targets": ["bench_dbms"]
}
],
"workflowPresets": [
{
"name": "dev",
"displayName": "Build debug binary workflow",
"steps": [
{
"type": "configure",
"name": "dev"
},
{
"type": "build",
"name": "dev"
}
]
},
{
"name": "unit-tests",
"displayName": "Build dbms unit tests workflow",
"steps": [
{
"type": "configure",
"name": "dev"
},
{
"type": "build",
"name": "unit-tests"
}
]
},
{
"name": "unit-tests-all",
"displayName": "Build all unit tests workflow",
"steps": [
{
"type": "configure",
"name": "dev"
},
{
"type": "build",
"name": "unit-tests-all"
}
]
},
{
"name": "benchmarks",
"displayName": "Build benchmarks workflow",
"steps": [
{
"type": "configure",
"name": "benchmarks"
},
{
"type": "build",
"name": "benchmarks"
}
]
},
{
"name": "asan-tests",
"displayName": "Build dbms Address Sanitizer tests workflow",
"steps": [
{
"type": "configure",
"name": "asan"
},
{
"type": "build",
"name": "asan"
}
]
},
{
"name": "asan-tests-all",
"displayName": "Build all Address Sanitizer tests workflow",
"steps": [
{
"type": "configure",
"name": "asan"
},
{
"type": "build",
"name": "asan-all"
}
]
},
{
"name": "tsan-tests",
"displayName": "Build dbms Thread Sanitizer tests workflow",
"steps": [
{
"type": "configure",
"name": "tsan"
},
{
"type": "build",
"name": "tsan"
}
]
},
{
"name": "tsan-tests-all",
"displayName": "Build all Thread Sanitizer tests workflow",
"steps": [
{
"type": "configure",
"name": "tsan"
},
{
"type": "build",
"name": "tsan-all"
}
]
},
{
"name": "release",
"displayName": "Build release binary workflow",
"steps": [
{
"type": "configure",
"name": "release"
},
{
"type": "build",
"name": "release"
}
]
}
]
}
37 changes: 12 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,21 +149,14 @@ To build TiFlash for development:

```shell
# In the TiFlash repository root:
mkdir cmake-build-debug # The directory name can be customized
cd cmake-build-debug

cmake .. -GNinja -DCMAKE_BUILD_TYPE=DEBUG

ninja tiflash
cmake --workflow --preset dev
```

Note: In Linux, usually you need to explicitly specify to use LLVM.

```shell
# In cmake-build-debug directory:
cmake .. -GNinja -DCMAKE_BUILD_TYPE=DEBUG \
-DCMAKE_C_COMPILER=/usr/bin/clang-17 \
-DCMAKE_CXX_COMPILER=/usr/bin/clang++-17
export CC="/usr/bin/clang-17"
export CXX="/usr/bin/clang++-17"
```

In MacOS, if you install llvm clang, you need to explicitly specify to use llvm clang.
Expand All @@ -177,7 +170,12 @@ export CXX="/opt/homebrew/opt/llvm/bin/clang++"

Or use `CMAKE_C_COMPILER` and `CMAKE_CXX_COMPILER` to specify the compiler, like this:
```shell
mkdir cmake-build-debug
cd cmake-build-debug

cmake .. -GNinja -DCMAKE_BUILD_TYPE=DEBUG -DCMAKE_C_COMPILER=/opt/homebrew/opt/llvm/bin/clang -DCMAKE_CXX_COMPILER=/opt/homebrew/opt/llvm/bin/clang++

ninja tiflash
```

After building, you can get TiFlash binary in `dbms/src/Server/tiflash` in the `cmake-build-debug` directory.
Expand Down Expand Up @@ -270,11 +268,8 @@ cmake .. -GNinja -DCMAKE_BUILD_TYPE=DEBUG -DFOO=BAR
Unit tests are automatically enabled in debug profile. To build these unit tests:

```shell
cd cmake-build-debug
cmake .. -GNinja -DCMAKE_BUILD_TYPE=DEBUG
ninja gtests_dbms # Most TiFlash unit tests
ninja gtests_libdaemon # Settings related tests
ninja gtests_libcommon
# In the TiFlash repository root:
cmake --workflow --preset unit-tests-all
```

Then, to run these unit tests:
Expand All @@ -296,12 +291,7 @@ To build unit test executables with sanitizer enabled:

```shell
# In the TiFlash repository root:
mkdir cmake-build-sanitizer
cd cmake-build-sanitizer
cmake .. -GNinja -DENABLE_TESTS=ON -DCMAKE_BUILD_TYPE=ASan # or TSan
ninja gtests_dbms
ninja gtests_libdaemon
ninja gtests_libcommon
cmake --workflow --preset asan-tests-all # or tsan-tests-all
```

There are known false positives reported from leak sanitizer (which is included in address sanitizer). To suppress these errors, set the following environment variables before running the executables:
Expand Down Expand Up @@ -359,10 +349,7 @@ To build micro benchmark tests, you need release profile and tests enabled:
```shell
# In the TiFlash repository root:
mkdir cmake-build-release
cd cmake-build-release
cmake .. -GNinja -DCMAKE_BUILD_TYPE=RELEASE -DENABLE_TESTS=ON
ninja bench_dbms
cmake --workflow --preset benchmarks
```
Then, to run these micro benchmarks:
Expand Down

0 comments on commit 9d130eb

Please sign in to comment.