[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
diff --git a/recipes-wam/cef/files/chromium/0031-M118-fix-Add-a-way-to-set-different-lib-paths-host-a.patch b/recipes-wam/cef/files/chromium/0031-M118-fix-Add-a-way-to-set-different-lib-paths-host-a.patch
new file mode 100644 (file)
index 0000000..fa4dfe6
--- /dev/null
@@ -0,0 +1,135 @@
+From e1bc5ea870e17afee145009194e6f2092dd1d3ff Mon Sep 17 00:00:00 2001
+From: Roger Zanoni <rzanoni@igalia.com>
+Date: Sun, 12 Nov 2023 19:41:07 -0300
+Subject: [PATCH 31/33] [M118-fix] Add a way to set different lib paths host
+ and target
+
+meta-clang on AGL defines a simplified path structure for clang's
+runtime libraries and a different lib naming convention.
+
+Upstream-Status: Inappropriate
+Signed-off-by: Roger Zanoni <rzanoni@igalia.com>
+---
+ build/config/clang/BUILD.gn  | 80 +++++++++++-------------------------
+ build/config/clang/clang.gni |  3 ++
+ 2 files changed, 27 insertions(+), 56 deletions(-)
+
+diff --git a/build/config/clang/BUILD.gn b/build/config/clang/BUILD.gn
+index fe044e29e428b..33edce7aed9a2 100644
+--- a/build/config/clang/BUILD.gn
++++ b/build/config/clang/BUILD.gn
+@@ -3,6 +3,7 @@
+ # found in the LICENSE file.
+ import("//build/config/rust.gni")
++import("//v8/gni/snapshot_toolchain.gni")
+ import("clang.gni")
+ if (is_ios) {
+@@ -95,66 +96,33 @@ template("clang_lib") {
+     }
+   } else {
+     config(target_name) {
+-      _dir = ""
++      if (current_toolchain == host_toolchain ||
++          current_toolchain == v8_snapshot_toolchain) {
++        _base_path = "$clang_base_path"
++        _cpu = host_cpu
++      } else {
++        _base_path = "$clang_base_path_target"
++        _cpu = target_cpu
++      }
++
++      if (_cpu == "x64") {
++        _suffix = "-x86_64"
++      } else if (_cpu == "x86") {
++        _suffix = "-i386"
++      } else if (_cpu == "arm64") {
++        _suffix = "-aarch64"
++      } else if (_cpu == "arm") {
++        _suffix = "-arm"
++      } else {
++        assert(false)  # Unhandled cpu type
++      }
++
++      _dir = "linux"
+       _libname = invoker.libname
+       _prefix = "lib"
+-      _suffix = ""
+       _ext = "a"
+-      if (is_win) {
+-        _dir = "windows"
+-        _prefix = ""
+-        _ext = "lib"
+-        if (current_cpu == "x64") {
+-          _suffix = "-x86_64"
+-        } else if (current_cpu == "x86") {
+-          _suffix = "-i386"
+-        } else if (current_cpu == "arm64") {
+-          _suffix = "-aarch64"
+-        } else {
+-          assert(false)  # Unhandled cpu type
+-        }
+-      } else if (is_apple) {
+-        _dir = "darwin"
+-      } else if (is_linux || is_chromeos) {
+-        if (current_cpu == "x64") {
+-          _dir = "x86_64-unknown-linux-gnu"
+-        } else if (current_cpu == "x86") {
+-          _dir = "i386-unknown-linux-gnu"
+-        } else if (current_cpu == "arm") {
+-          _dir = "armv7-unknown-linux-gnueabihf"
+-        } else if (current_cpu == "arm64") {
+-          _dir = "aarch64-unknown-linux-gnu"
+-        } else {
+-          assert(false)  # Unhandled cpu type
+-        }
+-      } else if (is_fuchsia) {
+-        if (current_cpu == "x64") {
+-          _dir = "x86_64-unknown-fuchsia"
+-        } else if (current_cpu == "arm64") {
+-          _dir = "aarch64-unknown-fuchsia"
+-        } else {
+-          assert(false)  # Unhandled cpu type
+-        }
+-      } else if (is_android) {
+-        _dir = "linux"
+-        if (current_cpu == "x64") {
+-          _suffix = "-x86_64-android"
+-        } else if (current_cpu == "x86") {
+-          _suffix = "-i686-android"
+-        } else if (current_cpu == "arm") {
+-          _suffix = "-arm-android"
+-        } else if (current_cpu == "arm64") {
+-          _suffix = "-aarch64-android"
+-        } else if (current_cpu == "riscv64") {
+-          _suffix = "-riscv64-android"
+-        } else {
+-          assert(false)  # Unhandled cpu type
+-        }
+-      } else {
+-        assert(false)  # Unhandled target platform
+-      }
+-      _clang_lib_dir = "$clang_base_path/lib/clang/$clang_version/lib"
++      _clang_lib_dir = "$_base_path/lib/clang/$clang_version/lib"
+       _lib_file = "${_prefix}clang_rt.${_libname}${_suffix}.${_ext}"
+       libs = [ "$_clang_lib_dir/$_dir/$_lib_file" ]
+     }
+diff --git a/build/config/clang/clang.gni b/build/config/clang/clang.gni
+index 1a065b5e348b0..46fb56693b494 100644
+--- a/build/config/clang/clang.gni
++++ b/build/config/clang/clang.gni
+@@ -26,6 +26,9 @@ declare_args() {
+       build_with_chromium && !is_official_build && is_linux && !is_castos
+   clang_base_path = default_clang_base_path
++  
++  # used only for linking
++  clang_base_path_target = default_clang_base_path
+   # Specifies whether or not bitcode should be embedded during compilation.
+   # This is used for creating a MLGO corpus from Chromium in the non-ThinLTO case.
+-- 
+2.42.1
+