cmakeconfig.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 defines from the configuration.
  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. "config",
  28. metavar="CONFIG_FILENAME",
  29. help="configuration file name")
  30. parser.add_argument(
  31. "cmake",
  32. metavar="OUTPUT_FILENAME",
  33. help="generated CMake file name")
  34. args = parser.parse_args()
  35. kconf = kconfiglib.Kconfig(args.kconfig)
  36. kconf.load_config(args.config)
  37. kconf.write_cmakeconf(args.cmake)
  38. if __name__ == "__main__":
  39. main()