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"] |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 14 | else: |
Christophe Favergeon | a614de9 | 2021-01-20 13:26:22 +0100 | [diff] [blame^] | 15 | cflags = ["-Wno-attributes","-Wno-unused-function","-Wno-unused-variable","-Wno-implicit-function-declaration",config.cflags,"-D__GNUC_PYTHON__"] |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 16 | |
| 17 | transform = glob.glob(os.path.join(ROOT,"Source","TransformFunctions","*.c")) |
Christophe Favergeon | 9e28408 | 2019-05-23 09:08:30 +0200 | [diff] [blame] | 18 | #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 Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 20 | transform.remove(os.path.join(ROOT,"Source","TransformFunctions","TransformFunctions.c")) |
Christophe Favergeon | 2f12ed8 | 2020-07-22 09:10:21 +0200 | [diff] [blame] | 21 | transform.remove(os.path.join(ROOT,"Source","TransformFunctions","TransformFunctionsF16.c")) |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 22 | |
| 23 | support = glob.glob(os.path.join(ROOT,"Source","SupportFunctions","*.c")) |
| 24 | support.remove(os.path.join(ROOT,"Source","SupportFunctions","SupportFunctions.c")) |
Christophe Favergeon | 9e773df | 2020-08-10 10:55:47 +0200 | [diff] [blame] | 25 | support.remove(os.path.join(ROOT,"Source","SupportFunctions","SupportFunctionsF16.c")) |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 26 | |
| 27 | fastmath = glob.glob(os.path.join(ROOT,"Source","FastMathFunctions","*.c")) |
| 28 | fastmath.remove(os.path.join(ROOT,"Source","FastMathFunctions","FastMathFunctions.c")) |
| 29 | |
| 30 | filtering = glob.glob(os.path.join(ROOT,"Source","FilteringFunctions","*.c")) |
| 31 | filtering.remove(os.path.join(ROOT,"Source","FilteringFunctions","FilteringFunctions.c")) |
Christophe Favergeon | 626af7e | 2020-08-05 07:28:13 +0200 | [diff] [blame] | 32 | filtering.remove(os.path.join(ROOT,"Source","FilteringFunctions","FilteringFunctionsF16.c")) |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 33 | |
| 34 | matrix = glob.glob(os.path.join(ROOT,"Source","MatrixFunctions","*.c")) |
| 35 | matrix.remove(os.path.join(ROOT,"Source","MatrixFunctions","MatrixFunctions.c")) |
Christophe Favergeon | 116bc4d | 2020-08-06 11:00:40 +0200 | [diff] [blame] | 36 | matrix.remove(os.path.join(ROOT,"Source","MatrixFunctions","MatrixFunctionsF16.c")) |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 37 | |
| 38 | statistics = glob.glob(os.path.join(ROOT,"Source","StatisticsFunctions","*.c")) |
| 39 | statistics.remove(os.path.join(ROOT,"Source","StatisticsFunctions","StatisticsFunctions.c")) |
Christophe Favergeon | 18a5fbc | 2020-08-07 11:18:02 +0200 | [diff] [blame] | 40 | statistics.remove(os.path.join(ROOT,"Source","StatisticsFunctions","StatisticsFunctionsF16.c")) |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 41 | |
| 42 | complexf = glob.glob(os.path.join(ROOT,"Source","ComplexMathFunctions","*.c")) |
| 43 | complexf.remove(os.path.join(ROOT,"Source","ComplexMathFunctions","ComplexMathFunctions.c")) |
Christophe Favergeon | 626af7e | 2020-08-05 07:28:13 +0200 | [diff] [blame] | 44 | complexf.remove(os.path.join(ROOT,"Source","ComplexMathFunctions","ComplexMathFunctionsF16.c")) |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 45 | |
| 46 | basic = glob.glob(os.path.join(ROOT,"Source","BasicMathFunctions","*.c")) |
| 47 | basic.remove(os.path.join(ROOT,"Source","BasicMathFunctions","BasicMathFunctions.c")) |
Christophe Favergeon | 2f12ed8 | 2020-07-22 09:10:21 +0200 | [diff] [blame] | 48 | basic.remove(os.path.join(ROOT,"Source","BasicMathFunctions","BasicMathFunctionsF16.c")) |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 49 | |
| 50 | controller = glob.glob(os.path.join(ROOT,"Source","ControllerFunctions","*.c")) |
| 51 | controller.remove(os.path.join(ROOT,"Source","ControllerFunctions","ControllerFunctions.c")) |
| 52 | |
Christophe Favergeon | 9e28408 | 2019-05-23 09:08:30 +0200 | [diff] [blame] | 53 | common = glob.glob(os.path.join(ROOT,"Source","CommonTables","*.c")) |
| 54 | common.remove(os.path.join(ROOT,"Source","CommonTables","CommonTables.c")) |
Christophe Favergeon | 729752f | 2020-08-07 11:50:27 +0200 | [diff] [blame] | 55 | common.remove(os.path.join(ROOT,"Source","CommonTables","CommonTablesF16.c")) |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 56 | |
Christophe Favergeon | 2f12ed8 | 2020-07-22 09:10:21 +0200 | [diff] [blame] | 57 | interpolation = glob.glob(os.path.join(ROOT,"Source","InterpolationFunctions","*.c")) |
| 58 | interpolation.remove(os.path.join(ROOT,"Source","InterpolationFunctions","InterpolationFunctions.c")) |
Christophe Favergeon | c793588 | 2020-08-06 13:14:33 +0200 | [diff] [blame] | 59 | interpolation.remove(os.path.join(ROOT,"Source","InterpolationFunctions","InterpolationFunctionsF16.c")) |
Christophe Favergeon | 2f12ed8 | 2020-07-22 09:10:21 +0200 | [diff] [blame] | 60 | |
Christophe Favergeon | 9e28408 | 2019-05-23 09:08:30 +0200 | [diff] [blame] | 61 | #modulesrc = glob.glob(os.path.join("cmsisdsp_pkg","src","*.c")) |
| 62 | modulesrc = [] |
Christophe Favergeon | 9e28408 | 2019-05-23 09:08:30 +0200 | [diff] [blame] | 63 | modulesrc.append(os.path.join("cmsisdsp_pkg","src","cmsismodule.c")) |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 64 | |
Christophe Favergeon | 729752f | 2020-08-07 11:50:27 +0200 | [diff] [blame] | 65 | allsrcs = support + fastmath + filtering + matrix + statistics + complexf + basic |
| 66 | allsrcs = allsrcs + controller + transform + modulesrc + common+ interpolation |
| 67 | |
| 68 | def notf16(number): |
Christophe Favergeon | a614de9 | 2021-01-20 13:26:22 +0100 | [diff] [blame^] | 69 | if re.search(r'f16',number): |
Christophe Favergeon | 729752f | 2020-08-07 11:50:27 +0200 | [diff] [blame] | 70 | return(False) |
Christophe Favergeon | a614de9 | 2021-01-20 13:26:22 +0100 | [diff] [blame^] | 71 | if re.search(r'F16',number): |
| 72 | return(False) |
| 73 | return(True) |
Christophe Favergeon | 729752f | 2020-08-07 11:50:27 +0200 | [diff] [blame] | 74 | |
Christophe Favergeon | a614de9 | 2021-01-20 13:26:22 +0100 | [diff] [blame^] | 75 | # If there are too many files, the linker command is failing on Windows. |
Christophe Favergeon | 729752f | 2020-08-07 11:50:27 +0200 | [diff] [blame] | 76 | # So f16 functions are removed since they are not currently available in the wrapper. |
| 77 | # A next version will have to structure this wrapper more cleanly so that the |
| 78 | # build can work even with more functions |
| 79 | srcs = list(filter(notf16, allsrcs)) |
| 80 | |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 81 | module1 = Extension(config.extensionName, |
Christophe Favergeon | 729752f | 2020-08-07 11:50:27 +0200 | [diff] [blame] | 82 | sources = (srcs |
Christophe Favergeon | 53f828f | 2019-03-25 13:42:44 +0100 | [diff] [blame] | 83 | ) |
| 84 | , |
| 85 | include_dirs = includes + [numpy.get_include()], |
| 86 | #extra_compile_args = ["-Wno-unused-variable","-Wno-implicit-function-declaration",config.cflags] |
| 87 | extra_compile_args = cflags |
| 88 | ) |
| 89 | |
| 90 | setup (name = config.setupName, |
| 91 | version = '0.0.1', |
| 92 | description = config.setupDescription, |
| 93 | ext_modules = [module1], |
Christophe Favergeon | 729752f | 2020-08-07 11:50:27 +0200 | [diff] [blame] | 94 | 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] | 95 | url="https://github.com/ARM-software/CMSIS_5", |
| 96 | classifiers=[ |
| 97 | "Programming Language :: Python", |
| 98 | "License :: OSI Approved :: Apache Software License", |
| 99 | "Operating System :: OS Independent", |
Chris Knorowski chris.knorowski@sensiml.com | 2512416 | 2019-08-19 12:37:17 -0700 | [diff] [blame] | 100 | ]) |