diff --git a/tools/barcode_tools/DEPS b/tools/barcode_tools/DEPS index dc5c86ec6..d0325a65a 100644 --- a/tools/barcode_tools/DEPS +++ b/tools/barcode_tools/DEPS @@ -4,19 +4,10 @@ deps = { # Used by barcode_tools - "third_party/zxing/core": + "barcode_tools/third_party/zxing/core": "http://zxing.googlecode.com/svn/trunk/core@2349", # Used by barcode_tools - "third_party/zxing/javase": + "barcode_tools/third_party/zxing/javase": "http://zxing.googlecode.com/svn/trunk/javase@2349", } - -hooks = [ - { - # A change to a .gyp, .gypi, or to GYP itself should run the generator. - "pattern": ".", - "action": ["python", "src/build/gyp_chromium", "--depth=.", - "barcode_tools.gyp"], - }, -] \ No newline at end of file diff --git a/tools/barcode_tools/README b/tools/barcode_tools/README new file mode 100644 index 000000000..880cc7d9c --- /dev/null +++ b/tools/barcode_tools/README @@ -0,0 +1,17 @@ +This file explains how to set up the Zebra Crossing (Zxing) library in order to +use it in the barcode encoder and decoder tools. Zxing could be found at: +https://code.google.com/p/zxing/ + +After checkout, the relevant files from Zxing should be in third_party/zxing, +relative to this README. + +In order to run barcode_encoder.py and barcode_decoder.py we need to have build +two jar files: zxing/core/core.jar and zxing/javase/javase.jar. In order to +build these we have to have Ant already installed. Building is as simple as +running the build_zxing.py script: +./build_zxing.py, +which should automatically call ant with the respective build files from the +Zxing checkout. + +For more information on how to run barcode_encoder.py and barcode_decoder.py +check the documentation in the main functions inside these tools. diff --git a/tools/barcode_tools/barcode_decoder.py b/tools/barcode_tools/barcode_decoder.py index 0c65f91f5..e07675808 100755 --- a/tools/barcode_tools/barcode_decoder.py +++ b/tools/barcode_tools/barcode_decoder.py @@ -267,7 +267,7 @@ def _main(): options.barcode_width = options.yuv_frame_width script_dir = os.path.dirname(os.path.abspath(sys.argv[0])) - zxing_dir = os.path.join(script_dir, '..', 'third_party', 'zxing') + zxing_dir = os.path.join(script_dir, 'third_party', 'zxing') # Convert the overlaid YUV video into a set of PNG frames. convert_yuv_to_png_files(options.yuv_file, options.yuv_frame_width, diff --git a/tools/barcode_tools/barcode_encoder.py b/tools/barcode_tools/barcode_encoder.py index 244a8ccaa..4c943b81e 100755 --- a/tools/barcode_tools/barcode_encoder.py +++ b/tools/barcode_tools/barcode_encoder.py @@ -327,7 +327,7 @@ def _main(): options.base_frame_width, options.base_frame_height, options.base_yuv) script_dir = os.path.dirname(os.path.abspath(sys.argv[0])) - zxing_dir = os.path.join(script_dir, '..', 'third_party', 'zxing') + zxing_dir = os.path.join(script_dir, 'third_party', 'zxing') # Generate barcodes - will generate them in PNG. generate_upca_barcodes(number_of_barcodes, options.barcode_width, options.barcode_height, diff --git a/tools/barcode_tools/barcode_tools.gyp b/tools/barcode_tools/barcode_tools.gyp deleted file mode 100644 index c1f40cf6a..000000000 --- a/tools/barcode_tools/barcode_tools.gyp +++ /dev/null @@ -1,47 +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. - -{ - 'targets': [ - { - 'target_name': 'zxing', - 'message': 'build zxing barcode tool', - 'type': 'none', - 'actions': [ - { - 'action_name': 'build_zxing_core', - 'inputs': [ - '<(DEPTH)/third_party/zxing/core/build.xml', - ], - 'outputs': [ - '<(DEPTH)/third_party/zxing/core/core.jar', - ], - 'action': [ - 'ant', - '-buildfile', - '<(DEPTH)/third_party/zxing/core/build.xml', - ] - }, - { - 'action_name': 'build_zxing_javase', - 'inputs': [ - '<(DEPTH)/third_party/zxing/javase/build.xml', - ], - 'outputs': [ - '<(DEPTH)/third_party/zxing/javase/javase.jar', - ], - 'action': [ - 'ant', - '-buildfile', - '<(DEPTH)/third_party/zxing/javase/build.xml', - ] - }, - ], - }, - ], -} diff --git a/tools/barcode_tools/build_zxing.py b/tools/barcode_tools/build_zxing.py new file mode 100644 index 000000000..0f49c85d6 --- /dev/null +++ b/tools/barcode_tools/build_zxing.py @@ -0,0 +1,33 @@ +#!/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. + +import subprocess +import sys + + +def run_ant_build_command(path_to_ant_build_file): + """Tries to build the passed build file with ant.""" + process = subprocess.Popen([ + 'ant', '-buildfile', '%s' % path_to_ant_build_file], + stdout=subprocess.PIPE, stderr=subprocess.PIPE) + output, error = process.communicate() + if process.returncode != 0: + print 'Error: ', error + else: + print output + + +def _main(): + run_ant_build_command('third_party/zxing/core/build.xml') + run_ant_build_command('third_party/zxing/javase/build.xml') + return 0 + + +if __name__ == '__main__': + sys.exit(_main()) \ No newline at end of file