Skip to content

Commit 0f3e137

Browse files
Move CppSource into Assets
Rename platform preprocessor symbols to TARGET_OS_NAME Disable bitcode in iOS builds Use static linking for iOS (i.e. [DllImport("__Internal")]) Build iOS into a hidden directory so it's ignored by Unity Remove NativeScriptConstants.PluginName Update Unity project and company name Update README.md Update .gitignore
1 parent 97421db commit 0f3e137

22 files changed

Lines changed: 192 additions & 68 deletions

.gitignore

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
# Typical location for CMake build files and Visual Studio 2017 generated directories
2-
/cmake
3-
/NativeScript.dir
4-
/x64
1+
# Rider IDE
2+
.idea

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ C++ is the standard language for video games as well as many other fields. By pr
8484
Debug::Log(message);
8585
}
8686

87-
* Platform-dependent compilation via the [usual flags](https://docs.unity3d.com/Manual/PlatformDependentCompilation.html) (e.g. `#if UNITY_EDITOR`)
87+
* Platform-dependent compilation (e.g. `#if TARGET_OS_ANDROID`)
8888
* [CMake](https://cmake.org/) build system sets up any IDE project or command-line build
8989

9090
# Code Generator

Unity/Assets/CppSource.meta

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,29 @@ project(NativeScript CXX)
33

44
# Set platform-dependent compilation defines matching C#
55
if (EDITOR)
6-
add_definitions(-DUNITY_EDITOR)
6+
add_definitions(-DTARGET_OS_EDITOR)
77
if (WIN32)
8-
add_definitions(-DUNITY_EDITOR_WIN)
8+
add_definitions(-DTARGET_OS_EDITOR_WIN)
99
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
10-
add_definitions(-DUNITY_EDITOR_OSX)
10+
add_definitions(-DTARGET_OS_EDITOR_OSX)
1111
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
12-
add_definitions(-DUNITY_EDITOR_LINUX)
12+
add_definitions(-DTARGET_OS_EDITOR_LINUX)
1313
endif()
1414
else()
15-
add_definitions(-DUNITY_STANDALONE)
15+
add_definitions(-DTARGET_OS_STANDALONE)
1616
if (WIN32)
17-
add_definitions(-DUNITY_STANDALONE_WIN)
17+
add_definitions(-DTARGET_OS_WIN)
1818
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
19-
add_definitions(-DUNITY_STANDALONE_OSX)
19+
add_definitions(-DTARGET_OS_OSX)
2020
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
21-
add_definitions(-DUNITY_STANDALONE_LINUX)
21+
add_definitions(-DTARGET_OS_LINUX)
2222
endif()
2323
endif()
2424
if (IOS)
25-
add_definitions(-DUNITY_IOS)
25+
add_definitions(-DTARGET_OS_IPHONE)
2626
endif()
2727
if (ANDROID_NDK)
28-
add_definitions(-DUNITY_ANDROID)
28+
add_definitions(-DTARGET_OS_ANDROID)
2929
endif()
3030

3131
# Use NDK on Android
@@ -36,22 +36,22 @@ endif()
3636

3737
# Set output path
3838
if (ANDROID_NDK)
39-
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/../Assets/Plugins/Android)
40-
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/../Assets/Plugins/Android)
41-
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/../Assets/Plugins/Android)
39+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/../Plugins/Android)
40+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/../Plugins/Android)
41+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/../Plugins/Android)
4242
elseif (IOS)
43-
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/../Assets/Plugins/iOS)
44-
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/../Assets/Plugins/iOS)
45-
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/../Assets/Plugins/iOS)
43+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/../Plugins/.iOS)
44+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/../Plugins/.iOS)
45+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/../Plugins/.iOS)
4646
elseif (WIN32 OR (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") OR (${CMAKE_SYSTEM_NAME} MATCHES "Linux"))
4747
if (EDITOR)
48-
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/../Assets/Plugins/Editor)
49-
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/../Assets/Plugins/Editor)
50-
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/../Assets/Plugins/Editor)
48+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/../Plugins/Editor)
49+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/../Plugins/Editor)
50+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/../Plugins/Editor)
5151
else()
52-
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/../Assets/Plugins)
53-
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/../Assets/Plugins)
54-
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/../Assets/Plugins)
52+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/../Plugins)
53+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/../Plugins)
54+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/../Plugins)
5555
endif()
5656
endif()
5757

@@ -75,6 +75,9 @@ set(
7575
# Build a library. If on an Apple platform, build it in a bundle.
7676
add_library(${PROJECT_NAME} MODULE ${SOURCES})
7777
set_target_properties(${PROJECT_NAME} PROPERTIES BUNDLE TRUE)
78+
if (IOS)
79+
set_xcode_property(${PROJECT_NAME} ENABLE_BITCODE "NO")
80+
endif()
7881

7982
# Enable C++11
8083
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11)

Unity/Assets/CppSource/CMakeLists.txt.meta

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Unity/Assets/CppSource/Game.meta

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Unity/Assets/CppSource/Game/Game.cpp.meta

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Unity/Assets/CppSource/Game/Game.h.meta

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)