Skip to content

Commit 2845c4a

Browse files
committed
Add UNFINISHED macos port, nothing should work but thats to be expected
1 parent eea4260 commit 2845c4a

30 files changed

Lines changed: 3728 additions & 609 deletions

CMakeLists.txt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ include_directories(
9191

9292
# source files
9393
collect_sources(BORA_SOURCES
94-
src/*.cpp src/*.h src/*.hpp src/*.manifest src/*.rc src/*.cc
94+
src/mainDynamicLibrary.cpp
95+
src/host/*
96+
src/software/common/*
9597
)
9698
collect_sources(BORA_CONTRIBS
9799
../global/cpp/contribs/*.cpp ../global/cpp/contribs/*.hpp ../global/cpp/contribs/*.h
@@ -106,12 +108,13 @@ collect_sources(BORA_3RDPARTY
106108
# ../global/libs/*.a ../global/libs/*.lib ../global/libs/*.dlib
107109
#)
108110

109-
file(GLOB_RECURSE BORA_SOURCES_WRAPPER src/*.cpp src/*.h src/*.hpp src/*.manifest src/*.rc src/*.cc)
110-
file(GLOB_RECURSE HOST_FILES src/host/*.cpp src/host/*.h src/host/*.hpp src/host/*.cc src/software/common/nGraphics/* src/software/common/nWindow/* src/software/common/nGraphics/* src/software/win32/nGraphics/* src/software/common/nGUI/*)
111-
list(REMOVE_ITEM BORA_SOURCES_WRAPPER ${HOST_FILES})
111+
#file(GLOB_RECURSE BORA_SOURCES_WRAPPER src/*.cpp src/*.h src/*.hpp src/*.manifest src/*.rc src/*.cc)
112+
#file(GLOB_RECURSE HOST_FILES src/host/*.cpp src/host/*.h src/host/*.hpp src/host/*.cc src/software/common/nGraphics/* src/software/common/nWindow/* src/software/common/nGraphics/* src/software/win32/nGraphics/* src/software/common/nGUI/*)
113+
file(GLOB_RECURSE BORA_SOURCES_WRAPPER src/wrapper/*)
112114
file(GLOB_RECURSE BORA_SOURCES_CONTRIBWRAPPER ../global/cpp/contribs/*.cpp ../global/cpp/contribs/*.h ../global/cpp/contribs/*.hpp)
113115
file(GLOB_RECURSE GRAPH_FILES ../global/cpp/contribs/nGraphics/*)
114116
list(REMOVE_ITEM BORA_SOURCES_CONTRIBWRAPPER ${GRAPH_FILES})
117+
list(REMOVE_ITEM BORA_SOURCES ${BORA_SOURCES_WRAPPER})
115118

116119
if (NOT DEFINED WAMR_BUILD_MEMORY64)
117120
set (WAMR_BUILD_MEMORY64 1)

cmake/platform/macos.cmake

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
collect_sources(BORA_SOURCES_PLATFORM
2+
src/host/*
3+
src/software/darwin/*
4+
)
5+
enable_language(OBJCXX)
6+
7+
file(GLOB_RECURSE BORA_DARWIN_SOURCE src/software/darwin/*)
8+
file(GLOB_RECURSE BORA_CONTRIBS_DARWIN
9+
../global/cpp/contribs/*.mm
10+
)
11+
12+
set_source_files_properties(${BORA_DARWIN_SOURCE} PROPERTIES LANGUAGE OBJCXX)
13+
14+
set(WAMR_BUILD_PLATFORM "darwin")
15+
include(${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake)
16+
find_package(OpenGL REQUIRED)
17+
# Set WAMR_BUILD_TARGET, currently values supported:
18+
# "X86_64", "AMD_64", "X86_32", "AARCH64[sub]", "ARM[sub]", "THUMB[sub]",
19+
# "MIPS", "XTENSA", "RISCV64[sub]", "RISCV32[sub]"
20+
if (NOT DEFINED WAMR_BUILD_TARGET)
21+
if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64)")
22+
set (WAMR_BUILD_TARGET "AARCH64")
23+
elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "riscv64")
24+
set (WAMR_BUILD_TARGET "RISCV64")
25+
elseif (CMAKE_SIZEOF_VOID_P EQUAL 8)
26+
# Build as X86_64 by default in 64-bit platform
27+
set (WAMR_BUILD_TARGET "X86_64")
28+
elseif (CMAKE_SIZEOF_VOID_P EQUAL 4)
29+
# Build as X86_32 by default in 32-bit platform
30+
set (WAMR_BUILD_TARGET "X86_32")
31+
else ()
32+
message(SEND_ERROR "Unsupported build target platform!")
33+
endif ()
34+
endif ()
35+
36+
set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/contribs/wasm-micro-runtime)
37+
set (CMAKE_SHARED_LINKER_FLAGS "-Wl,-U,_get_ext_lib_export_apis")
38+
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
39+
set (CMAKE_MACOSX_RPATH True)
40+
41+
include(${WAMR_ROOT_DIR}/core/shared/utils/uncommon/shared_uncommon.cmake)
42+
include_directories(${WAMR_ROOT_DIR}/product-mini/platforms/common ./src/host/templates ../global/cpp ../global/contribs ./src ./src/software/common ./src/software/darwin ./contribs ./3rdparty)
43+
44+
add_compile_definitions(
45+
TAZABASEDIR=\"${CMAKE_SOURCE_DIR}/contribs/TAZA/code\"
46+
NOMINMAX
47+
_WINSOCKAPI_
48+
GLEW_STATIC
49+
SPIRV_SKIA_CONFLICT_HACK
50+
)
51+
52+
if(ENABLE_ASAN)
53+
add_compile_options("-fsanitize=address")
54+
add_link_options("-fsanitize=address")
55+
endif()
56+
57+
58+
# Executable
59+
add_executable(BORA
60+
${BORA_SOURCES_WRAPPER}
61+
)
62+
63+
target_compile_definitions(BORA PRIVATE
64+
TAZABASEDIR="${CMAKE_SOURCE_DIR}/contribs/TAZA/code"
65+
NOMINMAX _WINSOCKAPI_ WRAPPER SK_DIRECT3D
66+
)
67+
68+
add_compile_options(
69+
-include ${CMAKE_CURRENT_SOURCE_DIR}/../global/cpp/contribs/TypeDefinitions.h
70+
)
71+
72+
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
73+
file(GLOB_RECURSE BORA_LIBS ${CMAKE_SOURCE_DIR}/libs/Debug/*.a)
74+
else()
75+
file(GLOB_RECURSE BORA_LIBS ${CMAKE_SOURCE_DIR}/libs/Release/*.a)
76+
endif()
77+
78+
79+
add_library(BORA_COMPAT SHARED ${BORA_CONTRIBS_DARWIN} ${BORA_SOURCES_PLATFORM} ${BORA_SOURCES} ${BORA_CONTRIBS} ${BORA_TAZA} ${BORA_3RDPARTY})
80+
target_sources(BORA_COMPAT PRIVATE ${WAMR_RUNTIME_LIB_SOURCE})
81+
target_link_libraries(BORA_COMPAT PRIVATE Vulkan::Vulkan OpenGL::GL ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS} -lm -ldl -lpthread ${BORA_SKIA_LIBRARY} ${BORA_LIBS}
82+
-lbrotlienc -lbrotlidec -lbrotlicommon
83+
"-framework AppKit"
84+
)
85+
86+
target_precompile_headers(BORA_COMPAT PRIVATE
87+
../global/cpp/contribs/TypeDefinitions.h
88+
)
89+
90+
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
91+
add_dependencies(BORA_COMPAT skia_debug)
92+
else()
93+
add_dependencies(BORA_COMPAT skia_release)
94+
endif()
95+
96+
set_target_properties(BORA_COMPAT PROPERTIES
97+
OUTPUT_NAME "LATEST"
98+
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_SYSTEM_NAME}/compatibility"
99+
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_SYSTEM_NAME}/compatibility"
100+
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_SYSTEM_NAME}/compatibility"
101+
)
102+
set_target_properties(BORA PROPERTIES
103+
OUTPUT_NAME "bora"
104+
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_SYSTEM_NAME}"
105+
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_SYSTEM_NAME}"
106+
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_SYSTEM_NAME}"
107+
)
108+
109+
add_dependencies(BORA BORA_COMPAT)

cmake/platform/windows.cmake

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
collect_sources(BORA_SOURCES_PLATFORM
2+
src/host/*
3+
src/software/win32/*
4+
)
15

26
set(WAMR_BUILD_PLATFORM "windows")
37
include(${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake)
@@ -13,7 +17,6 @@ endif()
1317
include(${WAMR_ROOT_DIR}/core/shared/utils/uncommon/shared_uncommon.cmake)
1418
include_directories(${WAMR_ROOT_DIR}/product-mini/platforms/common ./src/host/templates ../global/cpp ../global/contribs ./src ./src/software/common ./src/software/win32 ./contribs ./3rdparty)
1519

16-
1720
add_compile_definitions(
1821
TAZABASEDIR=\"${CMAKE_SOURCE_DIR}/contribs/TAZA/code\"
1922
NOMINMAX
@@ -49,7 +52,7 @@ else()
4952
file(GLOB_RECURSE BORA_LIBS ${CMAKE_SOURCE_DIR}/libs/Release/*.lib)
5053
endif()
5154
52-
add_library(BORA_COMPAT SHARED src/library.def ${BORA_SOURCES} ${BORA_CONTRIBS} ${BORA_TAZA} ${BORA_3RDPARTY})
55+
add_library(BORA_COMPAT SHARED src/library.def ${BORA_SOURCES_PLATFORM} ${BORA_SOURCES} ${BORA_CONTRIBS} ${BORA_TAZA} ${BORA_3RDPARTY})
5356
target_sources(BORA_COMPAT PRIVATE ${WAMR_RUNTIME_LIB_SOURCE})
5457
target_link_libraries(BORA_COMPAT PRIVATE Vulkan::Vulkan ntdll ${BORA_SKIA_LIBRARY} ${BORA_LIBS} opengl32.lib)
5558
target_precompile_headers(BORA_COMPAT PRIVATE

src/host/hostSymbols.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
#include "hostSymbols.h"
22

33
#include "Commands.h"
4-
#include "bora/boraLoggingSymbols.h"
54
#include "stl/string.h"
6-
#include "bora/boraMemorySymbols.h"
75
#include "bora/boraWindowSymbols.h"
86
#include "stl/atomic.h"
97
#include "stl/faults.h"
@@ -12,9 +10,6 @@
1210
// Its hacky but it should work for the demo
1311
void hostSymbols::initalizeSymbols() {
1412
registers->add(std::make_unique<BoraThreadSymbols>());
15-
registers->add(std::make_unique<BoraInputSymbols>());
16-
registers->add(std::make_unique<BoraLoggingSymbols>());
17-
registers->add(std::make_unique<BoraMemorySymbols>());
1813
// registers->add(std::make_unique<BoraStringSymbols>()); - DEPRECATED - 6/13/2025
1914
registers->add(std::make_unique<boraAtomicSymbols>());
2015
registers->add(std::make_unique<HostCommandSymbols>());

src/host/hostSymbols.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#include "bora/boraInputSymbols.h"
21
#include "stl/thread.h"
32
#include "hostSymbolRegister.h"
43

src/mainDynamicLibrary.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include "TAZA.h"
88
#include <stdlib.h>
99
#include <string.h>
10-
1110
#include "host/Commands.h"
1211
#include "nWindow/bnMessageBox.h"
1312
#include "nWindow/bnUserWindow.h"
@@ -30,14 +29,14 @@ static char **app_argv;
3029
using InitializeSymbolsFunc = int(*)(int, char * b[]);
3130

3231

33-
inline std::wstring UTF8ToWString2(const std::string& utf8)
34-
{
35-
if (utf8.empty()) return {};
36-
int size_needed = MultiByteToWideChar(CP_UTF8, 0, utf8.data(), (int)utf8.size(), nullptr, 0);
37-
std::wstring wstr(size_needed, 0);
38-
MultiByteToWideChar(CP_UTF8, 0, utf8.data(), (int)utf8.size(), wstr.data(), size_needed);
39-
return wstr;
40-
}
32+
// inline std::wstring UTF8ToWString2(const std::string& utf8)
33+
// {
34+
// if (utf8.empty()) return {};
35+
// int size_needed = MultiByteToWideChar(CP_UTF8, 0, utf8.data(), (int)utf8.size(), nullptr, 0);
36+
// std::wstring wstr(size_needed, 0);
37+
// MultiByteToWideChar(CP_UTF8, 0, utf8.data(), (int)utf8.size(), wstr.data(), size_needed);
38+
// return wstr;
39+
// }
4140

4241
#include <cstring>
4342
#include <string>
@@ -556,12 +555,12 @@ if (msg == ON_UPDATE){
556555
}
557556

558557
bnWindow* win;
559-
ULONG_PTR gdiplusToken;
558+
// ULONG_PTR gdiplusToken;
560559

561560
int
562561
main(int argc, char *argv[]){
563-
GdiplusStartupInput gdiplusStartupInput;
564-
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, nullptr);
562+
// GdiplusStartupInput gdiplusStartupInput;
563+
// GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, nullptr);
565564
// CreateBlockingMessageBox(L"test", L"Messagebox Title", L"Messagebox Body for descriptions and details");
566565
std::cin.get();
567566
// devBnLogoWindow();

src/software/common/Data.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
#include <fstream>
55
#include <stdexcept>
66

7+
struct ShaderData {
8+
bool valid = false;
9+
sVec<u8> data;
10+
sVec<u8> ogData;
11+
};
12+
713
class Data {
814
public:
915
// Constructor from file path

src/software/common/nGUI/bnFontMgr.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
bnFontMgr::bnFontMgr()
44
{
5+
#ifdef WIN32
56
mgr = sk_sp<SkFontMgr>(SkFontMgr_New_DirectWrite());
7+
#elif defined(__APPLE__)
8+
mgr = SkFontMgr_New_CoreText(nullptr); // todo?
9+
#endif
610
}
711

812
bnFontMgr::~bnFontMgr() {

src/software/common/nGUI/bnFontMgr.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#include "bskia/include/core/SkTextBlob.h"
55
#ifdef WIN32
66
#include "bskia/include/ports/SkTypeface_win.h"
7+
#elif defined(__APPLE__)
8+
#include "bskia/include/ports/SkFontMgr_mac_ct.h"
79
#endif
810

911
class bnFontMgr

0 commit comments

Comments
 (0)