This repository has been archived by the owner on Jun 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
01-build-c-only.patch
236 lines (214 loc) · 7.93 KB
/
01-build-c-only.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 40e1b72..f7730e8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -24,10 +24,11 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
-cmake_minimum_required(VERSION 2.6)
+cmake_minimum_required(VERSION 3.13)
project(NE10 C CXX ASM)
+option(NE10_BUILD_ARM_ONLY "Build for ARM only using optimized functions." OFF)
option(NE10_BUILD_SHARED "Build NE10 shared libraries" OFF)
option(NE10_BUILD_STATIC "Build NE10 static libraries" ON)
option(NE10_BUILD_EXAMPLES "Build NE10 examples" ON)
@@ -94,6 +95,10 @@ option(NE10_ENABLE_IMGPROC "Build image processing functionalities to NE10" ON)
set(NE10_VERSION 10)
+if (NE10_BUILD_ARM_ONLY)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DARM_ONLY")
+endif()
+
if(BUILD_DEBUG)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-strict-aliasing -O0 -DDEBUG -g -Wall -Wno-unused-but-set-variable")
message("-- Building type: DEBUG")
@@ -187,7 +192,7 @@ endif()
# Make sure we are compiling for an ARM system.
# This is a verbose fail-fast in case we are trying to compile for non-ARM;
# otherwise it would fail at `make` with obscure errors.
-if(GNULINUX_PLATFORM AND (NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^arm"))
+if(False)
message(FATAL_ERROR "You are trying to compile for non-ARM (CMAKE_SYSTEM_PROCESSOR='${CMAKE_SYSTEM_PROCESSOR}')! see doc/building.md for cross compilation instructions.")
endif()
diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt
index 4f158e9..243cead 100644
--- a/modules/CMakeLists.txt
+++ b/modules/CMakeLists.txt
@@ -365,11 +365,22 @@ include_directories (
${PROJECT_SOURCE_DIR}/common
)
+set(EXPORTED_HEADERS
+ ../inc/NE10.h
+ ../inc/NE10_dsp.h
+ ../inc/NE10_imgproc.h
+ ../inc/NE10_init.h
+ ../inc/NE10_macros.h
+ ../inc/NE10_math.h
+ ../inc/NE10_physics.h
+ ../inc/NE10_types.h
+ )
+
if(NE10_BUILD_STATIC OR ANDROID_PLATFORM OR IOS_DEMO)
add_library( NE10 STATIC
${NE10_C_SRCS}
- ${NE10_INTRINSIC_SRCS}
- ${NE10_NEON_SRCS}
+ $<$<BOOL:${NE10_BUILD_ARM_ONLY}>:${NE10_INTRINSIC_SRCS}>
+ $<$<BOOL:${NE10_BUILD_ARM_ONLY}>:${NE10_NEON_SRCS}>
${NE10_INIT_SRCS}
)
set_target_properties(NE10 PROPERTIES
@@ -381,6 +392,15 @@ if(NE10_BUILD_STATIC OR ANDROID_PLATFORM OR IOS_DEMO)
LINKER_LANGUAGE C
)
+ set_target_properties(NE10 PROPERTIES PUBLIC_HEADER "${EXPORTED_HEADERS}")
+
+ install(TARGETS NE10
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/ne10
+ COMPONENT library
+ )
+
if(IOS_DEMO)
install(TARGETS NE10
DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/../ios/NE10Demo/libs/)
@@ -391,13 +411,15 @@ if(NE10_BUILD_SHARED)
add_library( NE10_shared SHARED
${NE10_C_SRCS}
- ${NE10_INTRINSIC_SRCS}
- ${NE10_NEON_SRCS}
+ $<$<BOOL:${NE10_BUILD_ARM_ONLY}>:${NE10_INTRINSIC_SRCS}>
+ $<$<BOOL:${NE10_BUILD_ARM_ONLY}>:${NE10_NEON_SRCS}>
${NE10_INIT_SRCS}
)
target_link_libraries(NE10_shared m)
+ set_target_properties(NE10_shared PROPERTIES PUBLIC_HEADER "${EXPORTED_HEADERS}")
+
set_target_properties(NE10_shared PROPERTIES
OUTPUT_NAME "NE10"
CLEAN_DIRECT_OUTPUT 1
@@ -405,10 +427,17 @@ if(NE10_BUILD_SHARED)
LINKER_LANGUAGE C
)
+ install(TARGETS NE10_shared
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/ne10
+ COMPONENT library
+ )
+
add_library( NE10_test SHARED
${NE10_C_SRCS}
- ${NE10_INTRINSIC_SRCS}
- ${NE10_NEON_SRCS}
+ $<$<BOOL:${NE10_BUILD_ARM_ONLY}>:${NE10_INTRINSIC_SRCS}>
+ $<$<BOOL:${NE10_BUILD_ARM_ONLY}>:${NE10_NEON_SRCS}>
${NE10_INIT_SRCS}
)
diff --git a/modules/dsp/NE10_init_dsp.c b/modules/dsp/NE10_init_dsp.c
index a23ed16..ccaea50 100644
--- a/modules/dsp/NE10_init_dsp.c
+++ b/modules/dsp/NE10_init_dsp.c
@@ -31,6 +31,7 @@
ne10_result_t ne10_init_dsp (ne10_int32_t is_NEON_available)
{
+#ifdef ARM_ONLY
if (NE10_OK == is_NEON_available)
{
ne10_fft_alloc_c2c_float32 = ne10_fft_alloc_c2c_float32_neon;
@@ -84,6 +85,7 @@ ne10_result_t ne10_init_dsp (ne10_int32_t is_NEON_available)
#endif // ENABLE_NE10_IIR_LATTICE_FLOAT_NEON
}
else
+#endif // ARM_ONLY
{
ne10_fft_alloc_c2c_float32 = ne10_fft_alloc_c2c_float32_c;
ne10_fft_alloc_c2c_int32 = ne10_fft_alloc_c2c_int32_c;
diff --git a/modules/imgproc/NE10_init_imgproc.c b/modules/imgproc/NE10_init_imgproc.c
index 6468098..d70eb96 100644
--- a/modules/imgproc/NE10_init_imgproc.c
+++ b/modules/imgproc/NE10_init_imgproc.c
@@ -31,6 +31,7 @@
ne10_result_t ne10_init_imgproc (ne10_int32_t is_NEON_available)
{
+#ifdef ARM_ONLY
if (NE10_OK == is_NEON_available)
{
ne10_img_resize_bilinear_rgba = ne10_img_resize_bilinear_rgba_neon;
@@ -43,6 +44,7 @@ ne10_result_t ne10_init_imgproc (ne10_int32_t is_NEON_available)
ne10_img_boxfilter_rgba8888 = ne10_img_boxfilter_rgba8888_neon;
}
else
+#endif // ARM_ONLY
{
ne10_img_resize_bilinear_rgba = ne10_img_resize_bilinear_rgba_c;
ne10_img_rotate_rgba = ne10_img_rotate_rgba_c;
diff --git a/modules/imgproc/NE10_resize.c b/modules/imgproc/NE10_resize.c
index cd9f757..bfdaa8c 100644
--- a/modules/imgproc/NE10_resize.c
+++ b/modules/imgproc/NE10_resize.c
@@ -348,6 +348,7 @@ static void ne10_img_resize_cal_offset_linear (ne10_int32_t* xofs,
}
+#ifdef ARM_ONLY
extern void ne10_img_hresize_4channels_linear_neon (const ne10_uint8_t** src,
ne10_int32_t** dst,
ne10_int32_t count,
@@ -439,6 +440,7 @@ static void ne10_img_resize_generic_linear_neon (ne10_uint8_t* src,
NE10_FREE (buffer_);
}
+#endif // ARM_ONLY
/**
* @ingroup IMG_RESIZE
@@ -481,6 +483,7 @@ void ne10_img_resize_bilinear_rgba_c (ne10_uint8_t* dst,
NE10_FREE (buffer_);
}
+#ifdef ARM_ONLY
/**
* @ingroup IMG_RESIZE
* Specific implementation of @ref ne10_img_resize_bilinear_rgba using NEON SIMD capabilities.
@@ -521,6 +524,7 @@ void ne10_img_resize_bilinear_rgba_neon (ne10_uint8_t* dst,
ne10_img_resize_generic_linear_neon (src, dst, xofs, ialpha, yofs, ibeta, xmin, xmax, ksize, srcw, srch, src_stride, dstw, dsth, cn);
NE10_FREE (buffer_);
}
+#endif // ARM_ONLY
/**
* @} end of IMG_RESIZE group
diff --git a/modules/math/NE10_init_math.c b/modules/math/NE10_init_math.c
index 0e11345..66635ce 100644
--- a/modules/math/NE10_init_math.c
+++ b/modules/math/NE10_init_math.c
@@ -31,6 +31,7 @@
ne10_result_t ne10_init_math (int is_NEON_available)
{
+#ifdef ARM_ONLY
if (NE10_OK == is_NEON_available)
{
ne10_addc_float = ne10_addc_float_neon;
@@ -123,6 +124,7 @@ ne10_result_t ne10_init_math (int is_NEON_available)
ne10_identitymat_2x2f = ne10_identitymat_2x2f_neon;
}
else
+#endif // ARM_ONLY
{
ne10_addc_float = ne10_addc_float_c;
ne10_addc_vec2f = ne10_addc_vec2f_c;
diff --git a/modules/physics/NE10_init_physics.c b/modules/physics/NE10_init_physics.c
index ae8fae9..7bacae0 100644
--- a/modules/physics/NE10_init_physics.c
+++ b/modules/physics/NE10_init_physics.c
@@ -35,6 +35,7 @@
ne10_result_t ne10_init_physics (ne10_int32_t is_NEON_available)
{
+#ifdef ARM_ONLY
if (NE10_OK == is_NEON_available)
{
#ifdef ENABLE_NE10_PHYSICS_COMPUTE_AABB_VEC2F_NEON
@@ -56,6 +57,7 @@ ne10_result_t ne10_init_physics (ne10_int32_t is_NEON_available)
#endif // ENABLE_NE10_PHYSICS_RELATIVE_V_VEC2F_NEON
}
else
+#endif // ARM_ONLY
{
ne10_physics_compute_aabb_vec2f = ne10_physics_compute_aabb_vec2f_c;
ne10_physics_relative_v_vec2f = ne10_physics_relative_v_vec2f_c;