cmakedep.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/usr/bin/env python3
  2. # Copyright (C) 2018 RDA Technologies Limited and/or its affiliates("RDA").
  3. # All rights reserved.
  4. #
  5. # This software is supplied "AS IS" without any warranties.
  6. # RDA assumes no responsibility or liability for the use of the software,
  7. # conveys no license or title under any patent, copyright, or mask work
  8. # right to the product. RDA reserves the right to make changes in the
  9. # software without notification. RDA also make no representation or
  10. # warranty that such application will be suitable for the specified use
  11. # without further testing or modification.
  12. import argparse
  13. import sys
  14. import kconfiglib
  15. DESCRIPTION = """
  16. Generates a CMake file with cmake configuration dependency.
  17. """
  18. def main():
  19. parser = argparse.ArgumentParser(description=DESCRIPTION)
  20. parser.add_argument(
  21. "--kconfig",
  22. metavar="KCONFIG_FILENAME",
  23. dest="kconfig",
  24. default="Kconfig",
  25. help="top-level Kconfig file (default: Kconfig)")
  26. parser.add_argument(
  27. "cmake",
  28. metavar="OUTPUT_FILENAME",
  29. help="generated CMake file name")
  30. args = parser.parse_args()
  31. kconf = kconfiglib.Kconfig(args.kconfig)
  32. with open(args.cmake, 'w') as f:
  33. f.write('set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS\n{})\n'
  34. .format('\n'.join(kconf._filelist).replace('\\', '/')))
  35. if __name__ == "__main__":
  36. main()