Skip to content

Commit

Permalink
feat: Refactor stacktrace definitions and add platform-specific confi… (
Browse files Browse the repository at this point in the history
#82)

* feat: Refactor stacktrace definitions and add platform-specific configurations

* feat: Update Open Space Toolkit Core version to 2.2.0 in CMakeLists, Python requirements, and Dockerfile

* fix: Remove architecture-specific stacktrace definitions in CMakeLists.txt

* style: update ostk-core dockerfile versioning to match other ostk repos

* Apply suggestions from code review

Co-authored-by: Antoine Paletta <[email protected]>

---------

Co-authored-by: Antoine Paletta <[email protected]>
  • Loading branch information
guillaumeloftorbital and apaletta3 authored Mar 25, 2024
1 parent 34df4d7 commit 4883f83
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 8 deletions.
20 changes: 17 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -218,15 +218,29 @@ SET (Boost_USE_MULTITHREADED ON)

FIND_PACKAGE ("Boost" "1.82" REQUIRED COMPONENTS "url" "system" "filesystem" "regex" "log")

ADD_DEFINITIONS(-DBOOST_STACKTRACE_USE_BACKTRACE -DBOOST_STACKTRACE_BACKTRACE_INCLUDE_FILE=</usr/lib/gcc/x86_64-linux-gnu/9/include/backtrace.h>)
## Stacktrace definitions
# Detect system architecture
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
# Architecture-specific include for x86_64
set(BACKTRACE_INCLUDE "/usr/lib/gcc/x86_64-linux-gnu/9/include/backtrace.h")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
# Example path adjustment for aarch64, adjust the path as needed
set(BACKTRACE_INCLUDE "/usr/lib/gcc/aarch64-linux-gnu/9/include/backtrace.h")
else()
message(FATAL_ERROR "Unsupported architecture: ${CMAKE_SYSTEM_PROCESSOR}")
endif()

# Add definitions with architecture-specific path
ADD_DEFINITIONS(-DBOOST_STACKTRACE_USE_BACKTRACE)
ADD_DEFINITIONS(-DBOOST_STACKTRACE_BACKTRACE_INCLUDE_FILE=<${BACKTRACE_INCLUDE}>)

IF (NOT Boost_FOUND)
MESSAGE (SEND_ERROR "[Boost] not found.")
ENDIF ()

### Open Space Toolkit ▸ Core [2.1.x]
### Open Space Toolkit ▸ Core [3.0.x]

FIND_PACKAGE ("OpenSpaceToolkitCore" "2.1" REQUIRED)
FIND_PACKAGE ("OpenSpaceToolkitCore" "3.0" REQUIRED)

IF (NOT OpenSpaceToolkitCore_FOUND)

Expand Down
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ extract_python_package_version := $(shell echo $(project_version) | sed 's/-/./'

dev_username := developer


# Handle multi-platform builds locally (CI sets these env vars, but need defaults here)
TARGETPLATFORM ?= linux/amd64
$(info Target platform is $(TARGETPLATFORM))


pull: ## Pull all images

@ echo "Pulling images..."
Expand Down Expand Up @@ -213,6 +219,7 @@ build-packages-cpp-standalone: ## Build C++ packages (standalone)
@ echo "Building C++ packages..."

docker run \
--platform $(TARGETPLATFORM) \
--rm \
--volume="$(CURDIR):/app:delegated" \
--volume="/app/build" \
Expand All @@ -236,6 +243,7 @@ build-packages-python-standalone: ## Build Python packages (standalone)
@ echo "Building Python packages..."

docker run \
--platform $(TARGETPLATFORM) \
--rm \
--volume="$(CURDIR):/app:delegated" \
--volume="/app/build" \
Expand Down
9 changes: 9 additions & 0 deletions bindings/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,15 @@ FUNCTION (PY_ADD_PACKAGE_DIRECTORY NAME)
# Package directory name
SET (PACKAGE_DIRECTORY_NAME ${NAME})

# Set platforme name for wheel
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
SET (PLATFORM "manylinux2014_x86_64")
ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
SET (PLATFORM "manylinux2014_aarch64")
ELSE()
MESSAGE (FATAL_ERROR "Unsupported platform")
ENDIF()

# Get python extension for relevant shared library spotting
STRING (REPLACE "." "" EXTENSION "${PYTHON_VERSION}")

Expand Down
2 changes: 1 addition & 1 deletion bindings/python/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Apache License 2.0

open-space-toolkit-core~=2.1.0
open-space-toolkit-core~=3.0.0
1 change: 1 addition & 0 deletions bindings/python/tools/python/setup.cfg.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[bdist_wheel]
python-tag=py${EXTENSION}
bdist-dir=./dist${EXTENSION}
plat-name=${PLATFORM}

[metadata]
name = open-space-toolkit-io
Expand Down
21 changes: 17 additions & 4 deletions docker/development/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@ ARG BASE_IMAGE_VERSION="latest"

# General purpose development image (root user)

FROM openspacecollective/open-space-toolkit-base:${BASE_IMAGE_VERSION} as root-user
FROM openspacecollective/open-space-toolkit-base-development:${BASE_IMAGE_VERSION} as root-user

LABEL maintainer="[email protected]"

# Dependencies

# jq

RUN apt-get update \
&& apt-get install -y jq \
&& rm -rf /var/lib/apt/lists/*

## {fmt}

ARG FMT_VERSION="5.2.0"
Expand All @@ -32,12 +38,19 @@ RUN apt-get update -y \

## Open Space Toolkit ▸ Core

ARG OSTK_CORE_VERSION="2.1.0"
ARG TARGETPLATFORM
ARG OSTK_CORE_MAJOR="3"
ARG OSTK_CORE_MINOR="0"

## Force an image rebuild when new Core patch versions are detected
ADD https://api.github.com/repos/open-space-collective/open-space-toolkit-core/git/matching-refs/tags/${OSTK_CORE_MAJOR}.${OSTK_CORE_MINOR} /tmp/open-space-toolkit-core/versions.json

RUN mkdir -p /tmp/open-space-toolkit-core \
&& cd /tmp/open-space-toolkit-core \
&& wget --quiet https://github.com/open-space-collective/open-space-toolkit-core/releases/download/${OSTK_CORE_VERSION}/open-space-toolkit-core-${OSTK_CORE_VERSION}-1.x86_64-runtime.deb \
&& wget --quiet https://github.com/open-space-collective/open-space-toolkit-core/releases/download/${OSTK_CORE_VERSION}/open-space-toolkit-core-${OSTK_CORE_VERSION}-1.x86_64-devel.deb \
&& export LATEST_PATCH_OF_MINOR=$(jq -r .[-1].ref versions.json | cut -d "/" -f3) \
&& export PACKAGE_PLATFORM=$(if [ ${TARGETPLATFORM} = "linux/amd64" ]; then echo "x86_64"; elif [ ${TARGETPLATFORM} = "linux/arm64" ]; then echo "aarch64"; else echo "Unknown platform" && exit 1; fi;) \
&& wget --quiet https://github.com/open-space-collective/open-space-toolkit-core/releases/download/${LATEST_PATCH_OF_MINOR}/open-space-toolkit-core-${LATEST_PATCH_OF_MINOR}-1.${PACKAGE_PLATFORM}-runtime.deb \
&& wget --quiet https://github.com/open-space-collective/open-space-toolkit-core/releases/download/${LATEST_PATCH_OF_MINOR}/open-space-toolkit-core-${LATEST_PATCH_OF_MINOR}-1.${PACKAGE_PLATFORM}-devel.deb \
&& apt-get install -y ./*.deb \
&& rm -rf /tmp/open-space-toolkit-core

Expand Down

0 comments on commit 4883f83

Please sign in to comment.