From bfdb97e53b1b6d037d00711f4601aabf167dbfbf Mon Sep 17 00:00:00 2001
From: Shawn Anastasio <shawnanastasio@yahoo.com>
Date: Sat, 1 Sep 2018 16:43:48 -0500
Subject: [PATCH] Add support for ppc64

---
 chromium/scripts/build_ffmpeg.py         | 11 +++++++++--
 chromium/scripts/copy_config.sh          |  2 +-
 chromium/scripts/generate_gn.py          |  2 +-
 chromium/scripts/generate_gn_unittest.py | 10 ++++++++--
 4 files changed, 19 insertions(+), 6 deletions(-)

Index: chromium-119.0.6045.59/third_party/ffmpeg/chromium/scripts/build_ffmpeg.py
===================================================================
--- chromium-119.0.6045.59.orig/third_party/ffmpeg/chromium/scripts/build_ffmpeg.py
+++ chromium-119.0.6045.59/third_party/ffmpeg/chromium/scripts/build_ffmpeg.py
@@ -43,7 +43,7 @@ BRANDINGS = [
 ARCH_MAP = {
     'android': ['ia32', 'x64', 'arm-neon', 'arm64'],
     'linux': [
-        'ia32', 'x64', 'noasm-x64', 'arm', 'arm-neon', 'arm64'
+        'ia32', 'x64', 'noasm-x64', 'arm', 'arm-neon', 'arm64', 'ppc64'
     ],
     'mac': ['x64', 'arm64'],
     'win': ['ia32', 'x64', 'arm64'],
@@ -145,6 +145,8 @@ def DetermineHostOsAndArch():
     host_arch = 'mips64el'
   elif platform.machine().startswith('arm'):
     host_arch = 'arm'
+  elif platform.machine() == 'ppc64le':
+    host_arch = 'ppc64'
   else:
     return None
 
@@ -923,6 +925,11 @@ def ConfigureAndBuild(target_arch, targe
             '--extra-cflags=--target=mips64el-linux-gnuabi64',
             '--extra-ldflags=--target=mips64el-linux-gnuabi64',
         ])
+    elif target_arch == 'ppc64':
+      configure_flags['Common'].extend([
+        '--arch=ppc64le',
+        '--extra-cflags=-mcpu=power8'
+      ])
     else:
       print(
           'Error: Unknown target arch %r for target OS %r!' % (target_arch,
Index: chromium-119.0.6045.59/third_party/ffmpeg/chromium/scripts/copy_config.sh
===================================================================
--- chromium-119.0.6045.59.orig/third_party/ffmpeg/chromium/scripts/copy_config.sh
+++ chromium-119.0.6045.59/third_party/ffmpeg/chromium/scripts/copy_config.sh
@@ -10,7 +10,7 @@ for os in android linux linux-noasm mac
     # Copy config files for various architectures:
     #   - ia32/x64 have config.asm, config.h
     #   - arm/arm-neon have config.h
-    for arch in arm arm-neon arm64 ia32 x64 mipsel mips64el; do
+    for arch in arm arm-neon arm64 ia32 x64 mipsel mips64el ppc64; do
       # Don't waste time on non-existent configs, if no config.h then skip.
       [ ! -e "build.$arch.$os/$target/config.h" ] && continue
       for f in config.h config_components.h config.asm libavutil/avconfig.h libavutil/ffversion.h libavcodec/bsf_list.c libavcodec/codec_list.c libavcodec/parser_list.c libavformat/demuxer_list.c libavformat/muxer_list.c libavformat/protocol_list.c; do
Index: chromium-119.0.6045.59/third_party/ffmpeg/chromium/scripts/generate_gn.py
===================================================================
--- chromium-119.0.6045.59.orig/third_party/ffmpeg/chromium/scripts/generate_gn.py
+++ chromium-119.0.6045.59/third_party/ffmpeg/chromium/scripts/generate_gn.py
@@ -82,7 +82,7 @@ _Attrs = ('ARCHITECTURE', 'TARGET', 'PLA
 Attr = collections.namedtuple('Attr', _Attrs)(*_Attrs)
 SUPPORT_MATRIX = {
     Attr.ARCHITECTURE:
-        set(['ia32', 'x64', 'arm', 'arm64', 'arm-neon']),
+        set(['ia32', 'x64', 'arm', 'arm64', 'arm-neon', 'ppc64']),
     Attr.TARGET:
         set(['Chromium', 'Chrome', 'ChromeOS']),
     Attr.PLATFORM:
Index: chromium-119.0.6045.59/third_party/ffmpeg/chromium/scripts/generate_gn_unittest.py
===================================================================
--- chromium-119.0.6045.59.orig/third_party/ffmpeg/chromium/scripts/generate_gn_unittest.py
+++ chromium-119.0.6045.59/third_party/ffmpeg/chromium/scripts/generate_gn_unittest.py
@@ -329,6 +329,10 @@ class SourceSetUnittest(unittest.TestCas
     f = SourceSet(
         set(['common', 'arm-neon', 'chrome', 'chromeos']),
         set([SourceListCondition('arm-neon', 'ChromeOS', 'linux')]))
+    g = SourceSet(
+        set(['common']),
+        set([SourceListCondition('ppc64', 'Chromium', 'linux')]))
+
 
     expected = set()
     expected.add(
@@ -340,7 +344,8 @@ class SourceSetUnittest(unittest.TestCas
                 SourceListCondition('x64', 'Chromium', 'linux'),
                 SourceListCondition('x64', 'Chrome', 'linux'),
                 SourceListCondition('arm', 'Chromium', 'linux'),
-                SourceListCondition('arm-neon', 'ChromeOS', 'linux')
+                SourceListCondition('arm-neon', 'ChromeOS', 'linux'),
+                SourceListCondition('ppc64', 'Chromium', 'linux')
             ])))
     expected.add(
         SourceSet(
@@ -368,7 +373,7 @@ class SourceSetUnittest(unittest.TestCas
             set(['arm-neon', 'chromeos']),
             set([SourceListCondition('arm-neon', 'ChromeOS', 'linux')])))
 
-    source_sets = gg.CreatePairwiseDisjointSets([a, b, c, d, e, f])
+    source_sets = gg.CreatePairwiseDisjointSets([a, b, c, d, e, f, g])
     self.assertEqualSourceSets(expected, set(source_sets))
 
   def testReduceConditions(self):
@@ -381,6 +386,7 @@ class SourceSetUnittest(unittest.TestCas
             SourceListCondition('arm', 'Chromium', 'linux'),
             SourceListCondition('arm64', 'Chromium', 'linux'),
             SourceListCondition('arm-neon', 'Chromium', 'linux'),
+            SourceListCondition('ppc64', 'Chromium', 'linux'),
         ]))
     gg.ReduceConditionalLogic(a)
 
