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

Cleanup names build samples #39

Merged
merged 10 commits into from
Aug 6, 2024
6 changes: 3 additions & 3 deletions .github/workflows/cmake-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
- name: Build using CMake on Linux for amd64
if: ${{ Contains(matrix.os, 'ubuntu') }}
run: >
./build_samples_x64.sh
./build_plugin_x64.sh
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}

Expand All @@ -93,13 +93,13 @@ jobs:
- name: Build using CMake on Linux for arm64
if: ${{ Contains(matrix.os, 'ubuntu') }}
run: >
./build_samples_arm64.sh
./build_plugin_arm64.sh
-DCMAKE_CXX_COMPILER=${{ matrix.arm_cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.arm_c_compiler }}

- name: Build using CMake on Windows
shell: powershell
if: ${{ Contains(matrix.os, 'windows') }}
run: >
./build_samples.bat
./build_plugin.bat
--no-tests
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
- name: Run build script for Linux x64
if: ${{ Contains(matrix.os, 'ubuntu') }}
run: >
./build_samples_x64.sh
./build_plugin_x64.sh
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}

Expand All @@ -67,7 +67,7 @@ jobs:
- name: Run build script for Linux arm64
if: ${{ Contains(matrix.os, 'ubuntu') }}
run: >
./build_samples_arm64.sh
./build_plugin_arm64.sh
-DCMAKE_CXX_COMPILER=${{ matrix.arm_cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.arm_c_compiler }}

Expand All @@ -83,7 +83,7 @@ jobs:
shell: powershell
if: ${{ Contains(matrix.os, 'windows') }}
run: >
.\build_samples.bat
.\build_plugin.bat
--no-tests

- name: Package Artifacts Windows
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ Run one of the following to build the plugin.
The following will default to your OS selected C compiler.

```bash
./build_samples.sh --no-tests
./build_plugin.sh --no-tests
```

The following will use gcc. You may also replace gcc/g++ with clang/clang++.

```bash
./build_samples.sh --no-tests -DCMAKE_CXX_COMPILER=gcc -DCMAKE_C_COMPILER=g++
./build_plugin.sh --no-tests -DCMAKE_CXX_COMPILER=gcc -DCMAKE_C_COMPILER=g++
```

After running the script the resulting .so file can be found at
Expand Down Expand Up @@ -69,7 +69,7 @@ $Env:VCPKG_ROOT = "Path/To/Vcpkg"
Run the following to build the plugin.

```powershell
./build_samples.bat --no-tests --debug
./build_plugin.bat --no-tests --debug
```

