Added MacOS support
This commit is contained in:
parent
b73a360893
commit
b17ddf6f7e
9 changed files with 149 additions and 15 deletions
|
|
@ -2,7 +2,7 @@
|
||||||
#-----------------------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------------------
|
||||||
set(PROJ_NAME omnia-framework)
|
set(PROJ_NAME omnia-framework)
|
||||||
set(MAJOR_VER 0)
|
set(MAJOR_VER 0)
|
||||||
set(MINOR_VER 1)
|
set(MINOR_VER 2)
|
||||||
#-----------------------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------------------
|
||||||
|
|
||||||
#Setup
|
#Setup
|
||||||
|
|
@ -97,16 +97,44 @@ endif()
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
target_link_libraries(${OMNIA_GFX_LIB} PUBLIC mingw32)
|
target_link_libraries(${OMNIA_GFX_LIB} PUBLIC mingw32)
|
||||||
target_link_libraries(${OMNIA_STD_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)
|
endif (WIN32)
|
||||||
|
|
||||||
target_link_libraries(${OMNIA_GFX_LIB} PUBLIC ${OMNIA_STD_LIB})
|
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_STD_LIB})
|
||||||
target_link_libraries(${TEST_TARGET} PUBLIC ${OMNIA_GFX_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")
|
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_STD_LIB} PUBLIC tinfo boost_regex)
|
||||||
target_link_libraries(${OMNIA_GFX_LIB} PUBLIC xcb xcb-randr)
|
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 ()
|
||||||
#-----------------------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
43
README.md
43
README.md
|
|
@ -115,3 +115,46 @@ cd OmniaFramework
|
||||||
```
|
```
|
||||||
|
|
||||||
> **<u>NOTE</u>**: The same build options for the `./build` script apply here, as explained in the **Windows** section.
|
> **<u>NOTE</u>**: The same build options for the `./build` script apply here, as explained in the **Windows** section.
|
||||||
|
|
||||||
|
### <u>Build instructions - MacOS</u>
|
||||||
|
|
||||||
|
##### 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
|
||||||
|
```
|
||||||
|
|
||||||
|
> **<u>NOTE</u>**: The same build options for the `./build` script apply here, as explained in the **Windows** section.
|
||||||
|
|
|
||||||
18
build
18
build
|
|
@ -5,7 +5,15 @@ set -e
|
||||||
MAKE_COMMAND=make
|
MAKE_COMMAND=make
|
||||||
MAKEFILE_TYPE="Unix Makefiles"
|
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
|
MAKE_COMMAND=mingw32-make.exe
|
||||||
MAKEFILE_TYPE="MinGW Makefiles"
|
MAKEFILE_TYPE="MinGW Makefiles"
|
||||||
fi
|
fi
|
||||||
|
|
@ -14,10 +22,10 @@ if [[ "$1" == "debug" || "$1" == "release" ]]; then
|
||||||
BUILD_TYPE="$(tr '[:lower:]' '[:upper:]' <<< ${1:0:1})${1:1}"
|
BUILD_TYPE="$(tr '[:lower:]' '[:upper:]' <<< ${1:0:1})${1:1}"
|
||||||
rm -rf bin
|
rm -rf bin
|
||||||
cmake -B bin -S ./ -G "$MAKEFILE_TYPE" -DCMAKE_BUILD_TYPE=$BUILD_TYPE
|
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/
|
cp -r extra/* bin/
|
||||||
typeset -i build_number=$(cat other/build.nr)
|
build_number=$(cat other/build.nr)
|
||||||
((build_number++))
|
build_number=$((build_number + 1))
|
||||||
truncate -s 0 other/build.nr
|
truncate -s 0 other/build.nr
|
||||||
echo $build_number >> other/build.nr
|
echo $build_number >> other/build.nr
|
||||||
cd other
|
cd other
|
||||||
|
|
@ -30,7 +38,7 @@ elif [[ "$1" == "install" ]]; then
|
||||||
else
|
else
|
||||||
cp -r extra/* bin/
|
cp -r extra/* bin/
|
||||||
printf "\n\033[0;32mBuilding Changes...\n\n\033[0m"
|
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
|
if [[ "$1" == "run" ]]; then
|
||||||
printf "\n\033[0;32mRunning Test Application...\n\n\033[0m"
|
printf "\n\033[0;32mRunning Test Application...\n\n\033[0m"
|
||||||
cd bin
|
cd bin
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
1909
|
1924
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
|
[0.2.1923]
|
||||||
|
Added MacOS support
|
||||||
|
|
||||||
[0.1.1823]
|
[0.1.1823]
|
||||||
Added more Builtin signals
|
Added more Builtin signals
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,19 @@ set -e
|
||||||
|
|
||||||
RELEASE_DIR=
|
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
|
RELEASE_DIR=../bin/OmniaFramework_linux64
|
||||||
mkdir -p $RELEASE_DIR/lib
|
mkdir -p $RELEASE_DIR/lib
|
||||||
cp ../bin/libostd.so $RELEASE_DIR/lib
|
cp ../bin/libostd.so $RELEASE_DIR/lib
|
||||||
cp ../bin/libogfx.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
|
RELEASE_DIR=../bin/OmniaFramework_w64
|
||||||
mkdir -p $RELEASE_DIR/lib
|
mkdir -p $RELEASE_DIR/lib
|
||||||
cp ../bin/libostd.dll $RELEASE_DIR/lib
|
cp ../bin/libostd.dll $RELEASE_DIR/lib
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,23 @@ set -e
|
||||||
|
|
||||||
RELEASE_DIR=
|
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
|
RELEASE_DIR=../bin/OmniaFramework_linux64
|
||||||
sudo rm -rf /usr/include/ostd 2> /dev/null
|
sudo rm -rf /usr/include/ostd 2> /dev/null
|
||||||
sudo rm -rf /usr/include/ogfx 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/include/ogfx /usr/include/
|
||||||
sudo cp -r $RELEASE_DIR/lib/libostd.so /usr/lib/
|
sudo cp -r $RELEASE_DIR/lib/libostd.so /usr/lib/
|
||||||
sudo cp -r $RELEASE_DIR/lib/libogfx.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
|
RELEASE_DIR=../bin/OmniaFramework_w64
|
||||||
rm -rf $MSYS_ROOT/ucrt64/include/ostd 2> /dev/null
|
rm -rf $MSYS_ROOT/ucrt64/include/ostd 2> /dev/null
|
||||||
rm -rf $MSYS_ROOT/ucrt64/include/ogfx 2> /dev/null
|
rm -rf $MSYS_ROOT/ucrt64/include/ogfx 2> /dev/null
|
||||||
|
|
|
||||||
|
|
@ -79,8 +79,37 @@ void Utils::setConsoleCursorPosition(int32_t x, int32_t y)
|
||||||
printf("\033[%d;%dH",x+1,y+1);
|
printf("\033[%d;%dH",x+1,y+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
|
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
|
#endif
|
||||||
|
|
||||||
|
|
||||||
int32_t Utils::getConsoleWidth(void)
|
int32_t Utils::getConsoleWidth(void)
|
||||||
{
|
{
|
||||||
int32_t rows = 0, cols = 0;
|
int32_t rows = 0, cols = 0;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#include "Logic.hpp"
|
#include "Logic.hpp"
|
||||||
#include "Utils.hpp"
|
#include "Utils.hpp"
|
||||||
#include "String.hpp"
|
#include "String.hpp"
|
||||||
#include <bits/stdc++.h>
|
// #include <bits/stdc++.h>
|
||||||
|
|
||||||
namespace ostd
|
namespace ostd
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue