Skip to content
  • Ian Romanick's avatar
    glsl: Add utility to convert text files to C strings · 412472da
    Ian Romanick authored
    
    
    Will be used to convert the .glsl source file containing software fp64
    routines to a .h file that can be included while building the compiler.
    
    This commit contains two squashed together: the first from Ian adding
    the utility (with the existing title), and the second from Dylan making
    the code both python2 and python3 compatible.
    
    This is somewhat modeled after the xxd utility that comes with Vim.
    
    Signed-off-by: default avatarIan Romanick <ian.d.romanick@intel.com>
    
    xxd.py: Make python2 and 3 compatible
    
    This makes use of unicode_literals, so that undecorated strings are
    considered text (python2 unicode, python3 str) and not bytes in python2
    and text in python3. It makes use of io.open, which provides python2
    with python3's open behavior (it's an alias in python3), in particular
    support for the 't' and 'b' option. Finally, it decorates all of the
    string literals with the 'b' prefix, so that python interprets them as
    bytes.
    
    I've removed the stdin and stdout options, as python2 always requires
    these to be bytes, but python3 always treats them as text (there is a
    way to get at the underlying bytes buffer, but that's even more
    complexity), and makes the input files required arguments.
    
    In the meson we use the '@INPUT@' shorthand instead of listing each
    input, as meson will expand that to [prog_python, '@INPUT0@', @INPUT1@,
    ..., @OUTPUT@, ...]
    412472da