Use libvpx's obj_int_extract and unpack_lib_posix to generate offset header file.

This patch removes generate_asm_header.gypi and uses libvpx's obj_int_extract and
unpack_lib_posix to generate offset header files.

It make the simliar feature's implementation consistent.

R=andrew@webrtc.org, fischman@webrtc.org, fischman@chromium.org
BUG=334447

Committed: https://code.google.com/p/webrtc/source/detail?r=5517

Review URL: https://webrtc-codereview.appspot.com/7769006

git-svn-id: http://webrtc.googlecode.com/svn/trunk/webrtc@5524 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/build/common.gypi b/build/common.gypi
index e4a4b09..d8b958a 100644
--- a/build/common.gypi
+++ b/build/common.gypi
@@ -25,11 +25,13 @@
             'webrtc_root%': '<(DEPTH)/third_party/webrtc',
             'apk_tests_path%': '<(DEPTH)/third_party/webrtc/build/apk_tests.gyp',
             'modules_java_gyp_path%': '<(DEPTH)/third_party/webrtc/modules/modules_java_chromium.gyp',
+            'gen_core_neon_offsets_gyp%': '<(DEPTH)/third_party/webrtc/modules/audio_processing/gen_core_neon_offsets_chromium.gyp',
           }, {
             'build_with_libjingle%': 0,
             'webrtc_root%': '<(DEPTH)/webrtc',
             'apk_tests_path%': '<(DEPTH)/webrtc/build/apk_test_noop.gyp',
             'modules_java_gyp_path%': '<(DEPTH)/webrtc/modules/modules_java.gyp',
+            'gen_core_neon_offsets_gyp%':'<(DEPTH)/webrtc/modules/audio_processing/gen_core_neon_offsets.gyp',
           }],
         ],
       },
@@ -38,7 +40,7 @@
       'webrtc_root%': '<(webrtc_root)',
       'apk_tests_path%': '<(apk_tests_path)',
       'modules_java_gyp_path%': '<(modules_java_gyp_path)',
-
+      'gen_core_neon_offsets_gyp%': '<(gen_core_neon_offsets_gyp)',
       'webrtc_vp8_dir%': '<(webrtc_root)/modules/video_coding/codecs/vp8',
       'rbe_components_path%': '<(webrtc_root)/modules/remote_bitrate_estimator',
       'include_opus%': 1,
@@ -48,6 +50,7 @@
     'webrtc_root%': '<(webrtc_root)',
     'apk_tests_path%': '<(apk_tests_path)',
     'modules_java_gyp_path%': '<(modules_java_gyp_path)',
+    'gen_core_neon_offsets_gyp%': '<(gen_core_neon_offsets_gyp)',
     'webrtc_vp8_dir%': '<(webrtc_vp8_dir)',
     'include_opus%': '<(include_opus)',
     'rbe_components_path%': '<(rbe_components_path)',
