Skip to content
Draft
Show file tree
Hide file tree
Changes from 6 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
53 changes: 53 additions & 0 deletions .github/workflows/copilot-setup-steps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: "Copilot Setup Steps"

# Automatically run the setup steps when they are changed to allow for easy validation, and
# allow manual testing through the repository's "Actions" tab
on:
workflow_dispatch:
push:
paths:
- .github/workflows/copilot-setup-steps.yml
pull_request:
paths:
- .github/workflows/copilot-setup-steps.yml

jobs:
# The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot.
copilot-setup-steps:
runs-on: ubuntu-24.04

# Set the permissions to the lowest permissions possible needed for your steps.
# Copilot will be given its own token for its operations.
permissions:
# If you want to clone the repository as part of your setup steps, for example to install dependencies, you'll need the `contents: read` permission.
# If you don't clone the repository in your setup steps, Copilot will do this for you automatically after the steps complete.
contents: read

# You can define any steps you want, and they will run before the agent starts.
# If you do not check out your code, Copilot will do this for you.
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
fetch-depth: 0 # required to ensure we have tags

- name: Set up GobySoft apt repository
run: |
echo "deb http://packages.gobysoft.org/ubuntu/release/ $(lsb_release -c -s)/" | sudo tee /etc/apt/sources.list.d/gobysoft_release.list
sudo apt-key adv --recv-key --keyserver keyserver.ubuntu.com 19478082E2F8D3FE
sudo apt-get update

- name: Install dependencies
run: |
sudo apt-get install -y \
cmake \
g++ \
libjack-jackd2-dev \
libgoby3-dev \
libgoby3-moos-dev \
libdccl4-dev \
libboost-dev \
libboost-serialization-dev \
libb64-dev \
protobuf-compiler \
libprotobuf-dev
25 changes: 17 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules/")

cmake_minimum_required(VERSION 3.5.1 FATAL_ERROR)

# require C++14
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# require C++17 (Goby 3.x headers use C++17 features such as if constexpr)
if(NOT CMAKE_CXX_STANDARD OR CMAKE_CXX_STANDARD LESS 17)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
message(STATUS "Setting CMAKE_CXX_STANDARD to 17 as required by Goby 3.x")
endif()

# versions
set(PROJECT_VERSION_MAJOR "1")
Expand All @@ -16,20 +19,20 @@ set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT

set(PROJECT_SOVERSION "1")

find_package(ProtobufLocal REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIRS})
find_package(Protobuf REQUIRED)
include_directories(${Protobuf_INCLUDE_DIRS})

include(GobyTarget)

find_package(DCCL REQUIRED)
get_target_property(DCCL_INCLUDE_DIR dccl INTERFACE_INCLUDE_DIRECTORIES)

message("Using DCCL in ${DCCL_INCLUDE_DIR}")
include_directories("${DCCL_INCLUDE_DIR}")
protobuf_include_dirs("${DCCL_INCLUDE_DIR}")

find_package(GOBY 3 REQUIRED zeromq moos)
message("Using Goby in ${GOBY_INCLUDE_DIR}")
include_directories("${GOBY_INCLUDE_DIR}")
protobuf_include_dirs("${GOBY_INCLUDE_DIR}")

find_package(MOOS 10 REQUIRED)

Expand Down Expand Up @@ -73,7 +76,12 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${project_LIB_DIR} CACHE PATH
"Output directory for the static libraries (archives)" )

include_directories(${project_INC_DIR})
protobuf_include_dirs(${project_INC_DIR})

# Set import dirs for protoc used by GobyTarget functions
list(APPEND GOBY_PROTOBUF_IMPORT_DIRS
"${DCCL_INCLUDE_DIR}"
"${GOBY_INCLUDE_DIR}"
"${project_INC_DIR}")


