Skip to content

Move examples to their own subdirectories #589

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

Merged
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
11 changes: 1 addition & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -521,16 +521,7 @@ endif()
install(FILES ${CMAKE_SOURCE_DIR}/LICENSE.TXT
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/doc/${PROJECT_NAME}/")

install(
FILES examples/basic/gpu_shared_memory.c
examples/basic/utils_level_zero.h
examples/basic/basic.c
examples/basic/ipc_level_zero.c
examples/basic/ipc_ipcapi_anon_fd.sh
examples/basic/ipc_ipcapi_consumer.c
examples/basic/ipc_ipcapi_producer.c
examples/basic/ipc_ipcapi_shm.sh
DESTINATION "${CMAKE_INSTALL_DOCDIR}/examples")
install(DIRECTORY examples DESTINATION "${CMAKE_INSTALL_DOCDIR}")

# Add the include directory and the headers target to the install.
install(DIRECTORY "${PROJECT_SOURCE_DIR}/include/"
Expand Down
2 changes: 1 addition & 1 deletion benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function(add_umf_benchmark)
PRIVATE ${UMF_CMAKE_SOURCE_DIR}/include
${UMF_CMAKE_SOURCE_DIR}/src/utils
${UMF_CMAKE_SOURCE_DIR}/test/common
${UMF_CMAKE_SOURCE_DIR}/examples/basic)
${UMF_CMAKE_SOURCE_DIR}/examples/common)

target_link_directories(${BENCH_NAME} PRIVATE ${ARG_LIBDIRS})

Expand Down
17 changes: 10 additions & 7 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@ if(UMF_BUILD_GPU_EXAMPLES

add_umf_executable(
NAME ${EXAMPLE_NAME}
SRCS basic/gpu_shared_memory.c
SRCS gpu_shared_memory/gpu_shared_memory.c
LIBS disjoint_pool ze_loader umf)

target_include_directories(
${EXAMPLE_NAME} PRIVATE ${UMF_CMAKE_SOURCE_DIR}/src/utils
${UMF_CMAKE_SOURCE_DIR}/include)
${EXAMPLE_NAME}
PRIVATE ${UMF_CMAKE_SOURCE_DIR}/src/utils
${UMF_CMAKE_SOURCE_DIR}/include
${UMF_CMAKE_SOURCE_DIR}/examples/common)

target_link_directories(${EXAMPLE_NAME} PRIVATE ${LIBHWLOC_LIBRARY_DIRS})

Expand Down Expand Up @@ -87,13 +89,14 @@ if(UMF_BUILD_GPU_EXAMPLES

add_umf_executable(
NAME ${EXAMPLE_NAME}
SRCS basic/ipc_level_zero.c
SRCS ipc_level_zero/ipc_level_zero.c
LIBS disjoint_pool ze_loader umf)

target_include_directories(
${EXAMPLE_NAME}
PRIVATE ${LEVEL_ZERO_INCLUDE_DIRS} ${UMF_CMAKE_SOURCE_DIR}/src/utils
${UMF_CMAKE_SOURCE_DIR}/include)
${UMF_CMAKE_SOURCE_DIR}/include
${UMF_CMAKE_SOURCE_DIR}/examples/common)

target_link_directories(${EXAMPLE_NAME} PRIVATE ${LIBHWLOC_LIBRARY_DIRS})

Expand Down Expand Up @@ -124,7 +127,7 @@ function(build_umf_ipc_example name)
set(EX_NAME ${EXAMPLE_NAME}_${loop_var})
add_umf_executable(
NAME ${EX_NAME}
SRCS basic/${BASE_NAME}_${loop_var}.c
SRCS ipc_ipcapi/${BASE_NAME}_${loop_var}.c
LIBS umf)

target_include_directories(
Expand All @@ -138,7 +141,7 @@ endfunction()
function(add_umf_ipc_example script)
set(EXAMPLE_NAME umf_example_${script})

file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/basic/${script}.sh
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/ipc_ipcapi/${script}.sh
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})

add_test(
Expand Down
12 changes: 7 additions & 5 deletions test/test_installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,15 @@ def _create_match_list(self) -> List[str]:
"share/doc",
"share/doc/umf",
]

examples_dir = Path(self.workspace_dir, "examples")
examples_dirs = [dir for dir in examples_dir.iterdir() if dir.is_dir()]
examples = [
f"share/doc/umf/examples/{file_path.name}"
for example_dir in examples_dirs
for file_path in example_dir.iterdir()
examples_files = [
str(entry.relative_to(self.workspace_dir))
for entry in sorted(
examples_dir.rglob("*"), key=lambda x: str(x).casefold()
)
]
examples = [f"share/doc/umf/" + file for file in examples_files]
examples = sorted(examples)
examples.insert(0, "share/doc/umf/examples")
share.extend(examples)
Expand Down