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")) |
Christophe Favergeon | 9e773df | 2020-08-10 10:55:47 +0200 | [diff] [blame] | 28 | support.remove(os.path.join(ROOT,"Source","SupportFunctions","SupportFunctionsF16.c")) |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 29 | |
| 30 | fastmath = glob.glob(os.path.join(ROOT,"Source","FastMathFunctions","*.c")) |
| 31 | fastmath.remove(os.path.join(ROOT,"Source","FastMathFunctions","FastMathFunctions.c")) |
| 32 | |
| 33 | filtering = glob.glob(os.path.join(ROOT,"Source","FilteringFunctions","*.c")) |
| 34 | filtering.remove(os.path.join(ROOT,"Source","FilteringFunctions","FilteringFunctions.c")) |
Christophe Favergeon | 626af7e | 2020-08-05 07:28:13 +0200 | [diff] [blame] | 35 | filtering.remove(os.path.join(ROOT,"Source","FilteringFunctions","FilteringFunctionsF16.c")) |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 36 | |
| 37 | matrix = glob.glob(os.path.join(ROOT,"Source","MatrixFunctions","*.c")) |
| 38 | matrix.remove(os.path.join(ROOT,"Source","MatrixFunctions","MatrixFunctions.c")) |
Christophe Favergeon | 116bc4d | 2020-08-06 11:00:40 +0200 | [diff] [blame] | 39 | matrix.remove(os.path.join(ROOT,"Source","MatrixFunctions","MatrixFunctionsF16.c")) |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 40 | |
| 41 | statistics = glob.glob(os.path.join(ROOT,"Source","StatisticsFunctions","*.c")) |
| 42 | statistics.remove(os.path.join(ROOT,"Source","StatisticsFunctions","StatisticsFunctions.c")) |
Christophe Favergeon | 18a5fbc | 2020-08-07 11:18:02 +0200 | [diff] [blame] | 43 | statistics.remove(os.path.join(ROOT,"Source","StatisticsFunctions","StatisticsFunctionsF16.c")) |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 44 | |
| 45 | complexf = glob.glob(os.path.join(ROOT,"Source","ComplexMathFunctions","*.c")) |
| 46 | complexf.remove(os.path.join(ROOT,"Source","ComplexMathFunctions","ComplexMathFunctions.c")) |
Christophe Favergeon | 626af7e | 2020-08-05 07:28:13 +0200 | [diff] [blame] | 47 | complexf.remove(os.path.join(ROOT,"Source","ComplexMathFunctions","ComplexMathFunctionsF16.c")) |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 48 | |
| 49 | basic = glob.glob(os.path.join(ROOT,"Source","BasicMathFunctions","*.c")) |
| 50 | basic.remove(os.path.join(ROOT,"Source","BasicMathFunctions","BasicMathFunctions.c")) |
Christophe Favergeon | 2f12ed8 | 2020-07-22 09:10:21 +0200 | [diff] [blame] | 51 | basic.remove(os.path.join(ROOT,"Source","BasicMathFunctions","BasicMathFunctionsF16.c")) |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 52 | |
| 53 | controller = glob.glob(os.path.join(ROOT,"Source","ControllerFunctions","*.c")) |
| 54 | controller.remove(os.path.join(ROOT,"Source","ControllerFunctions","ControllerFunctions.c")) |
| 55 | |
Christophe Favergeon | 9e28408 | 2019-05-23 09:08:30 +0200 | [diff] [blame] | 56 | common = glob.glob(os.path.join(ROOT,"Source","CommonTables","*.c")) |
| 57 | common.remove(os.path.join(ROOT,"Source","CommonTables","CommonTables.c")) |
Christophe Favergeon | 729752f | 2020-08-07 11:50:27 +0200 | [diff] [blame] | 58 | common.remove(os.path.join(ROOT,"Source","CommonTables","CommonTablesF16.c")) |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 59 | |
Christophe Favergeon | 2f12ed8 | 2020-07-22 09:10:21 +0200 | [diff] [blame] | 60 | interpolation = glob.glob(os.path.join(ROOT,"Source","InterpolationFunctions","*.c")) |
| 61 | interpolation.remove(os.path.join(ROOT,"Source","InterpolationFunctions","InterpolationFunctions.c")) |
Christophe Favergeon | c793588 | 2020-08-06 13:14:33 +0200 | [diff] [blame] | 62 | interpolation.remove(os.path.join(ROOT,"Source","InterpolationFunctions","InterpolationFunctionsF16.c")) |
Christophe Favergeon | 2f12ed8 | 2020-07-22 09:10:21 +0200 | [diff] [blame] | 63 | |
Christophe Favergeon | 9e28408 | 2019-05-23 09:08:30 +0200 | [diff] [blame] | 64 | #modulesrc = glob.glob(os.path.join("cmsisdsp_pkg","src","*.c")) |
| 65 | modulesrc = [] |
Christophe Favergeon | 9e28408 | 2019-05-23 09:08:30 +0200 | [diff] [blame] | 66 | modulesrc.append(os.path.join("cmsisdsp_pkg","src","cmsismodule.c")) |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 67 | |
Christophe Favergeon | 729752f | 2020-08-07 11:50:27 +0200 | [diff] [blame] | 68 | allsrcs = support + fastmath + filtering + matrix + statistics + complexf + basic |
| 69 | allsrcs = allsrcs + controller + transform + modulesrc + common+ interpolation |
| 70 | |
| 71 | def 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 |
| 81 | srcs = list(filter(notf16, allsrcs)) |
| 82 | |
| 83 | |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 84 | module1 = Extension(config.extensionName, |
Christophe Favergeon | 729752f | 2020-08-07 11:50:27 +0200 | [diff] [blame] | 85 | sources = (srcs |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 86 | ) |
| 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 | |
| 93 | setup (name = config.setupName, |
| 94 | version = '0.0.1', |
| 95 | description = config.setupDescription, |
| 96 | ext_modules = [module1], |
Christophe Favergeon | 729752f | 2020-08-07 11:50:27 +0200 | [diff] [blame] | 97 | 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] | 98 | 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.com | 2512416 | 2019-08-19 12:37:17 -0700 | [diff] [blame] | 103 | ]) |