blob: a0b3d999bec6d102347db408cc4589ed4eda79d7 [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 Favergeon18383772021-04-30 15:00:14 +020061quaternion = glob.glob(os.path.join(ROOT,"Source","QuaternionMathFunctions","*.c"))
62quaternion.remove(os.path.join(ROOT,"Source","QuaternionMathFunctions","QuaternionMathFunctions.c"))
63
64#distance = glob.glob(os.path.join(ROOT,"Source","DistanceFunctions","*.c"))
65#distance.remove(os.path.join(ROOT,"Source","DistanceFunctions","DistanceFunctions.c"))
66
67
Christophe Favergeon9e284082019-05-23 09:08:30 +020068#modulesrc = glob.glob(os.path.join("cmsisdsp_pkg","src","*.c"))
69modulesrc = []
Christophe Favergeon9e284082019-05-23 09:08:30 +020070modulesrc.append(os.path.join("cmsisdsp_pkg","src","cmsismodule.c"))
Christophe Favergeon53f828f2019-03-25 13:42:44 +010071
Christophe Favergeon729752f2020-08-07 11:50:27 +020072allsrcs = support + fastmath + filtering + matrix + statistics + complexf + basic
73allsrcs = allsrcs + controller + transform + modulesrc + common+ interpolation
Christophe Favergeon18383772021-04-30 15:00:14 +020074allsrcs = allsrcs + quaternion
Christophe Favergeon729752f2020-08-07 11:50:27 +020075
76def notf16(number):
Christophe Favergeona614de92021-01-20 13:26:22 +010077 if re.search(r'f16',number):
Christophe Favergeon729752f2020-08-07 11:50:27 +020078 return(False)
Christophe Favergeona614de92021-01-20 13:26:22 +010079 if re.search(r'F16',number):
80 return(False)
81 return(True)
Christophe Favergeon729752f2020-08-07 11:50:27 +020082
Christophe Favergeona614de92021-01-20 13:26:22 +010083# If there are too many files, the linker command is failing on Windows.
Christophe Favergeon729752f2020-08-07 11:50:27 +020084# So f16 functions are removed since they are not currently available in the wrapper.
85# A next version will have to structure this wrapper more cleanly so that the
86# build can work even with more functions
87srcs = list(filter(notf16, allsrcs))
88
Christophe Favergeon53f828f2019-03-25 13:42:44 +010089module1 = Extension(config.extensionName,
Christophe Favergeon729752f2020-08-07 11:50:27 +020090 sources = (srcs
Christophe Favergeon53f828f2019-03-25 13:42:44 +010091 )
92 ,
93 include_dirs = includes + [numpy.get_include()],
94 #extra_compile_args = ["-Wno-unused-variable","-Wno-implicit-function-declaration",config.cflags]
95 extra_compile_args = cflags
96 )
97
98setup (name = config.setupName,
Christophe Favergeon18383772021-04-30 15:00:14 +020099 version = '1.0.0',
Christophe Favergeon53f828f2019-03-25 13:42:44 +0100100 description = config.setupDescription,
101 ext_modules = [module1],
Christophe Favergeon18383772021-04-30 15:00:14 +0200102 author = 'Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved.',
Christophe Favergeon53f828f2019-03-25 13:42:44 +0100103 url="https://github.com/ARM-software/CMSIS_5",
104 classifiers=[
105 "Programming Language :: Python",
106 "License :: OSI Approved :: Apache Software License",
107 "Operating System :: OS Independent",
Chris Knorowski chris.knorowski@sensiml.com25124162019-08-19 12:37:17 -0700108 ])