Commit 24d1f432 authored by Ghislain MARY's avatar Ghislain MARY

Remove build dependency to xxd (and therefore to vim).

parent c6310fe6
......@@ -29,7 +29,6 @@ Compilation and installation
* Required dependencies:
- oRTP
- libspeex and libspeexdsp
- vim
- bctoolbox
* Optional dependencies (for video to be enabled, see --enable-video):
- libavcodec
......
......@@ -408,23 +408,20 @@ add_custom_target(ms2-voipdescs-header
)
if(APPLE OR ANDROID OR GLX_FOUND)
find_program(XXD_PROGRAM xxd)
if(NOT XXD_PROGRAM)
message(FATAL_ERROR "You need the xxd program to build mediastreamer2.")
endif()
find_package(PythonInterp REQUIRED)
find_program(SED_PROGRAM sed)
if(NOT SED_PROGRAM)
message(FATAL_ERROR "You need the sed program to build mediastreamer2.")
endif()
add_custom_target(ms2-yuv2rgb-fs-header
COMMAND ${CMAKE_COMMAND} -DXXD_PROGRAM=${XXD_PROGRAM} -DSED_PROGRAM=${SED_PROGRAM}
COMMAND ${CMAKE_COMMAND} -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} -DSED_PROGRAM=${SED_PROGRAM}
-DINPUT_DIR=${CMAKE_CURRENT_SOURCE_DIR} -DOUTPUT_DIR=${CMAKE_CURRENT_BINARY_DIR}
-DSOURCE_FILE="yuv2rgb.fs"
-P "${CMAKE_CURRENT_SOURCE_DIR}/generate_yuv2rgb_header.cmake"
BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/yuv2rgb.fs.h"
)
add_custom_target(ms2-yuv2rgb-vs-header
COMMAND ${CMAKE_COMMAND} -DXXD_PROGRAM=${XXD_PROGRAM} -DSED_PROGRAM=${SED_PROGRAM}
COMMAND ${CMAKE_COMMAND} -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} -DSED_PROGRAM=${SED_PROGRAM}
-DINPUT_DIR=${CMAKE_CURRENT_SOURCE_DIR} -DOUTPUT_DIR=${CMAKE_CURRENT_BINARY_DIR}
-DSOURCE_FILE="yuv2rgb.vs"
-P "${CMAKE_CURRENT_SOURCE_DIR}/generate_yuv2rgb_header.cmake"
......
......@@ -21,7 +21,7 @@
############################################################################
execute_process(
COMMAND "${XXD_PROGRAM}" "-i" "${SOURCE_FILE}"
COMMAND "${PYTHON_EXECUTABLE}" "${INPUT_DIR}/../tools/xxd.py" "-i" "${SOURCE_FILE}"
OUTPUT_FILE "${OUTPUT_DIR}/${SOURCE_FILE}.tmp"
WORKING_DIRECTORY ${INPUT_DIR}
)
......
#!/usr/bin/python
# Copyright (C) 2016 Belledonne Communications SARL
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
import argparse
import string
import sys
def print_include_hexdump_line(buf):
hexbuf = [('0x%02x' % ord(i)) for i in buf]
finalcomma = ''
if len(hexbuf) == 12:
finalcomma = ','
print(" {0}{1}".format(", ".join(hexbuf[i] for i in range(0, len(hexbuf))), finalcomma))
def include_hexdump(infilename):
varname = infilename.replace('.', '_').replace('-', '_')
infile = open(infilename, 'r')
size = 0
print("unsigned char {0}[] = {{".format(varname))
while True:
buf = infile.read(12)
if not buf:
break
print_include_hexdump_line(buf)
size = size + len(buf)
print("};")
print("unsigned int {0}_len = {1};".format(varname, size))
def print_hexdump_line(counter, buf):
hexbuf = [('%02x' % ord(i)) for i in buf]
print("{0}: {1:<39} {2}".format(("%08x" % (counter * 16)),
' '.join([''.join(hexbuf[i : i + 2]) for i in range(0, len(hexbuf), 2)]),
''.join([c if c in string.printable[:-5] else '.' for c in buf])))
def hexdump(infilename):
infile = open(infilename, 'r')
counter = 0
while True:
buf = infile.read(16)
if not buf:
break
print_hexdump_line(counter, buf)
counter += 1
def main(argv = None):
if argv is None:
argv = sys.argv
argparser = argparse.ArgumentParser(description="Make a hexdump.")
argparser.add_argument('-i', '--include', help="Output in C include file style. A complete static array definition is written (named after the input file).", action='store_true')
argparser.add_argument('infile', help="File to dump.")
args = argparser.parse_args()
if args.include:
include_hexdump(args.infile)
else:
hexdump(args.infile)
if __name__ == "__main__":
sys.exit(main())
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment