generate_library_loader.gni 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. # Copyright 2014 The Chromium Authors. All rights reserved.
  2. # Use of this source code is governed by a BSD-style license that can be
  3. # found in the LICENSE file.
  4. # This template makes a stub for a Linux system library that dynamically loads
  5. # it at runtime.
  6. # name: Name to use for the value of the --name arg.
  7. # output_h/output_cc: Names for the generated header/cc file with no dir.
  8. # header: header file to process. Example: "<foo/bar.h>"
  9. # functions: List of strings for functions to process.
  10. # config: (optional) Label of the config generated by pkgconfig.
  11. # bundled_header: (optional)
  12. template("generate_library_loader") {
  13. output_h = "$root_gen_dir/library_loaders/" + invoker.output_h
  14. output_cc = "$root_gen_dir/library_loaders/" + invoker.output_cc
  15. action_visibility = [ ":$target_name" ]
  16. action("${target_name}_loader") {
  17. visibility = action_visibility
  18. script = "//tools/generate_library_loader/generate_library_loader.py"
  19. outputs = [
  20. output_h,
  21. output_cc,
  22. ]
  23. args = [
  24. "--name",
  25. invoker.name,
  26. "--output-h",
  27. rebase_path(output_h, root_build_dir),
  28. "--output-cc",
  29. rebase_path(output_cc, root_build_dir),
  30. "--header",
  31. invoker.header,
  32. # Note GYP build exposes a per-target variable to control this, which, if
  33. # manually set to true, will disable dlopen(). Its not clear this is
  34. # needed, so here we just leave off. If this can be done globally, we can
  35. # expose one switch for this value, otherwise we need to add a template
  36. # param for this.
  37. "--link-directly=0",
  38. ]
  39. if (defined(invoker.bundled_header)) {
  40. args += [
  41. "--bundled-header",
  42. invoker.bundled_header,
  43. ]
  44. }
  45. args += invoker.functions
  46. }
  47. source_set(target_name) {
  48. if (defined(invoker.config)) {
  49. public_configs = [ invoker.config ]
  50. }
  51. sources = [
  52. output_cc,
  53. output_h,
  54. ]
  55. public_deps = [ ":${target_name}_loader" ]
  56. }
  57. }