Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON)

project(BabylonNative)

set(SUPPORTED_PLATFORMS "Win32" "UWP" "Android")
set(SUPPORTED_PLATFORMS "Win32" "UWP" "Android" "Apple")
if (ANDROID)
set(BABYLON_NATIVE_PLATFORM "Android" CACHE STRING "Target platform for Babylon Native.")
elseif (APPLE)
set(BABYLON_NATIVE_PLATFORM "Apple" CACHE STRING "Target platform for Babylon Native.")
else()
set(BABYLON_NATIVE_PLATFORM "Win32" CACHE STRING "Target platform for Babylon Native.")
endif()
Expand All @@ -22,13 +24,14 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if(ANDROID)
set(ARCH ${ANDROID_ABI})
set(ARCH ${ANDROID_ABI})
elseif(${CMAKE_CXX_COMPILER} MATCHES "x86/cl.exe$")
set(ARCH "x86")
elseif(${CMAKE_CXX_COMPILER} MATCHES "x64/cl.exe$")
set(ARCH "x64")
elseif(${CMAKE_CXX_COMPILER} MATCHES "arm/cl.exe$")
set(ARCH "ARM")
elseif(APPLE)
else()
message(FATAL_ERROR "Unrecognized compiler: ${CMAKE_CXX_COMPILER}")
endif()
Expand Down
27 changes: 25 additions & 2 deletions Library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ add_compile_definitions(BGFX_CONFIG_DEBUG_UNIFORM=0)
add_compile_definitions(BGFX_CONFIG_MULTITHREADED=0)
add_compile_definitions(BGFX_CONFIG_MAX_VERTEX_STREAMS=32)
add_compile_definitions(BGFX_CONFIG_MAX_COMMAND_BUFFER_SIZE=12582912)
if(BABYLON_NATIVE_PLATFORM STREQUAL "Apple")
# no Vulkan on Apple
add_compile_definitions(BGFX_CONFIG_RENDERER_VULKAN=0)
endif()
set(BGFX_BUILD_EXAMPLES OFF CACHE BOOL "Build the BGFX examples.")
set(BGFX_BUILD_TOOLS OFF CACHE BOOL "Build the BGFX tools.")
add_subdirectory(Dependencies/bgfx.cmake EXCLUDE_FROM_ALL)
Expand All @@ -41,10 +45,17 @@ set_property(TARGET bgfx PROPERTY FOLDER Dependencies/bgfx)
set_property(TARGET bimg PROPERTY FOLDER Dependencies/bgfx)
set_property(TARGET bx PROPERTY FOLDER Dependencies/bgfx)

set(CMAKE_USE_WINSSL ON CACHE BOOL "Set cURL to use WinSSL by default.")
if(BABYLON_NATIVE_PLATFORM STREQUAL "Apple")
set(CURL_CA_BUNDLE "none" CACHE FILEPATH "Path to SSL CA Certificate Bundle")
set(CURL_CA_PATH "none" CACHE PATH "Path to SSL CA Certificate Directory")
set(CMAKE_USE_SECTRANSP ON CACHE BOOL "enable Apple OS native SSL/TLS")
else()
set(CMAKE_USE_WINSSL ON CACHE BOOL "Set cURL to use WinSSL by default.")
endif()
add_subdirectory(Dependencies/curl EXCLUDE_FROM_ALL)
set_property(TARGET libcurl PROPERTY FOLDER Dependencies/curl)


# TODO: Certain parts of cURL's functionality are gated behind WINAPI checks
# that cause the functionality to become unavailable in UWP. Find a better way
# to ensure that functionality is enabled, then remove the following workaround.
Expand Down Expand Up @@ -85,6 +96,10 @@ if(BABYLON_NATIVE_PLATFORM STREQUAL "Android")
"Source/ShaderCompilerOpenGL.cpp")
endif()

if(BABYLON_NATIVE_PLATFORM STREQUAL "Apple")
set(SOURCES ${SOURCES}
"Source/ShaderCompilerMetal.cpp")
endif()


add_library(Library ${SOURCES})
Expand All @@ -109,7 +124,13 @@ target_include_directories(Library PRIVATE "Dependencies/base-n/include")
target_include_directories(Library PRIVATE "Dependencies/bgfx.cmake/bgfx/include")
target_include_directories(Library PRIVATE "Dependencies/bgfx.cmake/bimg/include")
target_include_directories(Library PRIVATE "Dependencies/bgfx.cmake/bx/include")
target_include_directories(Library PRIVATE "Dependencies/bgfx.cmake/bx/include/compat/msvc")
if(MSVC)
Comment thread
bghgary marked this conversation as resolved.
target_include_directories( bx PRIVATE "Dependencies/bgfx.cmake/bx/include/compat/msvc")
elseif(MINGW)
target_include_directories( bx PRIVATE "Dependencies/bgfx.cmake/bx/include/compat/msvc/mingw")
elseif(APPLE)
target_include_directories( bx PRIVATE "Dependencies/bgfx.cmake/bx/include/compat/msvc/osx")
endif()
target_include_directories(Library PRIVATE "Dependencies/curl/include")
target_include_directories(Library PRIVATE "Dependencies/glslang")
target_include_directories(Library PRIVATE "Dependencies/SPIRV-Cross")
Expand All @@ -131,6 +152,7 @@ if(WINDOWS_STORE)
target_link_libraries(Library PRIVATE arcana)
endif()

if(BABYLON_NATIVE_PLATFORM STREQUAL "Win32" OR BABYLON_NATIVE_PLATFORM STREQUAL "UWP")
target_link_libraries(Library
PRIVATE "crypt32.lib"
PRIVATE "d2d1.lib"
Expand All @@ -144,6 +166,7 @@ target_link_libraries(Library
PRIVATE "shlwapi.lib"
PRIVATE "ws2_32.lib"
PRIVATE "wldap32.lib")
endif()

if(WINDOWS_STORE)
target_link_libraries(Library PRIVATE "kernel32.lib")
Expand Down
6 changes: 4 additions & 2 deletions Library/Dependencies/napi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ cmake_minimum_required(VERSION 3.12)
project(napi)

if (ANDROID)
set(NAPI_JAVASCRIPT_ENGINE "V8")
set(NAPI_JAVASCRIPT_ENGINE "V8")
elseif (APPLE)
set(NAPI_JAVASCRIPT_ENGINE "JavaScriptCore")
endif()

set(SUPPORTED_JAVASCRIPT_ENGINES "Chakra" "V8")
set(SUPPORTED_JAVASCRIPT_ENGINES "Chakra" "V8" "JavaScriptCore")
set(NAPI_JAVASCRIPT_ENGINE "V8" CACHE STRING "JavaScript engine for N-API.")
if(NOT(NAPI_JAVASCRIPT_ENGINE IN_LIST SUPPORTED_JAVASCRIPT_ENGINES))
message(FATAL_ERROR "Unrecognized engine: ${NAPI_JAVASCRIPT_ENGINE}")
Expand Down
14 changes: 14 additions & 0 deletions Library/Dependencies/napi/source/env_JavaScriptCore.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <napi/env.h>
#include <napi/js_native_api_types.h>

namespace babylon
{
Env::Env(const char* executablePath, std::function<void(std::function<void()>)> executeOnScriptThread)
: Napi::Env{ }
{
}

Env::~Env()
{
}
}
1 change: 0 additions & 1 deletion Library/Dependencies/napi/source/env_v8.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <napi/env.h>
#include <napi/js_native_api_types.h>
#include "js_native_api_v8.h"
#include <libplatform/libplatform.h>

namespace
{
Expand Down
Loading