After running the script the resulting `.so` file can be found at
Expand Down
204 changes: 102 additions & 102 deletions build_samples.bat → build_plugin.bat
Original file line number Diff line number Diff line change
@@ -1,102 +1,102 @@
:: Copyright © 2024 Seagate Technology LLC and/or its Affiliates
:: Copyright 2018-present Network Optix, Inc. Licensed under MPL 2.0: www.mozilla.org/MPL/2.0/
@echo off
setlocal %= Reset errorlevel and prohibit changing env vars of the parent shell. =%
if [%1] == [/?] goto :show_usage
if [%1] == [-h] goto :show_usage
if [%1] == [--help] goto :show_usage
goto :skip_show_usage
:show_usage
echo Usage: %~n0%~x0 [--no-tests] [--debug] [^<cmake-generation-args^>...]
echo --debug Compile using Debug configuration (without optimizations) instead of Release.
goto :exit
:skip_show_usage
:: Make the build dir at the same level as the parent dir of this script, suffixed with "-build".
set BASE_DIR_WITH_BACKSLASH=%~dp0
set BASE_DIR=%BASE_DIR_WITH_BACKSLASH:~0,-1%
set BUILD_DIR=%BASE_DIR%-build
if [%1] == [--no-tests] (
shift
set NO_TESTS=1
) else (
set NO_TESTS=0
)
if [%1] == [--debug] (
shift
set BUILD_TYPE=Debug
) else (
set BUILD_TYPE=Release
)
if [%BUILD_TYPE%] == [Release] (
set BUILD_OPTIONS=--config %BUILD_TYPE%
)
echo on
rmdir /S /Q "%BUILD_DIR%" 2>NUL
@echo off
:: Build source
set SOURCE_DIR="%BASE_DIR%\src"
set PLUGIN_NAME="cloudfuse_plugin"
set PLUGIN_BUILD_DIR=%BUILD_DIR%\%PLUGIN_NAME%
@echo on
mkdir "%PLUGIN_BUILD_DIR%" || @exit /b
cd "%PLUGIN_BUILD_DIR%" || @exit /b
cmake "%SOURCE_DIR%" -G "Visual Studio 17 2022" -Ax64 %1 %2 %3 %4 %5 %6 %7 %8 %9 --preset default || @exit /b
cmake --build . %BUILD_OPTIONS% || @exit /b
@echo off
set ARTIFACT=%PLUGIN_BUILD_DIR%\%BUILD_TYPE%\%PLUGIN_NAME%.dll
if not exist "%ARTIFACT%" (
echo ERROR: Failed to build %PLUGIN_NAME%.
exit /b 70
)
echo:
echo Built: %ARTIFACT%
::Build Tests
set SOURCE_DIR="%BASE_DIR%\src\unit_tests"
set UNIT_TESTS="unit_tests"
set UNIT_TESTS_BUILD_DIR=%BUILD_DIR%\%UNIT_TESTS%
@echo on
mkdir "%UNIT_TESTS_BUILD_DIR%" || @exit /b
cd "%UNIT_TESTS_BUILD_DIR%" || @exit /b
cmake "%SOURCE_DIR%" -G "Visual Studio 17 2022" -Ax64 %1 %2 %3 %4 %5 %6 %7 %8 %9 --preset default || @exit /b
cmake --build . %BUILD_OPTIONS% || @exit /b
@echo off
set ARTIFACT=%UNIT_TESTS_BUILD_DIR%\%BUILD_TYPE%\analytics_plugin_ut.exe
if not exist "%ARTIFACT%" (
echo ERROR: Failed to build %UNIT_TESTS%.
exit /b 70
)
echo:
echo Built: %ARTIFACT%
:: Run unit tests if needed.
if [%NO_TESTS%] == [1] echo NOTE: Unit tests were not run. & goto :skip_tests
echo on
cd "%BUILD_DIR%\unit_tests" || @goto :exit
ctest --output-on-failure -C %BUILD_TYPE% || @goto :exit
@echo off
:skip_tests
echo:
echo Samples built successfully, see the binaries in %BUILD_DIR%
goto :exit
:exit
exit /b %ERRORLEVEL% %= Needed for a proper cmd.exe exit status. =%
:: Copyright © 2024 Seagate Technology LLC and/or its Affiliates
:: Copyright 2018-present Network Optix, Inc. Licensed under MPL 2.0: www.mozilla.org/MPL/2.0/

@echo off
setlocal %= Reset errorlevel and prohibit changing env vars of the parent shell. =%

if [%1] == [/?] goto :show_usage
if [%1] == [-h] goto :show_usage
if [%1] == [--help] goto :show_usage
goto :skip_show_usage
:show_usage
echo Usage: %~n0%~x0 [--no-tests] [--debug] [^<cmake-generation-args^>...]
echo --debug Compile using Debug configuration (without optimizations) instead of Release.
goto :exit
:skip_show_usage

:: Make the build dir at the same level as the parent dir of this script, suffixed with "-build".
set BASE_DIR_WITH_BACKSLASH=%~dp0
set BASE_DIR=%BASE_DIR_WITH_BACKSLASH:~0,-1%
set BUILD_DIR=%BASE_DIR%-build

if [%1] == [--no-tests] (
shift
set NO_TESTS=1
) else (
set NO_TESTS=0
)

if [%1] == [--debug] (
shift
set BUILD_TYPE=Debug
) else (
set BUILD_TYPE=Release
)