diff --git a/build/generate_asm_header.gypi b/build/generate_asm_header.gypi
deleted file mode 100644
index 4600bb1..0000000
--- a/build/generate_asm_header.gypi
+++ /dev/null
@@ -1,79 +0,0 @@
-# Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
-#
-# Use of this source code is governed by a BSD-style license
-# that can be found in the LICENSE file in the root of the source
-# tree. An additional intellectual property rights grant can be found
-# in the file PATENTS.  All contributing project authors may
-# be found in the AUTHORS file in the root of the source tree.
-
-# This file is meant to be included into a target to provide an action
-# to generate C header files. These headers include definitions
-# that can be used in ARM assembly files.
-#
-# To use this, create a gyp target with the following form:
-# {
-#   'target_name': 'my_asm_headers_lib',
-#   'type': 'static_library',
-#   'sources': [
-#     'foo.c',
-#     'bar.c',
-#   ],
-#   'includes': ['path/to/this/gypi/file'],
-# }
-#
-# The headers are guaranteed to be generated before any
-# source files, even within this target, are compiled.
-#
-# The 'asm_header_dir' variable specifies the path suffix that output
-# files are generated under.
-
-# TODO(kma): port this block from Android into other build systems.
-{
-  'variables': {
-    'out_dir': '<(SHARED_INTERMEDIATE_DIR)/<(asm_header_dir)',
-    'process_outputs_as_sources': 1,
-    'conditions': [
-      # We only support Android and iOS.
-      ['OS=="android"', {
-        'compiler_to_use':
-          '<!(/bin/echo -n ${ANDROID_GOMA_WRAPPER} <(android_toolchain)/*-gcc)',
-        'compiler_options': '-I<(webrtc_root)/.. -I<@(android_ndk_include) -S',
-        'pattern_to_detect': 'offset_',
-      }],
-      ['OS=="ios"', {
-        'compiler_to_use': 'clang',
-        'compiler_options':
-          '-arch armv7 -I<(webrtc_root)/.. -isysroot $(SDKROOT) -S',
-        'pattern_to_detect': '_offset_',
-      }],
-    ]
-  },
-  'rules': [
-    {
-      'rule_name': 'generate_asm_header',
-      'extension': 'c',
-      'inputs': [
-        'generate_asm_header.py',
-      ],
-      'outputs': [
-        '<(out_dir)/<(RULE_INPUT_ROOT).h',
-      ],
-      'action': [
-        'python',
-        '<(webrtc_root)/build/generate_asm_header.py',
-        '--compiler=<(compiler_to_use)',
-        '--options=<(compiler_options)',
-        '--pattern=<(pattern_to_detect)',
-        '--dir=<(out_dir)',
-        '<(RULE_INPUT_PATH)',
-      ],
-      'message': 'Generating assembly header files',
-      'process_outputs_as_sources': 1,
-    },
-  ],
-  'direct_dependent_settings': {
-    'include_dirs': ['<(out_dir)',],
-  },
-  # This target exports a hard dependency because it generates header files.
-  'hard_dependency': 1,
-}
diff --git a/build/generate_asm_header.py b/build/generate_asm_header.py
deleted file mode 100644
index c159d50..0000000
--- a/build/generate_asm_header.py
+++ /dev/null
@@ -1,74 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
-#
-# Use of this source code is governed by a BSD-style license
-# that can be found in the LICENSE file in the root of the source
-# tree. An additional intellectual property rights grant can be found
-# in the file PATENTS.  All contributing project authors may
-# be found in the AUTHORS file in the root of the source tree.
-
-"""This script is a tool to generate special header files from input
-C source files.
-
-It first assembles the input source files to generate intermediate assembly
-files (*.s). Then it parses the .s files and finds declarations of variables
-whose names start with the string specified as the third argument in the
-command-line, translates the variable names and values into constant defines
-and writes them into header files.
-"""
-
-import os
-import re
-import subprocess
-import sys
-from optparse import OptionParser
-
-def main(argv):
-  parser = OptionParser()
-  usage = 'Usage: %prog [options] input_filename'
-  parser.set_usage(usage)
-  parser.add_option('--compiler', default = 'gcc', help = 'compiler name')
-  parser.add_option('--options', default = '-S', help = 'compiler options')
-  parser.add_option('--pattern', default = 'offset_', help = 'A match pattern'
-                    ' used for searching the relevant constants.')
-  parser.add_option('--dir', default = '.', help = 'output directory')
-  (options, args) = parser.parse_args()
-
-  # Generate complete intermediate and header file names.
-  input_filename = args[0]
-  output_root = (options.dir + '/' +
-      os.path.splitext(os.path.basename(input_filename))[0])
-  interim_filename = output_root + '.s'
-  out_filename = output_root + '.h'
-
-  # Set the shell command with the compiler and options inputs.
-  compiler_command = (options.compiler + " " + options.options + " " +
-      input_filename + " -o " + interim_filename)
-
-  # Run the shell command and generate the intermediate file.
-  subprocess.check_call(compiler_command, shell=True)
-
-  interim_file = open(interim_filename)  # The intermediate file.
-  out_file = open(out_filename, 'w')  # The output header file.
-
-  # Generate the output header file.
-  while True:
-    line = interim_file.readline()
-    if not line: break
-    if line.startswith(options.pattern):
-      # Find name of the next constant and write to the output file.
-      const_name = re.sub(r'^_', '', line.split(':')[0])
-      out_file.write('#define %s ' % const_name)
-
-      # Find value of the constant we just found and write to the output file.
-      line = interim_file.readline()
-      const_value = filter(str.isdigit, line.split(' ')[0])
-      if const_value != '':
-        out_file.write('%s\n' % const_value)
-
-  interim_file.close()
-  out_file.close()
-
-if __name__ == "__main__":
-  main(sys.argv[1:])
diff --git a/modules/audio_processing/audio_processing.gypi b/modules/audio_processing/audio_processing.gypi
index ed62a8a..dd5a586 100644
--- a/modules/audio_processing/audio_processing.gypi
+++ b/modules/audio_processing/audio_processing.gypi
@@ -12,6 +12,7 @@
       '<(webrtc_root)/common_audio/common_audio.gyp:common_audio',
       '<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:system_wrappers',
     ],
+    'shared_generated_dir': '<(SHARED_INTERMEDIATE_DIR)/audio_processing/asm_offsets',
   },
   'targets': [
     {
@@ -194,12 +195,15 @@
         'conditions': [
           ['OS=="android" or OS=="ios"', {
             'dependencies': [
-              'audio_processing_offsets',
+              '<(gen_core_neon_offsets_gyp):*',
             ],
             'sources': [
               'aecm/aecm_core_neon.S',
               'ns/nsx_core_neon.S',
             ],
+            'include_dirs': [
+              '<(shared_generated_dir)',
+            ],
             'sources!': [
               'aecm/aecm_core_neon.c',
               'ns/nsx_core_neon.c',
@@ -208,22 +212,6 @@
           }],
         ],
       }],
-      'conditions': [
-        ['OS=="android" or OS=="ios"', {
-          'targets': [{
-            'target_name': 'audio_processing_offsets',
-            'type': 'none',
-            'sources': [
-              'aecm/aecm_core_neon_offsets.c',
-              'ns/nsx_core_neon_offsets.c',
-            ],
-            'variables': {
-              'asm_header_dir': 'asm_offsets',
-            },
-            'includes': ['../../build/generate_asm_header.gypi',],
-          }],
-        }],
-      ],
     }],
   ],
 }
