Skip to content

Commit

Permalink
Moved C++ headers to miniocpp subdirectory
Browse files Browse the repository at this point in the history
  * Use #include <miniocpp/header.h> to include minio-cpp now
  * Header files have consistent guards that don't start with _
  * Added a SPDX license identifier to each source and header file
  * Use clang-format-18 to format the source code
  • Loading branch information
kobalicek committed Mar 26, 2024
1 parent b29b43e commit f97b3b3
Show file tree
Hide file tree
Showing 84 changed files with 559 additions and 373 deletions.
91 changes: 52 additions & 39 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,34 @@ permissions:
contents: read

jobs:
coding-style:
name: "Coding Style Check"
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install dependencies if Ubuntu
run: |
wget --quiet -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
echo 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-18 main' | sudo tee -a /etc/apt/sources.list
sudo apt-get -qy update
sudo apt-get -qy install clang-format-18
clang-format-18 --version
- name: Coding Style Check
shell: bash
run: |
CLANG_FORMAT=clang-format-18 ./check-style.sh
build:
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- {
name: "Ubuntu_Latest_GCC",
os: Ubuntu-latest,
os: ubuntu-latest,
build_type: "Release",
cc: "gcc",
cxx: "g++"
Expand All @@ -45,8 +63,20 @@ jobs:
cxx: "cl"
}

name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}

steps:
- uses: actions/checkout@v2
- name: Checkout minio-cpp
uses: actions/checkout@v4
with:
path: "minio-cpp"

- name: Checkout vcpkg
uses: actions/checkout@v4
with:
repository: microsoft/vcpkg
path: "vcpkg"

- name: Print env
run: |
Expand All @@ -57,22 +87,20 @@ jobs:
if: startsWith(matrix.config.name, 'Ubuntu_Latest_GCC')
run: |
wget --quiet -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
echo 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main' | sudo tee -a /etc/apt/sources.list
echo 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-18 main' | sudo tee -a /etc/apt/sources.list
sudo apt-get -qy update
sudo apt-get -qy install cmake clang-format-14
sudo apt-get -qy install cmake
wget --quiet https://dl.min.io/server/minio/release/linux-amd64/minio
chmod +x minio
cmake --version
clang-format --version
./minio --version
- name: Install dependencies if macOS
if: startsWith(matrix.config.os, 'macos')
run: |
brew install pkg-config cmake clang-format minio/stable/minio
brew install pkg-config cmake minio/stable/minio
cmake --version
minio --version
clang-format --version
- name: Install dependencies if Windows
shell: bash
Expand All @@ -83,35 +111,21 @@ jobs:
chmod +x minio.exe
cmake --version
- name: Install vcpkg
shell: bash
run: |
mkdir -p ~/.vcpkg
touch ~/.vcpkg/vcpkg.path.txt
wget --quiet -O vcpkg-master.zip https://github.com/microsoft/vcpkg/archive/refs/heads/master.zip
unzip -qq vcpkg-master.zip
./vcpkg-master/bootstrap-vcpkg.sh
./vcpkg-master/vcpkg integrate install
./vcpkg-master/vcpkg install
- name: C++ Style check if not Windows
if: ${{ !startsWith(matrix.config.os, 'windows') }}
shell: bash
run: |
./check-style.sh
- name: Configure and Build
shell: bash
run: |
cmake -B ./build -DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} -DCMAKE_TOOLCHAIN_FILE=./vcpkg-master/scripts/buildsystems/vcpkg.cmake -DMINIO_CPP_TEST:BOOL=ON
cmake --build ./build --config ${{ matrix.config.build_type }} -j 4
./vcpkg/bootstrap-vcpkg.sh
cd minio-cpp
../vcpkg/vcpkg install
cmake . -B ./build -DCMAKE_BUILD_TYPE=${{matrix.config.build_type}} -DCMAKE_TOOLCHAIN_FILE=../vcpkg/scripts/buildsystems/vcpkg.cmake -DMINIO_CPP_TEST:BOOL=ON
cmake --build ./build --config ${{matrix.config.build_type}} -j 4
- name: Start MinIO server if Ubuntu
if: startsWith(matrix.config.name, 'Ubuntu_Latest_GCC')
run: |
mkdir -p ~/.minio/certs
cp ./tests/public.crt ./tests/private.key ~/.minio/certs/
sudo cp ./tests/public.crt /usr/local/share/ca-certificates/
cp ./minio-cpp/tests/public.crt ./minio-cpp/tests/private.key ~/.minio/certs/
sudo cp ./minio-cpp/tests/public.crt /usr/local/share/ca-certificates/
sudo update-ca-certificates
MINIO_CI_CD=true ./minio server /tmp/test-xl/{1...4}/ &
sleep 10
Expand All @@ -127,29 +141,28 @@ jobs:
shell: bash
run: |
mkdir -p ~/.minio/certs
cp ./tests/public.crt ./tests/private.key ~/.minio/certs/
certutil -addstore -f "ROOT" ./tests/public.crt
cp ./minio-cpp/tests/public.crt ./minio-cpp/tests/private.key ~/.minio/certs/
certutil -addstore -f "ROOT" ./minio-cpp/tests/public.crt
MINIO_CI_CD=true ./minio.exe server test-xl/{1...4}/ &
sleep 10
- name: Run tests if Ubuntu
if: startsWith(matrix.config.name, 'Ubuntu_Latest_GCC')
run: |
SERVER_ENDPOINT=localhost:9000 ACCESS_KEY=minioadmin SECRET_KEY=minioadmin ENABLE_HTTPS=1 ./build/tests
SERVER_ENDPOINT=localhost:9000 ACCESS_KEY=minioadmin SECRET_KEY=minioadmin ENABLE_HTTPS=1 ./minio-cpp/build/tests
- name: Run tests if macOS
if: startsWith(matrix.config.name, 'macos')
run: |
SERVER_ENDPOINT=localhost:9000 ACCESS_KEY=minioadmin SECRET_KEY=minioadmin ./build/tests
SERVER_ENDPOINT=localhost:9000 ACCESS_KEY=minioadmin SECRET_KEY=minioadmin ./minio-cpp/build/tests
- name: Run tests if Windows
shell: bash
if: startsWith(matrix.config.os, 'windows')
run: |
SERVER_ENDPOINT=localhost:9000 ACCESS_KEY=minioadmin SECRET_KEY=minioadmin ENABLE_HTTPS=1 ./build/Release/tests.exe
SERVER_ENDPOINT=localhost:9000 ACCESS_KEY=minioadmin SECRET_KEY=minioadmin ENABLE_HTTPS=1 ./minio-cpp/build/Release/tests.exe
- name: Run CMake test
working-directory: ${{github.workspace}}/build
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -C ${{ matrix.config.build_type }}
run: |
cd minio-cpp/build
ctest -C ${{ matrix.config.build_type }}
35 changes: 19 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.10)
cmake_policy(SET CMP0091 NEW)

