[cef][wam] Make the recipe work with official chromium release tarballs
[AGL/meta-agl-demo.git] / recipes-wam / cef / files / chromium / 0031-M118-fix-Add-a-way-to-set-different-lib-paths-host-a.patch
1 From e1bc5ea870e17afee145009194e6f2092dd1d3ff Mon Sep 17 00:00:00 2001
2 From: Roger Zanoni <rzanoni@igalia.com>
3 Date: Sun, 12 Nov 2023 19:41:07 -0300
4 Subject: [PATCH 31/33] [M118-fix] Add a way to set different lib paths host
5  and target
6
7 meta-clang on AGL defines a simplified path structure for clang's
8 runtime libraries and a different lib naming convention.
9
10 Upstream-Status: Inappropriate
11 Signed-off-by: Roger Zanoni <rzanoni@igalia.com>
12 ---
13  build/config/clang/BUILD.gn  | 80 +++++++++++-------------------------
14  build/config/clang/clang.gni |  3 ++
15  2 files changed, 27 insertions(+), 56 deletions(-)
16
17 diff --git a/build/config/clang/BUILD.gn b/build/config/clang/BUILD.gn
18 index fe044e29e428b..33edce7aed9a2 100644
19 --- a/build/config/clang/BUILD.gn
20 +++ b/build/config/clang/BUILD.gn
21 @@ -3,6 +3,7 @@
22  # found in the LICENSE file.
23  
24  import("//build/config/rust.gni")
25 +import("//v8/gni/snapshot_toolchain.gni")
26  import("clang.gni")
27  
28  if (is_ios) {
29 @@ -95,66 +96,33 @@ template("clang_lib") {
30      }
31    } else {
32      config(target_name) {
33 -      _dir = ""
34 +      if (current_toolchain == host_toolchain ||
35 +          current_toolchain == v8_snapshot_toolchain) {
36 +        _base_path = "$clang_base_path"
37 +        _cpu = host_cpu
38 +      } else {
39 +        _base_path = "$clang_base_path_target"
40 +        _cpu = target_cpu
41 +      }
42 +
43 +      if (_cpu == "x64") {
44 +        _suffix = "-x86_64"
45 +      } else if (_cpu == "x86") {
46 +        _suffix = "-i386"
47 +      } else if (_cpu == "arm64") {
48 +        _suffix = "-aarch64"
49 +      } else if (_cpu == "arm") {
50 +        _suffix = "-arm"
51 +      } else {
52 +        assert(false)  # Unhandled cpu type
53 +      }
54 +
55 +      _dir = "linux"
56        _libname = invoker.libname
57        _prefix = "lib"
58 -      _suffix = ""
59        _ext = "a"
60 -      if (is_win) {
61 -        _dir = "windows"
62 -        _prefix = ""
63 -        _ext = "lib"
64 -        if (current_cpu == "x64") {
65 -          _suffix = "-x86_64"
66 -        } else if (current_cpu == "x86") {
67 -          _suffix = "-i386"
68 -        } else if (current_cpu == "arm64") {
69 -          _suffix = "-aarch64"
70 -        } else {
71 -          assert(false)  # Unhandled cpu type
72 -        }
73 -      } else if (is_apple) {
74 -        _dir = "darwin"
75 -      } else if (is_linux || is_chromeos) {
76 -        if (current_cpu == "x64") {
77 -          _dir = "x86_64-unknown-linux-gnu"
78 -        } else if (current_cpu == "x86") {
79 -          _dir = "i386-unknown-linux-gnu"
80 -        } else if (current_cpu == "arm") {
81 -          _dir = "armv7-unknown-linux-gnueabihf"
82 -        } else if (current_cpu == "arm64") {
83 -          _dir = "aarch64-unknown-linux-gnu"
84 -        } else {
85 -          assert(false)  # Unhandled cpu type
86 -        }
87 -      } else if (is_fuchsia) {
88 -        if (current_cpu == "x64") {
89 -          _dir = "x86_64-unknown-fuchsia"
90 -        } else if (current_cpu == "arm64") {
91 -          _dir = "aarch64-unknown-fuchsia"
92 -        } else {
93 -          assert(false)  # Unhandled cpu type
94 -        }
95 -      } else if (is_android) {
96 -        _dir = "linux"
97 -        if (current_cpu == "x64") {
98 -          _suffix = "-x86_64-android"
99 -        } else if (current_cpu == "x86") {
100 -          _suffix = "-i686-android"
101 -        } else if (current_cpu == "arm") {
102 -          _suffix = "-arm-android"
103 -        } else if (current_cpu == "arm64") {
104 -          _suffix = "-aarch64-android"
105 -        } else if (current_cpu == "riscv64") {
106 -          _suffix = "-riscv64-android"
107 -        } else {
108 -          assert(false)  # Unhandled cpu type
109 -        }
110 -      } else {
111 -        assert(false)  # Unhandled target platform
112 -      }
113  
114 -      _clang_lib_dir = "$clang_base_path/lib/clang/$clang_version/lib"
115 +      _clang_lib_dir = "$_base_path/lib/clang/$clang_version/lib"
116        _lib_file = "${_prefix}clang_rt.${_libname}${_suffix}.${_ext}"
117        libs = [ "$_clang_lib_dir/$_dir/$_lib_file" ]
118      }
119 diff --git a/build/config/clang/clang.gni b/build/config/clang/clang.gni
120 index 1a065b5e348b0..46fb56693b494 100644
121 --- a/build/config/clang/clang.gni
122 +++ b/build/config/clang/clang.gni
123 @@ -26,6 +26,9 @@ declare_args() {
124        build_with_chromium && !is_official_build && is_linux && !is_castos
125  
126    clang_base_path = default_clang_base_path
127 +  
128 +  # used only for linking
129 +  clang_base_path_target = default_clang_base_path
130  
131    # Specifies whether or not bitcode should be embedded during compilation.
132    # This is used for creating a MLGO corpus from Chromium in the non-ThinLTO case.
133 -- 
134 2.42.1
135