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 |
| 7 | from config import ROOT |
Christophe Favergeon | 729752f | 2020-08-07 11:50:27 +0200 | [diff] [blame^] | 8 | import re |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 9 | |
Christophe Favergeon | aefd277 | 2020-01-08 09:01:17 +0100 | [diff] [blame] | 10 | 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] | 11 | |
| 12 | if 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 |
| 17 | else: |
Chris Knorowski chris.knorowski@sensiml.com | 2512416 | 2019-08-19 12:37:17 -0700 | [diff] [blame] | 18 | cflags = ["-Wno-unused-variable","-Wno-implicit-function-declaration",config.cflags,"-D__GNUC_PYTHON__"] |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 19 | |
| 20 | transform = glob.glob(os.path.join(ROOT,"Source","TransformFunctions","*.c")) |
Christophe Favergeon | 9e28408 | 2019-05-23 09:08:30 +0200 | [diff] [blame] | 21 | #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 Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 23 | transform.remove(os.path.join(ROOT,"Source","TransformFunctions","TransformFunctions.c")) |
Christophe Favergeon | 2f12ed8 | 2020-07-22 09:10:21 +0200 | [diff] [blame] | 24 | transform.remove(os.path.join(ROOT,"Source","TransformFunctions","TransformFunctionsF16.c")) |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 25 | |
| 26 | support = glob.glob(os.path.join(ROOT,"Source","SupportFunctions","*.c")) |
| 27 | support.remove(os.path.join(ROOT,"Source","SupportFunctions","SupportFunctions.c")) |
| 28 | |
| 29 | fastmath = glob.glob(os.path.join(ROOT,"Source","FastMathFunctions","*.c")) |
| 30 | fastmath.remove(os.path.join(ROOT,"Source","FastMathFunctions","FastMathFunctions.c")) |
| 31 | |
| 32 | filtering = glob.glob(os.path.join(ROOT,"Source","FilteringFunctions","*.c")) |
| 33 | filtering.remove(os.path.join(ROOT,"Source","FilteringFunctions","FilteringFunctions.c")) |
Christophe Favergeon | 626af7e | 2020-08-05 07:28:13 +0200 | [diff] [blame] | 34 | filtering.remove(os.path.join(ROOT,"Source","FilteringFunctions","FilteringFunctionsF16.c")) |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 35 | |
| 36 | matrix = glob.glob(os.path.join(ROOT,"Source","MatrixFunctions","*.c")) |
| 37 | matrix.remove(os.path.join(ROOT,"Source","MatrixFunctions","MatrixFunctions.c")) |
Christophe Favergeon | 116bc4d | 2020-08-06 11:00:40 +0200 | [diff] [blame] | 38 | matrix.remove(os.path.join(ROOT,"Source","MatrixFunctions","MatrixFunctionsF16.c")) |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 39 | |
| 40 | statistics = glob.glob(os.path.join(ROOT,"Source","StatisticsFunctions","*.c")) |
| 41 | statistics.remove(os.path.join(ROOT,"Source","StatisticsFunctions","StatisticsFunctions.c")) |
Christophe Favergeon | 18a5fbc | 2020-08-07 11:18:02 +0200 | [diff] [blame] | 42 | statistics.remove(os.path.join(ROOT,"Source","StatisticsFunctions","StatisticsFunctionsF16.c")) |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 43 | |
| 44 | complexf = glob.glob(os.path.join(ROOT,"Source","ComplexMathFunctions","*.c")) |
| 45 | complexf.remove(os.path.join(ROOT,"Source","ComplexMathFunctions","ComplexMathFunctions.c")) |
Christophe Favergeon | 626af7e | 2020-08-05 07:28:13 +0200 | [diff] [blame] | 46 | complexf.remove(os.path.join(ROOT,"Source","ComplexMathFunctions","ComplexMathFunctionsF16.c")) |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 47 | |
| 48 | basic = glob.glob(os.path.join(ROOT,"Source","BasicMathFunctions","*.c")) |
| 49 | basic.remove(os.path.join(ROOT,"Source","BasicMathFunctions","BasicMathFunctions.c")) |
Christophe Favergeon | 2f12ed8 | 2020-07-22 09:10:21 +0200 | [diff] [blame] | 50 | basic.remove(os.path.join(ROOT,"Source","BasicMathFunctions","BasicMathFunctionsF16.c")) |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 51 | |
| 52 | controller = glob.glob(os.path.join(ROOT,"Source","ControllerFunctions","*.c")) |
| 53 | controller.remove(os.path.join(ROOT,"Source","ControllerFunctions","ControllerFunctions.c")) |
| 54 | |
Christophe Favergeon | 9e28408 | 2019-05-23 09:08:30 +0200 | [diff] [blame] | 55 | common = glob.glob(os.path.join(ROOT,"Source","CommonTables","*.c")) |
| 56 | common.remove(os.path.join(ROOT,"Source","CommonTables","CommonTables.c")) |
Christophe Favergeon | 729752f | 2020-08-07 11:50:27 +0200 | [diff] [blame^] | 57 | common.remove(os.path.join(ROOT,"Source","CommonTables","CommonTablesF16.c")) |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 58 | |
Christophe Favergeon | 2f12ed8 | 2020-07-22 09:10:21 +0200 | [diff] [blame] | 59 | interpolation = glob.glob(os.path.join(ROOT,"Source","InterpolationFunctions","*.c")) |
| 60 | interpolation.remove(os.path.join(ROOT,"Source","InterpolationFunctions","InterpolationFunctions.c")) |
Christophe Favergeon | c793588 | 2020-08-06 13:14:33 +0200 | [diff] [blame] | 61 | interpolation.remove(os.path.join(ROOT,"Source","InterpolationFunctions","InterpolationFunctionsF16.c")) |
Christophe Favergeon | 2f12ed8 | 2020-07-22 09:10:21 +0200 | [diff] [blame] | 62 | |
Christophe Favergeon | 9e28408 | 2019-05-23 09:08:30 +0200 | [diff] [blame] | 63 | #modulesrc = glob.glob(os.path.join("cmsisdsp_pkg","src","*.c")) |
| 64 | modulesrc = [] |
Christophe Favergeon | 9e28408 | 2019-05-23 09:08:30 +0200 | [diff] [blame] | 65 | modulesrc.append(os.path.join("cmsisdsp_pkg","src","cmsismodule.c")) |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 66 | |
Christophe Favergeon | 729752f | 2020-08-07 11:50:27 +0200 | [diff] [blame^] | 67 | allsrcs = support + fastmath + filtering + matrix + statistics + complexf + basic |
| 68 | allsrcs = allsrcs + controller + transform + modulesrc + common+ interpolation |
| 69 | |
| 70 | def 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 |
| 80 | srcs = list(filter(notf16, allsrcs)) |
| 81 | |
| 82 | |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 83 | module1 = Extension(config.extensionName, |
Christophe Favergeon | 729752f | 2020-08-07 11:50:27 +0200 | [diff] [blame^] | 84 | sources = (srcs |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 85 | ) |
| 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 | |
| 92 | setup (name = config.setupName, |
| 93 | version = '0.0.1', |
| 94 | description = config.setupDescription, |
| 95 | ext_modules = [module1], |
Christophe Favergeon | 729752f | 2020-08-07 11:50:27 +0200 | [diff] [blame^] | 96 | author = 'Copyright (C) 2010-2020 ARM Limited or its affiliates. All rights reserved.', |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 97 | 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.com | 2512416 | 2019-08-19 12:37:17 -0700 | [diff] [blame] | 102 | ]) |