Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
black-desk committed Dec 24, 2024
1 parent d576be0 commit 5c92d68
Show file tree
Hide file tree
Showing 57 changed files with 2,815 additions and 708 deletions.
78 changes: 76 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,71 @@ set(linyaps-box_CPACK_PACKAGING_INSTALL_PREFIX
"/opt/org.openatom.linyaps-box"
CACHE STRING "Install prefix for package generated by CPack.")

set(linyaps-box_CLONE_CHILD_STACK_SIZE
"(1 << 20)"
CACHE
STRING
"Size of child stack when using clone to create container porcess in bytes."
)

set(linyaps-box_STACK_GROWTH_DOWN
true
CACHE BOOL "The stack grows down.")

# ==============================================================================

set(linyaps-box_LIBRARY linyaps-box)
set(linyaps-box_LIBRARY_SOURCE
./src/linyaps_box/app.cpp
./src/linyaps_box/app.h
./src/linyaps_box/command/exec.cpp
./src/linyaps_box/command/exec.h
./src/linyaps_box/command/kill.cpp
./src/linyaps_box/command/kill.h
./src/linyaps_box/command/list.cpp
./src/linyaps_box/command/list.h
./src/linyaps_box/command/options.cpp
./src/linyaps_box/command/options.h
./src/linyaps_box/command/run.cpp
./src/linyaps_box/command/run.h
./src/linyaps_box/config.cpp
./src/linyaps_box/config.h
./src/linyaps_box/container.cpp
./src/linyaps_box/container.h
./src/linyaps_box/container_ref.cpp
./src/linyaps_box/container_ref.h
./src/linyaps_box/container_status.cpp
./src/linyaps_box/container_status.h
./src/linyaps_box/impl/json_printer.cpp
./src/linyaps_box/impl/json_printer.h
./src/linyaps_box/impl/status_directory.cpp
./src/linyaps_box/impl/status_directory.h
./src/linyaps_box/impl/table_printer.cpp
./src/linyaps_box/impl/table_printer.h
./src/linyaps_box/interface.cpp
./src/linyaps_box/interface.h
./src/linyaps_box/printer.cpp
./src/linyaps_box/printer.h
./src/linyaps_box/runtime.cpp
./src/linyaps_box/runtime.h
./src/linyaps_box/status_directory.cpp
./src/linyaps_box/status_directory.h
./src/linyaps_box/utils/atomic_write.cpp
./src/linyaps_box/utils/atomic_write.h
./src/linyaps_box/utils/socketpair.cpp
./src/linyaps_box/utils/socketpair.h
./src/linyaps_box/utils/file_describer.cpp
./src/linyaps_box/utils/file_describer.h
./src/linyaps_box/utils/fstat.cpp
./src/linyaps_box/utils/fstat.h
./src/linyaps_box/utils/open_file.cpp
./src/linyaps_box/utils/open_file.h
./src/linyaps_box/utils/mknod.cpp
./src/linyaps_box/utils/mknod.h
./src/linyaps_box/utils/mkdir.cpp
./src/linyaps_box/utils/mkdir.h
./src/linyaps_box/utils/touch.cpp
./src/linyaps_box/utils/touch.h
./src/container/container.cpp
./src/container/container.h
./src/container/helper.cpp
Expand Down Expand Up @@ -101,12 +162,25 @@ find_package(nlohmann_json 3.5.0 REQUIRED)
list(APPEND linyaps-box_LIBRARY_LINK_LIBRARIES PUBLIC
nlohmann_json::nlohmann_json)

find_package(CLI11 REQUIRED)
list(APPEND linyaps-box_LIBRARY_LINK_LIBRARIES PUBLIC CLI11::CLI11)

add_library("${linyaps-box_LIBRARY}" ${linyaps-box_LIBRARY_SOURCE})
target_include_directories("${linyaps-box_LIBRARY}"
${linyaps-box_LIBRARY_INCLUDE_DIRS})
target_link_libraries("${linyaps-box_LIBRARY}"
${linyaps-box_LIBRARY_LINK_LIBRARIES})
target_compile_features("${linyaps-box_LIBRARY}" PUBLIC cxx_std_17)
set_property(TARGET "${linyaps-box_LIBRARY}" PROPERTY CXX_STANDARD 17)
set_property(TARGET "${linyaps-box_LIBRARY}" PROPERTY CXX_EXTENSIONS OFF)
set_property(TARGET "${linyaps-box_LIBRARY}" PROPERTY CXX_STANDARD_REQUIRED ON)

target_compile_definitions(
"${linyaps-box_LIBRARY}"
PRIVATE
"LINYAPS_BOX_CLONE_CHILD_STACK_SIZE=${linyaps-box_CLONE_CHILD_STACK_SIZE}"
PRIVATE "LINYAPS_BOX_STACK_GROWTH_DOWN=${linyaps-box_STACK_GROWTH_DOWN}")

if(linyaps-box_ENABLE_SECCOMP)
target_compile_definitions("${linyaps-box_LIBRARY}"
PUBLIC LINYAPS_BOX_ENABLE_SECCOMP)
Expand All @@ -126,8 +200,6 @@ if(linyaps-box_ENABLE_COVERAGE)
FATAL_ERROR "Coverage is not supported for ${CMAKE_CXX_COMPILER_ID}.")
endif()
endif()
set_property(TARGET "${linyaps-box_LIBRARY}" PROPERTY CXX_STANDARD 17)
set_property(TARGET "${linyaps-box_LIBRARY}" PROPERTY CXX_STANDARD_REQUIRED ON)

