Skip to content

Commit

Permalink
build: update ostk core dependency, add python linking, fix static li…
Browse files Browse the repository at this point in the history
…brary building (#126)

* build: update ostk core dependency, add python linking, fix static library building

* chore: fix tests

---------

Co-authored-by: vishwa shah <vishwa@loftorbital.com>
  • Loading branch information
vishwa2710 and vishwaLoft authored Jun 27, 2023
1 parent a66a6f3 commit d0ef493
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 84 deletions.
29 changes: 24 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ OPTION (BUILD_UNIT_TESTS "Build tests" ON)
OPTION (BUILD_PYTHON_BINDINGS "Build Python bindings." ON)
OPTION (BUILD_CODE_COVERAGE "Build code coverage" OFF)
OPTION (BUILD_DOCUMENTATION "Build documentation" OFF)
OPTION (BUILD_WITH_DEBUG_SYMBOLS "Build with debug symbols" ON)

## Setup

Expand Down Expand Up @@ -131,7 +132,15 @@ SET (CMAKE_CXX_STANDARD 17)
SET (CMAKE_CXX_STANDARD_REQUIRED ON)
SET (CMAKE_CXX_EXTENSIONS OFF)

## Debugging Options
### Debug Symbols

IF (BUILD_WITH_DEBUG_SYMBOLS)

SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")

ENDIF ()

### Debugging Options

SET (CMAKE_VERBOSE_MAKEFILE 0) # Use 1 for debugging, 0 for release

Expand Down Expand Up @@ -209,6 +218,8 @@ SET (Boost_USE_MULTITHREADED ON)

FIND_PACKAGE ("Boost" "1.82")

ADD_DEFINITIONS(-DBOOST_STACKTRACE_USE_BACKTRACE -DBOOST_STACKTRACE_BACKTRACE_INCLUDE_FILE=</usr/lib/gcc/x86_64-linux-gnu/9/include/backtrace.h>)

IF (NOT Boost_FOUND)
MESSAGE (SEND_ERROR "[Boost] not found.")
ENDIF ()
Expand Down Expand Up @@ -317,6 +328,7 @@ IF (BUILD_SHARED_LIBRARY)
TARGET_INCLUDE_DIRECTORIES (${SHARED_LIBRARY_TARGET} PUBLIC "${PROJECT_SOURCE_DIR}/src/")

TARGET_LINK_LIBRARIES (${SHARED_LIBRARY_TARGET} "pthread")
TARGET_LINK_LIBRARIES (${SHARED_LIBRARY_TARGET} "dl")
TARGET_LINK_LIBRARIES (${SHARED_LIBRARY_TARGET} ${SGP4_LIBRARIES})
TARGET_LINK_LIBRARIES (${SHARED_LIBRARY_TARGET} ${NLopt_LIBRARIES})
TARGET_LINK_LIBRARIES (${SHARED_LIBRARY_TARGET} ${OpenSpaceToolkitCore_LIBRARIES})
Expand Down Expand Up @@ -347,25 +359,32 @@ IF (BUILD_STATIC_LIBRARY)
TARGET_INCLUDE_DIRECTORIES (${STATIC_LIBRARY_TARGET} PUBLIC "${PROJECT_SOURCE_DIR}/include/")

TARGET_LINK_LIBRARIES (${STATIC_LIBRARY_TARGET} "pthread")
TARGET_LINK_LIBRARIES (${STATIC_LIBRARY_TARGET} ${Boost_LIBRARIES})
TARGET_LINK_LIBRARIES (${SHARED_LIBRARY_TARGET} ${SGP4_LIBRARIES})
TARGET_LINK_LIBRARIES (${STATIC_LIBRARY_TARGET} "dl")
TARGET_LINK_LIBRARIES (${STATIC_LIBRARY_TARGET} ${SGP4_LIBRARIES})
TARGET_LINK_LIBRARIES (${STATIC_LIBRARY_TARGET} ${NLopt_LIBRARIES})
TARGET_LINK_LIBRARIES (${STATIC_LIBRARY_TARGET} ${OpenSpaceToolkitCore_LIBRARIES})
TARGET_LINK_LIBRARIES (${STATIC_LIBRARY_TARGET} ${OpenSpaceToolkitIO_LIBRARIES})
TARGET_LINK_LIBRARIES (${STATIC_LIBRARY_TARGET} ${OpenSpaceToolkitMathematics_LIBRARIES})
TARGET_LINK_LIBRARIES (${STATIC_LIBRARY_TARGET} ${OpenSpaceToolkitPhysics_LIBRARIES})

SET_TARGET_PROPERTIES (${STATIC_LIBRARY_TARGET} PROPERTIES VERSION ${PROJECT_VERSION_STRING} OUTPUT_NAME ${SHARED_LIBRARY_NAME} CLEAN_DIRECT_OUTPUT 1 INSTALL_RPATH "$ORIGIN/../lib:$ORIGIN/")
SET_TARGET_PROPERTIES (${STATIC_LIBRARY_TARGET} PROPERTIES VERSION ${PROJECT_VERSION_STRING} OUTPUT_NAME ${STATIC_LIBRARY_NAME} CLEAN_DIRECT_OUTPUT 1 INSTALL_RPATH "$ORIGIN/../lib:$ORIGIN/")

INSTALL (DIRECTORY "${PROJECT_SOURCE_DIR}/include/${PROJECT_PATH}/" DESTINATION ${INSTALL_INCLUDE} COMPONENT "headers" FILES_MATCHING PATTERN "*.hpp")
INSTALL (DIRECTORY "${PROJECT_SOURCE_DIR}/src/${PROJECT_PATH}/" DESTINATION ${INSTALL_INCLUDE} COMPONENT "headers" FILES_MATCHING PATTERN "*.tpp")
INSTALL (TARGETS ${SHARED_LIBRARY_TARGET} DESTINATION ${INSTALL_LIB} COMPONENT "libraries")
INSTALL (TARGETS ${STATIC_LIBRARY_TARGET} DESTINATION ${INSTALL_LIB} COMPONENT "libraries")

ENDIF ()

### Unit Tests

IF (BUILD_UNIT_TESTS)

IF (NOT BUILD_SHARED_LIBRARY)

MESSAGE (SEND_ERROR "[Unit Tests] cannot be built without [Shared Library].")

ENDIF ()

SET (UNIT_TESTS_TARGET "${PROJECT_PACKAGE_NAME}.test")

ENABLE_TESTING ()
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ start-development-link: build-development-image ## Start linked development envi

@ echo "Starting development environment (linked)..."

@ project_directory="$(CURDIR)" docker_development_image_repository=$(docker_development_image_repository) docker_image_version=$(docker_image_version) "$(CURDIR)/tools/development/start.sh" --link $(links)
@ docker_development_image_repository=$(docker_development_image_repository) docker_image_version=$(docker_image_version) "$(CURDIR)/tools/development/start.sh" --link $(links)

.PHONY: start-development-link

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-physics~=1.1.0
open-space-toolkit-physics~=1.1.1
2 changes: 1 addition & 1 deletion docker/development/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ RUN echo "VERSION_REGEX='^'\$2'\\.'\$3'\\.[0-9]*$'; curl https://api.github.com/
## Open Space Toolkit ▸ Core

ARG OSTK_CORE_MAJOR="0"
ARG OSTK_CORE_MINOR="6"
ARG OSTK_CORE_MINOR="7"

RUN mkdir -p /tmp/open-space-toolkit-core \
&& cd /tmp/open-space-toolkit-core \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ TEST_F(OpenSpaceToolkit_Astrodynamics_Flight_System_Dynamics_AtmosphericDrag, Co
}
catch (const ostk::core::error::runtime::Undefined& e)
{
EXPECT_EQ(expectedString, e.what());
EXPECT_EQ(expectedString, e.getMessage());
throw;
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ TEST_F(OpenSpaceToolkit_Astrodynamics_Flight_System_Dynamics_CentralBodyGravity,
}
catch (const ostk::core::error::runtime::Undefined& e)
{
EXPECT_EQ(expectedString, e.what());
EXPECT_EQ(expectedString, e.getMessage());
throw;
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ TEST_F(OpenSpaceToolkit_Astrodynamics_Flight_System_Dynamics_ThirdBodyGravity, C
}
catch (const ostk::core::error::runtime::Undefined& e)
{
EXPECT_EQ(expectedString, e.what());
EXPECT_EQ(expectedString, e.getMessage());
throw;
}
},
Expand All @@ -137,7 +137,7 @@ TEST_F(OpenSpaceToolkit_Astrodynamics_Flight_System_Dynamics_ThirdBodyGravity, C
}
catch (const ostk::core::error::RuntimeError& e)
{
EXPECT_EQ(expectedString, e.what());
EXPECT_EQ(expectedString, e.getMessage());
throw;
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ TEST_F(OpenSpaceToolkit_Astrodynamics_Trajectory_Orbit_Models_Propagated, Constr
}
catch (const ostk::core::error::RuntimeError& e)
{
EXPECT_EQ(e.what(), String("{Propagated} is undefined."));
EXPECT_EQ(e.getMessage(), String("{Propagated} is undefined."));
throw;
}
},
Expand Down Expand Up @@ -930,7 +930,7 @@ TEST_F(OpenSpaceToolkit_Astrodynamics_Trajectory_Orbit_Models_Propagated, SetCac
}
catch (const ostk::core::error::RuntimeError& e)
{
EXPECT_EQ(e.what(), String("{Propagated} is undefined."));
EXPECT_EQ(e.getMessage(), String("{Propagated} is undefined."));
throw;
}
},
Expand Down
14 changes: 14 additions & 0 deletions tools/development/helpers/install-python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

PYTHON_VERSION="3.11"

py_version=$(echo "${PYTHON_VERSION}" | sed 's/\.//')

project_directory="$(git rev-parse --show-toplevel)"
python_directory="${project_directory}/build/bindings/python/OpenSpaceToolkitAstrodynamicsPy-python-package-${PYTHON_VERSION}"

Expand All @@ -13,3 +15,15 @@ python${PYTHON_VERSION} -m pip install plotly pandas
python${PYTHON_VERSION} -m pip install . --force-reinstall

popd > /dev/null

for dep in ${deps}

do

echo "Installing ${dep} python package..."

dep_underscore=$(echo ${dep} | tr '-' '_' | sed 's/\/$//')

python${PYTHON_VERSION} -m pip install /usr/local/share/${dep_underscore}-*-py${py_version}-*.whl --quiet --force-reinstall;

done
93 changes: 23 additions & 70 deletions tools/development/start.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
#!/bin/bash

# Apache License 2.0
# Apache License 2.0

# Check input arguments

if [[ -z ${project_directory} ]]; then
echo "Variable [project_directory] is undefined."
exit 1
fi

if [[ -z ${docker_development_image_repository} ]]; then
echo "Variable [docker_development_image_repository] is undefined."
exit 1
Expand All @@ -25,6 +20,7 @@ project_directory=$(git rev-parse --show-toplevel)

options=()
command=""
deps=""

# Setup linked mode

Expand All @@ -35,80 +31,36 @@ if [[ ! -z ${1} ]] && [[ ${1} == "--link" ]]; then
do

# Extract last part of the path
link_without_trailing_slash=${link%/}
dep=${link_without_trailing_slash##*/}

# Log the linking step

echo "Linking with ${dep} at ${link}..."

# Open Space Toolkit ▸ Core

if [[ ${dep} == "open-space-toolkit-core" ]]; then

options+=( "-v" )
options+=( "${link}:/mnt/open-space-toolkit-core:ro" )

command="${command} \
rm -rf /usr/local/include/OpenSpaceToolkit/Core; \
rm -f /usr/local/lib/libopen-space-toolkit-core.so*; \
cp -as /mnt/open-space-toolkit-core/include/OpenSpaceToolkit/Core /usr/local/include/OpenSpaceToolkit/Core; \
cp -as /mnt/open-space-toolkit-core/src/OpenSpaceToolkit/Core/* /usr/local/include/OpenSpaceToolkit/Core/; \
ln -s /mnt/open-space-toolkit-core/lib/libopen-space-toolkit-core.so /usr/local/lib/; \
ln -s /mnt/open-space-toolkit-core/lib/libopen-space-toolkit-core.so.* /usr/local/lib/;"

fi

# Open Space Toolkit ▸ IO

if [[ ${dep} == "open-space-toolkit-io" ]]; then
dep=$(basename ${link})

options+=( "-v" )
options+=( "${link}:/mnt/open-space-toolkit-io:ro" )

command="${command} \
rm -rf /usr/local/include/OpenSpaceToolkit/IO; \
rm -f /usr/local/lib/libopen-space-toolkit-io.so*; \
cp -as /mnt/open-space-toolkit-io/include/OpenSpaceToolkit/IO /usr/local/include/OpenSpaceToolkit/IO; \
cp -as /mnt/open-space-toolkit-io/src/OpenSpaceToolkit/IO/* /usr/local/include/OpenSpaceToolkit/IO/; \
ln -s /mnt/open-space-toolkit-io/lib/libopen-space-toolkit-io.so /usr/local/lib/; \
ln -s /mnt/open-space-toolkit-io/lib/libopen-space-toolkit-io.so.* /usr/local/lib/;"

fi
deps+=" ${dep}"

# Open Space Toolkit ▸ Mathematics
# Log the linking step

if [[ ${dep} == "open-space-toolkit-mathematics" ]]; then
echo "Linking with ${dep} at ${link}..."

options+=( "-v" )
options+=( "${link}:/mnt/open-space-toolkit-mathematics:ro" )
# Open Space Toolkit ▸ Dep

command="${command} \
rm -rf /usr/local/include/OpenSpaceToolkit/Mathematics; \
rm -f /usr/local/lib/libopen-space-toolkit-mathematics.so*; \
cp -as /mnt/open-space-toolkit-mathematics/include/OpenSpaceToolkit/Mathematics /usr/local/include/OpenSpaceToolkit/Mathematics; \
cp -as /mnt/open-space-toolkit-mathematics/src/OpenSpaceToolkit/Mathematics/* /usr/local/include/OpenSpaceToolkit/Mathematics/; \
ln -s /mnt/open-space-toolkit-mathematics/lib/libopen-space-toolkit-mathematics.so /usr/local/lib/; \
ln -s /mnt/open-space-toolkit-mathematics/lib/libopen-space-toolkit-mathematics.so.* /usr/local/lib/;"
project_name=$(echo ${dep} | cut -d "-" -f 4)

if [ ${project_name} = "io" ]; then
project_name_capitalized="IO"
else
project_name_capitalized=${project_name^}
fi

# Open Space Toolkit ▸ Physics

if [[ ${dep} == "open-space-toolkit-physics" ]]; then
options+=( "-v" )
options+=( "${link}:/mnt/${dep}:ro" )

options+=( "-v" )
options+=( "${link}:/mnt/open-space-toolkit-physics:ro" )

command="${command} \
rm -rf /usr/local/include/OpenSpaceToolkit/Physics; \
rm -f /usr/local/lib/libopen-space-toolkit-physics.so*; \
cp -as /mnt/open-space-toolkit-physics/include/OpenSpaceToolkit/Physics /usr/local/include/OpenSpaceToolkit/Physics; \
cp -as /mnt/open-space-toolkit-physics/src/OpenSpaceToolkit/Physics/* /usr/local/include/OpenSpaceToolkit/Physics/; \
ln -s /mnt/open-space-toolkit-physics/lib/libopen-space-toolkit-physics.so /usr/local/lib/; \
ln -s /mnt/open-space-toolkit-physics/lib/libopen-space-toolkit-physics.so.* /usr/local/lib/;"

fi
command="${command} \
rm -rf /usr/local/include/OpenSpaceToolkit/${project_name_capitalized}; \
rm -f /usr/local/lib/lib${dep}.so*; \
cp -as /mnt/${dep}/include/OpenSpaceToolkit/${project_name_capitalized} /usr/local/include/OpenSpaceToolkit/${project_name_capitalized}; \
cp -as /mnt/${dep}/src/OpenSpaceToolkit/${project_name_capitalized}/* /usr/local/include/OpenSpaceToolkit/${project_name_capitalized}/; \
ln -s /mnt/${dep}/lib/lib${dep}.so /usr/local/lib/; \
ln -s /mnt/${dep}/lib/lib${dep}.so.* /usr/local/lib/; \
cp -as /mnt/${dep}/build/bindings/python/dist/* /usr/local/share;"

done

Expand All @@ -125,6 +77,7 @@ docker run \
"${options[@]}" \
--volume="${project_directory}:/app:delegated" \
--volume="${project_directory}/tools/development/helpers:/app/build/helpers:ro,delegated" \
--env="deps=${deps}" \
--workdir="/app/build" \
${docker_development_image_repository}:${docker_image_version} \
/bin/bash -c "${command}"

0 comments on commit d0ef493

Please sign in to comment.