first commit
This commit is contained in:
@@ -0,0 +1,4 @@
|
|||||||
|
.vs
|
||||||
|
build
|
||||||
|
output
|
||||||
|
.cache
|
||||||
Vendored
+17
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"editor.rulers": [
|
||||||
|
{
|
||||||
|
"column": 80
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"editor.renderWhitespace": "boundary",
|
||||||
|
"editor.formatOnSave": true,
|
||||||
|
"cmake.generator": "Ninja",
|
||||||
|
"C_Cpp.autocomplete": "disabled",
|
||||||
|
"files.exclude": {
|
||||||
|
"**/*.rpyc": true,
|
||||||
|
"**/*.rpa": true,
|
||||||
|
"**/*.rpymc": true,
|
||||||
|
"**/cache/": true
|
||||||
|
}
|
||||||
|
}
|
||||||
+162
@@ -0,0 +1,162 @@
|
|||||||
|
cmake_minimum_required (VERSION 3.25)
|
||||||
|
|
||||||
|
# ============================================================
|
||||||
|
# Policy
|
||||||
|
# ============================================================
|
||||||
|
if(WIN32 AND POLICY CMP0091)
|
||||||
|
cmake_policy(SET CMP0091 NEW)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# ============================================================
|
||||||
|
# Project
|
||||||
|
# ============================================================
|
||||||
|
set(SUB_PROJECT_NAME "Test")
|
||||||
|
project(${SUB_PROJECT_NAME} LANGUAGES CXX)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 23)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
|
||||||
|
# ============================================================
|
||||||
|
# Dependencies
|
||||||
|
# ============================================================
|
||||||
|
include(FetchContent)
|
||||||
|
|
||||||
|
if(NOT DEFINED ROOT_PROJECT_NAME)
|
||||||
|
set(ROOT_PROJECT_NAME "Root")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
FetchContent_Declare(
|
||||||
|
Common
|
||||||
|
GIT_REPOSITORY https://github.com/HappyTanuki/Bedrock-Common.git
|
||||||
|
GIT_TAG master
|
||||||
|
GIT_SHALLOW ON
|
||||||
|
)
|
||||||
|
FetchContent_MakeAvailable(Common)
|
||||||
|
|
||||||
|
FetchContent_Declare(
|
||||||
|
Encryption
|
||||||
|
GIT_REPOSITORY https://github.com/HappyTanuki/Bedrock-Encryption.git
|
||||||
|
GIT_TAG master
|
||||||
|
GIT_SHALLOW ON
|
||||||
|
)
|
||||||
|
FetchContent_MakeAvailable(Encryption)
|
||||||
|
|
||||||
|
# ============================================================
|
||||||
|
# Target – Networking
|
||||||
|
# ============================================================
|
||||||
|
file(GLOB_RECURSE SOURCES "src/*.cc")
|
||||||
|
|
||||||
|
if (CMAKE_MSVC_RUNTIME_LIBRARY MATCHES "DLL$")
|
||||||
|
add_executable(${SUB_PROJECT_NAME} ${SOURCES})
|
||||||
|
else ()
|
||||||
|
add_executable(${SUB_PROJECT_NAME} ${SOURCES})
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
target_link_libraries(${SUB_PROJECT_NAME} PUBLIC ${ROOT_PROJECT_NAME}::Common)
|
||||||
|
target_link_libraries(${SUB_PROJECT_NAME} PUBLIC ${ROOT_PROJECT_NAME}::Encryption)
|
||||||
|
|
||||||
|
target_include_directories(${SUB_PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||||
|
|
||||||
|
# ============================================================
|
||||||
|
# Compiler Options
|
||||||
|
# ============================================================
|
||||||
|
if (TARGET ${SUB_PROJECT_NAME})
|
||||||
|
target_precompile_headers(${SUB_PROJECT_NAME} PRIVATE
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/include/pch.h"
|
||||||
|
)
|
||||||
|
if(MSVC)
|
||||||
|
target_compile_options(${SUB_PROJECT_NAME} PRIVATE /MP)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(UNIX AND NOT APPLE AND CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||||
|
set_target_properties(${SUB_PROJECT_NAME} PROPERTIES
|
||||||
|
BUILD_WITH_INSTALL_RPATH TRUE
|
||||||
|
INSTALL_RPATH "$ORIGIN"
|
||||||
|
SKIP_BUILD_RPATH FALSE
|
||||||
|
BUILD_RPATH "$ORIGIN"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (NOT WIN32)
|
||||||
|
target_compile_options(
|
||||||
|
${SUB_PROJECT_NAME} PRIVATE
|
||||||
|
-maes
|
||||||
|
-msse2
|
||||||
|
-mssse3
|
||||||
|
-fno-exceptions -fno-rtti
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
add_compile_options(/utf-8)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||||
|
add_compile_options(-Wuseless-cast)
|
||||||
|
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||||
|
add_compile_options(
|
||||||
|
-Weverything
|
||||||
|
-Wno-c++98-compat
|
||||||
|
-Wno-c++98-compat-pedantic
|
||||||
|
-Wno-unused-macros
|
||||||
|
-Wno-padded
|
||||||
|
)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
target_link_libraries(${SUB_PROJECT_NAME} PUBLIC ws2_32)
|
||||||
|
target_link_libraries(${SUB_PROJECT_NAME} PUBLIC crypt32)
|
||||||
|
set_target_properties(${SUB_PROJECT_NAME} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
||||||
|
else()
|
||||||
|
add_compile_options(
|
||||||
|
-Werror
|
||||||
|
-Wall
|
||||||
|
-Wextra
|
||||||
|
-Wpedantic
|
||||||
|
-Wconversion
|
||||||
|
-Wsign-conversion
|
||||||
|
-Wshadow
|
||||||
|
-Wundef
|
||||||
|
-Wunreachable-code
|
||||||
|
-Wstrict-aliasing
|
||||||
|
-Wnull-dereference
|
||||||
|
-Wdouble-promotion
|
||||||
|
-Wformat=2
|
||||||
|
-Wcast-qual
|
||||||
|
-Wcast-align
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# ============================================================
|
||||||
|
# clang-tidy (Linux only)
|
||||||
|
# ============================================================
|
||||||
|
find_program(CLANG_TIDY_EXE NAMES clang-tidy)
|
||||||
|
if(CLANG_TIDY_EXE)
|
||||||
|
set(CMAKE_CXX_CLANG_TIDY
|
||||||
|
$<$<COMPILE_LANGUAGE:CXX>:clang-tidy;-checks=-*,google-readability-casting;-fix;-fix-errors>
|
||||||
|
)
|
||||||
|
if (PROJECT_IS_TOP_LEVEL AND CMAKE_EXPORT_COMPILE_COMMANDS)
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E create_symlink
|
||||||
|
${CMAKE_BINARY_DIR}/compile_commands.json
|
||||||
|
${CMAKE_BINARY_DIR}/../compile_commands.json
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (${PROJECT_IS_TOP_LEVEL})
|
||||||
|
set(BUILD_TESTING ON)
|
||||||
|
|
||||||
|
include(CTest)
|
||||||
|
enable_testing()
|
||||||
|
|
||||||
|
add_subdirectory(test)
|
||||||
|
|
||||||
|
add_custom_command(TARGET ${SUB_PROJECT_NAME} POST_BUILD
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||||
|
"$<TARGET_FILE:${SUB_PROJECT_NAME}>"
|
||||||
|
"${CMAKE_BINARY_DIR}/test"
|
||||||
|
COMMENT "Copying ${SUB_PROJECT_NAME} DLL/so to test output directory"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
@@ -0,0 +1,294 @@
|
|||||||
|
{
|
||||||
|
"version": 9,
|
||||||
|
"configurePresets": [
|
||||||
|
{
|
||||||
|
"name": "Paths",
|
||||||
|
"hidden": true,
|
||||||
|
"binaryDir": "${sourceDir}/output/${presetName}",
|
||||||
|
"installDir": "${sourceDir}/build/${presetName}",
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_ARCHIVE_OUTPUT_DIRECTORY": "${sourceDir}/build/${presetName}",
|
||||||
|
"CMAKE_LIBRARY_OUTPUT_DIRECTORY": "${sourceDir}/build/${presetName}",
|
||||||
|
"CMAKE_RUNTIME_OUTPUT_DIRECTORY": "${sourceDir}/build/${presetName}"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Linux-Clang-Build",
|
||||||
|
"hidden": true,
|
||||||
|
"inherits": [
|
||||||
|
"Paths"
|
||||||
|
],
|
||||||
|
"generator": "Ninja Multi-Config",
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_CXX_COMPILER": "/usr/bin/clang++"
|
||||||
|
},
|
||||||
|
"condition": {
|
||||||
|
"type": "equals",
|
||||||
|
"lhs": "${hostSystemName}",
|
||||||
|
"rhs": "Linux"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Linux-GCC-Build",
|
||||||
|
"hidden": true,
|
||||||
|
"inherits": [
|
||||||
|
"Paths"
|
||||||
|
],
|
||||||
|
"generator": "Ninja Multi-Config",
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_CXX_COMPILER": "/usr/bin/g++"
|
||||||
|
},
|
||||||
|
"condition": {
|
||||||
|
"type": "equals",
|
||||||
|
"lhs": "${hostSystemName}",
|
||||||
|
"rhs": "Linux"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Windows-Build",
|
||||||
|
"hidden": true,
|
||||||
|
"inherits": [
|
||||||
|
"Paths"
|
||||||
|
],
|
||||||
|
"generator": "Ninja",
|
||||||
|
"condition": {
|
||||||
|
"type": "equals",
|
||||||
|
"lhs": "${hostSystemName}",
|
||||||
|
"rhs": "Windows"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "x64Windows",
|
||||||
|
"hidden": true,
|
||||||
|
"architecture": {
|
||||||
|
"value": "x64",
|
||||||
|
"strategy": "external"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "x64Linux",
|
||||||
|
"hidden": true,
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_CXX_FLAGS": "-m64"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "x86Windows",
|
||||||
|
"hidden": true,
|
||||||
|
"architecture": {
|
||||||
|
"value": "x86",
|
||||||
|
"strategy": "external"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "x86Linux",
|
||||||
|
"hidden": true,
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_CXX_FLAGS": "-m32",
|
||||||
|
"CMAKE_EXE_LINKER_FLAGS": "-m32",
|
||||||
|
"CMAKE_SHARED_LINKER_FLAGS": "-m32"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Debug",
|
||||||
|
"hidden": true,
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_BUILD_TYPE": "Debug"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Release",
|
||||||
|
"hidden": true,
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_BUILD_TYPE": "Release"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "MD",
|
||||||
|
"hidden": true,
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreadedDLL"
|
||||||
|
},
|
||||||
|
"condition": {
|
||||||
|
"type": "equals",
|
||||||
|
"lhs": "${hostSystemName}",
|
||||||
|
"rhs": "Windows"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "MT",
|
||||||
|
"hidden": true,
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreaded"
|
||||||
|
},
|
||||||
|
"condition": {
|
||||||
|
"type": "equals",
|
||||||
|
"lhs": "${hostSystemName}",
|
||||||
|
"rhs": "Windows"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "MDd",
|
||||||
|
"hidden": true,
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreadedDebugDLL"
|
||||||
|
},
|
||||||
|
"condition": {
|
||||||
|
"type": "equals",
|
||||||
|
"lhs": "${hostSystemName}",
|
||||||
|
"rhs": "Windows"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "MTd",
|
||||||
|
"hidden": true,
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreadedDebug"
|
||||||
|
},
|
||||||
|
"condition": {
|
||||||
|
"type": "equals",
|
||||||
|
"lhs": "${hostSystemName}",
|
||||||
|
"rhs": "Windows"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Windows-x64-Debug",
|
||||||
|
"displayName": "Windows x64 Debug",
|
||||||
|
"inherits": [
|
||||||
|
"Windows-Build",
|
||||||
|
"Debug",
|
||||||
|
"x64Windows",
|
||||||
|
"MDd"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Windows-x86-Debug",
|
||||||
|
"displayName": "Windows x86 Debug",
|
||||||
|
"inherits": [
|
||||||
|
"Windows-Build",
|
||||||
|
"Debug",
|
||||||
|
"x86Windows",
|
||||||
|
"MDd"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Windows-x64-Release",
|
||||||
|
"displayName": "Windows x64 Release",
|
||||||
|
"inherits": [
|
||||||
|
"Windows-Build",
|
||||||
|
"Release",
|
||||||
|
"x64Windows",
|
||||||
|
"MD"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Windows-x86-Release",
|
||||||
|
"displayName": "Windows x86 Release",
|
||||||
|
"inherits": [
|
||||||
|
"Windows-Build",
|
||||||
|
"Release",
|
||||||
|
"x86Windows",
|
||||||
|
"MD"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Windows-x64-Debug-MT",
|
||||||
|
"displayName": "Windows x64 Debug MT",
|
||||||
|
"inherits": [
|
||||||
|
"Windows-Build",
|
||||||
|
"Debug",
|
||||||
|
"x64Windows",
|
||||||
|
"MTd"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Windows-x86-Debug-MT",
|
||||||
|
"displayName": "Windows x86 Debug MT",
|
||||||
|
"inherits": [
|
||||||
|
"Windows-Build",
|
||||||
|
"Debug",
|
||||||
|
"x86Windows",
|
||||||
|
"MTd"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Windows-x64-Release-MT",
|
||||||
|
"displayName": "Windows x64 Release MT",
|
||||||
|
"inherits": [
|
||||||
|
"Windows-Build",
|
||||||
|
"Release",
|
||||||
|
"x64Windows",
|
||||||
|
"MT"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Windows-x86-Release-MT",
|
||||||
|
"displayName": "Windows x86 Release MT",
|
||||||
|
"inherits": [
|
||||||
|
"Windows-Build",
|
||||||
|
"Release",
|
||||||
|
"x86Windows",
|
||||||
|
"MT"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Clang-x64",
|
||||||
|
"displayName": "Clang x64",
|
||||||
|
"inherits": [
|
||||||
|
"Linux-Clang-Build",
|
||||||
|
"x64Linux"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "GCC-x64",
|
||||||
|
"displayName": "GCC x64",
|
||||||
|
"inherits": [
|
||||||
|
"Linux-GCC-Build",
|
||||||
|
"x64Linux"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"buildPresets": [
|
||||||
|
{
|
||||||
|
"name": "Linux-Only",
|
||||||
|
"hidden": true,
|
||||||
|
"condition": {
|
||||||
|
"type": "equals",
|
||||||
|
"lhs": "${hostSystemName}",
|
||||||
|
"rhs": "Linux"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Debug-Clang-x64",
|
||||||
|
"inherits": [
|
||||||
|
"Linux-Only"
|
||||||
|
],
|
||||||
|
"configurePreset": "Clang-x64",
|
||||||
|
"configuration": "Debug"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Release-Clang-x64",
|
||||||
|
"inherits": [
|
||||||
|
"Linux-Only"
|
||||||
|
],
|
||||||
|
"configurePreset": "Clang-x64",
|
||||||
|
"configuration": "Release"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Debug-GCC-x64",
|
||||||
|
"inherits": [
|
||||||
|
"Linux-Only"
|
||||||
|
],
|
||||||
|
"configurePreset": "GCC-x64",
|
||||||
|
"configuration": "Debug"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Release-GCC-x64",
|
||||||
|
"inherits": [
|
||||||
|
"Linux-Only"
|
||||||
|
],
|
||||||
|
"configurePreset": "GCC-x64",
|
||||||
|
"configuration": "Release"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
#pragma once
|
||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include "encryption/util/helper.h"
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
std::ifstream payload1_file;
|
||||||
|
|
||||||
|
payload1_file.open("payload1.txt");
|
||||||
|
if (!payload1_file) {
|
||||||
|
std::cout << "파일 열기 실패\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
payload1_file.seekg(0, std::ios::end);
|
||||||
|
|
||||||
|
// 현재 위치 = 파일 크기
|
||||||
|
std::streampos size = payload1_file.tellg();
|
||||||
|
|
||||||
|
std::string payload1;
|
||||||
|
payload1.resize(size);
|
||||||
|
payload1_file.read(payload1.data(), size);
|
||||||
|
|
||||||
|
std::cout << "red: " << payload1 << std::endl;
|
||||||
|
|
||||||
|
auto bytes = bedrock::util::HexStrToBytes(payload1);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
file(GLOB TEST_SOURCES "*.cc")
|
||||||
|
|
||||||
|
foreach(test_src ${TEST_SOURCES})
|
||||||
|
get_filename_component(test_name ${test_src} NAME_WE)
|
||||||
|
add_executable(${test_name} ${test_src})
|
||||||
|
target_link_libraries(${test_name} PRIVATE ${PROJECT_NAME})
|
||||||
|
if(NOT WIN32)
|
||||||
|
target_compile_options(${test_name} PRIVATE -fno-exceptions -march=native -maes -msse2 -msse3 -mssse3 -msse4.1 -msse4.2)
|
||||||
|
endif()
|
||||||
|
add_test(NAME ${test_name} COMMAND ${test_name})
|
||||||
|
set_tests_properties(${test_name} PROPERTIES WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||||
|
endforeach()
|
||||||
Reference in New Issue
Block a user