blob: defb900c7b643b97a28033f40b4121d765f41b44 [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"))
Christophe Favergeon9e773df2020-08-10 10:55:47 +020028support.remove(os.path.join(ROOT,"Source","SupportFunctions","SupportFunctionsF16.c"))
Christophe Favergeon53f828f2019-03-25 13:42:44 +010029
30fastmath = glob.glob(os.path.join(ROOT,"Source","FastMathFunctions","*.c"))
31fastmath.remove(os.path.join(ROOT,"Source","FastMathFunctions","FastMathFunctions.c"))
32
33filtering = glob.glob(os.path.join(ROOT,"Source","FilteringFunctions","*.c"))
34filtering.remove(os.path.join(ROOT,"Source","FilteringFunctions","FilteringFunctions.c"))
Christophe Favergeon626af7e2020-08-05 07:28:13 +020035filtering.remove(os.path.join(ROOT,"Source","FilteringFunctions","FilteringFunctionsF16.c"))
Christophe Favergeon53f828f2019-03-25 13:42:44 +010036
37matrix = glob.glob(os.path.join(ROOT,"Source","MatrixFunctions","*.c"))
38matrix.remove(os.path.join(ROOT,"Source","MatrixFunctions","MatrixFunctions.c"))
Christophe Favergeon116bc4d2020-08-06 11:00:40 +020039matrix.remove(os.path.join(ROOT,"Source","MatrixFunctions","MatrixFunctionsF16.c"))
Christophe Favergeon53f828f2019-03-25 13:42:44 +010040
41statistics = glob.glob(os.path.join(ROOT,"Source","StatisticsFunctions","*.c"))
42statistics.remove(os.path.join(ROOT,"Source","StatisticsFunctions","StatisticsFunctions.c"))
Christophe Favergeon18a5fbc2020-08-07 11:18:02 +020043statistics.remove(os.path.join(ROOT,"Source","StatisticsFunctions","StatisticsFunctionsF16.c"))
Christophe Favergeon53f828f2019-03-25 13:42:44 +010044
45complexf = glob.glob(os.path.join(ROOT,"Source","ComplexMathFunctions","*.c"))
46complexf.remove(os.path.join(ROOT,"Source","ComplexMathFunctions","ComplexMathFunctions.c"))
Christophe Favergeon626af7e2020-08-05 07:28:13 +020047complexf.remove(os.path.join(ROOT,"Source","ComplexMathFunctions","ComplexMathFunctionsF16.c"))
Christophe Favergeon53f828f2019-03-25 13:42:44 +010048
49basic = glob.glob(os.path.join(ROOT,"Source","BasicMathFunctions","*.c"))
50basic.remove(os.path.join(ROOT,"Source","BasicMathFunctions","BasicMathFunctions.c"))
Christophe Favergeon2f12ed82020-07-22 09:10:21 +020051basic.remove(os.path.join(ROOT,"Source","BasicMathFunctions","BasicMathFunctionsF16.c"))
Christophe Favergeon53f828f2019-03-25 13:42:44 +010052
53controller = glob.glob(os.path.join(ROOT,"Source","ControllerFunctions","*.c"))
54controller.remove(os.path.join(ROOT,"Source","ControllerFunctions","ControllerFunctions.c"))
55
Christophe Favergeon9e284082019-05-23 09:08:30 +020056common = glob.glob(os.path.join(ROOT,"Source","CommonTables","*.c"))
57common.remove(os.path.join(ROOT,"Source","CommonTables","CommonTables.c"))
Christophe Favergeon729752f2020-08-07 11:50:27 +020058common.remove(os.path.join(ROOT,"Source","CommonTables","CommonTablesF16.c"))
Christophe Favergeon53f828f2019-03-25 13:42:44 +010059
Christophe Favergeon2f12ed82020-07-22 09:10:21 +020060interpolation = glob.glob(os.path.join(ROOT,"Source","InterpolationFunctions","*.c"))
61interpolation.remove(os.path.join(ROOT,"Source","InterpolationFunctions","InterpolationFunctions.c"))
Christophe Favergeonc7935882020-08-06 13:14:33 +020062interpolation.remove(os.path.join(ROOT,"Source","InterpolationFunctions","InterpolationFunctionsF16.c"))
Christophe Favergeon2f12ed82020-07-22 09:10:21 +020063
Christophe Favergeon9e284082019-05-23 09:08:30 +020064#modulesrc = glob.glob(os.path.join("cmsisdsp_pkg","src","*.c"))
65modulesrc = []
Christophe Favergeon9e284082019-05-23 09:08:30 +020066modulesrc.append(os.path.join("cmsisdsp_pkg","src","cmsismodule.c"))
Christophe Favergeon53f828f2019-03-25 13:42:44 +010067
Christophe Favergeon729752f2020-08-07 11:50:27 +020068allsrcs = support + fastmath + filtering + matrix + statistics + complexf + basic
69allsrcs = allsrcs + controller + transform + modulesrc + common+ interpolation
70
71def notf16(number):
72 if re.match(r'^.*_f16.c$',number):
73 return(False)
74 else:
75 return(True)
76
77# If there are too many files, the linker command in failing on Windows.
78# So f16 functions are removed since they are not currently available in the wrapper.
79# A next version will have to structure this wrapper more cleanly so that the
80# build can work even with more functions
81srcs = list(filter(notf16, allsrcs))
82
83
Christophe Favergeon53f828f2019-03-25 13:42:44 +010084module1 = Extension(config.extensionName,
Christophe Favergeon729752f2020-08-07 11:50:27 +020085 sources = (srcs
Christophe Favergeon53f828f2019-03-25 13:42:44 +010086 )
87 ,
88 include_dirs = includes + [numpy.get_include()],
89 #extra_compile_args = ["-Wno-unused-variable","-Wno-implicit-function-declaration",config.cflags]
90 extra_compile_args = cflags
91 )
92
93setup (name = config.setupName,
94 version = '0.0.1',
95 description = config.setupDescription,
96 ext_modules = [module1],
Christophe Favergeon729752f2020-08-07 11:50:27 +020097 author = 'Copyright (C) 2010-2020 ARM Limited or its affiliates. All rights reserved.',
Christophe Favergeon53f828f2019-03-25 13:42:44 +010098 url="https://github.com/ARM-software/CMSIS_5",
99 classifiers=[
100 "Programming Language :: Python",
101 "License :: OSI Approved :: Apache Software License",
102 "Operating System :: OS Independent",
Chris Knorowski chris.knorowski@sensiml.com25124162019-08-19 12:37:17 -0700103 ])