int
main (int argc, char *argv[])
{
	char *filename = NULL;
	void *ctx = ralloc(NULL, void*);
	char *info_log = ralloc_strdup(ctx, "");
	const char *shader;
	int ret;

	if (argc) {
		filename = argv[1];
	}

	shader = load_text_file (ctx, filename);
	if (shader == NULL)
	   return 1;

	ret = glcpp_preprocess(ctx, &shader, &info_log, NULL, API_OPENGL);

	printf("%s", shader);
	fprintf(stderr, "%s", info_log);

	ralloc_free(ctx);

	return ret;
}
Example #2
0
int
main (int argc, char *argv[])
{
	char *filename = NULL;
	void *ctx = ralloc(NULL, void*);
	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, "d", long_options, NULL)) != -1) {
		switch (c) {
		case DISABLE_LINE_CONTINUATIONS_OPT:
			gl_ctx.Const.DisableGLSLLineContinuations = true;
			break;
                case 'd':
			glcpp_parser_debug = 1;
			break;
		default:
			usage ();
			exit (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;

	_mesa_locale_init();

	ret = glcpp_preprocess(ctx, &shader, &info_log, NULL, &gl_ctx);

	printf("%s", shader);
	fprintf(stderr, "%s", info_log);

	ralloc_free(ctx);

	return ret;
}