## set instructions for `make install`
Expand Down Expand Up @@ -129,6 +137,7 @@ file(GLOB_RECURSE INCLUDE_FILES RELATIVE ${project_SRC_DIR}/lib
src/lib/messages/*.proto
src/lib/messages/*.h
src/lib/tcp/*.h
src/lib/acousticstoolbox/*.proto
src/lib/acousticstoolbox/*.h
src/lib/core/*.h
)
Expand Down
177 changes: 177 additions & 0 deletions cmake_modules/GobyTarget.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
# GobyTarget.cmake - convenience functions for building Goby targets
#
# Provides:
# add_goby_executable(TARGET <name>
# SOURCES <files>...
# [PROTOS <proto_files>...]
# [LINK_LIBRARIES <libs>...]
# [PROTO_IMPORT_DIRS <dirs>...]
# [PROTOC_OUT_DIR <dir>])
#
# add_goby_library(TARGET <name>
# [SOURCES <files>...]
# [PROTOS <proto_files>...]
# [LINK_LIBRARIES <libs>...]
# [PROTO_IMPORT_DIRS <dirs>...]
# [PROTOC_OUT_DIR <dir>]
# [STATIC] [MODULE])
#
# For add_goby_executable, linking against goby is implied.
# Proto files are compiled with protoc --cpp_out + --dccl_out (matching the
# original protobuf_generate_cpp_dccl behaviour).

# Internal helper: compile .proto files with --cpp_out + --dccl_out.
# Sets OUT_VAR in the caller's scope to the list of generated source files.
function(_goby_generate_protos OUT_VAR PROTOC_OUT_DIR PROTOS IMPORT_DIRS)
# Build deduplicated list of -I flags.
# We intentionally omit CMAKE_CURRENT_SOURCE_DIR and PROTOC_OUT_DIR here:
# each .proto is first copied into PROTOC_OUT_DIR so that protoc sees it at
# the path <PROTOC_OUT_DIR>/<name>.proto. protoc then derives the canonical
# proto name by matching the file path against the -I import dirs; because
# PROTOC_OUT_DIR is a subdirectory of one of the IMPORT_DIRS (e.g.
# build/include/netsim/acousticstoolbox is under build/include), the
# canonical name becomes the correct full path such as
# "netsim/acousticstoolbox/environment.proto" rather than just
# "environment.proto" from CMAKE_CURRENT_SOURCE_DIR. This ensures the
# descriptor table names in all generated .pb.cc files are consistent when
# one proto imports another (e.g. svp_request_response.proto imports
# environment.proto), preventing "has not been declared" link/compile errors.
set(_import_flags)
set(_seen_dirs)
foreach(_dir
${CMAKE_CURRENT_BINARY_DIR}
${IMPORT_DIRS}
${GOBY_PROTOBUF_IMPORT_DIRS})
if(_dir)
get_filename_component(_abs_dir "${_dir}" ABSOLUTE)
if(NOT "${_abs_dir}" IN_LIST _seen_dirs)
list(APPEND _seen_dirs "${_abs_dir}")
list(APPEND _import_flags -I "${_abs_dir}")
endif()
endif()
endforeach()

set(_all_generated)
foreach(_proto ${PROTOS})
get_filename_component(_abs_proto "${_proto}" ABSOLUTE)
get_filename_component(_proto_we "${_abs_proto}" NAME_WE)

# Copy the source .proto into PROTOC_OUT_DIR so that protoc's canonical
# name resolution works correctly (see comment above).
set(_proto_dest "${PROTOC_OUT_DIR}/${_proto_we}.proto")
set(_pb_h "${PROTOC_OUT_DIR}/${_proto_we}.pb.h")
set(_pb_cc "${PROTOC_OUT_DIR}/${_proto_we}.pb.cc")

# Run protoc with --cpp_out first, then --dccl_out last.
# This ordering matches the original protobuf_generate_cpp_dccl and ensures
# that the DCCL plugin can insert into the cpp-generated files.
add_custom_command(
OUTPUT "${_pb_h}" "${_pb_cc}"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_abs_proto}" "${_proto_dest}"
COMMAND protobuf::protoc
ARGS --cpp_out "${PROTOC_OUT_DIR}"
"${_proto_dest}"
${_import_flags}
--dccl_out "${PROTOC_OUT_DIR}"
DEPENDS "${_abs_proto}" protobuf::protoc
COMMENT "Running dccl protocol buffer compiler on ${_proto}"
VERBATIM)

set_source_files_properties("${_pb_h}" "${_pb_cc}" PROPERTIES GENERATED TRUE)
list(APPEND _all_generated "${_pb_h}" "${_pb_cc}")
endforeach()

set(${OUT_VAR} "${_all_generated}" PARENT_SCOPE)
endfunction()

# add_goby_executable - build a Goby application binary
# Linking against goby is implied; list any additional libs in LINK_LIBRARIES.
function(add_goby_executable)
cmake_parse_arguments(args
""
"TARGET;PROTOC_OUT_DIR"
"SOURCES;PROTOS;LINK_LIBRARIES;PROTO_IMPORT_DIRS"
${ARGN})

if(NOT args_TARGET)
message(FATAL_ERROR "add_goby_executable: TARGET is required")
endif()

set(_sources ${args_SOURCES})

if(args_PROTOS)
if(args_PROTOC_OUT_DIR)
set(_protoc_out_dir "${args_PROTOC_OUT_DIR}")
else()
set(_protoc_out_dir "${CMAKE_CURRENT_BINARY_DIR}/${args_TARGET}")
endif()
file(MAKE_DIRECTORY "${_protoc_out_dir}")

_goby_generate_protos(
_proto_generated
"${_protoc_out_dir}"
"${args_PROTOS}"
"${args_PROTO_IMPORT_DIRS}")

list(APPEND _sources ${_proto_generated})
endif()

add_executable(${args_TARGET} ${_sources})

if(args_PROTOS)
target_include_directories(${args_TARGET} PRIVATE "${_protoc_out_dir}")
endif()

target_link_libraries(${args_TARGET} goby ${args_LINK_LIBRARIES})
endfunction()

# add_goby_library - build a Goby library target (SHARED by default)
# Pass STATIC or MODULE to change the library type.
function(add_goby_library)
cmake_parse_arguments(args
"STATIC;MODULE"
"TARGET;PROTOC_OUT_DIR"
"SOURCES;PROTOS;LINK_LIBRARIES;PROTO_IMPORT_DIRS"
${ARGN})

if(NOT args_TARGET)
message(FATAL_ERROR "add_goby_library: TARGET is required")
endif()

set(_lib_type SHARED)
if(args_STATIC)
set(_lib_type STATIC)
elseif(args_MODULE)
set(_lib_type MODULE)
endif()

set(_sources ${args_SOURCES})

if(args_PROTOS)
if(args_PROTOC_OUT_DIR)
set(_protoc_out_dir "${args_PROTOC_OUT_DIR}")
else()
set(_protoc_out_dir "${CMAKE_CURRENT_BINARY_DIR}/${args_TARGET}")
endif()
file(MAKE_DIRECTORY "${_protoc_out_dir}")

_goby_generate_protos(
_proto_generated
"${_protoc_out_dir}"
"${args_PROTOS}"
"${args_PROTO_IMPORT_DIRS}")

list(APPEND _sources ${_proto_generated})
endif()

add_library(${args_TARGET} ${_lib_type} ${_sources})

if(args_PROTOS)
target_include_directories(${args_TARGET} PUBLIC
$<BUILD_INTERFACE:${_protoc_out_dir}>)
endif()

if(args_LINK_LIBRARIES)
target_link_libraries(${args_TARGET} ${args_LINK_LIBRARIES})
endif()
endfunction()
16 changes: 5 additions & 11 deletions src/apps/iBellhop/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
add_executable(iBellhop
iBellhop.cpp
iBellhopMain.cpp
)

target_link_libraries(iBellhop
${MOOS_LIBRARIES}
netsim_acousticstoolbox
goby_moos
${Boost_LIBRARIES}
${PROTOBUF_LIBRARIES}
add_goby_executable(TARGET iBellhop
SOURCES
iBellhop.cpp
iBellhopMain.cpp
LINK_LIBRARIES ${MOOS_LIBRARIES} netsim_acousticstoolbox goby_moos ${Boost_LIBRARIES}
)

project_install_bin(iBellhop)
13 changes: 7 additions & 6 deletions src/apps/netsim_core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
add_executable(netsim_core
netsim_core_main.cpp
jack_thread.cpp)

# -rdynamic is required so that the shared libraries can access the interthread static objects correctly
target_link_libraries(netsim_core "-rdynamic" goby goby_zeromq jack netsim_messages)
add_goby_executable(TARGET netsim_core
SOURCES
netsim_core_main.cpp
jack_thread.cpp
# -rdynamic is required so that the shared libraries can access the interthread static objects correctly
LINK_LIBRARIES -rdynamic goby_zeromq jack netsim_messages
)

if(export_goby_interfaces)
generate_interfaces_params(netsim_core "-extra-arg=-DNETSIM_MAX_MODEMS=${NETSIM_VISUALIZE_MAX_MODEMS}")
Expand Down
7 changes: 4 additions & 3 deletions src/apps/netsim_manager/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
add_executable(netsim_manager
manager.cpp)
add_goby_executable(TARGET netsim_manager
SOURCES manager.cpp
LINK_LIBRARIES goby_zeromq netsim_tcp netsim_messages
)

target_link_libraries(netsim_manager goby goby_zeromq netsim_tcp netsim_messages)
if(export_goby_interfaces)
generate_interfaces(netsim_manager)
endif()
Expand Down
12 changes: 5 additions & 7 deletions src/apps/netsim_postprocess/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${CMAKE_CURRENT_BINARY_DIR} config.proto)

add_executable(netsim_postprocess
netsim_postprocess_main.cpp
${PROTO_SRCS} ${PROTO_HDRS})

target_link_libraries(netsim_postprocess goby goby_zeromq netsim_messages)
add_goby_executable(TARGET netsim_postprocess
SOURCES netsim_postprocess_main.cpp
PROTOS config.proto
LINK_LIBRARIES goby_zeromq netsim_messages
)

if(export_goby_interfaces)
generate_interfaces(netsim_postprocess)
Expand Down
20 changes: 5 additions & 15 deletions src/apps/netsim_tool/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
protobuf_generate_cpp(
PROTO_SRCS PROTO_HDRS ${CMAKE_CURRENT_BINARY_DIR} config.proto)


add_executable(netsim_tool
main.cpp
${PROTO_SRCS} ${PROTO_HDRS})

target_link_libraries(netsim_tool
goby
goby_moos
goby_zeromq
netsim_messages
netsim_tcp
)
add_goby_executable(TARGET netsim_tool
SOURCES main.cpp
PROTOS config.proto
LINK_LIBRARIES goby_moos goby_zeromq netsim_messages netsim_tcp
)

if(export_goby_interfaces)
generate_interfaces(netsim_tool)
Expand Down
Loading