Expand Down Expand Up @@ -97,21 +100,21 @@ set(MINIO_CPP_SOURCES
)

set(MINIO_CPP_HEADERS
include/args.h
include/baseclient.h
include/client.h
include/config.h
include/credentials.h
include/error.h
include/http.h
include/providers.h
include/request.h
include/response.h
include/select.h
include/signer.h
include/sse.h
include/types.h
include/utils.h
include/miniocpp/args.h
include/miniocpp/baseclient.h
include/miniocpp/client.h
include/miniocpp/config.h
include/miniocpp/credentials.h
include/miniocpp/error.h
include/miniocpp/http.h
include/miniocpp/providers.h
include/miniocpp/request.h
include/miniocpp/response.h
include/miniocpp/select.h
include/miniocpp/signer.h
include/miniocpp/sse.h
include/miniocpp/types.h
include/miniocpp/utils.h
)

add_library(miniocpp STATIC ${MINIO_CPP_SOURCES} ${MINIO_CPP_HEADERS})
Expand Down Expand Up @@ -235,7 +238,7 @@ install(EXPORT miniocpp-config
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/miniocpp")

install(FILES
${MINIO_CPP_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/miniocpp")
${MINIO_CPP_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/minio-cpp")

configure_file(miniocpp.pc.in ${CMAKE_CURRENT_BINARY_DIR}/miniocpp.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/miniocpp.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Typically `minio-cpp` will be part of dependencies specified in `vcpkg.json` fil

## Hacking minio-cpp

In order to run minio-cpp tests and examples, you can do the following assuming `VCPKG_ROOT` points to a `vcpkg` installation:
In order to run minio-cpp tests and examples, you can do the following assuming `VCPKG_ROOT` points to a valid `vcpkg` installation:

```bash
$ git clone https://github.com/minio/minio-cpp
Expand All @@ -58,11 +58,10 @@ The examples above assumed that you have `vcpkg` already installed and you have
```bash
$ git clone https://github.com/minio/minio-cpp
$ cd minio-cpp
$ wget --quiet -O vcpkg-master.zip https://github.com/microsoft/vcpkg/archive/refs/heads/master.zip
$ unzip -qq vcpkg-master.zip
$ ./vcpkg-master/bootstrap-vcpkg.sh
$ ./vcpkg-master/vcpkg integrate install
$ cmake . -B ./build/Debug -DCMAKE_BUILD_TYPE=Debug -DMINIO_CPP_TEST=ON -DCMAKE_TOOLCHAIN_FILE=./vcpkg-master/scripts/buildsystems/vcpkg.cmake
$ git clone https://github.com/microsoft/vcpkg.git
$ ./vcpkg/bootstrap-vcpkg.sh
$ ./vcpkg/vcpkg install
$ cmake . -B ./build/Debug -DCMAKE_BUILD_TYPE=Debug -DMINIO_CPP_TEST=ON -DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake
$ cmake --build ./build/Debug
```

Expand Down
14 changes: 9 additions & 5 deletions check-style.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
#!/bin/bash

function clang_format() {
echo "verifying 'clang-format --output-replacements-xml --style=Google $@'"
if clang-format --output-replacements-xml --style=Google "$@" | grep -q '<replacement '; then
if [ -z "${CLANG_FORMAT}" ]; then
CLANG_FORMAT="clang-format"
fi

function do_clang_format() {
echo "verifying '${CLANG_FORMAT} --output-replacements-xml --style=Google $@'"
if ${CLANG_FORMAT} --output-replacements-xml --style=Google "$@" | grep -q '<replacement '; then
echo "ERROR:" "$@" "not in Google C/C++ style"
echo "To fix formatting run"
echo "$ clang-format -i --style=Google" "$@"
echo "$ ${CLANG_FORMAT} -i --style=Google" "$@"
return 255
fi
}
Expand All @@ -14,7 +18,7 @@ tmpfile="tmpfile.$RANDOM"
find src include examples tests -iname "*.cc" -o -iname "*.h" > "$tmpfile"
ec=0
while read -r file; do
if ! clang_format "$file"; then
if ! do_clang_format "$file"; then
ec=255
fi
done < "$tmpfile"
Expand Down
6 changes: 4 additions & 2 deletions examples/BucketExists.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// MinIO C++ Library for Amazon S3 Compatible Cloud Storage
// Copyright 2022 MinIO, Inc.
// Copyright 2022-2024 MinIO, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -12,8 +12,10 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0

#include "client.h"
#include <miniocpp/client.h>

int main() {
// Create S3 base URL.
Expand Down
6 changes: 4 additions & 2 deletions examples/ComposeObject.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// MinIO C++ Library for Amazon S3 Compatible Cloud Storage
// Composeright 2022 MinIO, Inc.
// Copyright 2022-2024 MinIO, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -12,8 +12,10 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0

#include "client.h"
#include <miniocpp/client.h>

int main() {
// Create S3 base URL.
Expand Down
6 changes: 4 additions & 2 deletions examples/CopyObject.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// MinIO C++ Library for Amazon S3 Compatible Cloud Storage
// Copyright 2022 MinIO, Inc.
// Copyright 2022-2024 MinIO, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -12,8 +12,10 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0

#include "client.h"
#include <miniocpp/client.h>

int main() {
// Create S3 base URL.
Expand Down
6 changes: 4 additions & 2 deletions examples/DeleteBucketEncryption.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// MinIO C++ Library for Amazon S3 Compatible Cloud Storage
// Copyright 2022 MinIO, Inc.
// Copyright 2022-2024 MinIO, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -12,8 +12,10 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0

#include "client.h"
#include <miniocpp/client.h>

int main() {
// Create S3 base URL.
Expand Down
6 changes: 4 additions & 2 deletions examples/DeleteBucketLifecycle.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// MinIO C++ Library for Amazon S3 Compatible Cloud Storage
// Copyright 2022 MinIO, Inc.
// Copyright 2022-2024 MinIO, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -12,8 +12,10 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0

#include "client.h"
#include <miniocpp/client.h>

int main() {
// Create S3 base URL.
Expand Down
6 changes: 4 additions & 2 deletions examples/DeleteBucketNotification.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// MinIO C++ Library for Amazon S3 Compatible Cloud Storage
// Copyright 2022 MinIO, Inc.
// Copyright 2022-2024 MinIO, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -12,8 +12,10 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0

#include "client.h"
#include <miniocpp/client.h>

int main() {
// Create S3 base URL.
Expand Down
Loading

0 comments on commit f97b3b3

Please sign in to comment.