mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-01-28 13:05:02 -08:00
vkd3d-compiler: Allow the --formatting option to modify individual flags.
Instead of replacing all of them. Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
4fda96190b
commit
55cfa465ea
@ -147,10 +147,11 @@ static void print_usage(const char *program_name)
|
|||||||
" -o, --output=<file> Write the output to <file>. If <file> is '-' or no\n"
|
" -o, --output=<file> Write the output to <file>. If <file> is '-' or no\n"
|
||||||
" output file is specified, output will be written to\n"
|
" output file is specified, output will be written to\n"
|
||||||
" standard output.\n"
|
" standard output.\n"
|
||||||
" --formatting=<type> Specify the formatting options for text output.\n"
|
" --formatting=<flags> Specify the formatting options for text output.\n"
|
||||||
" Valid values are 'none', 'print', 'colour', 'indent',\n"
|
" <flags> is a comma separated list of formatting flags,\n"
|
||||||
" 'offsets', 'header', and 'raw-ids'.\n"
|
" optionally prefixed by '+' or '-'. Valid flags are\n"
|
||||||
" Default is --formatting=indent,header.\n"
|
" 'colour', 'indent', 'offsets', 'header', and 'raw-ids'.\n"
|
||||||
|
" The 'indent' and 'header' flags are enabled by default.\n"
|
||||||
" --print-source-types Display the supported source types and exit.\n"
|
" --print-source-types Display the supported source types and exit.\n"
|
||||||
" --print-target-types Display the supported target types for the specified\n"
|
" --print-target-types Display the supported target types for the specified\n"
|
||||||
" source type and exit.\n"
|
" source type and exit.\n"
|
||||||
@ -235,7 +236,6 @@ static bool parse_formatting(uint32_t *formatting, char *arg)
|
|||||||
}
|
}
|
||||||
opts[] =
|
opts[] =
|
||||||
{
|
{
|
||||||
{"none", VKD3D_SHADER_COMPILE_OPTION_FORMATTING_NONE},
|
|
||||||
{"colour", VKD3D_SHADER_COMPILE_OPTION_FORMATTING_COLOUR},
|
{"colour", VKD3D_SHADER_COMPILE_OPTION_FORMATTING_COLOUR},
|
||||||
{"indent", VKD3D_SHADER_COMPILE_OPTION_FORMATTING_INDENT},
|
{"indent", VKD3D_SHADER_COMPILE_OPTION_FORMATTING_INDENT},
|
||||||
{"offsets", VKD3D_SHADER_COMPILE_OPTION_FORMATTING_OFFSETS},
|
{"offsets", VKD3D_SHADER_COMPILE_OPTION_FORMATTING_OFFSETS},
|
||||||
@ -246,12 +246,27 @@ static bool parse_formatting(uint32_t *formatting, char *arg)
|
|||||||
|
|
||||||
for (tok = strtok(arg, ","); tok; tok = strtok(NULL, ","))
|
for (tok = strtok(arg, ","); tok; tok = strtok(NULL, ","))
|
||||||
{
|
{
|
||||||
|
bool set = true;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
|
if (*tok == '-')
|
||||||
|
{
|
||||||
|
set = false;
|
||||||
|
++tok;
|
||||||
|
}
|
||||||
|
else if (*tok == '+')
|
||||||
|
{
|
||||||
|
++tok;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(opts); ++i)
|
for (i = 0; i < ARRAY_SIZE(opts); ++i)
|
||||||
{
|
{
|
||||||
if (!strcmp(tok, opts[i].name))
|
if (!strcmp(tok, opts[i].name))
|
||||||
{
|
{
|
||||||
|
if (set)
|
||||||
*formatting |= opts[i].value;
|
*formatting |= opts[i].value;
|
||||||
|
else
|
||||||
|
*formatting &= ~opts[i].value;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -335,8 +350,9 @@ 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;
|
||||||
enum vkd3d_shader_compile_option_formatting_flags formatting = 0;
|
|
||||||
int option;
|
int option;
|
||||||
|
|
||||||
static struct option long_options[] =
|
static struct option long_options[] =
|
||||||
@ -388,7 +404,6 @@ static bool parse_command_line(int argc, char **argv, struct options *options)
|
|||||||
case OPTION_TEXT_FORMATTING:
|
case OPTION_TEXT_FORMATTING:
|
||||||
if (!parse_formatting(&formatting, optarg))
|
if (!parse_formatting(&formatting, optarg))
|
||||||
return false;
|
return false;
|
||||||
add_compile_option(options, VKD3D_SHADER_COMPILE_OPTION_FORMATTING, formatting);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OPTION_PRINT_SOURCE_TYPES:
|
case OPTION_PRINT_SOURCE_TYPES:
|
||||||
@ -432,6 +447,7 @@ 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];
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user