blob: 2d6b8ccf56e954b0169f1e022db489922dce00c1 [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
7from config import ROOT
Christophe Favergeon729752f2020-08-07 11:50:27 +02008import re
Christophe Favergeon53f828f2019-03-25 13:42:44 +01009
Christophe Favergeonaefd2772020-01-08 09:01:17 +010010includes = [os.path.join(ROOT,"Include"),os.path.join(ROOT,"PrivateInclude"),os.path.join("cmsisdsp_pkg","src")]
Christophe Favergeon53f828f2019-03-25 13:42:44 +010011
12if sys.platform == 'win32':
13 cflags = ["-DWIN",config.cflags,"-DUNALIGNED_SUPPORT_DISABLE"]
Christophe Favergeon53f828f2019-03-25 13:42:44 +010014else:
Christophe Favergeona614de92021-01-20 13:26:22 +010015 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 +010016
17transform = glob.glob(os.path.join(ROOT,"Source","TransformFunctions","*.c"))
Christophe Favergeon9e284082019-05-23 09:08:30 +020018#transform.remove(os.path.join(ROOT,"Source","TransformFunctions","arm_dct4_init_q15.c"))
19#transform.remove(os.path.join(ROOT,"Source","TransformFunctions","arm_rfft_init_q15.c"))
Christophe Favergeon53f828f2019-03-25 13:42:44 +010020transform.remove(os.path.join(ROOT,"Source","TransformFunctions","TransformFunctions.c"))
Christophe Favergeon2f12ed82020-07-22 09:10:21 +020021transform.remove(os.path.join(ROOT,"Source","TransformFunctions","TransformFunctionsF16.c"))
Christophe Favergeon53f828f2019-03-25 13:42:44 +010022
23support = glob.glob(os.path.join(ROOT,"Source","SupportFunctions","*.c"))
24support.remove(os.path.join(ROOT,"Source","SupportFunctions","SupportFunctions.c"))
Christophe Favergeon9e773df2020-08-10 10:55:47 +020025support.remove(os.path.join(ROOT,"Source","SupportFunctions","SupportFunctionsF16.c"))
Christophe Favergeon53f828f2019-03-25 13:42:44 +010026
27fastmath = glob.glob(os.path.join(ROOT,"Source","FastMathFunctions","*.c"))
28fastmath.remove(os.path.join(ROOT,"Source","FastMathFunctions","FastMathFunctions.c"))
29
30filtering = glob.glob(os.path.join(ROOT,"Source","FilteringFunctions","*.c"))
31filtering.remove(os.path.join(ROOT,"Source","FilteringFunctions","FilteringFunctions.c"))
Christophe Favergeon626af7e2020-08-05 07:28:13 +020032filtering.remove(os.path.join(ROOT,"Source","FilteringFunctions","FilteringFunctionsF16.c"))
Christophe Favergeon53f828f2019-03-25 13:42:44 +010033
34matrix = glob.glob(os.path.join(ROOT,"Source","MatrixFunctions","*.c"))
35matrix.remove(os.path.join(ROOT,"Source","MatrixFunctions","MatrixFunctions.c"))
Christophe Favergeon116bc4d2020-08-06 11:00:40 +020036matrix.remove(os.path.join(ROOT,"Source","MatrixFunctions","MatrixFunctionsF16.c"))
Christophe Favergeon53f828f2019-03-25 13:42:44 +010037
38statistics = glob.glob(os.path.join(ROOT,"Source","StatisticsFunctions","*.c"))
39statistics.remove(os.path.join(ROOT,"Source","StatisticsFunctions","StatisticsFunctions.c"))
Christophe Favergeon18a5fbc2020-08-07 11:18:02 +020040statistics.remove(os.path.join(ROOT,"Source","StatisticsFunctions","StatisticsFunctionsF16.c"))
Christophe Favergeon53f828f2019-03-25 13:42:44 +010041
42complexf = glob.glob(os.path.join(ROOT,"Source","ComplexMathFunctions","*.c"))
43complexf.remove(os.path.join(ROOT,"Source","ComplexMathFunctions","ComplexMathFunctions.c"))
Christophe Favergeon626af7e2020-08-05 07:28:13 +020044complexf.remove(os.path.join(ROOT,"Source","ComplexMathFunctions","ComplexMathFunctionsF16.c"))
Christophe Favergeon53f828f2019-03-25 13:42:44 +010045
46basic = glob.glob(os.path.join(ROOT,"Source","BasicMathFunctions","*.c"))
47basic.remove(os.path.join(ROOT,"Source","BasicMathFunctions","BasicMathFunctions.c"))
Christophe Favergeon2f12ed82020-07-22 09:10:21 +020048basic.remove(os.path.join(ROOT,"Source","BasicMathFunctions","BasicMathFunctionsF16.c"))
Christophe Favergeon53f828f2019-03-25 13:42:44 +010049
50controller = glob.glob(os.path.join(ROOT,"Source","ControllerFunctions","*.c"))
51controller.remove(os.path.join(ROOT,"Source","ControllerFunctions","ControllerFunctions.c"))
52
Christophe Favergeon9e284082019-05-23 09:08:30 +020053common = glob.glob(os.path.join(ROOT,"Source","CommonTables","*.c"))
54common.remove(os.path.join(ROOT,"Source","CommonTables","CommonTables.c"))
Christophe Favergeon729752f2020-08-07 11:50:27 +020055common.remove(os.path.join(ROOT,"Source","CommonTables","CommonTablesF16.c"))
Christophe Favergeon53f828f2019-03-25 13:42:44 +010056
Christophe Favergeon2f12ed82020-07-22 09:10:21 +020057interpolation = glob.glob(os.path.join(ROOT,"Source","InterpolationFunctions","*.c"))
58interpolation.remove(os.path.join(ROOT,"Source","InterpolationFunctions","InterpolationFunctions.c"))
Christophe Favergeonc7935882020-08-06 13:14:33 +020059interpolation.remove(os.path.join(ROOT,"Source","InterpolationFunctions","InterpolationFunctionsF16.c"))
Christophe Favergeon2f12ed82020-07-22 09:10:21 +020060
Christophe Favergeon9e284082019-05-23 09:08:30 +020061#modulesrc = glob.glob(os.path.join("cmsisdsp_pkg","src","*.c"))
62modulesrc = []
Christophe Favergeon9e284082019-05-23 09:08:30 +020063modulesrc.append(os.path.join("cmsisdsp_pkg","src","cmsismodule.c"))
Christophe Favergeon53f828f2019-03-25 13:42:44 +010064
Christophe Favergeon729752f2020-08-07 11:50:27 +020065allsrcs = support + fastmath + filtering + matrix + statistics + complexf + basic
66allsrcs = allsrcs + controller + transform + modulesrc + common+ interpolation
67
68def notf16(number):
Christophe Favergeona614de92021-01-20 13:26:22 +010069 if re.search(r'f16',number):
Christophe Favergeon729752f2020-08-07 11:50:27 +020070 return(False)
Christophe Favergeona614de92021-01-20 13:26:22 +010071 if re.search(r'F16',number):
72 return(False)
73 return(True)
Christophe Favergeon729752f2020-08-07 11:50:27 +020074
Christophe Favergeona614de92021-01-20 13:26:22 +010075# If there are too many files, the linker command is failing on Windows.
Christophe Favergeon729752f2020-08-07 11:50:27 +020076# So f16 functions are removed since they are not currently available in the wrapper.
77# A next version will have to structure this wrapper more cleanly so that the
78# build can work even with more functions
79srcs = list(filter(notf16, allsrcs))
80
Christophe Favergeon53f828f2019-03-25 13:42:44 +010081module1 = Extension(config.extensionName,
Christophe Favergeon729752f2020-08-07 11:50:27 +020082 sources = (srcs
Christophe Favergeon53f828f2019-03-25 13:42:44 +010083 )
84 ,
85 include_dirs = includes + [numpy.get_include()],
86 #extra_compile_args = ["-Wno-unused-variable","-Wno-implicit-function-declaration",config.cflags]
87 extra_compile_args = cflags
88 )
89
90setup (name = config.setupName,
91 version = '0.0.1',
92 description = config.setupDescription,
93 ext_modules = [module1],
Christophe Favergeon729752f2020-08-07 11:50:27 +020094 author = 'Copyright (C) 2010-2020 ARM Limited or its affiliates. All rights reserved.',
Christophe Favergeon53f828f2019-03-25 13:42:44 +010095 url="https://github.com/ARM-software/CMSIS_5",
96 classifiers=[
97 "Programming Language :: Python",
98 "License :: OSI Approved :: Apache Software License",
99 "Operating System :: OS Independent",
Chris Knorowski chris.knorowski@sensiml.com25124162019-08-19 12:37:17 -0700100 ])