if [%BUILD_TYPE%] == [Release] (
set BUILD_OPTIONS=--config %BUILD_TYPE%
)

echo on
rmdir /S /Q "%BUILD_DIR%" 2>NUL
@echo off

:: Build source
set SOURCE_DIR="%BASE_DIR%\src"
set PLUGIN_NAME="cloudfuse_plugin"

set PLUGIN_BUILD_DIR=%BUILD_DIR%\%PLUGIN_NAME%
@echo on
mkdir "%PLUGIN_BUILD_DIR%" || @exit /b
cd "%PLUGIN_BUILD_DIR%" || @exit /b

cmake "%SOURCE_DIR%" -G "Visual Studio 17 2022" -Ax64 %1 %2 %3 %4 %5 %6 %7 %8 %9 --preset default || @exit /b
cmake --build . %BUILD_OPTIONS% || @exit /b
@echo off

set ARTIFACT=%PLUGIN_BUILD_DIR%\%BUILD_TYPE%\%PLUGIN_NAME%.dll

if not exist "%ARTIFACT%" (
echo ERROR: Failed to build %PLUGIN_NAME%.
exit /b 70
)
echo:
echo Built: %ARTIFACT%

::Build Tests
set SOURCE_DIR="%BASE_DIR%\src\unit_tests"
set UNIT_TESTS="unit_tests"

set UNIT_TESTS_BUILD_DIR=%BUILD_DIR%\%UNIT_TESTS%
@echo on
mkdir "%UNIT_TESTS_BUILD_DIR%" || @exit /b
cd "%UNIT_TESTS_BUILD_DIR%" || @exit /b

cmake "%SOURCE_DIR%" -G "Visual Studio 17 2022" -Ax64 %1 %2 %3 %4 %5 %6 %7 %8 %9 --preset default || @exit /b
cmake --build . %BUILD_OPTIONS% || @exit /b
@echo off

set ARTIFACT=%UNIT_TESTS_BUILD_DIR%\%BUILD_TYPE%\analytics_plugin_ut.exe

if not exist "%ARTIFACT%" (
echo ERROR: Failed to build %UNIT_TESTS%.
exit /b 70
)
echo:
echo Built: %ARTIFACT%

:: Run unit tests if needed.
if [%NO_TESTS%] == [1] echo NOTE: Unit tests were not run. & goto :skip_tests
echo on
cd "%BUILD_DIR%\unit_tests" || @goto :exit

ctest --output-on-failure -C %BUILD_TYPE% || @goto :exit
@echo off
:skip_tests

echo:
echo Samples built successfully, see the binaries in %BUILD_DIR%
goto :exit

:exit
exit /b %ERRORLEVEL% %= Needed for a proper cmd.exe exit status. =%
18 changes: 9 additions & 9 deletions build_samples.sh → build_plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,19 @@ esac

# Build source plugin
SOURCE_DIR="$BASE_DIR/src"
SAMPLE="cloudfuse_plugin"
PLUGIN_NAME="cloudfuse_plugin"
(set -x #< Log each command.
mkdir -p "$BUILD_DIR/$SAMPLE"
cd "$BUILD_DIR/$SAMPLE"
mkdir -p "$BUILD_DIR/$PLUGIN_NAME"
cd "$BUILD_DIR/$PLUGIN_NAME"

cmake "$SOURCE_DIR" `# allow empty array #` ${GEN_OPTIONS[@]+"${GEN_OPTIONS[@]}"} "$@"
cmake --build . `# allow empty array #` ${BUILD_OPTIONS[@]+"${BUILD_OPTIONS[@]}"}
)

ARTIFACT=$(find "$BUILD_DIR" -name "$SAMPLE.dll" -o -name "lib$SAMPLE.so")
ARTIFACT=$(find "$BUILD_DIR" -name "$PLUGIN_NAME.dll" -o -name "lib$PLUGIN_NAME.so")
if [ ! -f "$ARTIFACT" ]
then
echo "ERROR: Failed to build $SAMPLE."
echo "ERROR: Failed to build $PLUGIN_NAME."
exit 64
fi
echo ""
Expand All @@ -86,10 +86,10 @@ echo ""

# Build unit tests
SOURCE_DIR="$BASE_DIR/src/unit_tests"
SAMPLE="unit_tests"
UNIT_TESTS="unit_tests"
(set -x #< Log each command.
mkdir -p "$BUILD_DIR/$SAMPLE"
cd "$BUILD_DIR/$SAMPLE"
mkdir -p "$BUILD_DIR/$UNIT_TESTS"
cd "$BUILD_DIR/$UNIT_TESTS"

cmake "$SOURCE_DIR" `# allow empty array #` ${GEN_OPTIONS[@]+"${GEN_OPTIONS[@]}"} "$@"
cmake --build . `# allow empty array #` ${BUILD_OPTIONS[@]+"${BUILD_OPTIONS[@]}"}
Expand All @@ -98,7 +98,7 @@ SAMPLE="unit_tests"
ARTIFACT=$(find "$BUILD_DIR" -name "analytics_plugin_ut.exe" -o -name "analytics_plugin_ut")
if [ ! -f "$ARTIFACT" ]
then
echo "ERROR: Failed to build $SAMPLE."
echo "ERROR: Failed to build $UNIT_TESTS."
exit 64
fi
echo ""
Expand Down
2 changes: 1 addition & 1 deletion build_samples_arm32.sh → build_plugin_arm32.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ BASE_DIR=$(readlink -f "$(dirname "$0")") #< Absolute path to the current dir.

set -x #< Log each command.

"$BASE_DIR"/build_samples.sh \
"$BASE_DIR"/build_plugin.sh \
--no-tests \
-DCMAKE_TOOLCHAIN_FILE=$BASE_DIR/toolchain_arm32.cmake \
"$@"
2 changes: 1 addition & 1 deletion build_samples_arm64.sh → build_plugin_arm64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ BASE_DIR=$(readlink -f "$(dirname "$0")") #< Absolute path to the current dir.

set -x #< Log each command.

"$BASE_DIR"/build_samples.sh \
"$BASE_DIR"/build_plugin.sh \
--no-tests \
-DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT"/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=arm64-linux \
-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE="$BASE_DIR/toolchain_arm64.cmake" \
Expand Down
2 changes: 1 addition & 1 deletion build_samples_x64.sh → build_plugin_x64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ BASE_DIR=$(readlink -f "$(dirname "$0")") #< Absolute path to the current dir.

set -x #< Log each command.

"$BASE_DIR"/build_samples.sh \
"$BASE_DIR"/build_plugin.sh \
--no-tests \
-DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT"/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-linux \
-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE="$BASE_DIR/toolchain_x64.cmake" \
Expand Down
8 changes: 4 additions & 4 deletions tools/format.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

find ./src/lib/cloudfuse/ -iname '*.h' -o -iname '*.cpp' | xargs 'C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\Llvm\bin\clang-format.exe' -i
find ./src/plugin/ -iname '*.h' -o -iname '*.cpp' | xargs 'C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\Llvm\bin\clang-format.exe' -i
find ./src/unit_tests/ -iname '*.h' -o -iname '*.cpp' | xargs 'C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\Llvm\bin\clang-format.exe' -i
find ./unit_tests/ -iname '*.h' -o -iname '*.cpp' | xargs 'C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\Llvm\bin\clang-format.exe' -i
find ./src/lib/cloudfuse/ -iname '*.h' -o -iname '*.cpp' | xargs 'clang-format' -i
find ./src/plugin/ -iname '*.h' -o -iname '*.cpp' | xargs 'clang-format' -i
find ./src/unit_tests/ -iname '*.h' -o -iname '*.cpp' | xargs 'clang-format' -i
find ./unit_tests/ -iname '*.h' -o -iname '*.cpp' | xargs 'clang-format' -i
Loading