summaryrefslogtreecommitdiff
path: root/www-client/ungoogled-chromium/files/chromium-157-bindgen-libclang-paths.patch
blob: b4ca583b10b8cf4819a4b8156878f9d119d49597 (plain)
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
--- a/build/config/rust.gni
+++ b/build/config/rust.gni
@@ -63,6 +63,19 @@
   # the bindgen exectuable).
   rust_bindgen_root = "//third_party/rust-toolchain"
 
+  # Directory under which to find one of `libclang.{dll,so}` (a `lib[64]` or
+  # `bin` directory containing the libclang shared library).
+  # We don't need to worry about multlib, but specify the full path here
+  # in case a distribution does.
+  bindgen_libclang_path = ""
+
+  # Directory under which to find the `clang` resource directory.
+  # This is used by bindgen to find system headers.
+  bindgen_clang_resource_dir = ""
+
+  # Additional arguments to pass to clang when running bindgen.
+  bindgen_extra_clang_args = []
+
   # If you're using a Rust toolchain as specified by rust_sysroot_absolute,
   # set this to the output of `rustc -V`. Changing this string will cause all
   # Rust targets to be rebuilt, which allows you to update your toolchain and
--- a/build/rust/rust_bindgen_generator.gni
+++ b/build/rust/rust_bindgen_generator.gni
@@ -22,14 +22,18 @@
 
 # On Windows, the libclang.dll is beside the bindgen.exe, otherwise it is in
 # ../lib.
-_libclang_path = rust_bindgen_root
-if (!use_chromium_rust_toolchain &&
-    (host_cpu == "ppc64" || host_cpu == "s390x")) {
-  _libclang_path = rust_sysroot_absolute + "/lib64"
-} else if (host_os == "win") {
-  _libclang_path += "/bin"
+if (bindgen_libclang_path != "") {
+  _libclang_path = bindgen_libclang_path
 } else {
-  _libclang_path += "/lib"
+  _libclang_path = rust_bindgen_root
+  if (!use_chromium_rust_toolchain &&
+      (host_cpu == "ppc64" || host_cpu == "s390x")) {
+    _libclang_path = rust_sysroot_absolute + "/lib64"
+  } else if (host_os == "win") {
+    _libclang_path += "/bin"
+  } else {
+    _libclang_path += "/lib"
+  }
 }
 
 # Template to build Rust/C bindings with bindgen.
@@ -190,10 +194,17 @@
     if (is_linux) {
       # Linux clang, and clang libs, use a shared libstdc++, which we must
       # point to.
-      args += [
-        "--ld-library-path",
-        rebase_path(clang_base_path + "/lib", root_build_dir),
-      ]
+      if (bindgen_libclang_path != "") {
+        args += [
+          "--ld-library-path",
+          rebase_path(bindgen_libclang_path, root_build_dir),
+        ]
+      } else {
+        args += [
+          "--ld-library-path",
+          rebase_path(clang_base_path + "/lib", root_build_dir),
+        ]
+      }
     }
 
     args += [ "--bindgen-flags" ]
--- a/build/rust/gni_impl/libclang_args.gni
+++ b/build/rust/gni_impl/libclang_args.gni
@@ -19,6 +19,7 @@
 #   }
 
 import("//build/config/clang/clang.gni")
+import("//build/config/rust.gni")
 import("//build/config/sanitizers/sanitizers.gni")
 
 if (is_win) {
@@ -36,10 +37,17 @@
 # says the wrong thing. We point it to our clang's resource dir which will
 # make it behave consistently with our other command line flags and allows
 # system headers to be found.
-_libclang_extra_args += [
-  "-resource-dir",
-  rebase_path(clang_base_path + "/lib/clang/" + clang_version, root_build_dir),
-]
+if (bindgen_clang_resource_dir != "") {
+  _libclang_extra_args += [
+    "-resource-dir",
+    rebase_path(bindgen_clang_resource_dir, root_build_dir),
+  ]
+} else {
+  _libclang_extra_args += [
+    "-resource-dir",
+    rebase_path(clang_base_path + "/lib/clang/" + clang_version, root_build_dir),
+  ]
+}
 
 if (is_win) {
   # On Windows we fall back to using system headers from a sysroot from
@@ -92,6 +100,10 @@
   _libclang_extra_args += [ "-fno-sanitize-ignorelist" ]
 }
 
+if (bindgen_extra_clang_args != []) {
+  _libclang_extra_args += bindgen_extra_clang_args
+}
+
 # Args for parsing C headers.
 libclang_args_for_c = [
                         "{{defines}}",