Skip to content

Commit 894360c

Browse files
committed
Use manifest mode with vcpkg and build pipelines
1 parent b0de30e commit 894360c

File tree

5 files changed

+73
-36
lines changed

5 files changed

+73
-36
lines changed

.github/workflows/macos.yml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,18 @@ jobs:
2020
uses: actions/cache@v2
2121
id: cache-vcpkg
2222
with:
23-
path: vcpkg/
23+
path: build/vcpkg_installed/
2424
key: vcpkg-x64-osx
2525

26-
- name: Install Dependencies
27-
if: ${{ !steps.cache-vcpkg.outputs.cache-hit }}
28-
shell: pwsh
29-
run: |
30-
git clone https://github.com/microsoft/vcpkg
31-
cd vcpkg
32-
./bootstrap-vcpkg.sh -allowAppleClang
33-
./vcpkg integrate install
34-
./vcpkg install boost-program-options rapidjson gtest
35-
3626
- name: Create Build Environment
27+
if: ${{ !steps.cache-vcpkg.outputs.cache-hit }}
3728
run: cmake -E make_directory build
3829

3930
- name: Configure
4031
shell: pwsh
4132
working-directory: build/
4233
run: |
43-
$vcpkgToolchain = Join-Path '../vcpkg' './scripts/buildsystems/vcpkg.cmake' -Resolve
34+
$vcpkgToolchain = Join-Path $env:VCPKG_ROOT './scripts/buildsystems/vcpkg.cmake' -Resolve
4435
$cmakeBuildType = '${{ matrix.config }}'
4536
4637
cmake "-DCMAKE_TOOLCHAIN_FILE=$vcpkgToolchain" "-DCMAKE_BUILD_TYPE=$cmakeBuildType" ${{ github.workspace }}

.github/workflows/windows.yml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,18 @@ jobs:
2727
uses: actions/cache@v2
2828
id: cache-vcpkg
2929
with:
30-
path: vcpkg/
30+
path: build/vcpkg_installed/
3131
key: vcpkg-${{ steps.set-variables.outputs.vcpkg_triplet }}
3232

33-
- name: Install Dependencies
34-
if: ${{ !steps.cache-vcpkg.outputs.cache-hit }}
35-
shell: pwsh
36-
run: |
37-
git clone https://github.com/microsoft/vcpkg
38-
cd vcpkg
39-
.\bootstrap-vcpkg.bat
40-
.\vcpkg integrate install
41-
.\vcpkg install boost-program-options rapidjson gtest --triplet ${{ steps.set-variables.outputs.vcpkg_triplet }}
42-
4333
- name: Create Build Environment
34+
if: ${{ !steps.cache-vcpkg.outputs.cache-hit }}
4435
run: cmake -E make_directory build
4536

4637
- name: Configure
4738
shell: pwsh
4839
working-directory: build/
4940
run: |
50-
$vcpkgToolchain = Join-Path '..\vcpkg' '.\scripts\buildsystems\vcpkg.cmake' -Resolve
41+
$vcpkgToolchain = Join-Path $env:VCPKG_ROOT '.\scripts\buildsystems\vcpkg.cmake' -Resolve
5142
$vcpkgTriplet = '${{ steps.set-variables.outputs.vcpkg_triplet }}'
5243
$cmakeSharedLibs = $(if ('${{ matrix.libs }}' -eq 'shared') { 'ON' } else { 'OFF' })
5344
$msbuildArch = $(if ('${{ matrix.arch }}' -eq 'x64') { 'X64' } else { 'Win32' })

CMakeLists.txt

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,32 @@ if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/.git")
3131
endif()
3232
endif()
3333

34+
option(GRAPHQL_BUILD_SCHEMAGEN "Build the schemagen tool." ON)
35+
option(GRAPHQL_BUILD_CLIENTGEN "Build the clientgen tool." ON)
36+
option(GRAPHQL_BUILD_TESTS "Build the tests and sample schema library." ON)
37+
38+
if(GRAPHQL_BUILD_SCHEMAGEN)
39+
list(APPEND VCPKG_MANIFEST_FEATURES "schemagen")
40+
endif()
41+
42+
if(GRAPHQL_BUILD_CLIENTGEN)
43+
list(APPEND VCPKG_MANIFEST_FEATURES "clientgen")
44+
endif()
45+
46+
if(GRAPHQL_BUILD_TESTS)
47+
list(APPEND VCPKG_MANIFEST_FEATURES "tests")
48+
endif()
49+
50+
if(GRAPHQL_BUILD_SCHEMAGEN AND GRAPHQL_BUILD_CLIENTGEN)
51+
option(GRAPHQL_UPDATE_SAMPLES "Regenerate the sample schema sources whether or not we're building the tests." ON)
52+
53+
if(GRAPHQL_UPDATE_SAMPLES)
54+
list(APPEND VCPKG_MANIFEST_FEATURES "update-samples")
55+
endif()
56+
else()
57+
set(GRAPHQL_UPDATE_SAMPLES OFF CACHE BOOL "Disable regenerating samples." FORCE)
58+
endif()
59+
3460
project(cppgraphqlgen VERSION ${LATEST_VERSION})
3561

3662
set(GRAPHQL_INSTALL_INCLUDE_DIR include CACHE PATH "Header file install directory")
@@ -81,16 +107,6 @@ if(NOT pegtl_FOUND)
81107
add_subdirectory(PEGTL)
82108
endif()
83109

84-
option(GRAPHQL_BUILD_SCHEMAGEN "Build the schemagen tool." ON)
85-
86-
if(GRAPHQL_BUILD_SCHEMAGEN)
87-
option(GRAPHQL_UPDATE_SAMPLES "Regenerate the sample schema sources whether or not we're building the tests." ON)
88-
else()
89-
set(GRAPHQL_UPDATE_SAMPLES OFF CACHE BOOL "Disable regenerating samples." FORCE)
90-
endif()
91-
92-
option(GRAPHQL_BUILD_CLIENTGEN "Build the clientgen tool." ON)
93-
94110
option(GRAPHQL_UPDATE_VERSION "Regenerate graphqlservice/internal/Version.h and all of the version info rc files for Windows." ON)
95111

96112
add_subdirectory(cmake)

src/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,6 @@ install(FILES
406406

407407
# graphqljson
408408
if(BUILD_GRAPHQLJSON)
409-
option(GRAPHQL_BUILD_TESTS "Build the tests and sample schema library." ON)
410-
411409
target_link_libraries(graphqljson PUBLIC graphqlresponse)
412410

413411
install(TARGETS graphqljson

vcpkg.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "current-cppgraphqlgen",
3+
"version-string": "current",
4+
"features": {
5+
"schemagen": {
6+
"description": "Build the schemagen tool.",
7+
"dependencies": [
8+
"boost-program-options"
9+
]
10+
},
11+
"clientgen": {
12+
"description": "Build the clientgen tool.",
13+
"dependencies": [
14+
"boost-program-options"
15+
]
16+
},
17+
"tests": {
18+
"description": "Build tests.",
19+
"dependencies": [
20+
"gtest"
21+
]
22+
},
23+
"update-samples": {
24+
"description": "Regenerate the sample schema sources whether or not we're building the tests.",
25+
"dependencies": [
26+
{
27+
"name": "current-cppgraphqlgen",
28+
"default-features": false,
29+
"features": [
30+
"schemagen",
31+
"clientgen"
32+
]
33+
}
34+
]
35+
}
36+
},
37+
"dependencies": [
38+
"pegtl",
39+
"rapidjson"
40+
]
41+
}

0 commit comments

Comments
 (0)