diff --git a/CMakeLists.txt b/CMakeLists.txt index 14f1b63..fd0c021 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ #----------------------------------------------------------------------------------------- set(PROJ_NAME omnia-framework) set(MAJOR_VER 0) -set(MINOR_VER 1) +set(MINOR_VER 2) #----------------------------------------------------------------------------------------- #Setup @@ -97,16 +97,44 @@ endif() if (WIN32) target_link_libraries(${OMNIA_GFX_LIB} PUBLIC mingw32) target_link_libraries(${OMNIA_STD_LIB} PUBLIC mingw32) + target_link_libraries(${OMNIA_GFX_LIB} PUBLIC SDL2main SDL2 SDL2_gfx SDL2_ttf SDL2_image) endif (WIN32) target_link_libraries(${OMNIA_GFX_LIB} PUBLIC ${OMNIA_STD_LIB}) target_link_libraries(${TEST_TARGET} PUBLIC ${OMNIA_STD_LIB}) target_link_libraries(${TEST_TARGET} PUBLIC ${OMNIA_GFX_LIB}) -if (UNIX) +if (APPLE) + cmake_policy(SET CMP0167 OLD) + find_package(Boost REQUIRED COMPONENTS regex) + target_link_libraries(${OMNIA_STD_LIB} PUBLIC Boost::regex) + find_package(PkgConfig REQUIRED) + pkg_check_modules(SDL2 REQUIRED sdl2) + pkg_check_modules(SDL2_IMAGE REQUIRED SDL2_image) + pkg_check_modules(SDL2_TTF REQUIRED SDL2_ttf) + pkg_check_modules(SDL2_GFX REQUIRED SDL2_gfx) + target_include_directories(${OMNIA_GFX_LIB} PUBLIC + ${SDL2_INCLUDE_DIRS} + ${SDL2_IMAGE_INCLUDE_DIRS} + ${SDL2_TTF_INCLUDE_DIRS} + ${SDL2_GFX_INCLUDE_DIRS} + ) + target_link_directories(${OMNIA_GFX_LIB} PUBLIC + ${SDL2_LIBRARY_DIRS} + ${SDL2_IMAGE_LIBRARY_DIRS} + ${SDL2_TTF_LIBRARY_DIRS} + ${SDL2_GFX_LIBRARY_DIRS} + ) + target_link_libraries(${OMNIA_GFX_LIB} PUBLIC + ${SDL2_LIBRARIES} + ${SDL2_IMAGE_LIBRARIES} + ${SDL2_TTF_LIBRARIES} + ${SDL2_GFX_LIBRARIES} + ) +elseif (UNIX) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath,'$ORIGIN',-rpath,/usr/lib,-rpath,/usr/local/lib") target_link_libraries(${OMNIA_STD_LIB} PUBLIC tinfo boost_regex) target_link_libraries(${OMNIA_GFX_LIB} PUBLIC xcb xcb-randr) -endif (UNIX) -target_link_libraries(${OMNIA_GFX_LIB} PUBLIC SDL2main SDL2 SDL2_gfx SDL2_ttf SDL2_image) + target_link_libraries(${OMNIA_GFX_LIB} PUBLIC SDL2main SDL2 SDL2_gfx SDL2_ttf SDL2_image) +endif () #----------------------------------------------------------------------------------------- diff --git a/README.md b/README.md index 2be4814..d8c77d5 100644 --- a/README.md +++ b/README.md @@ -115,3 +115,46 @@ cd OmniaFramework ``` > **NOTE**: The same build options for the `./build` script apply here, as explained in the **Windows** section. + +### Build instructions - MacOS + +##### Step 1: Install HomeBrew + +```bash +/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" +``` + +##### Step 2: Add HomeBrew to PATH + +After installing HomeBrew, it should automatically tell you how to add it to path, in general it should loo something. like this: + +- **For Apple Silicon** + +```bash +echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile +eval "$(/opt/homebrew/bin/brew shellenv)" +``` + +- **For Intel Mac** + +```bash +echo 'eval "$(/usr/local/bin/brew shellenv)"' >> ~/.zprofile +eval "$(/usr/local/bin/brew shellenv)" +``` + +##### Step 3: Install dependencies + +```bash +brew install llvm gdb cmake make boost sdl2 sdl2_mixer sdl2_image sdl2_ttf sdl2_gfx pkg-config +``` + +##### Step 4: Build OmniaFramework + +```bash +git clone https://github.com/OmniaX-dev/OmniaFramework.git +cd OmniaFramework +./build release +./build install +``` + +> **NOTE**: The same build options for the `./build` script apply here, as explained in the **Windows** section. diff --git a/build b/build index 55643ed..5a889a7 100755 --- a/build +++ b/build @@ -5,7 +5,15 @@ set -e MAKE_COMMAND=make MAKEFILE_TYPE="Unix Makefiles" -if [ "$(expr substr $(uname -s) 1 10)" == "MINGW64_NT" ]; then +if [[ "$(uname)" == "Darwin" ]]; then + NJOBS=-j"$(sysctl -n hw.ncpu)" +else + NJOBS=-j$(nproc) +fi + +# -j"$(sysctl -n hw.ncpu)" + +if [[ "$(uname -s)" == MINGW64_NT* ]]; then MAKE_COMMAND=mingw32-make.exe MAKEFILE_TYPE="MinGW Makefiles" fi @@ -14,10 +22,10 @@ if [[ "$1" == "debug" || "$1" == "release" ]]; then BUILD_TYPE="$(tr '[:lower:]' '[:upper:]' <<< ${1:0:1})${1:1}" rm -rf bin cmake -B bin -S ./ -G "$MAKEFILE_TYPE" -DCMAKE_BUILD_TYPE=$BUILD_TYPE - $MAKE_COMMAND -C bin -j$(nproc) --no-print-directory + $MAKE_COMMAND -C bin $NJOBS --no-print-directory cp -r extra/* bin/ - typeset -i build_number=$(cat other/build.nr) - ((build_number++)) + build_number=$(cat other/build.nr) + build_number=$((build_number + 1)) truncate -s 0 other/build.nr echo $build_number >> other/build.nr cd other @@ -30,7 +38,7 @@ elif [[ "$1" == "install" ]]; then else cp -r extra/* bin/ printf "\n\033[0;32mBuilding Changes...\n\n\033[0m" - $MAKE_COMMAND -C bin -j$(nproc) --no-print-directory + $MAKE_COMMAND -C bin $NJOBS --no-print-directory if [[ "$1" == "run" ]]; then printf "\n\033[0;32mRunning Test Application...\n\n\033[0m" cd bin diff --git a/other/build.nr b/other/build.nr index 23357b1..86f295d 100644 --- a/other/build.nr +++ b/other/build.nr @@ -1 +1 @@ -1909 +1924 diff --git a/other/changelog.txt b/other/changelog.txt index ed07e77..a93be04 100644 --- a/other/changelog.txt +++ b/other/changelog.txt @@ -1,3 +1,6 @@ +[0.2.1923] +Added MacOS support + [0.1.1823] Added more Builtin signals diff --git a/other/create_release.sh b/other/create_release.sh index 91a8814..fd787b3 100755 --- a/other/create_release.sh +++ b/other/create_release.sh @@ -6,12 +6,19 @@ set -e RELEASE_DIR= -if [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then +if [[ "$(uname)" == "Darwin" ]]; then + RELEASE_DIR=../bin/OmniaFramework_macos + mkdir -p "$RELEASE_DIR/lib" + + # macOS shared libraries (.dylib) + cp ../bin/libostd.dylib "$RELEASE_DIR/lib" + cp ../bin/libogfx.dylib "$RELEASE_DIR/lib" +elif [[ "$(uname -s)" == Linux* ]]; then RELEASE_DIR=../bin/OmniaFramework_linux64 mkdir -p $RELEASE_DIR/lib cp ../bin/libostd.so $RELEASE_DIR/lib cp ../bin/libogfx.so $RELEASE_DIR/lib -elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW64_NT" ]; then +elif [[ "$(uname -s)" == MINGW64_NT* ]]; then RELEASE_DIR=../bin/OmniaFramework_w64 mkdir -p $RELEASE_DIR/lib cp ../bin/libostd.dll $RELEASE_DIR/lib diff --git a/other/install_release.sh b/other/install_release.sh index 5a311d1..eeb55d2 100755 --- a/other/install_release.sh +++ b/other/install_release.sh @@ -6,7 +6,23 @@ set -e RELEASE_DIR= -if [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then +if [[ "$(uname)" == "Darwin" ]]; then + RELEASE_DIR=../bin/OmniaFramework_macos + + # Remove old versions + sudo rm -rf /usr/local/include/ostd 2> /dev/null + sudo rm -rf /usr/local/include/ogfx 2> /dev/null + sudo rm -f /usr/local/lib/libostd.dylib 2> /dev/null + sudo rm -f /usr/local/lib/libogfx.dylib 2> /dev/null + + # Install headers + sudo cp -r "$RELEASE_DIR/include/ostd" /usr/local/include/ + sudo cp -r "$RELEASE_DIR/include/ogfx" /usr/local/include/ + + # Install libraries + sudo cp "$RELEASE_DIR/lib/libostd.dylib" /usr/local/lib/ + sudo cp "$RELEASE_DIR/lib/libogfx.dylib" /usr/local/lib/ +elif [[ "$(uname -s)" == Linux* ]]; then RELEASE_DIR=../bin/OmniaFramework_linux64 sudo rm -rf /usr/include/ostd 2> /dev/null sudo rm -rf /usr/include/ogfx 2> /dev/null @@ -16,7 +32,7 @@ if [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then sudo cp -r $RELEASE_DIR/include/ogfx /usr/include/ sudo cp -r $RELEASE_DIR/lib/libostd.so /usr/lib/ sudo cp -r $RELEASE_DIR/lib/libogfx.so /usr/lib/ -elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW64_NT" ]; then +elif [[ "$(uname -s)" == MINGW64_NT* ]]; then RELEASE_DIR=../bin/OmniaFramework_w64 rm -rf $MSYS_ROOT/ucrt64/include/ostd 2> /dev/null rm -rf $MSYS_ROOT/ucrt64/include/ogfx 2> /dev/null diff --git a/src/ostd/Console.cpp b/src/ostd/Console.cpp index f72e4b6..bf93a0e 100644 --- a/src/ostd/Console.cpp +++ b/src/ostd/Console.cpp @@ -79,8 +79,37 @@ void Utils::setConsoleCursorPosition(int32_t x, int32_t y) printf("\033[%d;%dH",x+1,y+1); } +#elif defined(__APPLE__) + +#include +#include +#include + +void Utils::clearConsole(void) +{ + // ANSI escape sequence: clear screen + move cursor to top-left + std::printf("\033[2J\033[H"); + std::fflush(stdout); +} + +void Utils::getConsoleSize(int32_t& outColumns, int32_t& outRows) +{ + struct winsize w; + ioctl(STDOUT_FILENO, TIOCGWINSZ, &w); + outRows = w.ws_row; + outColumns = w.ws_col; +} + +void Utils::setConsoleCursorPosition(int32_t x, int32_t y) +{ + // ANSI escape sequence: move cursor to (y+1, x+1) + std::printf("\033[%d;%dH", y + 1, x + 1); + std::fflush(stdout); +} + #endif + int32_t Utils::getConsoleWidth(void) { int32_t rows = 0, cols = 0; diff --git a/src/ostd/Logic.cpp b/src/ostd/Logic.cpp index ba7543b..fbc5ceb 100755 --- a/src/ostd/Logic.cpp +++ b/src/ostd/Logic.cpp @@ -1,7 +1,7 @@ #include "Logic.hpp" #include "Utils.hpp" #include "String.hpp" -#include +// #include namespace ostd {