blob: 22273c9edd1ce39a5830183a7ea143785ca54ffc [file] [log] [blame]
Christophe Favergeon53f828f2019-03-25 13:42:44 +01001from distutils.core import setup, Extension
2import glob
3import numpy
4import config
5import sys
6import os
Christophe Favergeon19dc9522021-09-22 15:37:22 +02007import os.path
Christophe Favergeon53f828f2019-03-25 13:42:44 +01008from config import ROOT
Christophe Favergeon729752f2020-08-07 11:50:27 +02009import re
Christophe Favergeon53f828f2019-03-25 13:42:44 +010010
Christophe Favergeonaefd2772020-01-08 09:01:17 +010011includes = [os.path.join(ROOT,"Include"),os.path.join(ROOT,"PrivateInclude"),os.path.join("cmsisdsp_pkg","src")]
Christophe Favergeon53f828f2019-03-25 13:42:44 +010012
13if sys.platform == 'win32':
14 cflags = ["-DWIN",config.cflags,"-DUNALIGNED_SUPPORT_DISABLE"]
Christophe Favergeon53f828f2019-03-25 13:42:44 +010015else:
Christophe Favergeona614de92021-01-20 13:26:22 +010016 cflags = ["-Wno-attributes","-Wno-unused-function","-Wno-unused-variable","-Wno-implicit-function-declaration",config.cflags,"-D__GNUC_PYTHON__"]
Christophe Favergeon53f828f2019-03-25 13:42:44 +010017
18transform = glob.glob(os.path.join(ROOT,"Source","TransformFunctions","*.c"))
Christophe Favergeon9e284082019-05-23 09:08:30 +020019#transform.remove(os.path.join(ROOT,"Source","TransformFunctions","arm_dct4_init_q15.c"))
20#transform.remove(os.path.join(ROOT,"Source","TransformFunctions","arm_rfft_init_q15.c"))
Christophe Favergeon53f828f2019-03-25 13:42:44 +010021transform.remove(os.path.join(ROOT,"Source","TransformFunctions","TransformFunctions.c"))
Christophe Favergeon2f12ed82020-07-22 09:10:21 +020022transform.remove(os.path.join(ROOT,"Source","TransformFunctions","TransformFunctionsF16.c"))
Christophe Favergeon53f828f2019-03-25 13:42:44 +010023
24support = glob.glob(os.path.join(ROOT,"Source","SupportFunctions","*.c"))
25support.remove(os.path.join(ROOT,"Source","SupportFunctions","SupportFunctions.c"))
Christophe Favergeon9e773df2020-08-10 10:55:47 +020026support.remove(os.path.join(ROOT,"Source","SupportFunctions","SupportFunctionsF16.c"))
Christophe Favergeon53f828f2019-03-25 13:42:44 +010027
28fastmath = glob.glob(os.path.join(ROOT,"Source","FastMathFunctions","*.c"))
29fastmath.remove(os.path.join(ROOT,"Source","FastMathFunctions","FastMathFunctions.c"))
30
31filtering = glob.glob(os.path.join(ROOT,"Source","FilteringFunctions","*.c"))
32filtering.remove(os.path.join(ROOT,"Source","FilteringFunctions","FilteringFunctions.c"))
Christophe Favergeon626af7e2020-08-05 07:28:13 +020033filtering.remove(os.path.join(ROOT,"Source","FilteringFunctions","FilteringFunctionsF16.c"))
Christophe Favergeon53f828f2019-03-25 13:42:44 +010034
35matrix = glob.glob(os.path.join(ROOT,"Source","MatrixFunctions","*.c"))
36matrix.remove(os.path.join(ROOT,"Source","MatrixFunctions","MatrixFunctions.c"))
Christophe Favergeon116bc4d2020-08-06 11:00:40 +020037matrix.remove(os.path.join(ROOT,"Source","MatrixFunctions","MatrixFunctionsF16.c"))
Christophe Favergeon53f828f2019-03-25 13:42:44 +010038
39statistics = glob.glob(os.path.join(ROOT,"Source","StatisticsFunctions","*.c"))
40statistics.remove(os.path.join(ROOT,"Source","StatisticsFunctions","StatisticsFunctions.c"))
Christophe Favergeon18a5fbc2020-08-07 11:18:02 +020041statistics.remove(os.path.join(ROOT,"Source","StatisticsFunctions","StatisticsFunctionsF16.c"))
Christophe Favergeon53f828f2019-03-25 13:42:44 +010042
43complexf = glob.glob(os.path.join(ROOT,"Source","ComplexMathFunctions","*.c"))
44complexf.remove(os.path.join(ROOT,"Source","ComplexMathFunctions","ComplexMathFunctions.c"))
Christophe Favergeon626af7e2020-08-05 07:28:13 +020045complexf.remove(os.path.join(ROOT,"Source","ComplexMathFunctions","ComplexMathFunctionsF16.c"))
Christophe Favergeon53f828f2019-03-25 13:42:44 +010046
47basic = glob.glob(os.path.join(ROOT,"Source","BasicMathFunctions","*.c"))
48basic.remove(os.path.join(ROOT,"Source","BasicMathFunctions","BasicMathFunctions.c"))
Christophe Favergeon2f12ed82020-07-22 09:10:21 +020049basic.remove(os.path.join(ROOT,"Source","BasicMathFunctions","BasicMathFunctionsF16.c"))
Christophe Favergeon53f828f2019-03-25 13:42:44 +010050
51controller = glob.glob(os.path.join(ROOT,"Source","ControllerFunctions","*.c"))
52controller.remove(os.path.join(ROOT,"Source","ControllerFunctions","ControllerFunctions.c"))
53
Christophe Favergeon9e284082019-05-23 09:08:30 +020054common = glob.glob(os.path.join(ROOT,"Source","CommonTables","*.c"))
55common.remove(os.path.join(ROOT,"Source","CommonTables","CommonTables.c"))
Christophe Favergeon729752f2020-08-07 11:50:27 +020056common.remove(os.path.join(ROOT,"Source","CommonTables","CommonTablesF16.c"))
Christophe Favergeon53f828f2019-03-25 13:42:44 +010057
Christophe Favergeon2f12ed82020-07-22 09:10:21 +020058interpolation = glob.glob(os.path.join(ROOT,"Source","InterpolationFunctions","*.c"))
59interpolation.remove(os.path.join(ROOT,"Source","InterpolationFunctions","InterpolationFunctions.c"))
Christophe Favergeonc7935882020-08-06 13:14:33 +020060interpolation.remove(os.path.join(ROOT,"Source","InterpolationFunctions","InterpolationFunctionsF16.c"))
Christophe Favergeon2f12ed82020-07-22 09:10:21 +020061
Christophe Favergeon18383772021-04-30 15:00:14 +020062quaternion = glob.glob(os.path.join(ROOT,"Source","QuaternionMathFunctions","*.c"))
63quaternion.remove(os.path.join(ROOT,"Source","QuaternionMathFunctions","QuaternionMathFunctions.c"))
64
65#distance = glob.glob(os.path.join(ROOT,"Source","DistanceFunctions","*.c"))
66#distance.remove(os.path.join(ROOT,"Source","DistanceFunctions","DistanceFunctions.c"))
67
68
Christophe Favergeon9e284082019-05-23 09:08:30 +020069#modulesrc = glob.glob(os.path.join("cmsisdsp_pkg","src","*.c"))
70modulesrc = []
Christophe Favergeon9e284082019-05-23 09:08:30 +020071modulesrc.append(os.path.join("cmsisdsp_pkg","src","cmsismodule.c"))
Christophe Favergeon53f828f2019-03-25 13:42:44 +010072
Christophe Favergeon729752f2020-08-07 11:50:27 +020073allsrcs = support + fastmath + filtering + matrix + statistics + complexf + basic
74allsrcs = allsrcs + controller + transform + modulesrc + common+ interpolation
Christophe Favergeon18383772021-04-30 15:00:14 +020075allsrcs = allsrcs + quaternion
Christophe Favergeon729752f2020-08-07 11:50:27 +020076
Christophe Favergeon19dc9522021-09-22 15:37:22 +020077missing=set(["arm_abs_f64"
78,"arm_absmax_f64"
79,"arm_absmin_f64"
80,"arm_add_f64"
81,"arm_barycenter_f32"
82,"arm_braycurtis_distance_f32"
83,"arm_canberra_distance_f32"
84,"arm_chebyshev_distance_f32"
85,"arm_chebyshev_distance_f64"
86,"arm_circularRead_f32"
87,"arm_cityblock_distance_f32"
88,"arm_cityblock_distance_f64"
89,"arm_cmplx_mag_f64"
90,"arm_cmplx_mag_squared_f64"
91,"arm_cmplx_mult_cmplx_f64"
92,"arm_copy_f64"
93,"arm_correlate_f64"
94,"arm_correlation_distance_f32"
95,"arm_cosine_distance_f32"
96,"arm_cosine_distance_f64"
97,"arm_dot_prod_f64"
98,"arm_entropy_f32"
99,"arm_entropy_f64"
100,"arm_euclidean_distance_f32"
101,"arm_euclidean_distance_f64"
102,"arm_exponent_f32"
103,"arm_fill_f64"
104,"arm_fir_f64"
105,"arm_fir_init_f64"
106,"arm_gaussian_naive_bayes_predict_f32"
107,"arm_jensenshannon_distance_f32"
108,"arm_kullback_leibler_f32"
109,"arm_kullback_leibler_f64"
110,"arm_logsumexp_dot_prod_f32"
111,"arm_logsumexp_f32"
112,"arm_mat_cholesky_f32"
113,"arm_mat_cholesky_f64"
114,"arm_mat_init_f32"
115,"arm_mat_ldlt_f32"
116,"arm_mat_ldlt_f64"
117,"arm_mat_mult_f64"
118,"arm_mat_solve_lower_triangular_f32"
119,"arm_mat_solve_lower_triangular_f64"
120,"arm_mat_solve_upper_triangular_f32"
121,"arm_mat_solve_upper_triangular_f64"
122,"arm_mat_sub_f64"
123,"arm_mat_trans_f64"
124,"arm_max_f64"
125,"arm_max_no_idx_f32"
126,"arm_max_no_idx_f64"
127,"arm_mean_f64"
128,"arm_merge_sort_f32"
129,"arm_merge_sort_init_f32"
130,"arm_min_f64"
131,"arm_minkowski_distance_f32"
132,"arm_mult_f64"
133,"arm_negate_f64"
134,"arm_offset_f64"
135,"arm_power_f64"
136,"arm_scale_f64"
137,"arm_sort_f32"
138,"arm_sort_init_f32"
139,"arm_spline_f32"
140,"arm_spline_init_f32"
141,"arm_std_f64"
142,"arm_sub_f64"
143,"arm_svm_linear_init_f32"
144,"arm_svm_linear_predict_f32"
145,"arm_svm_polynomial_init_f32"
146,"arm_svm_polynomial_predict_f32"
147,"arm_svm_rbf_init_f32"
148,"arm_svm_rbf_predict_f32"
149,"arm_svm_sigmoid_init_f32"
150,"arm_svm_sigmoid_predict_f32"
151,"arm_var_f64"
152,"arm_vexp_f32"
153,"arm_vexp_f64"
154,"arm_vlog_f64"
155,"arm_vsqrt_f32"
156,"arm_weighted_sum_f32"
157,"arm_circularRead_q15"
158,"arm_circularRead_q7"
159,"arm_div_q63_to_q31"
160,"arm_fir_sparse_q15"
161,"arm_fir_sparse_q31"
162,"arm_fir_sparse_q7"
163,"arm_mat_init_q15"
164,"arm_mat_init_q31"
165,"arm_vsqrt_q15"
166,"arm_vsqrt_q31"])
167
Christophe Favergeon729752f2020-08-07 11:50:27 +0200168def notf16(number):
Christophe Favergeona614de92021-01-20 13:26:22 +0100169 if re.search(r'f16',number):
Christophe Favergeon729752f2020-08-07 11:50:27 +0200170 return(False)
Christophe Favergeona614de92021-01-20 13:26:22 +0100171 if re.search(r'F16',number):
172 return(False)
173 return(True)
Christophe Favergeon729752f2020-08-07 11:50:27 +0200174
Christophe Favergeon19dc9522021-09-22 15:37:22 +0200175def isnotmissing(src):
176 name=os.path.splitext(os.path.basename(src))[0]
177 return(not (name in missing))
178
Christophe Favergeona614de92021-01-20 13:26:22 +0100179# If there are too many files, the linker command is failing on Windows.
Christophe Favergeon729752f2020-08-07 11:50:27 +0200180# So f16 functions are removed since they are not currently available in the wrapper.
181# A next version will have to structure this wrapper more cleanly so that the
182# build can work even with more functions
Christophe Favergeon19dc9522021-09-22 15:37:22 +0200183srcs = list(filter(isnotmissing,list(filter(notf16, allsrcs))))
184
Christophe Favergeon729752f2020-08-07 11:50:27 +0200185
Christophe Favergeon53f828f2019-03-25 13:42:44 +0100186module1 = Extension(config.extensionName,
Christophe Favergeon729752f2020-08-07 11:50:27 +0200187 sources = (srcs
Christophe Favergeon53f828f2019-03-25 13:42:44 +0100188 )
189 ,
190 include_dirs = includes + [numpy.get_include()],
191 #extra_compile_args = ["-Wno-unused-variable","-Wno-implicit-function-declaration",config.cflags]
192 extra_compile_args = cflags
193 )
194
195setup (name = config.setupName,
Christophe Favergeon18383772021-04-30 15:00:14 +0200196 version = '1.0.0',
Christophe Favergeone7de2432021-09-07 13:28:35 +0200197 packages=['cmsisdsp'],
Christophe Favergeon53f828f2019-03-25 13:42:44 +0100198 description = config.setupDescription,
199 ext_modules = [module1],
Christophe Favergeon18383772021-04-30 15:00:14 +0200200 author = 'Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved.',
Christophe Favergeon53f828f2019-03-25 13:42:44 +0100201 url="https://github.com/ARM-software/CMSIS_5",
202 classifiers=[
203 "Programming Language :: Python",
204 "License :: OSI Approved :: Apache Software License",
205 "Operating System :: OS Independent",
Chris Knorowski chris.knorowski@sensiml.com25124162019-08-19 12:37:17 -0700206 ])