Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

both_libraries don't work with vala generated sources #6960

Open
qboosh opened this issue Apr 12, 2020 · 2 comments
Open

both_libraries don't work with vala generated sources #6960

qboosh opened this issue Apr 12, 2020 · 2 comments

Comments

@qboosh
Copy link

qboosh commented Apr 12, 2020

Bug
When trying to build some vala based library with meson 0.53.x or 0.54, configuring with --default-libraries=both, I'm hitting numerous issues:

  • if include_dir is specified as list, configure fails when trying to match it with static library:
ERROR: Target 'gnome-games-support-1' has 1 outputs: ['libgnome-games-support-1.a'], but only 3 "install_dir"s were found.
  • after solving this issue (either by removing list install_dir, or adding workaround in mesonbuild/interpreter.py to replace install_dir by just first element for static part of BothLibrariesHolder), ninja build fails with:
ninja: error: 'games/cd7ac4c@@gnome-games-support-1@sha/meson-generated_category.c.o', needed by 'games/libgnome-games-support-1.a', missing and no known rule to make it

because object paths are generated differently for files generated by vala from sources in subdir.

How To Reproduce
My testcase is:
http://ftp.gnome.org/pub/GNOME/sources/libgnome-games-support/1.6/libgnome-games-support-1.6.1.tar.xz
Just cd into project directory, then:

meson build --default-library=both
ninja -C build

For quick preview, library is defined as (in games/meson.build):

lggs = library('gnome-games-support-1',
    [
        'config.vapi',
        'gridframe.vala',
        'scores/category.vala',
        'scores/context.vala',
        'scores/dialog.vala',
        'scores/directory-importer.vala',
        'scores/history-file-importer.vala',
        'scores/importer.vala',
        'scores/score.vala',
    ],
    install: true,
    install_dir: [
        true, # default libdir
        join_paths(includedir, includesubdir), # headers
        true, # default vapidir
    ],
    c_args: [
        # https://github.com/mesonbuild/meson/issues/4763
        '-include', 'config.h'
    ],
    vala_header: 'libgnome-games-support.h',
    vala_vapi: 'libgnome-games-support-1.vapi',
    vala_args: [
        '--abi-stability',
        '--target-glib=2.44',
    ],
    soversion: soversion,
    version: library_version,
    dependencies: lggs_interface_deps,
)

Expected behavior
Build succeeds with both libgnome-games-support.so.3.0.3 and libgnome-games-support.a built.

system parameters
Linux, Python 3.8.2
meson 0.54.0 (tried also last release of 0.53.x), ninja 1.10.0

@mjog
Copy link
Contributor

mjog commented Apr 27, 2021

Doesn't work with the both_libraries() function, either.

@milahu
Copy link
Contributor

milahu commented Feb 14, 2023

same problem with frida-core when i replace all static_library with library to build both shared and static libraries

build error

ninja: error: 'src/libfrida-helper-backend.so.p/meson-generated_frida-helper-backend.c.o', needed by 'src/libfrida-helper-backend.a', missing and no known rule to make it

there exists a similar target in build.ninja:

- build src/libfrida-helper-backend.so.p/meson-generated_frida-helper-backend.c.o
+ build src/libfrida-helper-backend.so.p/meson-generated_linux_frida-helper-backend.c.o
a million details

so src/libfrida-helper-backend.a requires
src/libfrida-helper-backend.so.p/meson-generated_frida-helper-backend.c.o
but it should require
src/libfrida-helper-backend.so.p/meson-generated_linux_frida-helper-backend.c.o

patch versus frida/frida-core@310ff06

diff --git a/lib/base/meson.build b/lib/base/meson.build
index 2a3b3e3..5b6325b 100644
--- a/lib/base/meson.build
+++ b/lib/base/meson.build
@@ -15,13 +15,12 @@ if host_os_family != 'windows'
   extra_deps += [gio_unix_dep]
 endif
 
