setup.py 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. quaternion = glob.glob(os.path.join(ROOT,"Source","QuaternionMathFunctions","*.c"))
  48. quaternion.remove(os.path.join(ROOT,"Source","QuaternionMathFunctions","QuaternionMathFunctions.c"))
  49. #distance = glob.glob(os.path.join(ROOT,"Source","DistanceFunctions","*.c"))
  50. #distance.remove(os.path.join(ROOT,"Source","DistanceFunctions","DistanceFunctions.c"))
  51. #modulesrc = glob.glob(os.path.join("cmsisdsp_pkg","src","*.c"))
  52. modulesrc = []
  53. modulesrc.append(os.path.join("cmsisdsp_pkg","src","cmsismodule.c"))
  54. allsrcs = support + fastmath + filtering + matrix + statistics + complexf + basic
  55. allsrcs = allsrcs + controller + transform + modulesrc + common+ interpolation
  56. allsrcs = allsrcs + quaternion
  57. def notf16(number):
  58. if re.search(r'f16',number):
  59. return(False)
  60. if re.search(r'F16',number):
  61. return(False)
  62. return(True)
  63. # If there are too many files, the linker command is failing on Windows.
  64. # So f16 functions are removed since they are not currently available in the wrapper.
  65. # A next version will have to structure this wrapper more cleanly so that the
  66. # build can work even with more functions
  67. srcs = list(filter(notf16, allsrcs))
  68. module1 = Extension(config.extensionName,
  69. sources = (srcs
  70. )
  71. ,
  72. include_dirs = includes + [numpy.get_include()],
  73. #extra_compile_args = ["-Wno-unused-variable","-Wno-implicit-function-declaration",config.cflags]
  74. extra_compile_args = cflags
  75. )
  76. setup (name = config.setupName,
  77. version = '1.0.0',
  78. description = config.setupDescription,
  79. ext_modules = [module1],
  80. author = 'Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved.',
  81. url="https://github.com/ARM-software/CMSIS_5",
  82. classifiers=[
  83. "Programming Language :: Python",
  84. "License :: OSI Approved :: Apache Software License",
  85. "Operating System :: OS Independent",
  86. ])