yet another no-frills web browser
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

configure 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/usr/bin/env python3
  2. import shutil
  3. import os
  4. import subprocess
  5. from colorama import Fore
  6. from colorama import Style
  7. def concat_options(default, options=[]):
  8. if not options:
  9. return default
  10. r = ''
  11. for option in options:
  12. if option is default:
  13. r += '*' + option + '* '
  14. else:
  15. r += option + ' '
  16. return r.strip()
  17. def prompt(prompt, default, options=[]):
  18. v = input("{} ({}): ".format(prompt, concat_options(default, options)))
  19. if v is not '':
  20. return v
  21. return default
  22. if __name__ == "__main__":
  23. # build options
  24. build_dir = prompt('build folder', 'build')
  25. build_type = prompt('build type', 'release', ['plain', 'debug', 'debugoptimized', 'release'])
  26. build_prefix = prompt('prefix', '/usr/local')
  27. build_pie = prompt('position-independent executable', 'true', ['true', 'false'])
  28. build_lto = prompt('link-time optimization', 'true', ['true', 'false'])
  29. # feature selection
  30. auto_features = prompt('Feature auto state', 'disabled', ['auto', 'enabled', 'disabled'])
  31. f_breakpad = prompt('Use breakpad', 'disabled', ['enabled', 'disabled'])
  32. f_plasma = prompt('Use plasma', 'disabled', ['enabled', 'disabled'])
  33. f_manpage = prompt('make manpage', 'enabled', ['enabled', 'disabled'])
  34. # compilers
  35. cc = prompt('C compiler', 'gcc')
  36. cpp = prompt('CPP compiler', 'g++')
  37. ld = prompt('Linker', 'gold')
  38. # clean build folder
  39. if os.path.isdir(build_dir):
  40. shutil.rmtree(build_dir)
  41. os.mkdir(build_dir, 0o700)
  42. env = {
  43. **os.environ,
  44. 'CC' : cc,
  45. 'CXX' : cpp
  46. }
  47. # configure build dir
  48. subprocess.run(['meson', '--buildtype={}'.format(build_type), '--prefix={}'.format(build_prefix), '--auto-features={}'.format(auto_features),
  49. '-Db_pie={}'.format(build_pie), '-Db_lto={}'.format(build_lto), '-Dcpp_link_args="-fuse-ld={}"'.format(ld),
  50. '-DBreakpad={}'.format(f_breakpad), '-DPlasma={}'.format(f_plasma), '-Dmanpage={}'.format(f_manpage),
  51. build_dir], env=env, check=True)
  52. print(f"{Style.BRIGHT}Configure step complete{Style.RESET_ALL}")
  53. print("For more configuration options run 'meson configure' in the configured build directory.")
  54. print("You can now build with 'ninja -C {}'.".format(build_dir))