Skip to content

Commit 55e6200

Browse files
committed
support iOS and Android
support char16_t, u16string, char32_t, and u32string
1 parent b7b082a commit 55e6200

File tree

18 files changed

+493
-364
lines changed

18 files changed

+493
-364
lines changed

.appveyor.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ install:
3636
- git submodule update --init
3737

3838
before_build:
39+
- cd tools/batch/ && update_parser_by_scheme.bat && cd ../../
3940
- mkdir build
4041
- cd build
4142
- if "%TARGET_VSENV%" equ "VS14_WIN32" cmake -G "Visual Studio 14 2015" -D CMAKE_CONFIGURATION_TYPES=%CONFIGURATION% -D CMAKE_CXX_COMPILER_ID=MSVC_14 ../

.gitlab-ci.yml

Lines changed: 91 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
variables:
22
GIT_SUBMODULE_STRATEGY: "recursive"
3+
ANDROID_NDK: "~/develop/android-ndk-r18b"
34

45
before_script:
56
- git lfs fetch
@@ -10,60 +11,54 @@ after_script:
1011

1112
stages:
1213
- check
13-
- test
14+
- build
1415

1516
checked_by_cppcheck:
1617
stage: check
1718
script:
18-
- echo check
19+
- 'cd tools/batch/ && ./update_parser_by_scheme.sh && cd ../../'
1920
- 'cppcheck . --enable=warning,style,performance,portability --xml-version=2 --error-exitcode=1 -i external/ -i build/ -i tools/'
2021
tags:
22+
- linux
23+
- python
2124
- cppcheck
2225

23-
test_win32:
24-
stage: test
26+
compile_windows:
27+
stage: build
2528
script:
29+
- 'cd tools/batch/ && python .\..\..\tools\jsonschematoc11 glTF_2.0_schema.ini && cd ../../'
2630
- 'call "%VS140COMNTOOLS%VsDevCmd.bat"'
2731
- 'if exist build rmdir /s /q build'
2832
- 'if exist output rmdir /s /q output'
29-
- 'mkdir build'
30-
- 'cd build'
31-
- 'cmake -G "Visual Studio 14 2015" ../'
33+
- 'mkdir build && cd build'
34+
- 'mkdir win32 && cd win32'
35+
- 'cmake -G "Visual Studio 14 2015" -DLIBGLTF_WITH_UNICODE=TRUE ../../'
3236
- 'msbuild libgltf.sln /t:Rebuild /p:Configuration="Debug" /p:Platform="Win32"'
33-
- '..\output\bin\win32\Debug\runtest.exe ..\resource\example-2.0\glTF-BarramundiFish.gltf'
34-
- '..\output\bin\win32\Debug\runtest.exe ..\resource\example-2.0\glTF-Draco-BarramundiFish.gltf'
35-
- '..\output\bin\win32\Debug\runtest.exe ..\resource\example-2.0\glTF-pbrSpecularGlossinessBarramundiFish.gltf'
37+
- '..\..\output\bin\win32\Debug\runtest.exe ..\..\resource\example-2.0\glTF-BarramundiFish.gltf'
38+
- '..\..\output\bin\win32\Debug\runtest.exe ..\..\resource\example-2.0\glTF-Draco-BarramundiFish.gltf'
39+
- '..\..\output\bin\win32\Debug\runtest.exe ..\..\resource\example-2.0\glTF-pbrSpecularGlossinessBarramundiFish.gltf'
3640
- 'cd ../'
37-
tags:
38-
- win32
39-
- cmake
40-
- vs2015
41-
42-
test_win64:
43-
stage: test
44-
script:
45-
- 'call "%VS140COMNTOOLS%VsDevCmd.bat"'
46-
- 'if exist build rmdir /s /q build'
47-
- 'if exist output rmdir /s /q output'
48-
- 'mkdir build'
49-
- 'cd build'
50-
- 'cmake -G "Visual Studio 14 2015 Win64" ../'
41+
- 'mkdir win64 && cd win64'
42+
- 'cmake -G "Visual Studio 14 2015 Win64" -DLIBGLTF_WITH_UNICODE=TRUE ../../'
5143
- 'msbuild libgltf.sln /t:Rebuild /p:Configuration="Debug" /p:Platform="x64"'
52-
- '..\output\bin\win64\Debug\runtest.exe ..\resource\example-2.0\glTF-BarramundiFish.gltf'
53-
- '..\output\bin\win64\Debug\runtest.exe ..\resource\example-2.0\glTF-Draco-BarramundiFish.gltf'
54-
- '..\output\bin\win64\Debug\runtest.exe ..\resource\example-2.0\glTF-pbrSpecularGlossinessBarramundiFish.gltf'
44+
- '..\..\output\bin\win64\Debug\runtest.exe ..\..\resource\example-2.0\glTF-BarramundiFish.gltf'
45+
- '..\..\output\bin\win64\Debug\runtest.exe ..\..\resource\example-2.0\glTF-Draco-BarramundiFish.gltf'
46+
- '..\..\output\bin\win64\Debug\runtest.exe ..\..\resource\example-2.0\glTF-pbrSpecularGlossinessBarramundiFish.gltf'
47+
- 'cd ../'
5548
- 'cd ../'
5649
tags:
50+
- win32
5751
- win64
52+
- python
5853
- cmake
5954
- vs2015
6055

61-
test_linux:
62-
stage: test
56+
compile_linux:
57+
stage: build
6358
script:
64-
- 'mkdir build'
65-
- 'cd build'
66-
- 'cmake -DCMAKE_BUILD_TYPE=Debug -DLIBGLTF_BUILD_GCOV=TRUE -G "Unix Makefiles" ../'
59+
- 'cd tools/batch/ && ./update_parser_by_scheme.sh && cd ../../'
60+
- 'mkdir build && cd build'
61+
- 'cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DLIBGLTF_BUILD_GCOV=TRUE ../'
6762
- 'make'
6863
- 'valgrind --leak-check=full --show-leak-kinds=all ./../output/bin/linux/runtest --coveralls'
6964
- 'valgrind --leak-check=full --show-leak-kinds=all ./../output/bin/linux/runtest --coveralls ../resource/nothing.gltf'
@@ -80,17 +75,17 @@ test_linux:
8075
- 'cd ../'
8176
tags:
8277
- linux
78+
- python
8379
- cmake
8480
- make
8581
- valgrind
86-
- gcc
8782
- gcovr
8883

89-
test_macos:
90-
stage: test
84+
compile_macos:
85+
stage: build
9186
script:
92-
- 'mkdir build'
93-
- 'cd build'
87+
- 'cd tools/batch/ && ./update_parser_by_scheme.sh && cd ../../'
88+
- 'mkdir build && cd build'
9489
- 'cmake -G "Unix Makefiles" ../'
9590
- 'make'
9691
- './../output/bin/macos/runtest ../resource/example-2.0/glTF-BarramundiFish.gltf'
@@ -99,6 +94,65 @@ test_macos:
9994
- 'cd ../'
10095
tags:
10196
- macos
97+
- python
10298
- cmake
10399
- make
104100
- gcc
101+
102+
compile_android:
103+
stage: build
104+
script:
105+
- 'cd tools/batch/ && ./update_parser_by_scheme.sh && cd ../../'
106+
- 'mkdir build && cd build'
107+
- 'mkdir armeabi-v7a && cd armeabi-v7a'
108+
- 'cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=/usr/bin/ninja -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake -DANDROID_ABI=armeabi-v7a -DANDROID_NDK=$ANDROID_NDK -DANDROID_NATIVE_API_LEVEL=19 -DANDROID_TOOLCHAIN=clang ../../'
109+
- 'ninja'
110+
- 'cd ../'
111+
- 'mkdir armeabi-v7a-with-neon && cd armeabi-v7a-with-neon'
112+
- 'cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=/usr/bin/ninja -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake -DANDROID_ABI=armeabi-v7a -DANDROID_ARM_NEON=ON -DANDROID_NDK=$ANDROID_NDK -DANDROID_NATIVE_API_LEVEL=19 -DANDROID_TOOLCHAIN=clang ../../'
113+
- 'ninja'
114+
- 'cd ../'
115+
- 'mkdir arm64-v8a && cd arm64-v8a'
116+
- 'cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=/usr/bin/ninja -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake -DANDROID_ABI=arm64-v8a -DANDROID_NDK=$ANDROID_NDK -DANDROID_NATIVE_API_LEVEL=19 -DANDROID_TOOLCHAIN=clang ../../'
117+
- 'ninja'
118+
- 'cd ../'
119+
- 'mkdir x86 && cd x86'
120+
- 'cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=/usr/bin/ninja -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake -DANDROID_ABI=x86 -DANDROID_NDK=$ANDROID_NDK -DANDROID_NATIVE_API_LEVEL=19 -DANDROID_TOOLCHAIN=clang ../../'
121+
- 'ninja'
122+
- 'cd ../'
123+
- 'mkdir x86_64 && cd x86_64'
124+
- 'cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=/usr/bin/ninja -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake -DANDROID_ABI=x86_64 -DANDROID_NDK=$ANDROID_NDK -DANDROID_NATIVE_API_LEVEL=19 -DANDROID_TOOLCHAIN=clang ../../'
125+
- 'ninja'
126+
- 'cd ../'
127+
- 'cd ../'
128+
tags:
129+
- linux
130+
- android
131+
- python
132+
- cmake
133+
- ninja
134+
135+
compile_ios:
136+
stage: build
137+
script:
138+
- 'cd tools/batch/ && ./update_parser_by_scheme.sh && cd ../../'
139+
- 'mkdir build && cd build'
140+
- 'mkdir os && cd os'
141+
- 'cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=../../external/ios-cmake/toolchain/iOS.cmake -DIOS_PLATFORM=OS -DLIBGLTF_PLATFORM_IOS=TRUE -DLIBGLTF_WITH_UNICODE=TRUE -DLIBGLTF_USING_CHAR16=TRUE ../../'
142+
- 'make libgltf'
143+
- 'cd ../'
144+
- 'mkdir simulator && cd simulator'
145+
- 'cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=../../external/ios-cmake/toolchain/iOS.cmake -DIOS_PLATFORM=SIMULATOR -DLIBGLTF_PLATFORM_IOS=TRUE -DLIBGLTF_WITH_UNICODE=TRUE -DLIBGLTF_USING_CHAR16=TRUE ../../'
146+
- 'make libgltf'
147+
- 'cd ../'
148+
- 'mkdir watchos && cd watchos'
149+
- 'cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=../../external/ios-cmake/toolchain/iOS.cmake -DIOS_PLATFORM=WATCHOS -DLIBGLTF_PLATFORM_IOS=TRUE -DLIBGLTF_WITH_UNICODE=TRUE -DLIBGLTF_USING_CHAR16=TRUE ../../'
150+
- 'make libgltf'
151+
- 'cd ../'
152+
- 'cd ../'
153+
tags:
154+
- macos
155+
- ios
156+
- python
157+
- cmake
158+
- make

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44
[submodule "external/glTF"]
55
path = external/glTF
66
url = https://github.com/KhronosGroup/glTF.git
7+
[submodule "external/ios-cmake"]
8+
path = external/ios-cmake
9+
url = https://github.com/Yangqing/ios-cmake.git

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ install:
2323

2424
script:
2525
- set -e
26+
- cd tools/batch/ && ./update_parser_by_scheme.sh && cd ../../
2627
- mkdir ./build && cd ./build
2728
- if [ $RUN_COVERALLS == true ]; then cmake -D LIBGLTF_COVERAGE_GCOV=TRUE ./../; else cmake ./../; fi
2829
- make

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log
22

3+
## 0.1.4 (2018/11/5)
4+
5+
* Support Android and iOS platforms
6+
37
## 0.0.1 (2017/12/5)
48

59
### Changes

CMakeLists.txt

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ set(CMAKE_DEBUG_POSTFIX "d")
1212
set(LIBGLTF_PLATFORM_WINDOWS FALSE)
1313
set(LIBGLTF_PLATFORM_LINUX FALSE)
1414
set(LIBGLTF_PLATFORM_MACOS FALSE)
15+
set(LIBGLTF_PLATFORM_ANDROID FALSE)
16+
option(LIBGLTF_PLATFORM_IOS OFF)
1517

1618
option(LIBGLTF_COVERAGE_GCOV "Coverage gcov (debug, Linux builds only)" OFF)
1719
option(LIBGLTF_WITH_UNICODE "Build with UNICODE" OFF)
@@ -46,7 +48,17 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
4648
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -lgcov")
4749
add_definitions(-DBUILD_COVERALLS)
4850
endif()
49-
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
51+
elseif(CMAKE_SYSTEM_NAME STREQUAL "Android")
52+
set(LIBGLTF_PLATFORM_ANDROID TRUE)
53+
add_definitions(-DLIBGLTF_PLATFORM_LINUX)
54+
set(DYNAMIC_LIBRARY_EXTENSION ".so")
55+
set(STATIC_LIBRARY_EXTENSION ".a")
56+
set(PLATFORM_NAME "android")
57+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wshadow -Wconversion -Wno-long-long -pedantic")
58+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -Wshadow -Wconversion -Wsign-conversion -Wno-long-long -pedantic")
59+
set(CMAKE_STATIC_LIBRARY_PREFIX "")
60+
set(CMAKE_SHARED_LIBRARY_PREFIX "")
61+
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND (NOT ${LIBGLTF_PLATFORM_IOS}))
5062
set(LIBGLTF_PLATFORM_MACOS TRUE)
5163
add_definitions(-DLIBGLTF_PLATFORM_MACOS)
5264
set(DYNAMIC_LIBRARY_EXTENSION ".dylib")
@@ -56,9 +68,19 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
5668
set(CMAKE_CXX_FLAGS "-std=c++11 -Wall -Wextra -Wshadow -Wconversion -Wsign-conversion -Wno-long-long -pedantic ${CMAKE_CXX_FLAGS}")
5769
set(CMAKE_STATIC_LIBRARY_PREFIX "")
5870
set(CMAKE_SHARED_LIBRARY_PREFIX "")
71+
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND ${LIBGLTF_PLATFORM_IOS})
72+
set(LIBGLTF_PLATFORM_IOS TRUE)
73+
add_definitions(-DLIBGLTF_PLATFORM_IOS)
74+
set(DYNAMIC_LIBRARY_EXTENSION ".dylib")
75+
set(STATIC_LIBRARY_EXTENSION ".a")
76+
set(PLATFORM_NAME "ios")
77+
set(CMAKE_C_FLAGS "-Wall -Wextra -Wshadow -Wconversion -Wno-long-long -pedantic ${CMAKE_C_FLAGS}")
78+
set(CMAKE_CXX_FLAGS "-std=c++11 -Wall -Wextra -Wshadow -Wconversion -Wsign-conversion -Wno-long-long -pedantic ${CMAKE_CXX_FLAGS}")
79+
set(CMAKE_STATIC_LIBRARY_PREFIX "")
80+
set(CMAKE_SHARED_LIBRARY_PREFIX "")
5981
endif()
6082

61-
if((NOT ${LIBGLTF_PLATFORM_WINDOWS}) AND (NOT ${LIBGLTF_PLATFORM_LINUX}) AND (NOT ${LIBGLTF_PLATFORM_MACOS}))
83+
if((NOT ${LIBGLTF_PLATFORM_WINDOWS}) AND (NOT ${LIBGLTF_PLATFORM_LINUX}) AND (NOT ${LIBGLTF_PLATFORM_ANDROID}) AND (NOT ${LIBGLTF_PLATFORM_MACOS}) AND (NOT ${LIBGLTF_PLATFORM_IOS}))
6284
message(FATAL_ERROR "Sorry, don't support your system ${CMAKE_SYSTEM_NAME}!")
6385
endif()
6486

@@ -106,4 +128,3 @@ add_subdirectory(source)
106128
add_subdirectory(tools)
107129

108130
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT libgltf)
109-

docs/index.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
11
# About
22

3-
This project can automatically generate C++11 code by glTF JSON schema. Then you can compile the generated C++11 code to parser the glTF to a struct `SGlTF` or convert the struct `SGlTF` to JSON string.
3+
This project can automatically generate C++11 code by glTF JSON schema. Then you can compile the generated C++11 code to parser the glTF string to a struct `SGlTF` or convert the struct `SGlTF` to JSON string.
44

55
It was used in [glTFForUE4](https://github.com/code4game/glTFForUE4).
66

7+
## Platforms
8+
9+
### Desktop
10+
11+
* Windows
12+
* Linux
13+
* MacOS
14+
15+
### Mobile
16+
17+
* Android (armeabi-v7a, armeabi-v7a-with-neon, arm64-v8a, x86 and x86_64)
18+
* iOS (iOS, simulator and watchOS)
19+
720
## Donation
821

922
[![Become a patreon](https://img.shields.io/badge/donation-become%20a%20patreon-ff69b4.svg?style=flat)](https://www.patreon.com/bePatron?u=7553208)

docs/usage.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,28 @@
11
# Usage
22

3-
Generate the `makefile` or `vs project` by [CMake].
3+
Generate the `makefile` or `ninja` or `vs project` by [CMake].
44

55
For now, just build to a static library - `libgltf.(lib/a/dylib)`.
66

77
## Advance
88

9+
### Generate new code by the official glTF schema
10+
911
> You can update the c++11 source code by `jsonschematoc11`.
1012
1113
Generate the c++11 code:
1214

13-
1. Run `tools/batch/update_parser_by_scheme.bat` or `tools/batch/update_parser_by_scheme.sh`
15+
1. Run `tools/batch/update_parser_by_scheme.bat` (Windows) or `tools/batch/update_parser_by_scheme.sh` (Unix/Linux/MacOS)
16+
2. Build your version by [CMake], [Ninja] or [VisualStudio].
17+
18+
### String encode
19+
20+
* default using utf8, char and std::string
21+
* set LIBGLTF_WITH_UNICODE as TRUE in cmake command, if you want using unicode
22+
* default using wchar_t and std::wstring
23+
* set LIBGLTF_USING_CHAR16 as TRUE in cmake command, if you wnat using utf16, char16_t and std::u16string
24+
* set LIBGLTF_USING_CHAR32 as TRUE in cmake command, if you want using utf32, char32_t and std::u32string
1425

1526
[CMake]: https://cmake.org
27+
[Ninja]: https://ninja-build.org
28+
[VisualStudio]: https://visualstudio.microsoft.com

external/ios-cmake

Submodule ios-cmake added at 8abaed6

0 commit comments

Comments
 (0)