diff --git a/modules/audio_processing/gen_core_neon_offsets.gyp b/modules/audio_processing/gen_core_neon_offsets.gyp
new file mode 100644
index 0000000..55c7968
--- /dev/null
+++ b/modules/audio_processing/gen_core_neon_offsets.gyp
@@ -0,0 +1,45 @@
+# Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
+#
+# Use of this source code is governed by a BSD-style license
+# that can be found in the LICENSE file in the root of the source
+# tree. An additional intellectual property rights grant can be found
+# in the file PATENTS.  All contributing project authors may
+# be found in the AUTHORS file in the root of the source tree.
+
+{
+  'includes': ['lib_core_neon_offsets.gypi'],
+  'targets' : [
+    {
+      'target_name': 'gen_nsx_core_neon_offsets_h',
+      'type': 'none',
+      'dependencies': [
+        'lib_core_neon_offsets',
+        '<(DEPTH)/third_party/libvpx/libvpx.gyp:libvpx_obj_int_extract#host',
+      ],
+      'sources': ['<(shared_generated_dir)/nsx_core_neon_offsets.o',],
+      'variables' : {
+        'unpack_lib_name':'nsx_core_neon_offsets.o',
+      },
+      'includes': [
+        '../../../third_party/libvpx/unpack_lib_posix.gypi',
+        '../../../third_party/libvpx/obj_int_extract.gypi',
+      ],
+    },
+    {
+      'target_name': 'gen_aecm_core_neon_offsets_h',
+      'type': 'none',
+      'dependencies': [
+        'lib_core_neon_offsets',
+        '<(DEPTH)/third_party/libvpx/libvpx.gyp:libvpx_obj_int_extract#host',
+      ],
+      'variables': {
+        'unpack_lib_name':'aecm_core_neon_offsets.o',
+      },
+      'sources': ['<(shared_generated_dir)/aecm_core_neon_offsets.o',],
+      'includes': [
+        '../../../third_party/libvpx/unpack_lib_posix.gypi',
+        '../../../third_party/libvpx/obj_int_extract.gypi',
+      ],
+    },
+  ],
+}
diff --git a/modules/audio_processing/gen_core_neon_offsets_chromium.gyp b/modules/audio_processing/gen_core_neon_offsets_chromium.gyp
new file mode 100644
index 0000000..f4a9134
--- /dev/null
+++ b/modules/audio_processing/gen_core_neon_offsets_chromium.gyp
@@ -0,0 +1,45 @@
+# Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
+#
+# Use of this source code is governed by a BSD-style license
+# that can be found in the LICENSE file in the root of the source
+# tree. An additional intellectual property rights grant can be found
+# in the file PATENTS.  All contributing project authors may
+# be found in the AUTHORS file in the root of the source tree.
+
+{
+  'includes': ['lib_core_neon_offsets.gypi'],
+  'targets' : [
+    {
+      'target_name': 'gen_nsx_core_neon_offsets_h',
+      'type': 'none',
+      'dependencies': [
+        'lib_core_neon_offsets',
+        '<(DEPTH)/third_party/libvpx/libvpx.gyp:libvpx_obj_int_extract#host',
+      ],
+      'sources': ['<(shared_generated_dir)/nsx_core_neon_offsets.o',],
+      'variables' : {
+        'unpack_lib_name':'nsx_core_neon_offsets.o',
+      },
+      'includes': [
+        '../../../../third_party/libvpx/unpack_lib_posix.gypi',
+        '../../../../third_party/libvpx/obj_int_extract.gypi',
+      ],
+    },
+    {
+      'target_name': 'gen_aecm_core_neon_offsets_h',
+      'type': 'none',
+      'dependencies': [
+        'lib_core_neon_offsets',
+        '<(DEPTH)/third_party/libvpx/libvpx.gyp:libvpx_obj_int_extract#host',
+      ],
+      'variables': {
+        'unpack_lib_name':'aecm_core_neon_offsets.o',
+      },
+      'sources': ['<(shared_generated_dir)/aecm_core_neon_offsets.o',],
+      'includes': [
+        '../../../../third_party/libvpx/unpack_lib_posix.gypi',
+        '../../../../third_party/libvpx/obj_int_extract.gypi',
+      ],
+    },
+  ],
+}
diff --git a/modules/audio_processing/lib_core_neon_offsets.gypi b/modules/audio_processing/lib_core_neon_offsets.gypi
new file mode 100644
index 0000000..42ec9ac
--- /dev/null
+++ b/modules/audio_processing/lib_core_neon_offsets.gypi
@@ -0,0 +1,51 @@
+# Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
+#
+# Use of this source code is governed by a BSD-style license
+# that can be found in the LICENSE file in the root of the source
+# tree. An additional intellectual property rights grant can be found
+# in the file PATENTS.  All contributing project authors may
+# be found in the AUTHORS file in the root of the source tree.
+
+# This file has common information for gen_core_neon_offsets.gyp
+# and gen_core_neon_offsets_chromium.gyp
+{
+  'variables': {
+    'variables' : {
+      'lib_intermediate_name': '',
+      'conditions' : [
+        ['android_webview_build==1', {
+          'lib_intermediate_name' : '<(android_src)/$(call intermediates-dir-for, STATIC_LIBRARIES, lib_core_neon_offsets)/lib_core_neon_offsets.a',
+        }],
+      ],
+    },
+    'shared_generated_dir': '<(SHARED_INTERMEDIATE_DIR)/audio_processing/asm_offsets',
+    'output_dir': '<(shared_generated_dir)',
+    'output_format': 'cheader',
+    'unpack_lib_search_path_list': [
+      '-a', '<(PRODUCT_DIR)/lib_core_neon_offsets.a',
+      '-a', '<(LIB_DIR)/webrtc/modules/audio_processing/lib_core_neon_offsets.a',
+      '-a', '<(LIB_DIR)/third_party/webrtc/modules/audio_processing/lib_core_neon_offsets.a',
+      '-a', '<(lib_intermediate_name)',
+    ],
+    'unpack_lib_output_dir':'<(shared_generated_dir)',
+  },
+  'includes': [
+    '../../build/common.gypi',
+  ],
+  'conditions': [
+    ['((target_arch=="arm" and arm_version==7) or target_arch=="armv7") and (OS=="android" or OS=="ios")', {
+      'targets' : [
+        {
+          'target_name': 'lib_core_neon_offsets',
+          'type': 'static_library',
+          'android_unmangled_name': 1,
+          'hard_dependency': 1,
+          'sources': [
+            'ns/nsx_core_neon_offsets.c',
+            'aecm/aecm_core_neon_offsets.c',
+          ],
+        },
+      ],
+    }],
+  ],
+}