# ==============================================================================

Expand All @@ -146,6 +218,7 @@ if(linyaps-box_STATIC)
endif()
target_compile_features("${linyaps-box_APP}" PRIVATE cxx_std_17)
set_property(TARGET "${linyaps-box_APP}" PROPERTY CXX_STANDARD 17)
set_property(TARGET "${linyaps-box_APP}" PROPERTY CXX_EXTENSIONS OFF)
set_property(TARGET "${linyaps-box_APP}" PROPERTY CXX_STANDARD_REQUIRED ON)

# ==============================================================================
Expand Down Expand Up @@ -192,6 +265,7 @@ target_link_libraries("${linyaps-box_UNIT_TESTS}"
${linyaps-box_UNIT_TESTS_LINK_LIBRARIES})
target_compile_features("${linyaps-box_UNIT_TESTS}" PRIVATE cxx_std_17)
set_property(TARGET "${linyaps-box_UNIT_TESTS}" PROPERTY CXX_STANDARD 17)
set_property(TARGET "${linyaps-box_UNIT_TESTS}" PROPERTY CXX_EXTENSIONS OFF)
set_property(TARGET "${linyaps-box_UNIT_TESTS}" PROPERTY CXX_STANDARD_REQUIRED
ON)

Expand Down
61 changes: 57 additions & 4 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,29 @@
"linyaps-box_ENABLE_CPACK": "ON"
}
},
{
"name": "static",
"displayName": "The static build profile",
"description": "The default configuration for produce static binary",
"binaryDir": "${sourceDir}/build-static",
"cacheVariables": {
"CMAKE_COLOR_DIAGNOSTICS": true,
"CMAKE_BUILD_TYPE": "Release",
"CMAKE_CXX_COMPILER_LAUNCHER": "$env{CMAKE_CXX_COMPILER_LAUNCHER}",
"CMAKE_CXX_CLANG_TIDY": "$env{CMAKE_CXX_CLANG_TIDY}",
"CMAKE_CXX_FLAGS": "-Wall -Wextra -Wpedantic -Werror -Os -fno-asynchronous-unwind-tables -fdata-sections -ffunction-sections -flto=auto $env{CXXFLAGS}",
"CMAKE_C_COMPILER_LAUNCHER": "$env{CMAKE_C_COMPILER_LAUNCHER}",
"CMAKE_C_CLANG_TIDY": "$env{CMAKE_C_CLANG_TIDY}",
"CMAKE_C_FLAGS": "-Wall -Wextra -Wpedantic -Werror -Os -fno-asynchronous-unwind-tables -fdata-sections -ffunction-sections -flto=auto $env{CFLAGS}",
"CMAKE_LINKER_TYPE": "$env{CMAKE_LINKER_TYPE}",
"CMAKE_EXE_LINKER_FLAGS_INIT": "-Wl,--gc-sections,--strip-all,--exclude-libs,ALL -flto=auto",
"linyaps-box_STATIC": true
}
},
{
"name": "ci",
"displayName": "The dev profile",
"description": "The default configuration for developers",
"displayName": "The CI profile",
"description": "The default configuration for CI",
"binaryDir": "${sourceDir}/build-ci",
"cacheVariables": {
"CMAKE_COLOR_DIAGNOSTICS": true,
Expand Down Expand Up @@ -74,6 +93,10 @@
{
"name": "ci",
"configurePreset": "ci"
},
{
"name": "static",
"configurePreset": "static"
}
],
"testPresets": [
Expand Down Expand Up @@ -109,6 +132,17 @@
"noTestsAction": "default",
"stopOnFailure": false
}
},
{
"name": "static",
"configurePreset": "static",
"output": {
"verbosity": "verbose"
},
"execution": {
"noTestsAction": "default",
"stopOnFailure": true
}
}
],
"workflowPresets": [
Expand Down Expand Up @@ -152,8 +186,8 @@
},
{
"name": "ci",
"displayName": "The default workflow for ci",
"description": "Configure, build then test with ci profile",
"displayName": "The default workflow for CI",
"description": "Configure, build then test with CI profile",
"steps": [
{
"type": "configure",
Expand All @@ -168,6 +202,25 @@
"name": "ci"
}
]
},
{
"name": "static",
"displayName": "The default workflow for static build",
"description": "Configure, build then test with static profile",
"steps": [
{
"type": "configure",
"name": "static"
},
{
"type": "build",
"name": "static"
},
{
"type": "test",
"name": "static"
}
]
}
]
}
Loading

0 comments on commit 5c92d68

Please sign in to comment.