/sdk/tools/gentmpkconfig.py

https://github.com/sonydevworld/spresense
Python | 73 lines | 22 code | 13 blank | 38 comment | 7 complexity | 543bb57ea8df47dbde5a7546eeec1a8c MD5 | raw file
  1. #!/usr/bin/env python3
  2. ############################################################################
  3. # tools/gentmpkconfig.py
  4. #
  5. # Copyright 2018 Sony Semiconductor Solutions Corporation
  6. #
  7. # Redistribution and use in source and binary forms, with or without
  8. # modification, are permitted provided that the following conditions
  9. # are met:
  10. #
  11. # 1. Redistributions of source code must retain the above copyright
  12. # notice, this list of conditions and the following disclaimer.
  13. # 2. Redistributions in binary form must reproduce the above copyright
  14. # notice, this list of conditions and the following disclaimer in
  15. # the documentation and/or other materials provided with the
  16. # distribution.
  17. # 3. Neither the name of Sony Semiconductor Solutions Corporation nor
  18. # the names of its contributors may be used to endorse or promote
  19. # products derived from this software without specific prior written
  20. # permission.
  21. #
  22. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  23. # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  24. # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  25. # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  26. # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  27. # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  28. # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  29. # OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  30. # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  31. # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  32. # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  33. # POSSIBILITY OF SUCH DAMAGE.
  34. #
  35. ############################################################################
  36. import os
  37. import sys
  38. import glob
  39. if len(sys.argv) < 2:
  40. print('output file not specified.', file=sys.stderr)
  41. sys.exit(1)
  42. with open('Kconfig', 'r') as f:
  43. buf = f.read()
  44. if sys.argv[1] == '-':
  45. outfile = sys.stdout
  46. else:
  47. outfile = open(sys.argv[1], 'w')
  48. print(buf, file=outfile)
  49. EXCLUDES = ['nuttx', 'apps', 'sdk']
  50. # Search top of Kconfig in the same level directories
  51. kconfigs = glob.glob('../*/Kconfig')
  52. # Add kconfigs from user application
  53. if 'SPRESENSE_HOME' in os.environ:
  54. kconfigs = kconfigs + glob.glob(os.path.join(os.environ['SPRESENSE_HOME'], "Kconfig"))
  55. for c in kconfigs:
  56. dn = os.path.dirname(c).split('/')[-1]
  57. # Add Kconfig excpet nuttx, apps and sdk directories
  58. if dn not in EXCLUDES:
  59. print('source "%s"' % c, file=outfile)
  60. outfile.close()