Compare commits
12 commits
Author | SHA1 | Date | |
---|---|---|---|
cb84f3dff8 | |||
416fdb3bdb | |||
a7a80571ea | |||
7f0fa0b90d | |||
9a1e6f24b1 | |||
daa49af247 | |||
f25ca44f03 | |||
47761441c0 | |||
810cea013e | |||
53f661ece8 | |||
7dbe088577 | |||
18129ac7c2 |
14 changed files with 333 additions and 117 deletions
3
.gitattributes
vendored
3
.gitattributes
vendored
|
@ -37,3 +37,6 @@
|
||||||
*.exe binary
|
*.exe binary
|
||||||
*.out binary
|
*.out binary
|
||||||
*.app binary
|
*.app binary
|
||||||
|
|
||||||
|
# Linux shell files must always be LF
|
||||||
|
*.sh text eol=lf
|
6
.gitignore
vendored
6
.gitignore
vendored
|
@ -21,3 +21,9 @@ build/**
|
||||||
# Blacklist specific build directories
|
# Blacklist specific build directories
|
||||||
linuxbuild/
|
linuxbuild/
|
||||||
build/
|
build/
|
||||||
|
.idea/
|
||||||
|
winbuild/
|
||||||
|
|
||||||
|
!Compile.sh
|
||||||
|
!Compile.bat
|
||||||
|
HarmonyLinkLib/.vscode/
|
||||||
|
|
|
@ -44,12 +44,12 @@ elseif(UNIX)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Set global output directories for all build types
|
# Set global output directories for all build types
|
||||||
foreach(TYPE IN ITEMS DEBUG RELEASE)
|
#foreach(TYPE IN ITEMS DEBUG RELEASE)
|
||||||
string(TOUPPER ${TYPE} TYPE_UPPER)
|
# string(TOUPPER ${TYPE} TYPE_UPPER)
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${TYPE_UPPER} "${CMAKE_BINARY_DIR}/bin/${TYPE}")
|
# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${TYPE_UPPER} "${CMAKE_BINARY_DIR}/bin/${TYPE}")
|
||||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${TYPE_UPPER} "${CMAKE_BINARY_DIR}/lib/${TYPE}")
|
# set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${TYPE_UPPER} "${CMAKE_BINARY_DIR}/lib/${TYPE}")
|
||||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${TYPE_UPPER} "${CMAKE_BINARY_DIR}/archive/${TYPE}")
|
# set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${TYPE_UPPER} "${CMAKE_BINARY_DIR}/archive/${TYPE}")
|
||||||
endforeach()
|
#endforeach()
|
||||||
|
|
||||||
# Add the library and executable directories
|
# Add the library and executable directories
|
||||||
|
|
||||||
|
|
68
Compile.bat
Normal file
68
Compile.bat
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
@echo off
|
||||||
|
setlocal enabledelayedexpansion
|
||||||
|
|
||||||
|
REM Clear the screen
|
||||||
|
cls
|
||||||
|
|
||||||
|
REM Define the color codes
|
||||||
|
set GREEN=
|
||||||
|
set NC=
|
||||||
|
|
||||||
|
REM Prompt the user to choose a compiler
|
||||||
|
echo %GREEN%Select the compiler to use:%NC%
|
||||||
|
echo 1^ ) MSBuild (default)
|
||||||
|
echo 2^ ) MinGW
|
||||||
|
echo 3^ ) Ninja
|
||||||
|
set /p choice=Enter the number of your choice:
|
||||||
|
|
||||||
|
REM Set the generator and compiler based on the user's choice
|
||||||
|
if "%choice%"=="2" (
|
||||||
|
set "GENERATOR=MinGW Makefiles"
|
||||||
|
set "COMPILER_OPTION=-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++"
|
||||||
|
) else if "%choice%"=="3" (
|
||||||
|
set "GENERATOR=Ninja"
|
||||||
|
set "COMPILER_OPTION="
|
||||||
|
) else (
|
||||||
|
set "GENERATOR=Visual Studio 17 2022"
|
||||||
|
set "COMPILER_OPTION=-A x64"
|
||||||
|
set "choice=1"
|
||||||
|
)
|
||||||
|
|
||||||
|
echo Using generator: %GENERATOR%
|
||||||
|
|
||||||
|
REM Prompt the user to choose a build type
|
||||||
|
echo %GREEN%Select the build type:%NC%
|
||||||
|
echo 1^ ) Release (default)
|
||||||
|
echo 2^ ) Debug
|
||||||
|
set /p build_choice=Enter the number of your choice:
|
||||||
|
|
||||||
|
REM Set the build type based on the user's choice
|
||||||
|
if "%build_choice%"=="2" (
|
||||||
|
set "BUILD_TYPE=Debug"
|
||||||
|
) else (
|
||||||
|
set "BUILD_TYPE=Release"
|
||||||
|
)
|
||||||
|
|
||||||
|
echo Build type: %BUILD_TYPE%
|
||||||
|
|
||||||
|
REM Create the build directory if it doesn't exist
|
||||||
|
if not exist "winbuild" (
|
||||||
|
mkdir winbuild
|
||||||
|
)
|
||||||
|
|
||||||
|
cd winbuild
|
||||||
|
|
||||||
|
REM Get the number of processors
|
||||||
|
for /f "tokens=2 delims==" %%a in ('wmic cpu get NumberOfLogicalProcessors /value') do set "NUM_PROCESSORS=%%a"
|
||||||
|
|
||||||
|
REM Run CMake with the selected generator and build type
|
||||||
|
cmake -G "%GENERATOR%" %COMPILER_OPTION% -DCMAKE_BUILD_TYPE=%BUILD_TYPE% ..
|
||||||
|
|
||||||
|
REM Build the project
|
||||||
|
if "%choice%"=="1" (
|
||||||
|
cmake --build . --config %BUILD_TYPE% -- /m:%NUM_PROCESSORS%
|
||||||
|
) else (
|
||||||
|
cmake --build . --config %BUILD_TYPE% -- -j %NUM_PROCESSORS%
|
||||||
|
)
|
||||||
|
|
||||||
|
cd ..
|
127
Compile.sh
Normal file
127
Compile.sh
Normal file
|
@ -0,0 +1,127 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
clear
|
||||||
|
|
||||||
|
# Define color codes
|
||||||
|
GREEN='\033[0;32m'
|
||||||
|
NC='\033[0m' # No Color
|
||||||
|
PURPLE='\033[0;35m'
|
||||||
|
GRAY='\033[1;30m'
|
||||||
|
|
||||||
|
# Ensure dialog is installed
|
||||||
|
if ! command -v dialog &> /dev/null
|
||||||
|
then
|
||||||
|
echo "dialog could not be found. Please install it to use this script."
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Function to check if a compiler is installed
|
||||||
|
check_compiler() {
|
||||||
|
if command -v $1 &> /dev/null
|
||||||
|
then
|
||||||
|
COMPILER_OPTIONS+=("$2" "$3" "$4")
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Array to store the menu options
|
||||||
|
COMPILER_OPTIONS=()
|
||||||
|
|
||||||
|
# Add available compilers to the options array
|
||||||
|
check_compiler g++ "1" "g++ (default)" "on"
|
||||||
|
check_compiler clang++ "2" "clang++" "off"
|
||||||
|
check_compiler clang++-15 "3" "clang++ 15" "off"
|
||||||
|
check_compiler clang++-16 "4" "clang++ 16" "off"
|
||||||
|
check_compiler clang++-17 "5" "clang++ 17" "off"
|
||||||
|
|
||||||
|
# Debug: print the compiler options
|
||||||
|
echo "Compiler options: ${COMPILER_OPTIONS[@]}"
|
||||||
|
|
||||||
|
# Check if any compilers are available
|
||||||
|
if [ ${#COMPILER_OPTIONS[@]} -eq 0 ]; then
|
||||||
|
dialog --msgbox "No compilers found. Please install a compiler to use this script." 10 40
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Prompt the user to choose one or more compilers
|
||||||
|
compiler_choices=$(dialog --colors --title "\Zb\Z5Select Compiler\Zn" --checklist "\nChoose one or more compilers:" 15 60 ${#COMPILER_OPTIONS[@]} "${COMPILER_OPTIONS[@]}" 3>&1 1>&2 2>&3)
|
||||||
|
|
||||||
|
# Process the selected compilers
|
||||||
|
C_COMPILERS=()
|
||||||
|
CXX_COMPILERS=()
|
||||||
|
|
||||||
|
# Debug: print the compiler choices
|
||||||
|
echo "Compiler choices: $compiler_choices"
|
||||||
|
|
||||||
|
for choice in $compiler_choices; do
|
||||||
|
case $choice in
|
||||||
|
1)
|
||||||
|
C_COMPILERS+=("gcc")
|
||||||
|
CXX_COMPILERS+=("g++")
|
||||||
|
;;
|
||||||
|
2)
|
||||||
|
C_COMPILERS+=("clang")
|
||||||
|
CXX_COMPILERS+=("clang++")
|
||||||
|
;;
|
||||||
|
3)
|
||||||
|
C_COMPILERS+=("clang-15")
|
||||||
|
CXX_COMPILERS+=("clang++-15")
|
||||||
|
;;
|
||||||
|
4)
|
||||||
|
C_COMPILERS+=("clang-16")
|
||||||
|
CXX_COMPILERS+=("clang++-16")
|
||||||
|
;;
|
||||||
|
5)
|
||||||
|
C_COMPILERS+=("clang-17")
|
||||||
|
CXX_COMPILERS+=("clang++-17")
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# Output the chosen compilers
|
||||||
|
msg="Chosen compilers:\n"
|
||||||
|
for i in "${!C_COMPILERS[@]}"; do
|
||||||
|
msg+="C compiler: ${C_COMPILERS[$i]}, C++ compiler: ${CXX_COMPILERS[$i]}\n"
|
||||||
|
done
|
||||||
|
|
||||||
|
dialog --colors --msgbox "\Zb\Z5$msg\Zn" 20 60
|
||||||
|
|
||||||
|
# Prompt the user to choose a build type
|
||||||
|
build_choice=$(dialog --colors --title "\Zb\Z5Select Build Type\Zn" --menu "\nChoose a build type:" 10 40 2 \
|
||||||
|
1 "Release (default)" \
|
||||||
|
2 "Debug" 3>&1 1>&2 2>&3)
|
||||||
|
|
||||||
|
# Set the build type based on the user's choice
|
||||||
|
case $build_choice in
|
||||||
|
2)
|
||||||
|
BUILD_TYPE=Debug
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
BUILD_TYPE=Release
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Output the chosen build type
|
||||||
|
dialog --colors --msgbox "\Zb\Z5Build type:\Zn $BUILD_TYPE" 10 40
|
||||||
|
|
||||||
|
clear
|
||||||
|
|
||||||
|
# Create the build directory if it doesn't exist
|
||||||
|
if [ ! -d "linuxbuild" ]; then
|
||||||
|
mkdir linuxbuild
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd linuxbuild
|
||||||
|
|
||||||
|
# Run CMake with the selected compilers and build type
|
||||||
|
for i in "${!C_COMPILERS[@]}"; do
|
||||||
|
cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_C_COMPILER=${C_COMPILERS[$i]} -DCMAKE_CXX_COMPILER=${CXX_COMPILERS[$i]} ..
|
||||||
|
# Build the project
|
||||||
|
cmake --build . --config $BUILD_TYPE -j 15 #--clean-first #--verbose
|
||||||
|
done
|
||||||
|
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
# End with a success message
|
||||||
|
dialog --colors --msgbox "\Zb\Z5Build(s) completed successfully!\Zn" 10 40
|
|
@ -12,7 +12,7 @@
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.10)
|
cmake_minimum_required(VERSION 3.10)
|
||||||
project(HarmonyLinkLib VERSION 2.1.1)
|
project(HarmonyLinkLib VERSION 2.1.2 LANGUAGES CXX)
|
||||||
|
|
||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
|
|
||||||
|
@ -28,6 +28,18 @@ FetchContent_MakeAvailable(fmt)
|
||||||
set_target_properties(fmt PROPERTIES FOLDER External)
|
set_target_properties(fmt PROPERTIES FOLDER External)
|
||||||
set_target_properties(fmt PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
|
set_target_properties(fmt PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
|
||||||
|
|
||||||
|
# Fetch ghc library
|
||||||
|
FetchContent_Declare(
|
||||||
|
ghc_filesystem
|
||||||
|
GIT_REPOSITORY https://github.com/gulrak/filesystem.git
|
||||||
|
GIT_TAG v1.5.14 # Specify the desired version of ghc
|
||||||
|
)
|
||||||
|
|
||||||
|
FetchContent_MakeAvailable(ghc_filesystem)
|
||||||
|
|
||||||
|
set_target_properties(ghc_filesystem PROPERTIES FOLDER External)
|
||||||
|
set_target_properties(ghc_filesystem PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
|
||||||
|
|
||||||
# Find the current Git branch and the last commit timestamp
|
# Find the current Git branch and the last commit timestamp
|
||||||
find_package(Git QUIET)
|
find_package(Git QUIET)
|
||||||
if(GIT_FOUND)
|
if(GIT_FOUND)
|
||||||
|
@ -69,7 +81,6 @@ set(COMMON_SOURCES
|
||||||
"src/Platform/IPlatformUtilities.cpp"
|
"src/Platform/IPlatformUtilities.cpp"
|
||||||
"src/HarmonyLinkLib.cpp"
|
"src/HarmonyLinkLib.cpp"
|
||||||
"src/Version.cpp"
|
"src/Version.cpp"
|
||||||
"src/dllmain.cpp"
|
|
||||||
"src/Platform/WineUtilities.cpp"
|
"src/Platform/WineUtilities.cpp"
|
||||||
"src/Utilities.cpp"
|
"src/Utilities.cpp"
|
||||||
)
|
)
|
||||||
|
@ -92,11 +103,6 @@ set(COMMON_INCLUDES
|
||||||
"src/Utilities.h"
|
"src/Utilities.h"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Adding fmt headers explicitly
|
|
||||||
set(FMT_HEADERS
|
|
||||||
"${fmt_SOURCE_DIR}/include/fmt"
|
|
||||||
)
|
|
||||||
|
|
||||||
set(WINDOWS_SOURCES
|
set(WINDOWS_SOURCES
|
||||||
"src/Platform/Windows/WindowsUtilities.cpp"
|
"src/Platform/Windows/WindowsUtilities.cpp"
|
||||||
)
|
)
|
||||||
|
@ -125,6 +131,18 @@ set(MAC_INCLUDES
|
||||||
"src/Platform/Unix/UnixUtilities.h"
|
"src/Platform/Unix/UnixUtilities.h"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Platform-specific definitions
|
||||||
|
if(WIN32)
|
||||||
|
add_definitions(-DBUILD_WINDOWS)
|
||||||
|
elseif(UNIX)
|
||||||
|
if(APPLE)
|
||||||
|
add_definitions(-DBUILD_MACOS)
|
||||||
|
else()
|
||||||
|
add_definitions(-DBUILD_LINUX)
|
||||||
|
endif()
|
||||||
|
add_definitions(-DBUILD_UNIX)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Platform-specific definitions
|
# Platform-specific definitions
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
message(STATUS "Compiling for Windows...")
|
message(STATUS "Compiling for Windows...")
|
||||||
|
@ -144,8 +162,16 @@ elseif(UNIX)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Detect the compiler name
|
||||||
|
get_filename_component(COMPILER_NAME ${CMAKE_CXX_COMPILER} NAME)
|
||||||
|
|
||||||
|
# Replace forbidden characters in file names (optional, if needed)
|
||||||
|
string(REPLACE "." "_" COMPILER_NAME ${COMPILER_NAME})
|
||||||
|
string(REPLACE "/" "_" COMPILER_NAME ${COMPILER_NAME})
|
||||||
|
string(REPLACE "\\" "_" COMPILER_NAME ${COMPILER_NAME})
|
||||||
|
|
||||||
# Create the shared library
|
# Create the shared library
|
||||||
add_library(HarmonyLinkLibShared SHARED ${LIB_SOURCES} ${SHARED_SOURCES})
|
add_library(HarmonyLinkLibShared SHARED ${LIB_SOURCES} ${SHARED_SOURCES} ${LIB_INCLUDES})
|
||||||
target_include_directories(HarmonyLinkLibShared
|
target_include_directories(HarmonyLinkLibShared
|
||||||
PRIVATE
|
PRIVATE
|
||||||
"${PROJECT_SOURCE_DIR}/src"
|
"${PROJECT_SOURCE_DIR}/src"
|
||||||
|
@ -154,9 +180,10 @@ target_include_directories(HarmonyLinkLibShared
|
||||||
"${PROJECT_SOURCE_DIR}/include"
|
"${PROJECT_SOURCE_DIR}/include"
|
||||||
)
|
)
|
||||||
target_compile_definitions(HarmonyLinkLibShared PRIVATE HARMONYLINKLIB_SHARED)
|
target_compile_definitions(HarmonyLinkLibShared PRIVATE HARMONYLINKLIB_SHARED)
|
||||||
|
set_target_properties(HarmonyLinkLibShared PROPERTIES OUTPUT_NAME "HarmonyLinkLibShared_${COMPILER_NAME}")
|
||||||
|
|
||||||
# Create the static library
|
# Create the static library
|
||||||
add_library(HarmonyLinkLibStatic STATIC ${LIB_SOURCES})
|
add_library(HarmonyLinkLibStatic STATIC ${LIB_SOURCES} ${LIB_INCLUDES})
|
||||||
target_include_directories(HarmonyLinkLibStatic
|
target_include_directories(HarmonyLinkLibStatic
|
||||||
PRIVATE
|
PRIVATE
|
||||||
"${PROJECT_SOURCE_DIR}/src"
|
"${PROJECT_SOURCE_DIR}/src"
|
||||||
|
@ -165,27 +192,46 @@ target_include_directories(HarmonyLinkLibStatic
|
||||||
"${PROJECT_SOURCE_DIR}/include"
|
"${PROJECT_SOURCE_DIR}/include"
|
||||||
)
|
)
|
||||||
target_compile_definitions(HarmonyLinkLibStatic PRIVATE HARMONYLINKLIB_STATIC)
|
target_compile_definitions(HarmonyLinkLibStatic PRIVATE HARMONYLINKLIB_STATIC)
|
||||||
|
set_target_properties(HarmonyLinkLibStatic PROPERTIES OUTPUT_NAME "HarmonyLinkLibStatic_${COMPILER_NAME}")
|
||||||
# Include fmt headers
|
|
||||||
target_include_directories(HarmonyLinkLibStatic PRIVATE ${FMT_HEADERS})
|
|
||||||
|
|
||||||
# Set output directories for all build types
|
# Set output directories for all build types
|
||||||
foreach(TYPE IN ITEMS DEBUG RELEASE)
|
#foreach(TYPE IN ITEMS DEBUG RELEASE)
|
||||||
string(TOUPPER ${TYPE} TYPE_UPPER)
|
# string(TOUPPER ${TYPE} TYPE_UPPER)
|
||||||
set_target_properties(HarmonyLinkLibShared PROPERTIES
|
# set_target_properties(HarmonyLinkLibShared PROPERTIES
|
||||||
RUNTIME_OUTPUT_DIRECTORY_${TYPE_UPPER} "${CMAKE_BINARY_DIR}/bin/${TYPE}/HarmonyLinkLib"
|
# RUNTIME_OUTPUT_DIRECTORY_${TYPE_UPPER} "${CMAKE_BINARY_DIR}/bin/${TYPE}/HarmonyLinkLib"
|
||||||
LIBRARY_OUTPUT_DIRECTORY_${TYPE_UPPER} "${CMAKE_BINARY_DIR}/lib/${TYPE}/HarmonyLinkLib"
|
# LIBRARY_OUTPUT_DIRECTORY_${TYPE_UPPER} "${CMAKE_BINARY_DIR}/lib/${TYPE}/HarmonyLinkLib"
|
||||||
ARCHIVE_OUTPUT_DIRECTORY_${TYPE_UPPER} "${CMAKE_BINARY_DIR}/archive/${TYPE}/HarmonyLinkLib"
|
# ARCHIVE_OUTPUT_DIRECTORY_${TYPE_UPPER} "${CMAKE_BINARY_DIR}/archive/${TYPE}/HarmonyLinkLib"
|
||||||
)
|
# )
|
||||||
set_target_properties(HarmonyLinkLibStatic PROPERTIES
|
# set_target_properties(HarmonyLinkLibStatic PROPERTIES
|
||||||
ARCHIVE_OUTPUT_DIRECTORY_${TYPE_UPPER} "${CMAKE_BINARY_DIR}/archive/${TYPE}/HarmonyLinkLibStatic"
|
# ARCHIVE_OUTPUT_DIRECTORY_${TYPE_UPPER} "${CMAKE_BINARY_DIR}/archive/${TYPE}/HarmonyLinkLibStatic"
|
||||||
)
|
# )
|
||||||
endforeach()
|
#endforeach()
|
||||||
|
|
||||||
target_link_libraries(HarmonyLinkLibStatic PRIVATE fmt)
|
# Link fmt to HarmonyLinkLib
|
||||||
target_link_libraries(HarmonyLinkLibShared PRIVATE fmt)
|
target_link_libraries(HarmonyLinkLibStatic PRIVATE fmt::fmt-header-only)
|
||||||
|
target_link_libraries(HarmonyLinkLibShared PRIVATE fmt::fmt-header-only)
|
||||||
|
|
||||||
if (UNIX)
|
# Link ghc to HarmonyLinkLib
|
||||||
target_link_libraries(HarmonyLinkLibStatic PRIVATE stdc++fs)
|
target_link_libraries(HarmonyLinkLibStatic PRIVATE ghc_filesystem)
|
||||||
target_link_libraries(HarmonyLinkLibShared PRIVATE stdc++fs)
|
target_link_libraries(HarmonyLinkLibShared PRIVATE ghc_filesystem)
|
||||||
|
|
||||||
|
# Determine the compiler and set appropriate flags for libc++
|
||||||
|
if (UNIX AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
|
# Use libc++ instead of libstdc++ with Clang
|
||||||
|
target_compile_options(HarmonyLinkLibStatic PRIVATE -stdlib=libc++)
|
||||||
|
target_compile_options(HarmonyLinkLibShared PRIVATE -stdlib=libc++)
|
||||||
|
target_link_options(HarmonyLinkLibStatic PRIVATE -stdlib=libc++)
|
||||||
|
target_link_options(HarmonyLinkLibShared PRIVATE -stdlib=libc++)
|
||||||
|
|
||||||
|
# Link against the libc++ library and the filesystem library
|
||||||
|
target_link_libraries(HarmonyLinkLibStatic PRIVATE c++ c++abi c++experimental)
|
||||||
|
target_link_libraries(HarmonyLinkLibShared PRIVATE c++ c++abi c++experimental)
|
||||||
|
elseif (UNIX AND CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||||
|
# Use libstdc++ with GCC
|
||||||
|
target_link_options(HarmonyLinkLibStatic PRIVATE -static-libgcc -static-libstdc++)
|
||||||
|
target_link_options(HarmonyLinkLibShared PRIVATE -static-libgcc -static-libstdc++)
|
||||||
|
|
||||||
|
# Link against the libstdc++ filesystem library if necessary
|
||||||
|
#target_link_libraries(HarmonyLinkLibStatic PRIVATE stdc++fs)
|
||||||
|
#target_link_libraries(HarmonyLinkLibShared PRIVATE stdc++fs)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// Use a preprocessor definition to switch between export and import declarations
|
// Use a preprocessor definition to switch between export and import declarations
|
||||||
#ifdef _WIN32
|
#ifdef BUILD_WINDOWS
|
||||||
#ifdef HARMONYLINKLIB_STATIC
|
#ifdef HARMONYLINKLIB_STATIC
|
||||||
#define HARMONYLINKLIB_API
|
#define HARMONYLINKLIB_API
|
||||||
#else
|
#else
|
||||||
|
@ -25,6 +25,14 @@
|
||||||
#define HARMONYLINKLIB_API __declspec(dllimport)
|
#define HARMONYLINKLIB_API __declspec(dllimport)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
#else
|
||||||
|
#ifdef HARMONYLINKLIB_SHARED
|
||||||
|
#ifdef __clang__
|
||||||
|
#define HARMONYLINKLIB_API __attribute__((visibility("default")))
|
||||||
#else
|
#else
|
||||||
#define HARMONYLINKLIB_API
|
#define HARMONYLINKLIB_API
|
||||||
#endif
|
#endif
|
||||||
|
#else
|
||||||
|
#define HARMONYLINKLIB_API
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
|
@ -44,17 +44,19 @@ class IPlatformUtilities;
|
||||||
|
|
||||||
namespace HarmonyLinkLib
|
namespace HarmonyLinkLib
|
||||||
{
|
{
|
||||||
extern "C" HARMONYLINKLIB_API bool get_is_wine();
|
HARMONYLINKLIB_API bool HL_Init();
|
||||||
|
|
||||||
extern "C" HARMONYLINKLIB_API bool get_is_linux();
|
HARMONYLINKLIB_API bool get_is_wine();
|
||||||
|
|
||||||
extern "C" HARMONYLINKLIB_API bool get_is_docked();
|
HARMONYLINKLIB_API bool get_is_linux();
|
||||||
|
|
||||||
extern "C" HARMONYLINKLIB_API FCPUInfo* get_cpu_info();
|
HARMONYLINKLIB_API bool get_is_docked();
|
||||||
|
|
||||||
extern "C" HARMONYLINKLIB_API FDevice* get_device_info();
|
HARMONYLINKLIB_API FCPUInfo* get_cpu_info();
|
||||||
|
|
||||||
extern "C" HARMONYLINKLIB_API FOSVerInfo* get_os_version();
|
HARMONYLINKLIB_API FDevice* get_device_info();
|
||||||
|
|
||||||
extern "C" HARMONYLINKLIB_API FBattery* get_battery_status();
|
HARMONYLINKLIB_API FOSVerInfo* get_os_version();
|
||||||
|
|
||||||
|
HARMONYLINKLIB_API FBattery* get_battery_status();
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,10 +16,19 @@
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "Platform/IPlatformUtilities.h"
|
#include "Platform/IPlatformUtilities.h"
|
||||||
|
#include "Version.h"
|
||||||
|
|
||||||
namespace HarmonyLinkLib
|
namespace HarmonyLinkLib
|
||||||
{
|
{
|
||||||
std::shared_ptr<IPlatformUtilities> PlatformUtilities = IPlatformUtilities::GetInstance();
|
std::shared_ptr<IPlatformUtilities> PlatformUtilities = nullptr;
|
||||||
|
|
||||||
|
bool HL_Init()
|
||||||
|
{
|
||||||
|
std::wcout << "HarmonyLink V" << version::ToString().c_str() << " Copyright (C) 2023 Jordon Brooks\n";
|
||||||
|
PlatformUtilities = IPlatformUtilities::GetInstance();
|
||||||
|
|
||||||
|
return PlatformUtilities != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
bool get_is_wine()
|
bool get_is_wine()
|
||||||
{
|
{
|
||||||
|
@ -92,8 +101,6 @@ namespace HarmonyLinkLib
|
||||||
|
|
||||||
FOSVerInfo* get_os_version()
|
FOSVerInfo* get_os_version()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
if (!PlatformUtilities)
|
if (!PlatformUtilities)
|
||||||
{
|
{
|
||||||
std::wcout << "Failed to get platform utilities!\n";
|
std::wcout << "Failed to get platform utilities!\n";
|
||||||
|
|
|
@ -49,7 +49,7 @@ namespace HarmonyLinkLib
|
||||||
INSTANCE = std::make_shared<UnixUtilities>();
|
INSTANCE = std::make_shared<UnixUtilities>();
|
||||||
// ... other platform checks
|
// ... other platform checks
|
||||||
#else
|
#else
|
||||||
std::wcout << "Platform is not supported.\n"
|
std::wcout << "Platform is not supported.\n";
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,12 +18,14 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <filesystem>
|
#include <ghc/filesystem.hpp>
|
||||||
|
|
||||||
#ifdef BUILD_WINDOWS
|
#ifdef BUILD_WINDOWS
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
namespace fs = ghc::filesystem;
|
||||||
|
|
||||||
namespace HarmonyLinkLib
|
namespace HarmonyLinkLib
|
||||||
{
|
{
|
||||||
bool force_detect_wine = false;
|
bool force_detect_wine = false;
|
||||||
|
@ -38,7 +40,7 @@ namespace HarmonyLinkLib
|
||||||
|
|
||||||
FBattery result = {};
|
FBattery result = {};
|
||||||
for (int i = 0; i <= 9; ++i) {
|
for (int i = 0; i <= 9; ++i) {
|
||||||
if (std::string bat_path = append + "/sys/class/power_supply/BAT" + std::to_string(i); std::filesystem::exists(bat_path)) {
|
if (std::string bat_path = append + "/sys/class/power_supply/BAT" + std::to_string(i); fs::exists(bat_path)) {
|
||||||
result.has_battery = true;
|
result.has_battery = true;
|
||||||
|
|
||||||
std::ifstream status_file(bat_path + "/status");
|
std::ifstream status_file(bat_path + "/status");
|
||||||
|
|
|
@ -1,61 +0,0 @@
|
||||||
// Copyright (c) 2024 Jordon Brooks
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include "Version.h"
|
|
||||||
|
|
||||||
namespace HarmonyLinkLib
|
|
||||||
{
|
|
||||||
void HarmonyLinkInit()
|
|
||||||
{
|
|
||||||
std::wcout << "HarmonyLink V" << version::ToString().c_str() << " Copyright (C) 2023 Jordon Brooks\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#if BUILD_WINDOWS
|
|
||||||
#include <windows.h>
|
|
||||||
|
|
||||||
// Standard DLL entry point
|
|
||||||
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
|
|
||||||
switch (fdwReason) {
|
|
||||||
case DLL_PROCESS_ATTACH:
|
|
||||||
// Code to run when the DLL is loaded
|
|
||||||
HarmonyLinkLib::HarmonyLinkInit();
|
|
||||||
break;
|
|
||||||
case DLL_THREAD_ATTACH:
|
|
||||||
// Code to run when a thread is created during the DLL's lifetime
|
|
||||||
case DLL_THREAD_DETACH:
|
|
||||||
// Code to run when a thread ends normally.
|
|
||||||
case DLL_PROCESS_DETACH:
|
|
||||||
// Code to run when the DLL is unloaded
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return TRUE; // Successful DLL_PROCESS_ATTACH.
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if BUILD_UNIX
|
|
||||||
__attribute__((constructor))
|
|
||||||
static void onLibraryLoad() {
|
|
||||||
// Code to run when the library is loaded
|
|
||||||
HarmonyLinkLib::HarmonyLinkInit();
|
|
||||||
}
|
|
||||||
|
|
||||||
__attribute__((destructor))
|
|
||||||
static void onLibraryUnload() {
|
|
||||||
// Code to run when the library is unloaded
|
|
||||||
}
|
|
||||||
#endif
|
|
|
@ -85,10 +85,18 @@ void checkForQuit() {
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
std::cout << "Hello, World!" << '\n';
|
std::cout << "Hello, World!\n";
|
||||||
|
|
||||||
std::thread inputThread(checkForQuit);
|
std::thread inputThread(checkForQuit);
|
||||||
|
|
||||||
|
if (!HarmonyLinkLib::HL_Init())
|
||||||
|
{
|
||||||
|
std::cout << "Failed to init HarmonyLinkLib\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "HarmonyLinkLib successfully initialised!\n";
|
||||||
|
|
||||||
const bool isWine = HarmonyLinkLib::get_is_wine();
|
const bool isWine = HarmonyLinkLib::get_is_wine();
|
||||||
const char* test = isWine ? "is" : "isn't";
|
const char* test = isWine ? "is" : "isn't";
|
||||||
|
|
||||||
|
|
10
README.md
10
README.md
|
@ -61,22 +61,22 @@ As you can see, Even though it's running on Proton, we can still detect the unde
|
||||||
|
|
||||||
Integrate HarmonyLink 2.0 into your game project with ease:
|
Integrate HarmonyLink 2.0 into your game project with ease:
|
||||||
|
|
||||||
1. Download the latest version of HarmonyLink 2.0 from the [releases page](https://github.com/Jordonbc/HarmonyLink/releases/latest).
|
1. Download the latest version of HarmonyLink 2.0 from the [releases page](https://git.bbgames.dev/jordon/HarmonyLink/releases/latest).
|
||||||
2. Add the HarmonyLink DLL to your project according to your development environment's specifications.
|
2. Add the HarmonyLink DLL to your project according to your development environment's specifications.
|
||||||
3. Utilize the provided API to access device-specific metrics and enhance your game's performance on handheld devices.
|
3. Utilize the provided API to access device-specific metrics and enhance your game's performance on handheld devices.
|
||||||
|
|
||||||
Refer to the [integration documentation](https://github.com/Jordonbc/HarmonyLink/wiki/Integration-Guide) for detailed instructions.
|
Refer to the [integration documentation](https://git.bbgames.dev/jordon/HarmonyLink/wiki) for detailed instructions.
|
||||||
|
|
||||||
### Unreal Engine 5 Plugin
|
### Unreal Engine 5 Plugin
|
||||||
|
|
||||||
For developers leveraging Unreal Engine 5.3 or newer*, HarmonyLink 2.0 is readily accessible as a plugin:
|
For developers leveraging Unreal Engine 5.3 or newer*, HarmonyLink 2.0 is readily accessible as a plugin:
|
||||||
|
|
||||||
1. Clone or download the HarmonyLink UE5 Plugin from the [Unreal Engine Plugin repository](https://github.com/Jordonbc/HarmonyLinkUE).
|
1. Clone or download the HarmonyLink UE5 Plugin from the [Unreal Engine Plugin repository](https://git.bbgames.dev/jordon/HarmonyLinkUE).
|
||||||
2. Place the HarmonyLink plugin folder into the `Plugins` directory of your Unreal Engine 5 project.
|
2. Place the HarmonyLink plugin folder into the `Plugins` directory of your Unreal Engine 5 project.
|
||||||
3. Enable the HarmonyLink plugin from the Edit > Plugins menu within Unreal Engine 5.
|
3. Enable the HarmonyLink plugin from the Edit > Plugins menu within Unreal Engine 5.
|
||||||
4. Access HarmonyLink functionalities via Blueprints or C++ within your project.
|
4. Access HarmonyLink functionalities via Blueprints or C++ within your project.
|
||||||
|
|
||||||
For a step-by-step guide, visit the [Unreal Engine 5 Plugin instructions](https://github.com/Jordonbc/HarmonyLinkUE/wiki/Integration-Guide) on our wiki.
|
For a step-by-step guide, visit the [Unreal Engine 5 Plugin instructions](https://git.bbgames.dev/jordon/HarmonyLinkUE/wiki) on our wiki.
|
||||||
|
|
||||||
*With potential backward compatibility, not verified.
|
*With potential backward compatibility, not verified.
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ If you prefer to build HarmonyLink 2.0 from the source code, follow these steps:
|
||||||
5. Compile the code by running `cmake --build build --config Release`.
|
5. Compile the code by running `cmake --build build --config Release`.
|
||||||
6. The built DLL will be located in the `build/bin/HarmonyLinkLib` directory.
|
6. The built DLL will be located in the `build/bin/HarmonyLinkLib` directory.
|
||||||
|
|
||||||
For additional building options and troubleshooting, refer to the [building from source documentation](https://github.com/Jordonbc/HarmonyLink/wiki/Building-From-Source).
|
For additional building options and troubleshooting, refer to the [building from source documentation](https://git.bbgames.dev/jordon/HarmonyLink/wiki).
|
||||||
|
|
||||||
|
|
||||||
## How It Works
|
## How It Works
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue