diff options
author | marha <marha@users.sourceforge.net> | 2013-01-14 15:26:50 +0100 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2013-01-14 15:26:50 +0100 |
commit | c67a0f76ca34e441a817a7cdf261f496f3b3f2d6 (patch) | |
tree | c197b74a8c2f076aaa4f5506b90d6ad8e38b52b2 /mesalib/src/glsl/glcpp/glcpp.c | |
parent | 8d07c58314685d56a0586d0a437b541ea2b92a54 (diff) | |
parent | 2a1abdc8fe640583dac90dc316caf2d40b9ee4e2 (diff) | |
download | vcxsrv-c67a0f76ca34e441a817a7cdf261f496f3b3f2d6.tar.gz vcxsrv-c67a0f76ca34e441a817a7cdf261f496f3b3f2d6.tar.bz2 vcxsrv-c67a0f76ca34e441a817a7cdf261f496f3b3f2d6.zip |
Merge remote-tracking branch 'origin/released'
* origin/released:
libxtrans xwininfo libX11 libXau libXmu libXdmcp mesa mkfontscale xkeyboard-config git update 14 jan 2013
Conflicts:
mesalib/src/glsl/glcpp/.gitignore
Diffstat (limited to 'mesalib/src/glsl/glcpp/glcpp.c')
-rw-r--r-- | mesalib/src/glsl/glcpp/glcpp.c | 59 |
1 files changed, 56 insertions, 3 deletions
diff --git a/mesalib/src/glsl/glcpp/glcpp.c b/mesalib/src/glsl/glcpp/glcpp.c index bef9fd08e..13a32fd7d 100644 --- a/mesalib/src/glsl/glcpp/glcpp.c +++ b/mesalib/src/glsl/glcpp/glcpp.c @@ -24,6 +24,8 @@ #include <stdio.h> #include <string.h> #include <errno.h> +#include <getopt.h> + #include "glcpp.h" #include "main/mtypes.h" #include "main/shaderobj.h" @@ -102,6 +104,37 @@ load_text_file(void *ctx, const char *filename) return text; } +/* Initialize only those things that glcpp cares about. + */ +static void +init_fake_gl_context (struct gl_context *gl_ctx) +{ + gl_ctx->API = API_OPENGL_COMPAT; + gl_ctx->Const.DisableGLSLLineContinuations = false; +} + +static void +usage (void) +{ + fprintf (stderr, + "Usage: glcpp [OPTIONS] [--] [<filename>]\n" + "\n" + "Pre-process the given filename (stdin if no filename given).\n" + "The following options are supported:\n" + " --disable-line-continuations Do not interpret lines ending with a\n" + " backslash ('\\') as a line continuation.\n"); +} + +enum { + DISABLE_LINE_CONTINUATIONS_OPT = CHAR_MAX + 1 +}; + +const static struct option +long_options[] = { + {"disable-line-continuations", no_argument, 0, DISABLE_LINE_CONTINUATIONS_OPT }, + {0, 0, 0, 0 } +}; + int main (int argc, char *argv[]) { @@ -110,16 +143,36 @@ main (int argc, char *argv[]) char *info_log = ralloc_strdup(ctx, ""); const char *shader; int ret; + struct gl_context gl_ctx; + int c; + + init_fake_gl_context (&gl_ctx); + + while ((c = getopt_long(argc, argv, "", long_options, NULL)) != -1) { + switch (c) { + case DISABLE_LINE_CONTINUATIONS_OPT: + gl_ctx.Const.DisableGLSLLineContinuations = true; + break; + default: + usage (); + exit (1); + } + } - if (argc) { - filename = argv[1]; + if (optind + 1 < argc) { + printf ("Unexpected argument: %s\n", argv[optind+1]); + usage (); + exit (1); + } + if (optind < argc) { + filename = argv[optind]; } shader = load_text_file (ctx, filename); if (shader == NULL) return 1; - ret = glcpp_preprocess(ctx, &shader, &info_log, NULL, API_OPENGL_COMPAT); + ret = glcpp_preprocess(ctx, &shader, &info_log, NULL, &gl_ctx); printf("%s", shader); fprintf(stderr, "%s", info_log); |