blob: 82b8b2a0a92697cce47dde5e5006a42e25961700 [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"]
14 # Custom because a customized arm_math.h is required to build on windows
15 # since the visual compiler and the win platform are
16 # not supported by default in arm_math.h
17else:
Chris Knorowski chris.knorowski@sensiml.com25124162019-08-19 12:37:17 -070018 cflags = ["-Wno-unused-variable","-Wno-implicit-function-declaration",config.cflags,"-D__GNUC_PYTHON__"]
Christophe Favergeon53f828f2019-03-25 13:42:44 +010019
20transform = glob.glob(os.path.join(ROOT,"Source","TransformFunctions","*.c"))
Christophe Favergeon9e284082019-05-23 09:08:30 +020021#transform.remove(os.path.join(ROOT,"Source","TransformFunctions","arm_dct4_init_q15.c"))
22#transform.remove(os.path.join(ROOT,"Source","TransformFunctions","arm_rfft_init_q15.c"))
Christophe Favergeon53f828f2019-03-25 13:42:44 +010023transform.remove(os.path.join(ROOT,"Source","TransformFunctions","TransformFunctions.c"))
Christophe Favergeon2f12ed82020-07-22 09:10:21 +020024transform.remove(os.path.join(ROOT,"Source","TransformFunctions","TransformFunctionsF16.c"))
Christophe Favergeon53f828f2019-03-25 13:42:44 +010025
26support = glob.glob(os.path.join(ROOT,"Source","SupportFunctions","*.c"))
27support.remove(os.path.join(ROOT,"Source","SupportFunctions","SupportFunctions.c"))
28
29fastmath = glob.glob(os.path.join(ROOT,"Source","FastMathFunctions","*.c"))
30fastmath.remove(os.path.join(ROOT,"Source","FastMathFunctions","FastMathFunctions.c"))
31
32filtering = glob.glob(os.path.join(ROOT,"Source","FilteringFunctions","*.c"))
33filtering.remove(os.path.join(ROOT,"Source","FilteringFunctions","FilteringFunctions.c"))
Christophe Favergeon626af7e2020-08-05 07:28:13 +020034filtering.remove(os.path.join(ROOT,"Source","FilteringFunctions","FilteringFunctionsF16.c"))
Christophe Favergeon53f828f2019-03-25 13:42:44 +010035
36matrix = glob.glob(os.path.join(ROOT,"Source","MatrixFunctions","*.c"))
37matrix.remove(os.path.join(ROOT,"Source","MatrixFunctions","MatrixFunctions.c"))
Christophe Favergeon116bc4d2020-08-06 11:00:40 +020038matrix.remove(os.path.join(ROOT,"Source","MatrixFunctions","MatrixFunctionsF16.c"))
Christophe Favergeon53f828f2019-03-25 13:42:44 +010039
40statistics = glob.glob(os.path.join(ROOT,"Source","StatisticsFunctions","*.c"))
41statistics.remove(os.path.join(ROOT,"Source","StatisticsFunctions","StatisticsFunctions.c"))
Christophe Favergeon18a5fbc2020-08-07 11:18:02 +020042statistics.remove(os.path.join(ROOT,"Source","StatisticsFunctions","StatisticsFunctionsF16.c"))
Christophe Favergeon53f828f2019-03-25 13:42:44 +010043
44complexf = glob.glob(os.path.join(ROOT,"Source","ComplexMathFunctions","*.c"))
45complexf.remove(os.path.join(ROOT,"Source","ComplexMathFunctions","ComplexMathFunctions.c"))
Christophe Favergeon626af7e2020-08-05 07:28:13 +020046complexf.remove(os.path.join(ROOT,"Source","ComplexMathFunctions","ComplexMathFunctionsF16.c"))
Christophe Favergeon53f828f2019-03-25 13:42:44 +010047
48basic = glob.glob(os.path.join(ROOT,"Source","BasicMathFunctions","*.c"))
49basic.remove(os.path.join(ROOT,"Source","BasicMathFunctions","BasicMathFunctions.c"))
Christophe Favergeon2f12ed82020-07-22 09:10:21 +020050basic.remove(os.path.join(ROOT,"Source","BasicMathFunctions","BasicMathFunctionsF16.c"))
Christophe Favergeon53f828f2019-03-25 13:42:44 +010051
52controller = glob.glob(os.path.join(ROOT,"Source","ControllerFunctions","*.c"))
53controller.remove(os.path.join(ROOT,"Source","ControllerFunctions","ControllerFunctions.c"))
54
Christophe Favergeon9e284082019-05-23 09:08:30 +020055common = glob.glob(os.path.join(ROOT,"Source","CommonTables","*.c"))
56common.remove(os.path.join(ROOT,"Source","CommonTables","CommonTables.c"))
Christophe Favergeon729752f2020-08-07 11:50:27 +020057common.remove(os.path.join(ROOT,"Source","CommonTables","CommonTablesF16.c"))
Christophe Favergeon53f828f2019-03-25 13:42:44 +010058
Christophe Favergeon2f12ed82020-07-22 09:10:21 +020059interpolation = glob.glob(os.path.join(ROOT,"Source","InterpolationFunctions","*.c"))
60interpolation.remove(os.path.join(ROOT,"Source","InterpolationFunctions","InterpolationFunctions.c"))
Christophe Favergeonc7935882020-08-06 13:14:33 +020061interpolation.remove(os.path.join(ROOT,"Source","InterpolationFunctions","InterpolationFunctionsF16.c"))
Christophe Favergeon2f12ed82020-07-22 09:10:21 +020062
Christophe Favergeon9e284082019-05-23 09:08:30 +020063#modulesrc = glob.glob(os.path.join("cmsisdsp_pkg","src","*.c"))
64modulesrc = []
Christophe Favergeon9e284082019-05-23 09:08:30 +020065modulesrc.append(os.path.join("cmsisdsp_pkg","src","cmsismodule.c"))
Christophe Favergeon53f828f2019-03-25 13:42:44 +010066
Christophe Favergeon729752f2020-08-07 11:50:27 +020067allsrcs = support + fastmath + filtering + matrix + statistics + complexf + basic
68allsrcs = allsrcs + controller + transform + modulesrc + common+ interpolation
69
70def notf16(number):
71 if re.match(r'^.*_f16.c$',number):
72 return(False)
73 else:
74 return(True)
75
76# If there are too many files, the linker command in failing on Windows.
77# So f16 functions are removed since they are not currently available in the wrapper.
78# A next version will have to structure this wrapper more cleanly so that the
79# build can work even with more functions
80srcs = list(filter(notf16, allsrcs))
81
82
Christophe Favergeon53f828f2019-03-25 13:42:44 +010083module1 = Extension(config.extensionName,
Christophe Favergeon729752f2020-08-07 11:50:27 +020084 sources = (srcs
Christophe Favergeon53f828f2019-03-25 13:42:44 +010085 )
86 ,
87 include_dirs = includes + [numpy.get_include()],
88 #extra_compile_args = ["-Wno-unused-variable","-Wno-implicit-function-declaration",config.cflags]
89 extra_compile_args = cflags
90 )
91
92setup (name = config.setupName,
93 version = '0.0.1',
94 description = config.setupDescription,
95 ext_modules = [module1],
Christophe Favergeon729752f2020-08-07 11:50:27 +020096 author = 'Copyright (C) 2010-2020 ARM Limited or its affiliates. All rights reserved.',
Christophe Favergeon53f828f2019-03-25 13:42:44 +010097 url="https://github.com/ARM-software/CMSIS_5",
98 classifiers=[
99 "Programming Language :: Python",
100 "License :: OSI Approved :: Apache Software License",
101 "Operating System :: OS Independent",
Chris Knorowski chris.knorowski@sensiml.com25124162019-08-19 12:37:17 -0700102 ])