Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 1 | from distutils.core import setup, Extension |
| 2 | import glob |
| 3 | import numpy |
| 4 | import config |
| 5 | import sys |
| 6 | import os |
Christophe Favergeon | 19dc952 | 2021-09-22 15:37:22 +0200 | [diff] [blame^] | 7 | import os.path |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 8 | from config import ROOT |
Christophe Favergeon | 729752f | 2020-08-07 11:50:27 +0200 | [diff] [blame] | 9 | import re |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 10 | |
Christophe Favergeon | aefd277 | 2020-01-08 09:01:17 +0100 | [diff] [blame] | 11 | includes = [os.path.join(ROOT,"Include"),os.path.join(ROOT,"PrivateInclude"),os.path.join("cmsisdsp_pkg","src")] |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 12 | |
| 13 | if sys.platform == 'win32': |
| 14 | cflags = ["-DWIN",config.cflags,"-DUNALIGNED_SUPPORT_DISABLE"] |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 15 | else: |
Christophe Favergeon | a614de9 | 2021-01-20 13:26:22 +0100 | [diff] [blame] | 16 | cflags = ["-Wno-attributes","-Wno-unused-function","-Wno-unused-variable","-Wno-implicit-function-declaration",config.cflags,"-D__GNUC_PYTHON__"] |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 17 | |
| 18 | transform = glob.glob(os.path.join(ROOT,"Source","TransformFunctions","*.c")) |
Christophe Favergeon | 9e28408 | 2019-05-23 09:08:30 +0200 | [diff] [blame] | 19 | #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 Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 21 | transform.remove(os.path.join(ROOT,"Source","TransformFunctions","TransformFunctions.c")) |
Christophe Favergeon | 2f12ed8 | 2020-07-22 09:10:21 +0200 | [diff] [blame] | 22 | transform.remove(os.path.join(ROOT,"Source","TransformFunctions","TransformFunctionsF16.c")) |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 23 | |
| 24 | support = glob.glob(os.path.join(ROOT,"Source","SupportFunctions","*.c")) |
| 25 | support.remove(os.path.join(ROOT,"Source","SupportFunctions","SupportFunctions.c")) |
Christophe Favergeon | 9e773df | 2020-08-10 10:55:47 +0200 | [diff] [blame] | 26 | support.remove(os.path.join(ROOT,"Source","SupportFunctions","SupportFunctionsF16.c")) |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 27 | |
| 28 | fastmath = glob.glob(os.path.join(ROOT,"Source","FastMathFunctions","*.c")) |
| 29 | fastmath.remove(os.path.join(ROOT,"Source","FastMathFunctions","FastMathFunctions.c")) |
| 30 | |
| 31 | filtering = glob.glob(os.path.join(ROOT,"Source","FilteringFunctions","*.c")) |
| 32 | filtering.remove(os.path.join(ROOT,"Source","FilteringFunctions","FilteringFunctions.c")) |
Christophe Favergeon | 626af7e | 2020-08-05 07:28:13 +0200 | [diff] [blame] | 33 | filtering.remove(os.path.join(ROOT,"Source","FilteringFunctions","FilteringFunctionsF16.c")) |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 34 | |
| 35 | matrix = glob.glob(os.path.join(ROOT,"Source","MatrixFunctions","*.c")) |
| 36 | matrix.remove(os.path.join(ROOT,"Source","MatrixFunctions","MatrixFunctions.c")) |
Christophe Favergeon | 116bc4d | 2020-08-06 11:00:40 +0200 | [diff] [blame] | 37 | matrix.remove(os.path.join(ROOT,"Source","MatrixFunctions","MatrixFunctionsF16.c")) |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 38 | |
| 39 | statistics = glob.glob(os.path.join(ROOT,"Source","StatisticsFunctions","*.c")) |
| 40 | statistics.remove(os.path.join(ROOT,"Source","StatisticsFunctions","StatisticsFunctions.c")) |
Christophe Favergeon | 18a5fbc | 2020-08-07 11:18:02 +0200 | [diff] [blame] | 41 | statistics.remove(os.path.join(ROOT,"Source","StatisticsFunctions","StatisticsFunctionsF16.c")) |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 42 | |
| 43 | complexf = glob.glob(os.path.join(ROOT,"Source","ComplexMathFunctions","*.c")) |
| 44 | complexf.remove(os.path.join(ROOT,"Source","ComplexMathFunctions","ComplexMathFunctions.c")) |
Christophe Favergeon | 626af7e | 2020-08-05 07:28:13 +0200 | [diff] [blame] | 45 | complexf.remove(os.path.join(ROOT,"Source","ComplexMathFunctions","ComplexMathFunctionsF16.c")) |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 46 | |
| 47 | basic = glob.glob(os.path.join(ROOT,"Source","BasicMathFunctions","*.c")) |
| 48 | basic.remove(os.path.join(ROOT,"Source","BasicMathFunctions","BasicMathFunctions.c")) |
Christophe Favergeon | 2f12ed8 | 2020-07-22 09:10:21 +0200 | [diff] [blame] | 49 | basic.remove(os.path.join(ROOT,"Source","BasicMathFunctions","BasicMathFunctionsF16.c")) |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 50 | |
| 51 | controller = glob.glob(os.path.join(ROOT,"Source","ControllerFunctions","*.c")) |
| 52 | controller.remove(os.path.join(ROOT,"Source","ControllerFunctions","ControllerFunctions.c")) |
| 53 | |
Christophe Favergeon | 9e28408 | 2019-05-23 09:08:30 +0200 | [diff] [blame] | 54 | common = glob.glob(os.path.join(ROOT,"Source","CommonTables","*.c")) |
| 55 | common.remove(os.path.join(ROOT,"Source","CommonTables","CommonTables.c")) |
Christophe Favergeon | 729752f | 2020-08-07 11:50:27 +0200 | [diff] [blame] | 56 | common.remove(os.path.join(ROOT,"Source","CommonTables","CommonTablesF16.c")) |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 57 | |
Christophe Favergeon | 2f12ed8 | 2020-07-22 09:10:21 +0200 | [diff] [blame] | 58 | interpolation = glob.glob(os.path.join(ROOT,"Source","InterpolationFunctions","*.c")) |
| 59 | interpolation.remove(os.path.join(ROOT,"Source","InterpolationFunctions","InterpolationFunctions.c")) |
Christophe Favergeon | c793588 | 2020-08-06 13:14:33 +0200 | [diff] [blame] | 60 | interpolation.remove(os.path.join(ROOT,"Source","InterpolationFunctions","InterpolationFunctionsF16.c")) |
Christophe Favergeon | 2f12ed8 | 2020-07-22 09:10:21 +0200 | [diff] [blame] | 61 | |
Christophe Favergeon | 1838377 | 2021-04-30 15:00:14 +0200 | [diff] [blame] | 62 | quaternion = glob.glob(os.path.join(ROOT,"Source","QuaternionMathFunctions","*.c")) |
| 63 | quaternion.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 Favergeon | 9e28408 | 2019-05-23 09:08:30 +0200 | [diff] [blame] | 69 | #modulesrc = glob.glob(os.path.join("cmsisdsp_pkg","src","*.c")) |
| 70 | modulesrc = [] |
Christophe Favergeon | 9e28408 | 2019-05-23 09:08:30 +0200 | [diff] [blame] | 71 | modulesrc.append(os.path.join("cmsisdsp_pkg","src","cmsismodule.c")) |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 72 | |
Christophe Favergeon | 729752f | 2020-08-07 11:50:27 +0200 | [diff] [blame] | 73 | allsrcs = support + fastmath + filtering + matrix + statistics + complexf + basic |
| 74 | allsrcs = allsrcs + controller + transform + modulesrc + common+ interpolation |
Christophe Favergeon | 1838377 | 2021-04-30 15:00:14 +0200 | [diff] [blame] | 75 | allsrcs = allsrcs + quaternion |
Christophe Favergeon | 729752f | 2020-08-07 11:50:27 +0200 | [diff] [blame] | 76 | |
Christophe Favergeon | 19dc952 | 2021-09-22 15:37:22 +0200 | [diff] [blame^] | 77 | missing=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 Favergeon | 729752f | 2020-08-07 11:50:27 +0200 | [diff] [blame] | 168 | def notf16(number): |
Christophe Favergeon | a614de9 | 2021-01-20 13:26:22 +0100 | [diff] [blame] | 169 | if re.search(r'f16',number): |
Christophe Favergeon | 729752f | 2020-08-07 11:50:27 +0200 | [diff] [blame] | 170 | return(False) |
Christophe Favergeon | a614de9 | 2021-01-20 13:26:22 +0100 | [diff] [blame] | 171 | if re.search(r'F16',number): |
| 172 | return(False) |
| 173 | return(True) |
Christophe Favergeon | 729752f | 2020-08-07 11:50:27 +0200 | [diff] [blame] | 174 | |
Christophe Favergeon | 19dc952 | 2021-09-22 15:37:22 +0200 | [diff] [blame^] | 175 | def isnotmissing(src): |
| 176 | name=os.path.splitext(os.path.basename(src))[0] |
| 177 | return(not (name in missing)) |
| 178 | |
Christophe Favergeon | a614de9 | 2021-01-20 13:26:22 +0100 | [diff] [blame] | 179 | # If there are too many files, the linker command is failing on Windows. |
Christophe Favergeon | 729752f | 2020-08-07 11:50:27 +0200 | [diff] [blame] | 180 | # 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 Favergeon | 19dc952 | 2021-09-22 15:37:22 +0200 | [diff] [blame^] | 183 | srcs = list(filter(isnotmissing,list(filter(notf16, allsrcs)))) |
| 184 | |
Christophe Favergeon | 729752f | 2020-08-07 11:50:27 +0200 | [diff] [blame] | 185 | |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 186 | module1 = Extension(config.extensionName, |
Christophe Favergeon | 729752f | 2020-08-07 11:50:27 +0200 | [diff] [blame] | 187 | sources = (srcs |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 188 | ) |
| 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 | |
| 195 | setup (name = config.setupName, |
Christophe Favergeon | 1838377 | 2021-04-30 15:00:14 +0200 | [diff] [blame] | 196 | version = '1.0.0', |
Christophe Favergeon | e7de243 | 2021-09-07 13:28:35 +0200 | [diff] [blame] | 197 | packages=['cmsisdsp'], |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 198 | description = config.setupDescription, |
| 199 | ext_modules = [module1], |
Christophe Favergeon | 1838377 | 2021-04-30 15:00:14 +0200 | [diff] [blame] | 200 | author = 'Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved.', |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 201 | 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.com | 2512416 | 2019-08-19 12:37:17 -0700 | [diff] [blame] | 206 | ]) |