Skip to content

Commit

Permalink
core(code): semantic rewrite
Browse files Browse the repository at this point in the history
- changed naming conventions
- changed indent styling
- use vcpkg
- add file version information
  • Loading branch information
shdwmtr committed Jun 2, 2024
1 parent c62bf55 commit f4f511a
Show file tree
Hide file tree
Showing 43 changed files with 2,100 additions and 1,786 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
/build
/.vscode
/.vscode
/.vs
/out
114 changes: 68 additions & 46 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,46 @@
cmake_minimum_required(VERSION 3.5.0)
project(Millennium LANGUAGES CXX)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lunistring -liconv -lbrotlicommon -lcurl -lssh2 -lssl -lcrypto -lz -static-libgcc -static-libstdc++ -lstdc++ -lpthread")

# build boxer statically
set(BUILD_SHARED_LIBS OFF)
add_subdirectory(vendor/boxer)
cmake_policy(SET CMP0091 NEW)

set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
project(Millennium LANGUAGES CXX)

if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
add_compile_options(-Wno-format-security)
if (WIN32)
# debug output paths
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "C:/Program Files (x86)/Steam")
set(LIBRARY_OUTPUT_DIRECTORY "C:/Program Files (x86)/Steam")
endif()

set(PRIVATE_PRODUCT_NAME "Millennium [Steam Homebrew]")

# Set version information
add_compile_definitions(
VER_COMPANYNAME_STR="Steam Homebrew."
VER_PRIVATEBUILD=1.0.1
VER_PRERELEASE=1.0.1
VER_DEBUG=1.0.1
VER_FILEVERSION_STR="2.1.6"
VER_FILEVERSION=2,1,6
VER_PRODUCTVERSION_STR="2.1.6"
VER_PRODUCTVERSION=2,1,6
VER_FILEDESCRIPTION_STR="A plugin loader for the modern Steam Client."
VER_INTERNALNAME_STR="${PRIVATE_PRODUCT_NAME}"
VER_LEGALCOPYRIGHT_STR="Copyright \(c\) Steam Homebrew."
VER_LEGALTRADEMARKS1_STR="Copyright \(c\) Steam Homebrew."
VER_LEGALTRADEMARKS2_STR="Copyright \(c\) Steam Homebrew."
VER_ORIGINALFILENAME_STR="${PRIVATE_PRODUCT_NAME}"
VER_PRODUCTNAME_STR="${PRIVATE_PRODUCT_NAME}"
)

# Compile as release and compile MSVC as MT (static)
set(CMAKE_BUILD_TYPE Release)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")

include(FetchContent)
FetchContent_Declare(cpr GIT_REPOSITORY https://github.com/libcpr/cpr.git GIT_TAG 3b15fa82ea74739b574d705fea44959b58142eb8)
FetchContent_MakeAvailable(cpr)
# build boxer (message-box lib)
add_subdirectory(vendor/boxer)

# add_compile_options(-g -Og -lz)
set(CMAKE_CXX_STANDARD 17)
Expand All @@ -31,54 +58,49 @@ include_directories(
)

add_compile_definitions(
CURL_STATICLIB
FMT_HEADER_ONLY
CURL_STATICLIB # static lcurl

# prevent websocketpp from using boost
_WEBSOCKETPP_CPP11_THREAD_
ASIO_HAS_STD_INVOKE_RESULT
_WEBSOCKETPP_CPP11_TYPE_TRAITS_
_WEBSOCKETPP_CPP11_RANDOM_DEVICE_
ASIO_STANDALONE
_CRT_SECURE_NO_WARNINGS
)

# find_package(minizip REQUIRED)
find_package(Python COMPONENTS Development)
find_package(Threads REQUIRED)
ASIO_STANDALONE # static asio
ASIO_HAS_STD_INVOKE_RESULT # prevent use of boost

if (Python_FOUND)
message(STATUS "PYTHON include directory: ${Python_INCLUDE_DIRS}")
message(STATUS "PYTHON libraries: ${Python_LIBRARIES}")
else()
message("Python was not found. download & install here: https://www.python.org/ftp/python/3.11.8/python-3.11.8.exe")
endif()
FMT_HEADER_ONLY # implicit static link
_CRT_SECURE_NO_WARNINGS
)

message(STATUS "LIBGIT include directory: ${LIBGIT2_INCLUDE_DIRS}")
message(STATUS "LIBGIT libraries: ${LIBGIT2_LIBRARIES}")
find_package(cpr CONFIG REQUIRED) # used for web requests.
find_package(Python REQUIRED COMPONENTS Interpreter Development) # used to run plugin backends
find_package(unofficial-git2 CONFIG REQUIRED) # update millennium modules

include_directories(
${Python_INCLUDE_DIRS}
# ${Python_INCLUDE_DIRS}
"C:/Program Files (x86)/Python311-32/include"
${LIBGIT2_INCLUDE_DIRS}
"src/__builtins__"
)

set(CMAKE_BUILD_TYPE Debug)
set(SOURCE_FILES
"src/core/main.cpp"
"src/core/loader.cpp"
"src/core/backend/co_spawn.cpp"
"src/core/impl/c_python.cpp"
"src/core/impl/javascript.cpp"
"src/core/py_controller/co_spawn.cpp"
"src/core/ffi/c_python.cpp"
"src/core/ffi/javascript.cpp"
"src/core/ffi/gil.cc"
"src/utilities/log.cpp"
"src/core/ipc/pipe.cpp"
"src/generic/stream_parser.cc"
"src/__builtins__/executor.cc"
"src/deps/module.cc"
"src/core/hooks/web_load.cc"
"src/core/co_initialize/co_stub.cc"
version.rc
)

if (WIN32)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "C:/Program Files (x86)/Steam")
add_library(Millennium SHARED "${SOURCE_FILES}")
# add_executable(Millennium "${SOURCE_FILES}")
elseif(UNIX)
Expand All @@ -87,24 +109,24 @@ endif()

set_target_properties(Millennium PROPERTIES OUTPUT_NAME "user32")
set_target_properties(Millennium PROPERTIES PREFIX "")
set_target_properties(Millennium PROPERTIES NO_EXPORT TRUE)

if(MSVC)
# prevent MSVC from generating .lib and .exp archives
set_target_properties(Millennium PROPERTIES ARCHIVE_OUTPUT_NAME "" LINK_FLAGS "/NOEXP")
endif()

if(WIN32)
# link windows defined socket headers
target_link_libraries(Millennium
Ws2_32.lib
wsock32
${CMAKE_SOURCE_DIR}/vendor/win32/python311.lib
${CMAKE_SOURCE_DIR}/vendor/win32/git2.lib
)
elseif(UNIX)
target_link_libraries(Millennium
${Python_LIBRARIES}
git2
)
target_link_libraries(Millennium Ws2_32.lib wsock32)
endif()

target_link_libraries(Millennium
Boxer
cpr::cpr
Threads::Threads
Boxer
cpr::cpr
# ${Python_LIBRARIES}
# "D:/Development/millennium/vendor/win32/python311.lib"
# "C:/Users/Admin/Downloads/Python/Python-3.11.8/PCbuild/win32/python311.lib"
"C:/Users/Admin/Downloads/Python-3.11.8/Python-3.11.8/PCbuild/win32/python311.lib"
unofficial::git2::git2
)
18 changes: 18 additions & 0 deletions CMakeUserPresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"version": 2,
"configurePresets": [
{
"name": "default",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build",
"architecture": {
"value": "x86",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "C:/Users/Admin/vcpkg/scripts/buildsystems/vcpkg.cmake",
"VCPKG_TARGET_TRIPLET": "x86-windows-static"
}
}
]
}
85 changes: 0 additions & 85 deletions src/__builtins__/bootstrap.js

This file was deleted.

Loading

0 comments on commit f4f511a

Please sign in to comment.