-base = static_library('frida-base-' + api_version, base_sources,
+base = library('frida-base-' + api_version, base_sources,
   c_args: frida_component_cflags,
   vala_header: 'frida-base.h',
   vala_vapi: f'frida-base-@api_version@.vapi',
   dependencies: [glib_dep, gobject_dep, gio_dep, libsoup_dep, nice_dep, usrsctp_dep, gee_dep, json_glib_dep, gum_dep, openssl_dep] + extra_deps,
   install: true,
-  install_dir: [true, header_install_dir, true],
 )
 
 base_dep = declare_dependency(
diff --git a/lib/payload/meson.build b/lib/payload/meson.build
index dff3f8d..8065a69 100644
--- a/lib/payload/meson.build
+++ b/lib/payload/meson.build
@@ -36,14 +36,13 @@ if host_os_family == 'linux'
   extra_vala_args += ['--pkg=linux']
 endif
 
-payload = static_library('frida-payload-' + api_version, payload_sources,
+payload = library('frida-payload-' + api_version, payload_sources,
   c_args: frida_component_cflags,
   vala_args: extra_vala_args,
   vala_header: 'frida-payload.h',
   vala_vapi: f'frida-payload-@api_version@.vapi',
   dependencies: [gio_dep, gee_dep, json_glib_dep, gum_dep, gumjs_dep, base_dep],
   install: true,
-  install_dir: [true, header_install_dir, true],
 )
 
 payload_dep = declare_dependency(
diff --git a/lib/pipe/meson.build b/lib/pipe/meson.build
index e11e8d6..4354dfb 100644
--- a/lib/pipe/meson.build
+++ b/lib/pipe/meson.build
@@ -27,7 +27,7 @@ if host_os == 'android'
   vala_args += frida_selinux_vala_args
 endif
 
-pipe = static_library('frida-pipe', pipe_sources,
+pipe = library('frida-pipe', pipe_sources,
   c_args: frida_component_cflags,
   vala_args: vala_args,
   vala_header: 'frida-pipe.h',
diff --git a/lib/selinux/meson.build b/lib/selinux/meson.build
index f317db5..42a5187 100644
--- a/lib/selinux/meson.build
+++ b/lib/selinux/meson.build
@@ -2,7 +2,7 @@ frida_selinux_incdir = include_directories('.')
 
 install_headers('frida-selinux.h', subdir: 'frida-' + api_version)
 
-frida_selinux = static_library('frida-selinux', 'patch.c',
+frida_selinux = library('frida-selinux', 'patch.c',
   c_args: frida_component_cflags,
   dependencies: [glib_dep, libselinux_dep, libsepol_dep],
 )
diff --git a/src/api/merge.sh b/src/api/merge.sh
deleted file mode 100755
index 5729f5a..0000000
--- a/src/api/merge.sh
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/usr/bin/env bash
-
-ar_binary="$1"
-libtool_binary="$2"
-build_dir="$3"
-output_lib="$4"
-shift 4
-
-if [ -n "$libtool_binary" ]; then
-  exec "$libtool_binary" -static -o "$output_lib" "$@"
-else
-  priv_dir="$build_dir/frida-core-library@mrg"
-  mri_script="$priv_dir/merge.mri"
-
-  mkdir -p "$priv_dir"
-
-  echo "create $output_lib" > "$mri_script"
-  while [[ $# > 0 ]]; do
-    echo "addlib $1" >> "$mri_script"
-    shift
-  done
-  echo "save" >> "$mri_script"
-  echo "end" >> "$mri_script"
-
-  exec "$ar_binary" -M < "$mri_script"
-fi
diff --git a/src/api/meson.build b/src/api/meson.build
index e268c71..42265e2 100644
--- a/src/api/meson.build
+++ b/src/api/meson.build
@@ -38,17 +38,7 @@ custom_target('frida-core-vapi',
   install_dir: join_paths(get_option('datadir'), 'vala', 'vapi'),
 )
 
-custom_target('frida-core-library',
-  input: [core] + internal_libs,
-  output: 'libfrida-core-@0@.a'.format(api_version),
-  command: [
-    files('merge.sh'),
-    ar,
-    libtool,
-    meson.current_build_dir(),
-    '@OUTPUT@',
-    '@INPUT@'
-  ],
+library('frida-core-' + api_version, [core] + internal_libs,
   install: true,
   install_dir: get_option('libdir'),
 )
diff --git a/src/meson.build b/src/meson.build
index fe4ed80..84cc0c9 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -85,7 +85,7 @@ if host_os_family == 'darwin'
       'darwin/substituted2-client.c',
     ]
   endif
-  helper_backend = static_library('frida-helper-backend', helper_backend_sources,
+  helper_backend = library('frida-helper-backend', helper_backend_sources,
     c_args: frida_component_cflags,
     vala_args: ['--pkg=frida-gum-darwin-1.0', '--pkg=posix'],
     dependencies: [gmodule_dep, gio_dep, gio_unix_dep, gee_dep, gum_dep, base_dep, pipe_dep],
@@ -216,7 +216,7 @@ if host_os_family == 'linux'
   if host_os == 'android'
     helper_backend_extra_deps += [frida_selinux_dep]
   endif
-  helper_backend = static_library('frida-helper-backend', helper_backend_sources,
+  helper_backend = library('frida-helper-backend', helper_backend_sources,
     c_args: frida_component_cflags,
     vala_args: ['--pkg=posix', '--pkg=frida-gum-linux-1.0'],
     dependencies: [gio_dep, gio_unix_dep, gee_dep, gum_dep, base_dep] + helper_backend_extra_deps,
diff --git a/tests/meson.build b/tests/meson.build
index 987c857..0fe92e2 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -26,7 +26,7 @@ else
   system_vala_args += ['--pkg=posix']
 endif
 
-frida_tests = static_library('frida-tests', test_sources + [labrats_stamp],
+frida_tests = library('frida-tests', test_sources + [labrats_stamp],
   vala_args: system_vala_args,
   dependencies: [gmodule_dep, json_glib_dep, core_dep],
 )

https://github.com/frida/frida-core/blob/715e5099524d752f8112faecb92f47d79d7d3a5e/src/meson.build#L210

  helper_backend_sources = [
    'linux/frida-helper-backend.vala',
    'linux/frida-helper-backend-glue.c',
    'linux/frida-helper-types.vala',
  ]
  helper_backend_extra_deps = []
  if host_os == 'android'
    helper_backend_extra_deps += [frida_selinux_dep]
  endif
  # original with "static_library" -> build works
  #helper_backend = static_library('frida-helper-backend', helper_backend_sources,
  # patched with "library" -> build breaks
  helper_backend = library('frida-helper-backend', helper_backend_sources,
    c_args: frida_component_cflags,
    vala_args: ['--pkg=posix', '--pkg=frida-gum-linux-1.0'],
    dependencies: [gio_dep, gio_unix_dep, gee_dep, gum_dep, base_dep] + helper_backend_extra_deps,
  )

there exists a similar target in build.ninja:

- build src/libfrida-helper-backend.so.p/meson-generated_frida-helper-backend.c.o
+ build src/libfrida-helper-backend.so.p/meson-generated_linux_frida-helper-backend.c.o

so the problem is the prefix

- meson-generated_          # wrong
+ meson-generated_linux_    # expected, because its more specific

debug

find . -name "*.py" | xargs -d '\n' grep -Hn meson-generated 

./mesonbuild/backend/backends.py:813:            gen_source = 'meson-generated_' + rel_src[:-5] + '.c'
./mesonbuild/backend/backends.py:819:            gen_source = 'meson-generated_' + os.path.relpath(rel_src, targetdir)

https://github.com/mesonbuild/meson/blob/4d7a72b6db181f09034051ef703e151607784ea8/mesonbuild/backend/backends.py

    def object_filename_from_source(self, target: build.BuildTarget, source: 'FileOrString') -> str:
        assert isinstance(source, mesonlib.File)
        if isinstance(target, build.CompileTarget):
            return target.sources_map[source]
        build_dir = self.environment.get_build_dir()
        rel_src = source.rel_to_builddir(self.build_to_src)

        # foo.vala files compile down to foo.c and then foo.c.o, not foo.vala.o
        if rel_src.endswith(('.vala', '.gs')):

            # See description in generate_vala_compile for this logic.
            if source.is_built:
                if os.path.isabs(rel_src):
                    rel_src = rel_src[len(build_dir) + 1:]
                rel_src = os.path.relpath(rel_src, self.get_target_private_dir(target))
            else:
                rel_src = os.path.basename(rel_src)
            # A meson- prefixed directory is reserved; hopefully no-one creates a file name with such a weird prefix.
            gen_source = 'meson-generated_' + rel_src[:-5] + '.c'
        elif source.is_built:
            if os.path.isabs(rel_src):
                rel_src = rel_src[len(build_dir) + 1:]
            targetdir = self.get_target_private_dir(target)
            # A meson- prefixed directory is reserved; hopefully no-one creates a file name with such a weird prefix.
            gen_source = 'meson-generated_' + os.path.relpath(rel_src, targetdir)
--- /a/nix/store/1d96iljign9rczdgdrnyg2r9svfl16hj-meson-0.64.1/lib/python3.10/site-packages/mesonbuild/backend/backends.py	1970-01-01 01:00:01.000000000 +0100
+++ /b/nix/store/1d96iljign9rczdgdrnyg2r9svfl16hj-meson-0.64.1/lib/python3.10/site-packages/mesonbuild/backend/backends.py	2023-02-14 15:59:02.459275030 +0100
@@ -812,25 +812,63 @@
         if isinstance(target, build.CompileTarget):
             return target.sources_map[source]
         build_dir = self.environment.get_build_dir()
+        print("mesonbuild/backend/backends.py: build_dir:", build_dir)
         rel_src = source.rel_to_builddir(self.build_to_src)
+        print("mesonbuild/backend/backends.py: rel_src:", rel_src)
+
+        rel_src_1 = rel_src
 
         # foo.vala files compile down to foo.c and then foo.c.o, not foo.vala.o
         if rel_src.endswith(('.vala', '.gs')):
+            print("mesonbuild/backend/backends.py:   rel_src.endswith(('.vala', '.gs'): yes")
             # See description in generate_vala_compile for this logic.
             if source.is_built:
+                print("mesonbuild/backend/backends.py:   source.is_built: yes")
                 if os.path.isabs(rel_src):
+                    print("mesonbuild/backend/backends.py:   os.path.isabs(rel_src): yes")
+                    print("mesonbuild/backend/backends.py:   build_dir:", build_dir)
+                    print("mesonbuild/backend/backends.py:   rel_src 1:", rel_src)
                     rel_src = rel_src[len(build_dir) + 1:]
+                    print("mesonbuild/backend/backends.py:   rel_src 2:", rel_src)
+                else:
+                    print("mesonbuild/backend/backends.py:   os.path.isabs(rel_src): no")
+                print("mesonbuild/backend/backends.py:   priv_dir: ", self.get_target_private_dir(target))
+                targetdir = self.get_target_private_dir(target)
+                print("mesonbuild/backend/backends.py:   targetdir:", targetdir)
+                print("mesonbuild/backend/backends.py:   rel_src 2:", rel_src)
                 rel_src = os.path.relpath(rel_src, self.get_target_private_dir(target))
+                print("mesonbuild/backend/backends.py:   rel_src 3:", rel_src)
             else:
+                print("mesonbuild/backend/backends.py:   source.is_built: no")
+                print("mesonbuild/backend/backends.py:   rel_src 1:", rel_src)
                 rel_src = os.path.basename(rel_src)
+                print("mesonbuild/backend/backends.py:   rel_src 4:", rel_src)
+                targetdir = self.get_target_private_dir(target)
+                print("mesonbuild/backend/backends.py:   targetdir:", targetdir)
+                print("mesonbuild/backend/backends.py:   rel_src 1:", rel_src_1)
+                print("mesonbuild/backend/backends.py:   rel_src 4a", os.path.relpath(rel_src_1, targetdir))
+            print("mesonbuild/backend/backends.py:   rel_src 5:", rel_src)
             # A meson- prefixed directory is reserved; hopefully no-one creates a file name with such a weird prefix.
             gen_source = 'meson-generated_' + rel_src[:-5] + '.c'
+            print("mesonbuild/backend/backends.py:   gen_source:", gen_source)
         elif source.is_built:
+            print("mesonbuild/backend/backends.py:   rel_src.endswith(('.vala', '.gs'): no")
+            print("mesonbuild/backend/backends.py:   source.is_built: yes")
             if os.path.isabs(rel_src):
+                print("mesonbuild/backend/backends.py:   os.path.isabs(rel_src): yes")
+                print("mesonbuild/backend/backends.py:   build_dir:", build_dir)
+                print("mesonbuild/backend/backends.py:   rel_src 1:", rel_src)
                 rel_src = rel_src[len(build_dir) + 1:]
+                print("mesonbuild/backend/backends.py:   rel_src 6:", rel_src)
+            else:
+                print("mesonbuild/backend/backends.py:   os.path.isabs(rel_src): no")
+            print("mesonbuild/backend/backends.py:   rel_src 7:", rel_src)
             targetdir = self.get_target_private_dir(target)
+            print("mesonbuild/backend/backends.py:   targetdir:", targetdir)
+            print("mesonbuild/backend/backends.py:   relpath(rel_src, targetdir):", os.path.relpath(rel_src, targetdir))
             # A meson- prefixed directory is reserved; hopefully no-one creates a file name with such a weird prefix.
             gen_source = 'meson-generated_' + os.path.relpath(rel_src, targetdir)
+            print("mesonbuild/backend/backends.py:   gen_source:", gen_source)
         else:
             if os.path.isabs(rel_src):
                 # Use the absolute path directly to avoid file name conflicts

c file → meson-generated_linux_ prefix (good)
this file is generated from ../src/linux/frida-helper-backend.vala
so its in the build tree = $PWD

mesonbuild/backend/backends.py: build_dir: /home/user/src/nixpkgs/frida/frida-core/build
mesonbuild/backend/backends.py: source: src/libfrida-helper-backend.so.p/linux/frida-helper-backend.c
mesonbuild/backend/backends.py: self.build_to_src: ..
mesonbuild/utils/universal.py: rel_to_builddir
mesonbuild/utils/universal.py:   self.is_built = True
mesonbuild/utils/universal.py:   self.relative_name() = src/libfrida-helper-backend.so.p/linux/frida-helper-backend.c
mesonbuild/utils/universal.py:   build_to_src = ..
mesonbuild/utils/universal.py:   self.subdir = src/libfrida-helper-backend.so.p/linux
mesonbuild/utils/universal.py:   self.fname = frida-helper-backend.c
mesonbuild/utils/universal.py:   join(build_to_src, self.subdir, self.fname) = ../src/libfrida-helper-backend.so.p/linux/frida-helper-backend.c
mesonbuild/backend/backends.py: rel_src: src/libfrida-helper-backend.so.p/linux/frida-helper-backend.c
mesonbuild/backend/backends.py:   rel_src.endswith(('.vala', '.gs'): no
mesonbuild/backend/backends.py:   source.is_built: yes
mesonbuild/backend/backends.py:   os.path.isabs(rel_src): no
mesonbuild/backend/backends.py:   rel_src 7: src/libfrida-helper-backend.so.p/linux/frida-helper-backend.c
mesonbuild/backend/backends.py:   targetdir: src/libfrida-helper-backend.so.p
mesonbuild/backend/backends.py:   relpath(rel_src, targetdir): linux/frida-helper-backend.c
mesonbuild/backend/backends.py:   gen_source: meson-generated_linux/frida-helper-backend.c

vala file → meson-generated_ prefix (bad)
this file is *not* generated, so its in the source tree = $PWD/..

mesonbuild/backend/backends.py: build_dir: /home/user/src/nixpkgs/frida/frida-core/build
mesonbuild/backend/backends.py: source: src/linux/frida-helper-backend.vala
mesonbuild/backend/backends.py: self.build_to_src: ..
mesonbuild/utils/universal.py: rel_to_builddir
mesonbuild/utils/universal.py:   self.is_built = False
mesonbuild/utils/universal.py:   self.relative_name() = src/linux/frida-helper-backend.vala
mesonbuild/utils/universal.py:   build_to_src = ..
mesonbuild/utils/universal.py:   self.subdir = src
mesonbuild/utils/universal.py:   self.fname = linux/frida-helper-backend.vala
mesonbuild/utils/universal.py:   join(build_to_src, self.subdir, self.fname) = ../src/linux/frida-helper-backend.vala
mesonbuild/backend/backends.py: rel_src: ../src/linux/frida-helper-backend.vala
mesonbuild/backend/backends.py:   rel_src.endswith(('.vala', '.gs'): yes
mesonbuild/backend/backends.py:   source.is_built: no
mesonbuild/backend/backends.py:   rel_src 1: ../src/linux/frida-helper-backend.vala
mesonbuild/backend/backends.py:   rel_src 4: frida-helper-backend.vala
mesonbuild/backend/backends.py:   targetdir: src/libfrida-helper-backend.so.p
mesonbuild/backend/backends.py:   rel_src 1: ../src/linux/frida-helper-backend.vala
mesonbuild/backend/backends.py:   rel_src 4a ../../../src/linux/frida-helper-backend.vala
mesonbuild/backend/backends.py:   rel_src 5: frida-helper-backend.vala
mesonbuild/backend/backends.py:   gen_source: meson-generated_frida-helper-backend.c

this is wrong

     if source.is_built:
         if os.path.isabs(rel_src):
             rel_src = rel_src[len(build_dir) + 1:]
         rel_src = os.path.relpath(rel_src, self.get_target_private_dir(target))
     else:
         # wrong
         rel_src = os.path.basename(rel_src)

fix:

mesonbuild/utils/universal.py:   self.fname = linux/frida-helper-backend.vala
-                rel_src = os.path.basename(rel_src)
+                rel_src = source.fname

next error, same problem

ninja: error: 'src/libfrida-core.so.p/meson-generated_compiler.c.o', needed by 'src/libfrida-core.a', missing and no known rule to make it

src/compiler/meson.build

compiler_sources = files(
  'compiler.vala',
)

src/meson.build

core_sources = base_sources + local_sources + remote_sources + compiler_sources

core = library('frida-core', core_sources,

so the relative source path is compiler/compiler.vala
(relative to the library call in src/meson.build)

actual vs expected target

+ build src/libfrida-core.so.p/meson-generated_compiler_compiler.c.o
- build src/libfrida-core.so.p/meson-generated_compiler.c.o

good

mesonbuild/backend/backends.py: build_dir: /home/user/src/nixpkgs/frida/frida-core/build
mesonbuild/backend/backends.py: source: src/libfrida-core.so.p/compiler/compiler.c
mesonbuild/backend/backends.py: self.build_to_src: ..
mesonbuild/utils/universal.py: rel_to_builddir
mesonbuild/utils/universal.py:   self.is_built = True
mesonbuild/utils/universal.py:   self.relative_name() = src/libfrida-core.so.p/compiler/compiler.c
mesonbuild/utils/universal.py:   build_to_src = ..
mesonbuild/utils/universal.py:   self.subdir = src/libfrida-core.so.p/compiler
mesonbuild/utils/universal.py:   self.fname = compiler.c
mesonbuild/utils/universal.py:   join(build_to_src, self.subdir, self.fname) = ../src/libfrida-core.so.p/compiler/compiler.c
mesonbuild/backend/backends.py: rel_src: src/libfrida-core.so.p/compiler/compiler.c
mesonbuild/backend/backends.py:   rel_src.endswith(('.vala', '.gs'): no
mesonbuild/backend/backends.py:   source.is_built: yes
mesonbuild/backend/backends.py:   os.path.isabs(rel_src): no
mesonbuild/backend/backends.py:   rel_src 7: src/libfrida-core.so.p/compiler/compiler.c
mesonbuild/backend/backends.py:   targetdir: src/libfrida-core.so.p
mesonbuild/backend/backends.py:   relpath(rel_src, targetdir): compiler/compiler.c
mesonbuild/backend/backends.py:   gen_source: meson-generated_compiler/compiler.c

bad

mesonbuild/backend/backends.py: build_dir: /home/user/src/nixpkgs/frida/frida-core/build
mesonbuild/backend/backends.py: source: src/compiler/compiler.vala
mesonbuild/backend/backends.py: self.build_to_src: ..
mesonbuild/utils/universal.py: rel_to_builddir
mesonbuild/utils/universal.py:   self.is_built = False
mesonbuild/utils/universal.py:   self.relative_name() = src/compiler/compiler.vala
mesonbuild/utils/universal.py:   build_to_src = ..
mesonbuild/utils/universal.py:   self.subdir = src/compiler
mesonbuild/utils/universal.py:   self.fname = compiler.vala
mesonbuild/utils/universal.py:   join(build_to_src, self.subdir, self.fname) = ../src/compiler/compiler.vala
mesonbuild/backend/backends.py: rel_src: ../src/compiler/compiler.vala
mesonbuild/backend/backends.py:   rel_src.endswith(('.vala', '.gs'): yes
mesonbuild/backend/backends.py:   source.is_built: no
mesonbuild/backend/backends.py:   rel_src 1: ../src/compiler/compiler.vala
mesonbuild/backend/backends.py:   rel_src 4: compiler.vala
mesonbuild/backend/backends.py:   targetdir: src/libfrida-core.so.p
mesonbuild/backend/backends.py:   rel_src 1: ../src/compiler/compiler.vala
mesonbuild/backend/backends.py:   rel_src 4a ../../../src/compiler/compiler.vala
mesonbuild/backend/backends.py:   rel_src 5: compiler.vala
mesonbuild/backend/backends.py:   gen_source: meson-generated_compiler.c

so source.fname is also wrong

instead, we need

so the relative source path is compiler/compiler.vala
(relative to the library call in src/meson.build)

mesonbuild/backend/backends.py

    def object_filename_from_source(self, target: build.BuildTarget, source: 'FileOrString') -> str:

# ...
                # FIXME this is wrong
                #rel_src = os.path.basename(rel_src)

                # fix? no
                #rel_src = source.fname

                # fix!
                # note: source.relative_name() =! rel_src
                # source.relative_name() is relative to the source tree
                # rel_src is relative to the build tree
                # note: os.path.basename(targetdir) is a generated folder like libfrida-core.so.p
                targetdir = self.get_target_private_dir(target)
                rel_src = os.path.relpath(source.relative_name(), os.path.dirname(targetdir))

todo? also fix def generate_vala_compile in
mesonbuild/backend/ninjabackend.py

todo? also fix other backends (cmake?)

AttributeError: 'SharedLibrary' object has no attribute 'split'

different error, but also with vala

passing a shared_library to custom_target

payload = shared_library('frida-payload-' + api_version, payload_sources,
  # ...
)

agent_payload_modulated = custom_target('frida-agent-payload-modulated-' + api_version,
  input: payload,

mesonbuild/backend/ninjabackend.py

    def determine_dep_vapis(self, target):
        """
        Peek into the sources of BuildTargets we're linking with, and if any of
        them was built with Vala, assume that it also generated a .vapi file of
        the same name as the BuildTarget and return the path to it relative to
        the build directory.
        """
        result = OrderedSet()
        for dep in itertools.chain(target.link_targets, target.link_whole_targets):
            if not dep.is_linkable_target():
                continue
            for i in dep.sources:
                if hasattr(i, 'fname'):
                    i = i.fname

                # FIXME AttributeError: 'SharedLibrary' object has no attribute 'split'
                print("mesonbuild/backend/ninjabackend.py: i =", i)
                #if i.split('.')[-1] in compilers.lang_suffixes['vala']:
                # fix: cast i to string
                if str(i).split('.')[-1] in compilers.lang_suffixes['vala']:
mesonbuild/backend/backends.py: rel_src_new = socket.vala
mesonbuild/backend/ninjabackend.py: i = session.vala
mesonbuild/backend/backends.py: rel_src_old = pipe.vala
mesonbuild/backend/backends.py: rel_src_new = pipe.vala
mesonbuild/backend/ninjabackend.py: i = session.vala
mesonbuild/backend/ninjabackend.py: i = session.vala
mesonbuild/backend/ninjabackend.py: i = pipe.vala
mesonbuild/backend/ninjabackend.py: i = frida-payload-1.0

Traceback (most recent call last):
  File "/nix/store/9ans8jl63cpm124ybwcsv8xwbhpjq1a7-meson-0.64.1/lib/python3.10/site-packages/mesonbuild/backend/ninjabackend.py", line 1494, in determine_dep_vapis
    if i.split('.')[-1] in compilers.lang_suffixes['vala']:
AttributeError: 'SharedLibrary' object has no attribute 'split'

im giving up at this point, because frida-core is too much of a "static only" build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants