setup.py 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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
  8. import re
  9. includes = [os.path.join(ROOT,"Include"),os.path.join(ROOT,"PrivateInclude"),os.path.join("cmsisdsp_pkg","src")]
  10. if sys.platform == 'win32':
  11. cflags = ["-DWIN",config.cflags,"-DUNALIGNED_SUPPORT_DISABLE"]
  12. else:
  13. cflags = ["-Wno-attributes","-Wno-unused-function","-Wno-unused-variable","-Wno-implicit-function-declaration",config.cflags,"-D__GNUC_PYTHON__"]
  14. transform = glob.glob(os.path.join(ROOT,"Source","TransformFunctions","*.c"))
  15. #transform.remove(os.path.join(ROOT,"Source","TransformFunctions","arm_dct4_init_q15.c"))
  16. #transform.remove(os.path.join(ROOT,"Source","TransformFunctions","arm_rfft_init_q15.c"))
  17. transform.remove(os.path.join(ROOT,"Source","TransformFunctions","TransformFunctions.c"))
  18. transform.remove(os.path.join(ROOT,"Source","TransformFunctions","TransformFunctionsF16.c"))
  19. support = glob.glob(os.path.join(ROOT,"Source","SupportFunctions","*.c"))
  20. support.remove(os.path.join(ROOT,"Source","SupportFunctions","SupportFunctions.c"))
  21. support.remove(os.path.join(ROOT,"Source","SupportFunctions","SupportFunctionsF16.c"))
  22. fastmath = glob.glob(os.path.join(ROOT,"Source","FastMathFunctions","*.c"))
  23. fastmath.remove(os.path.join(ROOT,"Source","FastMathFunctions","FastMathFunctions.c"))
  24. filtering = glob.glob(os.path.join(ROOT,"Source","FilteringFunctions","*.c"))
  25. filtering.remove(os.path.join(ROOT,"Source","FilteringFunctions","FilteringFunctions.c"))
  26. filtering.remove(os.path.join(ROOT,"Source","FilteringFunctions","FilteringFunctionsF16.c"))
  27. matrix = glob.glob(os.path.join(ROOT,"Source","MatrixFunctions","*.c"))
  28. matrix.remove(os.path.join(ROOT,"Source","MatrixFunctions","MatrixFunctions.c"))
  29. matrix.remove(os.path.join(ROOT,"Source","MatrixFunctions","MatrixFunctionsF16.c"))
  30. statistics = glob.glob(os.path.join(ROOT,"Source","StatisticsFunctions","*.c"))
  31. statistics.remove(os.path.join(ROOT,"Source","StatisticsFunctions","StatisticsFunctions.c"))
  32. statistics.remove(os.path.join(ROOT,"Source","StatisticsFunctions","StatisticsFunctionsF16.c"))
  33. complexf = glob.glob(os.path.join(ROOT,"Source","ComplexMathFunctions","*.c"))
  34. complexf.remove(os.path.join(ROOT,"Source","ComplexMathFunctions","ComplexMathFunctions.c"))
  35. complexf.remove(os.path.join(ROOT,"Source","ComplexMathFunctions","ComplexMathFunctionsF16.c"))
  36. basic = glob.glob(os.path.join(ROOT,"Source","BasicMathFunctions","*.c"))
  37. basic.remove(os.path.join(ROOT,"Source","BasicMathFunctions","BasicMathFunctions.c"))
  38. basic.remove(os.path.join(ROOT,"Source","BasicMathFunctions","BasicMathFunctionsF16.c"))
  39. controller = glob.glob(os.path.join(ROOT,"Source","ControllerFunctions","*.c"))
  40. controller.remove(os.path.join(ROOT,"Source","ControllerFunctions","ControllerFunctions.c"))
  41. common = glob.glob(os.path.join(ROOT,"Source","CommonTables","*.c"))
  42. common.remove(os.path.join(ROOT,"Source","CommonTables","CommonTables.c"))
  43. common.remove(os.path.join(ROOT,"Source","CommonTables","CommonTablesF16.c"))
  44. interpolation = glob.glob(os.path.join(ROOT,"Source","InterpolationFunctions","*.c"))
  45. interpolation.remove(os.path.join(ROOT,"Source","InterpolationFunctions","InterpolationFunctions.c"))
  46. interpolation.remove(os.path.join(ROOT,"Source","InterpolationFunctions","InterpolationFunctionsF16.c"))
  47. #modulesrc = glob.glob(os.path.join("cmsisdsp_pkg","src","*.c"))
  48. modulesrc = []
  49. modulesrc.append(os.path.join("cmsisdsp_pkg","src","cmsismodule.c"))
  50. allsrcs = support + fastmath + filtering + matrix + statistics + complexf + basic
  51. allsrcs = allsrcs + controller + transform + modulesrc + common+ interpolation
  52. def notf16(number):
  53. if re.search(r'f16',number):
  54. return(False)
  55. if re.search(r'F16',number):
  56. return(False)
  57. return(True)
  58. # If there are too many files, the linker command is failing on Windows.
  59. # So f16 functions are removed since they are not currently available in the wrapper.
  60. # A next version will have to structure this wrapper more cleanly so that the
  61. # build can work even with more functions
  62. srcs = list(filter(notf16, allsrcs))
  63. module1 = Extension(config.extensionName,
  64. sources = (srcs
  65. )
  66. ,
  67. include_dirs = includes + [numpy.get_include()],
  68. #extra_compile_args = ["-Wno-unused-variable","-Wno-implicit-function-declaration",config.cflags]
  69. extra_compile_args = cflags
  70. )
  71. setup (name = config.setupName,
  72. version = '0.0.1',
  73. description = config.setupDescription,
  74. ext_modules = [module1],
  75. author = 'Copyright (C) 2010-2020 ARM Limited or its affiliates. All rights reserved.',
  76. url="https://github.com/ARM-software/CMSIS_5",
  77. classifiers=[
  78. "Programming Language :: Python",
  79. "License :: OSI Approved :: Apache Software License",
  80. "Operating System :: OS Independent",
  81. ])