meson.build 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. project('object generator', 'c')
  2. # FIXME: Note that this will not add a dependency to the compiler executable.
  3. # Code will not be rebuilt if it changes.
  4. comp = find_program('obj_generator.py')
  5. if host_machine.system() == 'windows'
  6. ext = '.obj'
  7. else
  8. ext = '.o'
  9. endif
  10. cc = meson.get_compiler('c').cmd_array().get(-1)
  11. # Generate an object file with configure_file to mimic prebuilt objects
  12. # provided by the source tree
  13. source1 = configure_file(input : 'source.c',
  14. output : 'source' + ext,
  15. command : [comp, cc, files('source.c'),
  16. join_paths(meson.current_build_dir(), 'source' + ext)])
  17. obj = static_library('obj', objects : source1)
  18. # Generate an object file manually.
  19. gen = generator(comp,
  20. output : '@BASENAME@' + ext,
  21. arguments : [cc, '@INPUT@', '@OUTPUT@'])
  22. generated = gen.process(['source2.c'])
  23. shr = shared_library('shr', generated,
  24. vs_module_defs : 'source2.def')
  25. # Generate an object file with indexed OUTPUT replacement.
  26. gen2 = generator(comp,
  27. output : '@BASENAME@' + ext,
  28. arguments : [cc, '@INPUT@', '@OUTPUT0@'])
  29. generated2 = gen2.process(['source3.c'])
  30. stc = static_library('stc', generated2)
  31. e = executable('prog', 'prog.c', link_with : [obj, shr, stc],
  32. install : true)
  33. test('objgen', e)