From d9e11b429ea8bd96017b5f491703d7486e1722c6 Mon Sep 17 00:00:00 2001 From: "zakkhoyt@google.com" Date: Thu, 1 Sep 2011 00:54:32 +0000 Subject: [PATCH] Review URL: http://webrtc-codereview.appspot.com/137004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@504 4adac7df-926f-26a2-2b94-8c16560cd09d --- src/build/merge_libs.py | 56 +++++++++++++++++++ src/video_engine.gyp | 28 +++++++++- .../main/test/AutoTest/vie_auto_test.gypi | 2 +- src/voice_engine.gyp | 27 ++++++++- 4 files changed, 110 insertions(+), 3 deletions(-) create mode 100644 src/build/merge_libs.py diff --git a/src/build/merge_libs.py b/src/build/merge_libs.py new file mode 100644 index 000000000..e2b96bf27 --- /dev/null +++ b/src/build/merge_libs.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python + +# Copyright (c) 2011 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. + +# Searches for libraries and/or object files on the specified path and +# merges them into a single library. + +import subprocess +import sys + +if __name__ == '__main__': + if len(sys.argv) != 3: + sys.stderr.write('Usage: ' + sys.argv[0] + ' \n') + sys.exit(2) + + search_path = sys.argv[1] + output_lib = sys.argv[2] + + from subprocess import Popen, PIPE + if sys.platform.startswith('linux'): + Popen(["rm -f " + output_lib], shell=True) + Popen(["rm -rf " + search_path + "/obj.target/*do_not_use*"], shell=True) + Popen(["ar crs " + output_lib + " $(find " + search_path + " -name *\.o)"], + shell=True) + + elif sys.platform == 'darwin': + Popen(["rm -f " + output_lib], shell=True) + Popen(["rm -f " + search_path + "/*do_not_use*"], shell=True) + Popen(["libtool -static -v -o " + output_lib + " $(find " + search_path + + " -name *\.a)"], shell=True) + + elif sys.platform == 'win32': + # We need to execute a batch file to set some environment variables for the + # lib command. VS 8 uses vsvars.bat and VS 9 uses vsvars32.bat. + # It's required that at least one of them is in the system PATH. + # We try both and suppress stderr and stdout to fail silently. + Popen(["del " + output_lib], stderr=PIPE, stdout=PIPE, shell=True) + Popen(["del /F /S /Q " + search_path + "/lib/*do_not_use*"], + shell=True) + Popen(["vsvars.bat"], stderr=PIPE, stdout=PIPE, shell=True) + Popen(["vsvars32.bat"], stderr=PIPE, stdout=PIPE, shell=True) + Popen(["lib /OUT:" + output_lib + " " + search_path + "/lib/*.lib"], + shell=True) + + else: + sys.stderr.write('Platform not supported: %r\n\n' % sys.platform) + sys.exit(1) + + +sys.exit(0) diff --git a/src/video_engine.gyp b/src/video_engine.gyp index 28131f02a..c7343c7ba 100644 --- a/src/video_engine.gyp +++ b/src/video_engine.gyp @@ -5,9 +5,35 @@ { 'includes': [ 'common_settings.gypi', # Common settings - # Defines target vie_auto_test 'video_engine/main/test/AutoTest/vie_auto_test.gypi', ], + 'variables': { + 'autotest_name': 'vie_auto_test', + }, + 'targets': [ + { + 'target_name': 'merged_lib', + 'type': 'none', + 'dependencies': [ + '<(autotest_name)', + ], + 'actions': [ + { + 'variables': { + 'output_lib_name': 'webrtc', + 'output_lib': '<(PRODUCT_DIR)/<(STATIC_LIB_PREFIX)<(output_lib_name)_<(OS)<(STATIC_LIB_SUFFIX)', + }, + 'action_name': 'merge_libs', + 'inputs': ['<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)<(autotest_name)<(EXECUTABLE_SUFFIX)'], + 'outputs': ['<(output_lib)'], + 'action': ['python', + './build/merge_libs.py', + '<(PRODUCT_DIR)', + '<(output_lib)'], + }, + ], + }, + ], } # Local Variables: diff --git a/src/video_engine/main/test/AutoTest/vie_auto_test.gypi b/src/video_engine/main/test/AutoTest/vie_auto_test.gypi index 2d81516b9..f1f7ef5cd 100644 --- a/src/video_engine/main/test/AutoTest/vie_auto_test.gypi +++ b/src/video_engine/main/test/AutoTest/vie_auto_test.gypi @@ -8,7 +8,7 @@ ], 'targets': [ { - 'target_name': 'vie_auto_test', + 'target_name': '<(autotest_name)', 'type': 'executable', 'dependencies': [ 'system_wrappers/source/system_wrappers.gyp:system_wrappers', diff --git a/src/voice_engine.gyp b/src/voice_engine.gyp index 7962ede12..22058756f 100644 --- a/src/voice_engine.gyp +++ b/src/voice_engine.gyp @@ -10,10 +10,35 @@ 'includes': [ 'common_settings.gypi', ], + 'variables': { + 'autotest_name': 'voe_auto_test', + }, 'targets': [ + { + 'target_name': 'merged_lib_voice', + 'type': 'none', + 'dependencies': [ + '<(autotest_name)', + ], + 'actions': [ + { + 'variables': { + 'output_lib_name': 'webrtc_voice_engine', + 'output_lib': '<(PRODUCT_DIR)/<(STATIC_LIB_PREFIX)<(output_lib_name)_<(OS)<(STATIC_LIB_SUFFIX)', + }, + 'action_name': 'merge_libs', + 'inputs': ['<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)<(autotest_name)<(EXECUTABLE_SUFFIX)'], + 'outputs': ['<(output_lib)'], + 'action': ['python', + './build/merge_libs.py', + '<(PRODUCT_DIR)', + '<(output_lib)'], + }, + ], + }, # Auto test - command line test for all platforms { - 'target_name': 'voe_auto_test', + 'target_name': '<(autotest_name)', 'type': 'executable', 'dependencies': [ 'voice_engine/main/source/voice_engine_core.gyp:voice_engine_core',