hc
2025-02-14 bbb9540dc49f70f6b703d1c8d1b85fa5f602d86e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# The gbm functions that might be missing
gbm_check_funcs = [
  'gbm_bo_map',
  'gbm_bo_unmap',
  'gbm_bo_get_offset',
  'gbm_bo_get_plane_count',
  'gbm_device_get_format_modifier_plane_count',
  'gbm_bo_get_handle_for_plane',
  'gbm_bo_get_stride_for_plane',
  'gbm_bo_get_fd_for_plane',
  'gbm_bo_get_modifier',
  'gbm_bo_create_with_modifiers',
  'gbm_surface_create_with_modifiers',
  'gbm_bo_get_bpp',
  'gbm_format_get_name',
]
 
libhook_cflags = [
  '-DLIBMALI_SO="libmali.so.' + mali_version.split('.')[0] + '"',
]
 
libhook_dep = [mali]
libhook_dep += dependency('threads')
libhook_dep += cc.find_library('dl', required : false)
libhook_dep += dependency('libdrm', version : '>= 2.4.0')
 
libhook_inc = []
 
needs_hook = false
 
gbm_symbol = map['gbm'][0]
if cc.has_function(gbm_symbol, dependencies : mali)
  # Add hooks to support new GBM APIs
  libhook_inc += include_directories('../include/GBM')
  libhook_cflags += '-DHAS_GBM'
  foreach symbol : gbm_check_funcs
    if cc.has_function(symbol, dependencies : mali)
      libhook_cflags += '-DHAS_' + symbol
    endif
  endforeach
 
  needs_hook = true
endif
 
egl_symbol = map['egl'][0]
if cc.has_function(egl_symbol, dependencies : mali) and platform == 'x11'
  # Add hooks to init X11 threads
  libhook_inc += include_directories('../include')
  libhook_dep += dependency('x11')
  libhook_cflags += '-DHAS_X11_EGL'
 
  needs_hook = true
endif
 
if not needs_hook
  libhook_ldflags = []
  subdir_done()
endif
 
libhook = shared_library(
  'mali_hook',
  'hook.c',
  c_args : libhook_cflags,
  include_directories : libhook_inc,
  dependencies : libhook_dep,
  install : true,
  version : mali_version)
 
libhook_ldflags = ['-L${libdir}', '-lmali_hook']
 
# A dummy library to ensure that the hook library would not be removed as unused
libinjector = static_library(
  'mali_hook_injector',
  'injector.c',
  install : true)
 
# Ensure that the hook library would not be removed as unused
libhook_ldflags += \
  ['-Wl,--whole-archive', '-lmali_hook_injector', '-Wl,--no-whole-archive']