Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix C++ build workflow #1065

Merged
merged 83 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
52e04a0
fix: update `loginAccessToken` in header and example
tangowithfoxtrot Aug 27, 2024
15cd86a
fmt: rm whitespace
tangowithfoxtrot Aug 27, 2024
e19fe98
fix: ignore cmake build files
tangowithfoxtrot Aug 27, 2024
3aaa290
feat: use state file
tangowithfoxtrot Aug 27, 2024
2e7f275
fmt and add output for easier usage
tangowithfoxtrot Aug 27, 2024
7be985f
fix: clang-tidy: don't use implicit type conversions
tangowithfoxtrot Aug 27, 2024
0f600ff
fix: actually pass the state file to the command runner
tangowithfoxtrot Aug 27, 2024
9bc182d
fmt readme; add IDE setup section
tangowithfoxtrot Aug 28, 2024
fc90d98
feat: getByIds
tangowithfoxtrot Aug 28, 2024
17da81f
breaking: update function params
tangowithfoxtrot Aug 29, 2024
5e8f19b
add headers and deserializer for secret syncing
tangowithfoxtrot Aug 29, 2024
88b5207
feat: secret syncing
tangowithfoxtrot Aug 29, 2024
3e121a6
update example wrapper script
tangowithfoxtrot Aug 29, 2024
94a36cd
Merge branch 'main' into sm-1403-review-and-update-cpp-sdk
tangowithfoxtrot Aug 29, 2024
1b3adef
fix: re-add deleted README
tangowithfoxtrot Aug 29, 2024
196e98b
update readme examples
tangowithfoxtrot Aug 29, 2024
7ab2134
inc pr feedback to simplify examples
tangowithfoxtrot Aug 30, 2024
f201745
use consistent var name for state file
tangowithfoxtrot Aug 30, 2024
3a7cd09
update example with PR feedback
tangowithfoxtrot Aug 30, 2024
e38763f
SM-1444: Add custom windows release profile
coltonhurst Sep 17, 2024
deec13f
SM-1444: Fix build-rust-cross-platform workflow
coltonhurst Sep 17, 2024
916925d
SM-1444: Fix build-rust-cross-platform workflow again
coltonhurst Sep 17, 2024
3bc467c
SM-1444: Edit upload artifact in workflow
coltonhurst Sep 17, 2024
9e8f09e
SM-1444: Add workaround GH Issue link
coltonhurst Sep 17, 2024
2bea524
Merge branch 'main' into sm/sm-1444
coltonhurst Sep 17, 2024
8475af7
Merge branch 'sm-1403-review-and-update-cpp-sdk' into update-cpp-vcpkg
tangowithfoxtrot Sep 18, 2024
8413bd0
try windows build
tangowithfoxtrot Sep 18, 2024
e3702e5
debug missing .so file for linux
tangowithfoxtrot Sep 18, 2024
1f64e85
fix: implicit declaration of stringstream
tangowithfoxtrot Sep 18, 2024
e45cfd6
check include/release for the bitwarden-c libs
tangowithfoxtrot Sep 18, 2024
366363f
remove `ls` that was used for debug
tangowithfoxtrot Sep 18, 2024
050024d
fix: Windows needs to link bitwarden_c.dll (not libbitwarden_c.dll)
tangowithfoxtrot Sep 18, 2024
fc8addb
debug missing files again
tangowithfoxtrot Sep 18, 2024
40e6b02
try failing sooner if library files are missing
tangowithfoxtrot Sep 18, 2024
a387afe
fix: bash syntax doesn't work in pwsh
tangowithfoxtrot Sep 18, 2024
55e5262
fix: AND/OR precedence was causing this step to always fail
tangowithfoxtrot Sep 18, 2024
30a62c9
fix: upload bitwarden_c.dll on Windows
tangowithfoxtrot Sep 18, 2024
df41bd2
fix: add TARGET var to Windows build
tangowithfoxtrot Sep 18, 2024
650e175
speed-up Windows build by using msys64 instead of building dependenciโ€ฆ
tangowithfoxtrot Sep 18, 2024
6357acf
fix: add `--noconfirm` to pacman
tangowithfoxtrot Sep 18, 2024
49b59ab
fix: pwsh var interpolation not working; use bash
tangowithfoxtrot Sep 18, 2024
a17b329
try removing install prefix from windows build
tangowithfoxtrot Sep 18, 2024
f3f891d
all the build flags
tangowithfoxtrot Sep 18, 2024
5651cd1
debug
tangowithfoxtrot Sep 18, 2024
049a41a
fix: line breaks are causing syntax error
tangowithfoxtrot Sep 18, 2024
17533b4
add cmake build flags
tangowithfoxtrot Sep 18, 2024
fee04b5
cheat by copying to local include dir
tangowithfoxtrot Sep 18, 2024
7d162ad
add `-r` to `cp` -_-
tangowithfoxtrot Sep 18, 2024
189cf43
cp didn't work; undo
tangowithfoxtrot Sep 18, 2024
27fe5ba
fix windows expected include directories
mzieniukbw Sep 19, 2024
e5e7975
trying out gnu lib instead of msvc for windows
mzieniukbw Sep 19, 2024
1eedbd9
trying out gnu lib instead of msvc for windows v2
mzieniukbw Sep 19, 2024
9610fd6
Revert "trying out gnu lib instead of msvc for windows v2"
mzieniukbw Sep 19, 2024
8478e76
Revert "trying out gnu lib instead of msvc for windows"
mzieniukbw Sep 19, 2024
dc5db61
windows using msvc with vcpkg
mzieniukbw Sep 19, 2024
0cbee90
windows using msvc with vcpkg v2
mzieniukbw Sep 19, 2024
c73d069
vcpkg cache
mzieniukbw Sep 19, 2024
320993d
try static-linking bitwarden-c
tangowithfoxtrot Sep 19, 2024
443c268
try increasing cmake verbosity
tangowithfoxtrot Sep 19, 2024
fb90d5f
fmt: whitespace
tangowithfoxtrot Sep 19, 2024
324c57a
fix: invalid pwsh syntax; use bash
tangowithfoxtrot Sep 19, 2024
25b03c1
Revert "fix: invalid pwsh syntax; use bash"
tangowithfoxtrot Sep 19, 2024
de29ac5
fix: invalid pwsh syntax; use bash
tangowithfoxtrot Sep 19, 2024
172bb26
copy all bitwarden_c files
tangowithfoxtrot Sep 19, 2024
75101fe
fix: copy correct bitwardenclient on windows
tangowithfoxtrot Sep 19, 2024
4cb627f
try copying bitwardenclient from build output dir
tangowithfoxtrot Sep 19, 2024
fa50fa9
try locating bitwarden_c
tangowithfoxtrot Sep 19, 2024
f2a2b17
troubleshoot path
tangowithfoxtrot Sep 19, 2024
6b33981
fix: copy bitwarden_c artifact
tangowithfoxtrot Sep 19, 2024
e657017
Merge branch 'main' into test-cpp-vcpkg-with-gnu-workaround
tangowithfoxtrot Sep 19, 2024
b90cb09
windows builds cleanup
mzieniukbw Sep 20, 2024
a3465d5
windows builds cleanup
mzieniukbw Sep 20, 2024
dfff33d
windows builds cleanup fix
mzieniukbw Sep 20, 2024
c48dd0a
windows c++ build not producing the .lib files fix
mzieniukbw Sep 20, 2024
1276c97
windows use the dynamically linked .lib file for c++
mzieniukbw Sep 20, 2024
781a788
windows include bitwarden_c.dll into the artifacts
mzieniukbw Sep 20, 2024
d0e51b7
Revert: windows include bitwarden_c.dll into the artifacts
mzieniukbw Sep 20, 2024
2c7c678
windows include bitwarden_c.dll into the artifacts testing
mzieniukbw Sep 20, 2024
6f53a89
windows include bitwarden_c.dll into the artifacts fix
mzieniukbw Sep 20, 2024
a768e98
windows include bitwarden_c.dll into the artifacts fix
mzieniukbw Sep 20, 2024
e152c9c
rm commented-out caching; unneeded
tangowithfoxtrot Sep 20, 2024
d950159
fix: use powershell var interpolation; not cmd
tangowithfoxtrot Sep 20, 2024
3d8dd9e
Merge branch 'main' into test-cpp-vcpkg-with-gnu-workaround
tangowithfoxtrot Sep 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 32 additions & 37 deletions .github/workflows/build-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ jobs:
- os: macos-13
target: x86_64-apple-darwin

