setup.py 5.0 KB

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