Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
32 changes: 12 additions & 20 deletions .github/workflows/test_cpp_client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ name: C++ Client and ROS 2 C++ Node CI
- main
paths:
- ".github/workflows/test_cpp_client.yml"
- "build_cpp_client.cmd"
- "build_cpp_client.sh"
- "client/cpp/**"
- "client/python/example_user_scripts/sim_config/**"
- "core_sim/**"
Expand All @@ -16,6 +18,8 @@ name: C++ Client and ROS 2 C++ Node CI
- main
paths:
- ".github/workflows/test_cpp_client.yml"
- "build_cpp_client.cmd"
- "build_cpp_client.sh"
- "client/cpp/**"
- "client/python/example_user_scripts/sim_config/**"
- "core_sim/**"
Expand Down Expand Up @@ -44,11 +48,15 @@ jobs:
filters: |
client:
- '.github/workflows/test_cpp_client.yml'
- 'build_cpp_client.cmd'
- 'build_cpp_client.sh'
- 'client/cpp/**'
- 'client/python/example_user_scripts/sim_config/**'
- 'core_sim/**'
ros2:
- '.github/workflows/test_cpp_client.yml'
- 'build_cpp_client.cmd'
- 'build_cpp_client.sh'
- 'ros/projectairsim_ros2_cpp/**'
- 'client/cpp/**'
- 'client/python/example_user_scripts/sim_config/**'
Expand All @@ -67,17 +75,9 @@ jobs:
- name: Enable Developer Command Prompt
uses: ilammy/msvc-dev-cmd@v1

- name: Configure
- name: Build and run mocked unit tests
shell: cmd
run: >
cmake -S client/cpp
-B client/cpp/build_windows/Release
-G Ninja
-DCMAKE_BUILD_TYPE=Release

- name: Build
shell: cmd
run: cmake --build client/cpp/build_windows/Release --config Release --parallel
run: call .\build_cpp_client.cmd release --tests

- name: Package
shell: cmd
Expand Down Expand Up @@ -188,17 +188,9 @@ jobs:
sudo apt-get -y install --no-install-recommends \
build-essential cmake ninja-build

- name: Configure
shell: bash
run: |
cmake -S client/cpp \
-B client/cpp/build_linux/Release \
-G Ninja \
-DCMAKE_BUILD_TYPE=Release

- name: Build
- name: Build and run mocked unit tests
shell: bash
run: cmake --build client/cpp/build_linux/Release --config Release --parallel
run: ./build_cpp_client.sh release --tests

- name: Package
shell: bash
Expand Down
102 changes: 102 additions & 0 deletions build_cpp_client.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
@echo off
REM Copyright (C) Microsoft Corporation.
REM Copyright (C) 2025 IAMAI CONSULTING CORP
REM MIT License.

setlocal EnableExtensions EnableDelayedExpansion

set "BUILD_TYPE=Debug"
set "RUN_TESTS=OFF"

:parse_args
if "%~1"=="" goto args_done
if /I "%~1"=="debug" (
set "BUILD_TYPE=Debug"
shift
goto parse_args
)
if /I "%~1"=="release" (
set "BUILD_TYPE=Release"
shift
goto parse_args
)
if /I "%~1"=="--tests" (
set "RUN_TESTS=ON"
shift
goto parse_args
)
if /I "%~1"=="--test" (
set "RUN_TESTS=ON"
shift
goto parse_args
)
if /I "%~1"=="--help" goto usage
if /I "%~1"=="-h" goto usage
echo Unknown argument: %~1
goto usage_error

:args_done
set "ROOT_DIR=%~dp0"

REM Reuse an already initialized MSVC environment, such as a Developer
REM Command Prompt or the environment prepared by CI.
where /q cl.exe
if not errorlevel 1 goto compiler_ready

set "VS_INSTALL_DIR="
if defined VSINSTALLDIR set "VS_INSTALL_DIR=%VSINSTALLDIR%"

if not defined VS_INSTALL_DIR call :check_vs_install "%ProgramFiles%\Microsoft Visual Studio\2022\Community"
if not defined VS_INSTALL_DIR call :check_vs_install "%ProgramFiles%\Microsoft Visual Studio\2022\Professional"
if not defined VS_INSTALL_DIR call :check_vs_install "%ProgramFiles%\Microsoft Visual Studio\2022\Enterprise"
if not defined VS_INSTALL_DIR call :check_vs_install "%SystemDrive%\Progra~2\Microsoft Visual Studio\2022\BuildTools"

if not defined VS_INSTALL_DIR if exist "%SystemDrive%\Progra~2\Microsoft Visual Studio\Installer\vswhere.exe" (
for /f "tokens=*" %%I in ('"%SystemDrive%\Progra~2\Microsoft Visual Studio\Installer\vswhere.exe" -version "[17.0,18.0)" -latest -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath') do set "VS_INSTALL_DIR=%%I"
)

if not defined VS_INSTALL_DIR (
echo [ERROR] MSVC was not found. Install Visual Studio 2022 Build Tools with
echo the Desktop development with C++ workload.
exit /b 1
)

call "%VS_INSTALL_DIR%\VC\Auxiliary\Build\vcvarsall.bat" x64
if errorlevel 1 exit /b 1

:compiler_ready
where /q ninja
if errorlevel 1 (
echo [ERROR] Ninja was not found. Install Ninja or add it to PATH.
exit /b 1
)

set "BUILD_DIR=%ROOT_DIR%client\cpp\build_windows\%BUILD_TYPE%"
cmake -S "%ROOT_DIR%client\cpp" -B "%BUILD_DIR%" -G Ninja -DCMAKE_BUILD_TYPE=%BUILD_TYPE% -DBUILD_TESTING=%RUN_TESTS%
if errorlevel 1 exit /b 1
cmake --build "%BUILD_DIR%" --parallel
if errorlevel 1 exit /b 1

if /I "%RUN_TESTS%"=="ON" (
ctest --test-dir "%BUILD_DIR%" --output-on-failure
if errorlevel 1 exit /b 1
)

exit /b 0

:check_vs_install
if exist "%~1\VC\Auxiliary\Build\vcvarsall.bat" set "VS_INSTALL_DIR=%~1"
exit /b 0

:usage
echo Usage: build_cpp_client.cmd [debug^|release] [--tests]
echo.
echo Build the standalone ProjectAirSim C++ client without building SimLibs.
echo debug Build Debug artifacts (default).
echo release Build Release artifacts.
echo --tests Build and run the mocked unit tests. A simulator is not required.
exit /b 0

:usage_error
call :usage
exit /b 2
42 changes: 42 additions & 0 deletions build_cpp_client.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash
# Copyright (C) Microsoft Corporation.
# Copyright (C) 2025 IAMAI CONSULTING CORP
# MIT License.

set -euo pipefail

usage() {
cat <<'EOF'
Usage: ./build_cpp_client.sh [debug|release] [--tests]

Build the standalone ProjectAirSim C++ client without building SimLibs.
debug Build Debug artifacts (default).
release Build Release artifacts.
--tests Build and run the mocked unit tests. A simulator is not required.
EOF
}

build_type=Debug
run_tests=false

for arg in "$@"; do
case "$arg" in
debug) build_type=Debug ;;
release) build_type=Release ;;
--tests|--test) run_tests=true ;;
-h|--help) usage; exit 0 ;;
*) echo "Unknown argument: $arg" >&2; usage >&2; exit 2 ;;
esac
done

root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
build_dir="$root_dir/client/cpp/build_linux/$build_type"

cmake -S "$root_dir/client/cpp" -B "$build_dir" -G Ninja \
-DCMAKE_BUILD_TYPE="$build_type" \
-DBUILD_TESTING="$run_tests"
cmake --build "$build_dir" --parallel

if "$run_tests"; then
ctest --test-dir "$build_dir" --output-on-failure
fi
52 changes: 4 additions & 48 deletions build_linux.mk
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@ default:
@echo " all_no_test = Build + Package everything"
@echo " clean = Clean sim libs + Blocks build files"
@echo
@echo " simlibs_debug = Build sim libs + C++ client for Debug"
@echo " simlibs_release = Build sim libs + C++ client for Release"
@echo " cpp_client_debug = Build C++ client only for Debug"
@echo " cpp_client_release = Build C++ client only for Release"
@echo " package_cpp_client = Build Release C++ client and create versioned package"
@echo " simlibs_debug = Build sim libs for Debug"
@echo " simlibs_release = Build sim libs for Release"
@echo " test_simlibs_debug = Test sim libs for Debug"
@echo " test_simlibs_release = Test sim libs for Release"
@echo
Expand Down Expand Up @@ -65,55 +62,15 @@ CMAKE_CMD = cmake -G "Ninja"
CMAKE_DBG_BUILD_CMD = cmake --build $(CMAKE_BUILD_DIR)/Debug
CMAKE_REL_BUILD_CMD = cmake --build $(CMAKE_BUILD_DIR)/Release

CPP_CLIENT_DIR = client/cpp
CPP_CLIENT_DBG_BUILD_DIR = $(CPP_CLIENT_DIR)/build_linux/Debug
CPP_CLIENT_REL_BUILD_DIR = $(CPP_CLIENT_DIR)/build_linux/Release
CPP_CLIENT_CMAKE_CMD = cmake -G "Ninja"
CPP_CLIENT_DBG_BUILD_CMD = cmake --build $(CPP_CLIENT_DBG_BUILD_DIR) -j$(shell nproc)
CPP_CLIENT_REL_BUILD_CMD = cmake --build $(CPP_CLIENT_REL_BUILD_DIR) -j$(shell nproc)
CPP_CLIENT_PACKAGE_CMD = cmake --build $(CPP_CLIENT_REL_BUILD_DIR) --target package

.PHONY: config_simlibs_debug
config_simlibs_debug:
@echo "======================================================================="
@echo "Configuring the ProjectAirSimLibs project for Linux64-Debug..."
mkdir -p $(CMAKE_BUILD_DIR)/Debug $(REDIRECT_OUTPUT)
cd $(CMAKE_BUILD_DIR)/Debug && $(CMAKE_CMD) -DCMAKE_BUILD_TYPE=Debug ../../..

.PHONY: config_cpp_client_debug
config_cpp_client_debug:
@echo "======================================================================="
@echo "Configuring the C++ client project for Linux64-Debug..."
mkdir -p $(CPP_CLIENT_DBG_BUILD_DIR) $(REDIRECT_OUTPUT)
cd $(CPP_CLIENT_DBG_BUILD_DIR) && $(CPP_CLIENT_CMAKE_CMD) -DCMAKE_BUILD_TYPE=Debug $(CURDIR)/$(CPP_CLIENT_DIR)

.PHONY: cpp_client_debug
cpp_client_debug: config_cpp_client_debug
@echo "======================================================================="
@echo "Building the C++ client project for Linux64-Debug..."
$(CPP_CLIENT_DBG_BUILD_CMD)

.PHONY: config_cpp_client_release
config_cpp_client_release:
@echo "======================================================================="
@echo "Configuring the C++ client project for Linux64-Release..."
mkdir -p $(CPP_CLIENT_REL_BUILD_DIR) $(REDIRECT_OUTPUT)
cd $(CPP_CLIENT_REL_BUILD_DIR) && $(CPP_CLIENT_CMAKE_CMD) -DCMAKE_BUILD_TYPE=Release $(CURDIR)/$(CPP_CLIENT_DIR)

.PHONY: cpp_client_release
cpp_client_release: config_cpp_client_release
@echo "======================================================================="
@echo "Building the C++ client project for Linux64-Release..."
$(CPP_CLIENT_REL_BUILD_CMD)

.PHONY: package_cpp_client
package_cpp_client: cpp_client_release
@echo "======================================================================="
@echo "Packaging the C++ client for Linux64-Release..."
$(CPP_CLIENT_PACKAGE_CMD)

.PHONY: simlibs_debug
simlibs_debug: config_simlibs_debug cpp_client_debug
simlibs_debug: config_simlibs_debug
@echo "======================================================================="
@echo "Building the ProjectAirSimLibs project for Linux64-Debug..."
$(CMAKE_DBG_BUILD_CMD)
Expand All @@ -126,7 +83,7 @@ config_simlibs_release:
cd $(CMAKE_BUILD_DIR)/Release && $(CMAKE_CMD) -DCMAKE_BUILD_TYPE=Release ../../..

.PHONY: simlibs_release
simlibs_release: config_simlibs_release cpp_client_release
simlibs_release: config_simlibs_release
@echo "======================================================================="
@echo "Building the ProjectAirSimLibs project for Linux64-Release..."
$(CMAKE_REL_BUILD_CMD)
Expand All @@ -145,7 +102,6 @@ clean:
@echo "======================================================================="
@echo "Cleaning build files..."
rm -fr $(CMAKE_BUILD_DIR) $(REDIRECT_OUTPUT)
rm -fr $(CPP_CLIENT_DIR)/build_linux $(REDIRECT_OUTPUT)
rm -fr physics/matlab_sfunc/_deps $(REDIRECT_OUTPUT)
rm -fr physics/matlab_sfunc/message $(REDIRECT_OUTPUT)
rm -fr packages/projectairsim_simlibs $(REDIRECT_OUTPUT)
Expand Down
Loading
Loading