# - os: windows-2022
# target: x86_64-pc-windows-msvc
- os: macos-13
target: aarch64-apple-darwin

- os: windows-2022
target: x86_64-pc-windows-msvc

- os: ubuntu-22.04
target: x86_64-unknown-linux-gnu
Expand All @@ -52,16 +55,6 @@ jobs:
brew install nlohmann-json
brew install boost

- name: Cache vcpkg
if: runner.os == 'Windows'
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: C:/vcpkg/
key: vcpkg-${{ runner.os }}-${{ matrix.settings.target }}
restore-keys: |
vcpkg-${{ runner.os }}-
vcpkg-

- name: Export GitHub Actions cache environment variables
if: runner.os == 'Windows'
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
Expand All @@ -70,22 +63,6 @@ jobs:
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');

- name: Install libraries for Windows
if: runner.os == 'Windows' && steps.cache.outputs.cache-hit != 'true'
env:
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
run: |
vcpkg install boost --binarysource="clear;x-gha,readwrite"
vcpkg install nlohmann-json --binarysource="clear;x-gha,readwrite"
shell: pwsh

- name: Save cache
if: runner.os == 'Windows'
uses: actions/cache/save@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: C:/vcpkg/
key: vcpkg-${{ runner.os }}-${{ matrix.settings.target }}

- name: Download schemas
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
Expand Down Expand Up @@ -114,6 +91,20 @@ jobs:

Get-Acl languages/cpp/include/* | Format-List

- name: Ensure bitwarden-c is in include folder
working-directory: languages/cpp
shell: bash
run: |
mv include/release/* include/
if [[ '${{ runner.os }}' == 'macOS' || '${{ runner.os }}' == 'Linux' ]]; then
ls include/libbitwarden_c.* || { echo "Missing libbitwarden_c.*"; exit 1; }
fi
if [[ '${{ runner.os }}' == 'Windows' ]]; then
ls include/bitwarden_c.dll || { echo "Missing bitwarden_c.dll"; exit 1; }
ls include/bitwarden_c.dll.lib || { echo "Missing bitwarden_c.dll.lib"; exit 1; }
fi
rmdir include/release

- name: Build unix
working-directory: languages/cpp
if: runner.os == 'macOS' || runner.os == 'Linux'
Expand All @@ -139,24 +130,28 @@ jobs:
if: runner.os == 'Windows'
working-directory: languages/cpp
env:
BOOST_INCLUDE_DIR: C:\vcpkg\installed\x64-windows\include\boost
NLOHMANN_JSON_INCLUDE_DIR: C:\vcpkg\installed\x64-windows\include\nlohmann-json
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
run: |
mkdir build
cd build
$DNLOHMANN_PATH="C:\vcpkg\installed\x64-windows\include\nlohmann-json"
$DBOOST_PATH="C:\vcpkg\installed\x64-windows\include\boost"
$DTARGET="include/libbitwarden_c.dll"
cmake .. -DNLOHMANN=$DNLOHMANN_PATH -DBOOST=$DBOOST_PATH -DTARGET="include/libbitwarden_c.dll" -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/languages/cpp/ -DBUILD_TESTING=OFF
cmake --build .
$env:DTARGET="include\bitwarden_c.dll.lib"
cmake .. -DTARGET="$env:DTARGET" -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT\scripts\buildsystems\vcpkg.cmake"
cmake --build . --config Release
shell: pwsh

- name: Copy artifacts
working-directory: languages/cpp/build
shell: bash
run: |
mkdir artifacts
cp libbitwarden_c.* artifacts
cp libBitwardenClient.* artifacts
if [[ '${{ runner.os }}' == 'macOS' || '${{ runner.os }}' == 'Linux' ]]; then
cp libbitwarden_c.* artifacts
cp libBitwardenClient.* artifacts
fi
if [[ '${{ runner.os }}' == 'Windows' ]]; then
cp */BitwardenClient.* artifacts
cp ../include/bitwarden_c.{lib,dll.lib,dll} artifacts
fi

- name: Upload C++ package for ${{ matrix.settings.target }}
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
Expand Down
1 change: 1 addition & 0 deletions languages/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.15)
project(BitwardenClient)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)

# Set placeholders to be passed from command line
set(NLOHMANN_JSON_INCLUDE_DIR_PLACEHOLDER ${NLOHMANN})
Expand Down
17 changes: 9 additions & 8 deletions languages/cpp/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"name": "bitwarden-sdk-secrets",
"version": "0.1.0",
"homepage": "https://github.com/bitwarden/sdk/tree/languages/cpp",
"description": "Bitwarden Secrets Manager SDK for C++",
"dependencies": [
"boost",
"nlohmann-json"
]
"name": "bitwarden-sdk-secrets",
"version": "0.1.0",
"homepage": "https://github.com/bitwarden/sdk/tree/languages/cpp",
"description": "Bitwarden Secrets Manager SDK for C++",
"dependencies": [
"boost-uuid",
"boost-optional",
"nlohmann-json"
]
}
Loading