meson.build 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. project('winmain', 'c')
  2. # MinGW windres has a bug due to which it doesn't parse args with space properly:
  3. # https://github.com/mesonbuild/meson/pull/1346
  4. # https://sourceware.org/bugzilla/show_bug.cgi?id=4933
  5. if meson.get_compiler('c').get_id() == 'gcc' and host_machine.system() == 'windows'
  6. # Construct build_to_src and skip this test if it has spaces
  7. # because then the -I flag to windres will also have spaces
  8. # and we know the test will fail
  9. src_parts = meson.source_root().split('/')
  10. build_parts = meson.build_root().split('/')
  11. # Get the common path (which might just be '/' or 'C:/')
  12. common = []
  13. done = false
  14. count = 0
  15. if src_parts.length() > build_parts.length()
  16. parts = build_parts
  17. other = src_parts
  18. else
  19. parts = src_parts
  20. other = build_parts
  21. endif
  22. foreach part : parts
  23. if not done and part == other.get(count)
  24. common += [part]
  25. else
  26. done = true
  27. endif
  28. count += 1
  29. endforeach
  30. # Create path components to go down from the build root to the common path
  31. count = 0
  32. rel = build_parts
  33. foreach build : build_parts
  34. if count < build_parts.length() - common.length()
  35. rel += ['..']
  36. endif
  37. count += 1
  38. endforeach
  39. # Create path components to go up from the common path to the build root
  40. count = 0
  41. foreach src : src_parts
  42. if count >= common.length()
  43. rel += [src]
  44. endif
  45. count += 1
  46. endforeach
  47. build_to_src = '/'.join(rel)
  48. if build_to_src.contains(' ')
  49. message('build_to_src is: ' + build_to_src)
  50. error('MESON_SKIP_TEST build_to_src has spaces')
  51. endif
  52. # Welcome to the end of this conditional.
  53. # We hope you never have to implement something like this.
  54. endif
  55. subdir('inc')
  56. subdir('res')
  57. exe = executable('prog', 'prog.c',
  58. res,
  59. gui_app : true)
  60. test('winmain', exe)