mesonbuild / wrapdb

New wrap requests
https://mesonbuild.com/Adding-new-projects-to-wrapdb.html
MIT License
73 stars 189 forks source link

libuv v1.48.0 #1432

Closed ibc closed 6 months ago

ibc commented 6 months ago

Details

jpakkane commented 6 months ago

Please do not have fake commits. Instead use git commit -a --amend and force push.

ibc commented 6 months ago

Good to know. Thanks, I'll do.

ibc commented 6 months ago

Hi, authors. Perhaps someone could help me with a problem I have trying to make meson.build suitable for libuv 1.48.

libuv-1.48 has a new test for Windows that consists on spawning a copy of the uv_run_tests.exe executable renamed to uv_run_tests (without .exe extension). Here the commit that added it: https://github.com/libuv/libuv/commit/3f7191e5c27a0e1852fe046a5ec0512a47e4a409#diff-474ff289edd74587d2dbcd1e8792169a7a3d89b8c582f8715aadf83da67800f5R1402

I'm trying to achieve the same in meson.build doing this:

  libuv_test_exe = executable(
    'uv_run_tests',
    libuv_test_src,
    dependencies: [libuv_dep, libuv_test_deps],
    c_args: libuv_test_cargs,
    link_args: libuv_test_lflags,
  )
  # we need to copy the executable without extension (needed for a test in libuv)
  if win32
    copy_file_in_build_dir = find_program('copy_file_in_build_dir.py')
    run_command(
      copy_file_in_build_dir,
      'uv_run_tests.exe',
      'uv_run_tests_no_ext',
      check: true
    )
  endif
  test(
    'libuv_run_tests',
    libuv_test_exe,
    workdir: meson.current_source_dir(),
    protocol: 'tap',
    timeout: 300,
    is_parallel: false,
  )

copy_file_in_build_dir.py is a custom Python script I've added to copy the executable uv_run_tests.exe (in the build directory) to uv_run_tests_no_ext (also in the build directory).

The problem is that, despite run_command() is declared after executable(), when the Python script is called there is no executable file yet (nothing is built yet). This is due the fact that meson.build is a declarative language.

Is there something I can do to make the above run_command() be executed after the executable test file has been built? I'm now reading about custom_target() but I'm not sure if it's valid for what I need.

UPDATE:

I'm trying custom_target() but sme problem happens. I don't see that the custom target is built before running the tests despite I declare it between executable() and test(), and despite I add depends to it indicating that it depends on the test target:

  libuv_test_exe = executable(
    'uv_run_tests',
    libuv_test_src,
    dependencies: [libuv_dep, libuv_test_deps],
    c_args: libuv_test_cargs,
    link_args: libuv_test_lflags,
  )
  # we need to copy the executable without extension (needed for a test in libuv)
  if win32
    copy_file_in_build_dir = find_program('copy_file_in_build_dir.py')
    custom_target(
      'uv_run_tests_no_ext',
      command: [
        copy_file_in_build_dir,
        'uv_run_tests.exe',
        'uv_run_tests_no_ext'
      ],
      depends: [libuv_test_exe],
      output: 'uv_run_tests_no_ext'
    )
  endif
  test(
    'libuv_run_tests',
    libuv_test_exe,
    workdir: meson.current_source_dir(),
    protocol: 'tap',
    timeout: 300,
    is_parallel: false,
  )
ibc commented 6 months ago

And if I try this:

    libuv_test_exe = executable(
      'uv_run_tests',
      libuv_test_src,
      dependencies: [libuv_dep, libuv_test_deps],
      c_args: libuv_test_cargs,
      link_args: libuv_test_lflags,
    )

    uv_run_tests_no_ext = custom_target(
      'uv_run_tests_no_ext',
      command: ['cp', '@INPUT@', '@OUTPUT@'],
      input: libuv_test_exe.full_path(),
      output: 'uv_run_tests_no_ext',
      build_by_default: true,
      depends: [libuv_test_exe],
    )

    test(
      'libuv_run_tests',
      libuv_test_exe,
      workdir: meson.current_source_dir(),
      protocol: 'tap',
      timeout: 300,
      is_parallel: false,
      depends: [uv_run_tests_no_ext],
    )

I get this error:

 subprojects\libuv-v1.48.0\meson.build:702: WARNING: Source item 'D:\\a\\wrapdb\\wrapdb\\_build\\subprojects\\libuv-v1.48.0\\uv_run_tests.exe' cannot be converted to File object, because it is a generated file. This will become a hard error in the future.

  subprojects\libuv-v1.48.0\meson.build:702:26: ERROR: Fatal warnings enabled, aborting
ibc commented 6 months ago

Issue above is solved, CI is passing. I'm squashing commits. Will ping here when the PR is totally ready.

ibc commented 6 months ago

Hi, authors. This PR is ready. May you please run CI?

ibc commented 6 months ago

A new version of some project has been added to master branch since yesterday and hence sanity checks fail. I will merge master soon to fix it.

ibc commented 6 months ago

Upstream master branch merged in my branch. Authors, please enable CI again :)

ibc commented 6 months ago

CI is green. Saying it in case authors want to merge this PR. Otherwise tomorrow I'll have to merge master again :)