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

Portable Executor port to Rust #532

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ stlab_detect_thread_system(STLAB_DEFAULT_THREAD_SYSTEM)
set( STLAB_THREAD_SYSTEM ${STLAB_DEFAULT_THREAD_SYSTEM} CACHE STRING "Thread system to use (win32|pthread|pthread-emscripten|pthread-apple|none)")

stlab_detect_task_system(STLAB_DEFAULT_TASK_SYSTEM)
set(STLAB_TASK_SYSTEM ${STLAB_DEFAULT_TASK_SYSTEM} CACHE STRING "Task system to use (portable|libdispatch|windows).")
set(STLAB_TASK_SYSTEM ${STLAB_DEFAULT_TASK_SYSTEM} CACHE STRING "Task system to use (portable|libdispatch|windows|experimental_rust).")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that this whole library is experimental I wonder if we should call this task system portable_rust.


stlab_detect_main_executor(STLAB_DEFAULT_MAIN_EXECUTOR)
set(STLAB_MAIN_EXECUTOR ${STLAB_DEFAULT_MAIN_EXECUTOR} CACHE STRING "Main executor to use (qt5|qt6|libdispatch|emscripten|none).")
Expand Down Expand Up @@ -91,6 +91,10 @@ if (STLAB_TASK_SYSTEM STREQUAL "libdispatch")
target_link_libraries(stlab INTERFACE libdispatch::libdispatch)
endif()

if (STLAB_TASK_SYSTEM STREQUAL "experimental_rust")
add_subdirectory( rustport )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we maybe call this directory just rust? I'm not sure to what extent something is a port once the port is complete :)

endif()

if (STLAB_MAIN_EXECUTOR STREQUAL "libdispatch")
target_link_libraries(stlab INTERFACE libdispatch::libdispatch)
elseif (STLAB_MAIN_EXECUTOR STREQUAL "qt5")
Expand All @@ -99,6 +103,7 @@ elseif (STLAB_MAIN_EXECUTOR STREQUAL "qt6")
target_link_libraries( stlab INTERFACE Qt6::Core )
endif()

message(STATUS "stlab: Use Boost C++17 Shims: ${STLAB_USE_BOOST_CPP17_SHIMS}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leftover cruft? I think this variable was removed at one point.

message(STATUS "stlab: Disable Coroutines: ${STLAB_DEFAULT_NO_STD_COROUTINES}")
message(STATUS "stlab: Thread System: ${STLAB_THREAD_SYSTEM}")
message(STATUS "stlab: Task System: ${STLAB_TASK_SYSTEM}")
Expand All @@ -123,6 +128,10 @@ if ( BUILD_TESTING )
stlab::development
stlab::stlab )

if (STLAB_TASK_SYSTEM STREQUAL "experimental_rust")
target_link_libraries( testing INTERFACE RustyDefaultExecutor )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused that this is linked to testing instead of it being transitively brought in with stlab::stlab

endif ()

#
# Linking to the Boost unit test framework requires an additional
# preprocessor definition when the unit test compiled resources are
Expand Down
2 changes: 2 additions & 0 deletions cmake/StlabUtil.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ function( stlab_generate_config_file )
set( STLAB_TASK_SYSTEM_EMSCRIPTEN TRUE )
elseif (STLAB_TASK_SYSTEM STREQUAL "windows")
set( STLAB_TASK_SYSTEM_WINDOWS TRUE )
elseif (STLAB_TASK_SYSTEM STREQUAL "experimental_rust")
set( STLAB_TASK_SYSTEM_EXPERIMENTAL_RUST TRUE )
endif()

if (STLAB_MAIN_EXECUTOR STREQUAL "libdispatch")
Expand Down
1 change: 1 addition & 0 deletions rustport/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target
33 changes: 33 additions & 0 deletions rustport/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
cmake_minimum_required(VERSION 3.25)

include(FetchContent)

FetchContent_Declare(
Corrosion
GIT_REPOSITORY https://github.com/corrosion-rs/corrosion.git
GIT_TAG master # Needed for experimental feature `corrosion_experimental_cbindgen`.
)

# Set any global configuration variables such as `Rust_TOOLCHAIN` before this line!

FetchContent_MakeAvailable(Corrosion)

corrosion_import_crate(MANIFEST_PATH ./Cargo.toml)

corrosion_experimental_cbindgen(
TARGET default_executor
HEADER_NAME "bindings.h"
)

add_library(RustyDefaultExecutor INTERFACE)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe RustPortableDefaultExecutor?


target_include_directories(RustyDefaultExecutor
# PRIVATE
# # where the library itself will look for its internal headers
# ${CMAKE_CURRENT_SOURCE_DIR}/src
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above three lines are cruft I think.

INTERFACE
# where top-level project will look for the library's public headers
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cppshim/include>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is $<BUILD_INTERFACE: doing here?

)

target_link_libraries(RustyDefaultExecutor INTERFACE default_executor)
Loading
Loading