mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-compiler: Enable colour output by default when outputting to a colour capable tty.
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
9136e56435
commit
8d3e1e8300
@ -145,7 +145,8 @@ EXTRA_DIST += \
|
|||||||
|
|
||||||
bin_PROGRAMS = vkd3d-compiler
|
bin_PROGRAMS = vkd3d-compiler
|
||||||
vkd3d_compiler_SOURCES = programs/vkd3d-compiler/main.c
|
vkd3d_compiler_SOURCES = programs/vkd3d-compiler/main.c
|
||||||
vkd3d_compiler_LDADD = libvkd3d-shader.la
|
vkd3d_compiler_CFLAGS = $(AM_CFLAGS) @NCURSES_CFLAGS@
|
||||||
|
vkd3d_compiler_LDADD = libvkd3d-shader.la @NCURSES_LIBS@
|
||||||
|
|
||||||
LDADD = libvkd3d.la libvkd3d-utils.la
|
LDADD = libvkd3d.la libvkd3d-utils.la
|
||||||
AM_DEFAULT_SOURCE_EXT = .c
|
AM_DEFAULT_SOURCE_EXT = .c
|
||||||
|
10
configure.ac
10
configure.ac
@ -8,9 +8,10 @@ AC_CONFIG_HEADERS(include/config.h)
|
|||||||
AC_ARG_VAR([WIDL], [widl IDL compiler])
|
AC_ARG_VAR([WIDL], [widl IDL compiler])
|
||||||
AC_ARG_VAR([CROSSCC32], [32-bit Windows cross compiler])
|
AC_ARG_VAR([CROSSCC32], [32-bit Windows cross compiler])
|
||||||
AC_ARG_VAR([CROSSCC64], [64-bit Windows cross compiler])
|
AC_ARG_VAR([CROSSCC64], [64-bit Windows cross compiler])
|
||||||
AC_ARG_WITH([xcb], AS_HELP_STRING([--with-xcb], [Build with XCB library (default: test)]))
|
AC_ARG_WITH([ncurses], AS_HELP_STRING([--with-ncurses], [Build with the ncurses library (default: test)]))
|
||||||
AC_ARG_WITH([spirv-tools], AS_HELP_STRING([--with-spirv-tools],
|
AC_ARG_WITH([spirv-tools], AS_HELP_STRING([--with-spirv-tools],
|
||||||
[Build with SPIRV-Tools library (default: disabled)]))
|
[Build with SPIRV-Tools library (default: disabled)]))
|
||||||
|
AC_ARG_WITH([xcb], AS_HELP_STRING([--with-xcb], [Build with XCB library (default: test)]))
|
||||||
AC_ARG_ENABLE([demos],
|
AC_ARG_ENABLE([demos],
|
||||||
AS_HELP_STRING([--enable-demos], [Build demo programs (default: disabled)]),,
|
AS_HELP_STRING([--enable-demos], [Build demo programs (default: disabled)]),,
|
||||||
[enable_demos=no])
|
[enable_demos=no])
|
||||||
@ -109,6 +110,10 @@ VKD3D_CHECK_SONAME([vulkan], [vkGetInstanceProcAddr],
|
|||||||
["$ac_cv_lib_soname_MoltenVK"])],
|
["$ac_cv_lib_soname_MoltenVK"])],
|
||||||
[AC_MSG_ERROR([libvulkan and libMoltenVK not found.])])])])
|
[AC_MSG_ERROR([libvulkan and libMoltenVK not found.])])])])
|
||||||
|
|
||||||
|
AS_IF([test "x$with_ncurses" != "xno"],
|
||||||
|
[PKG_CHECK_MODULES([NCURSES], [ncurses],
|
||||||
|
[AC_DEFINE([HAVE_NCURSES], [1], [Define to 1 if you have ncurses.]) with_ncurses=yes],
|
||||||
|
[with_ncurses=no])])
|
||||||
AS_IF([test "x$with_spirv_tools" = "xyes"],
|
AS_IF([test "x$with_spirv_tools" = "xyes"],
|
||||||
[PKG_CHECK_MODULES([SPIRV_TOOLS], [SPIRV-Tools-shared],
|
[PKG_CHECK_MODULES([SPIRV_TOOLS], [SPIRV-Tools-shared],
|
||||||
[AC_DEFINE([HAVE_SPIRV_TOOLS], [1], [Define to 1 if you have SPIRV-Tools.])])],
|
[AC_DEFINE([HAVE_SPIRV_TOOLS], [1], [Define to 1 if you have SPIRV-Tools.])])],
|
||||||
@ -152,8 +157,9 @@ AS_ECHO(["
|
|||||||
|
|
||||||
widl: ${WIDL}
|
widl: ${WIDL}
|
||||||
|
|
||||||
Have XCB: ${HAVE_XCB}
|
Have ncurses: ${with_ncurses}
|
||||||
Have SPIRV-Tools: ${with_spirv_tools}
|
Have SPIRV-Tools: ${with_spirv_tools}
|
||||||
|
Have xcb: ${HAVE_XCB}
|
||||||
|
|
||||||
Building demos: ${enable_demos}
|
Building demos: ${enable_demos}
|
||||||
Building tests: ${enable_tests}
|
Building tests: ${enable_tests}
|
||||||
|
@ -17,9 +17,10 @@
|
|||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef _GNU_SOURCE
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
#endif
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@ -28,6 +29,9 @@
|
|||||||
|
|
||||||
#include "vkd3d_common.h"
|
#include "vkd3d_common.h"
|
||||||
#include "vkd3d_shader.h"
|
#include "vkd3d_shader.h"
|
||||||
|
#ifdef HAVE_NCURSES
|
||||||
|
#include <term.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define MAX_COMPILE_OPTIONS 3
|
#define MAX_COMPILE_OPTIONS 3
|
||||||
|
|
||||||
@ -180,6 +184,8 @@ struct options
|
|||||||
bool print_version;
|
bool print_version;
|
||||||
bool print_source_types;
|
bool print_source_types;
|
||||||
bool print_target_types;
|
bool print_target_types;
|
||||||
|
uint32_t formatting;
|
||||||
|
bool explicit_colour;
|
||||||
|
|
||||||
struct vkd3d_shader_compile_option compile_options[MAX_COMPILE_OPTIONS];
|
struct vkd3d_shader_compile_option compile_options[MAX_COMPILE_OPTIONS];
|
||||||
unsigned int compile_option_count;
|
unsigned int compile_option_count;
|
||||||
@ -230,7 +236,7 @@ static bool parse_buffer_uav(enum vkd3d_shader_compile_option_buffer_uav *buffer
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool parse_formatting(uint32_t *formatting, char *arg)
|
static bool parse_formatting(uint32_t *formatting, bool *colour, char *arg)
|
||||||
{
|
{
|
||||||
static const struct formatting_option
|
static const struct formatting_option
|
||||||
{
|
{
|
||||||
@ -270,6 +276,8 @@ static bool parse_formatting(uint32_t *formatting, char *arg)
|
|||||||
*formatting |= opts[i].value;
|
*formatting |= opts[i].value;
|
||||||
else
|
else
|
||||||
*formatting &= ~opts[i].value;
|
*formatting &= ~opts[i].value;
|
||||||
|
if (opts[i].value == VKD3D_SHADER_COMPILE_OPTION_FORMATTING_COLOUR)
|
||||||
|
*colour = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -353,8 +361,6 @@ static bool validate_target_type(
|
|||||||
|
|
||||||
static bool parse_command_line(int argc, char **argv, struct options *options)
|
static bool parse_command_line(int argc, char **argv, struct options *options)
|
||||||
{
|
{
|
||||||
enum vkd3d_shader_compile_option_formatting_flags formatting = VKD3D_SHADER_COMPILE_OPTION_FORMATTING_INDENT
|
|
||||||
| VKD3D_SHADER_COMPILE_OPTION_FORMATTING_HEADER;
|
|
||||||
enum vkd3d_shader_compile_option_buffer_uav buffer_uav;
|
enum vkd3d_shader_compile_option_buffer_uav buffer_uav;
|
||||||
int option;
|
int option;
|
||||||
|
|
||||||
@ -374,6 +380,8 @@ static bool parse_command_line(int argc, char **argv, struct options *options)
|
|||||||
memset(options, 0, sizeof(*options));
|
memset(options, 0, sizeof(*options));
|
||||||
options->source_type = VKD3D_SHADER_SOURCE_DXBC_TPF;
|
options->source_type = VKD3D_SHADER_SOURCE_DXBC_TPF;
|
||||||
options->target_type = VKD3D_SHADER_TARGET_SPIRV_BINARY;
|
options->target_type = VKD3D_SHADER_TARGET_SPIRV_BINARY;
|
||||||
|
options->formatting = VKD3D_SHADER_COMPILE_OPTION_FORMATTING_INDENT
|
||||||
|
| VKD3D_SHADER_COMPILE_OPTION_FORMATTING_HEADER;
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
@ -405,7 +413,7 @@ static bool parse_command_line(int argc, char **argv, struct options *options)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case OPTION_TEXT_FORMATTING:
|
case OPTION_TEXT_FORMATTING:
|
||||||
if (!parse_formatting(&formatting, optarg))
|
if (!parse_formatting(&options->formatting, &options->explicit_colour, optarg))
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -450,7 +458,6 @@ static bool parse_command_line(int argc, char **argv, struct options *options)
|
|||||||
if (options->print_target_types)
|
if (options->print_target_types)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
add_compile_option(options, VKD3D_SHADER_COMPILE_OPTION_FORMATTING, formatting);
|
|
||||||
if (optind < argc)
|
if (optind < argc)
|
||||||
options->filename = argv[argc - 1];
|
options->filename = argv[argc - 1];
|
||||||
|
|
||||||
@ -527,6 +534,26 @@ static FILE *open_output(const char *filename, bool *close)
|
|||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool has_colour(FILE *f)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_NCURSES
|
||||||
|
bool supported;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (!isatty(fileno(f)))
|
||||||
|
return false;
|
||||||
|
setupterm(NULL, fileno(f), &ret);
|
||||||
|
if (ret != 1)
|
||||||
|
return false;
|
||||||
|
supported = !!tigetstr("setaf");
|
||||||
|
del_curterm(cur_term);
|
||||||
|
|
||||||
|
return supported;
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
bool close_input = false, close_output = false;
|
bool close_input = false, close_output = false;
|
||||||
@ -585,6 +612,10 @@ int main(int argc, char **argv)
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!options.explicit_colour && has_colour(output))
|
||||||
|
options.formatting |= VKD3D_SHADER_COMPILE_OPTION_FORMATTING_COLOUR;
|
||||||
|
add_compile_option(&options, VKD3D_SHADER_COMPILE_OPTION_FORMATTING, options.formatting);
|
||||||
|
|
||||||
info.type = VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_INFO;
|
info.type = VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_INFO;
|
||||||
info.next = NULL;
|
info.next = NULL;
|
||||||
info.source_type = options.source_type;
|
info.source_type = options.source_type;
|
||||||
|
Loading…
Reference in New Issue
Block a user