From: John Kessenich Date: Tue, 7 Jan 2020 14:03:11 +0000 (-0700) Subject: Fix #1829: Add "--" command-line options for macro def/undef. X-Git-Tag: upstream/11.4.0~331^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6f98892dd19f34f77ccc60ca313166ea60b85cb6;p=platform%2Fupstream%2Fglslang.git Fix #1829: Add "--" command-line options for macro def/undef. This allows OpModuleProcessed logging to be consistent with everything taking "--" options. --- diff --git a/StandAlone/StandAlone.cpp b/StandAlone/StandAlone.cpp index c869fb1..28c5e15 100644 --- a/StandAlone/StandAlone.cpp +++ b/StandAlone/StandAlone.cpp @@ -204,7 +204,7 @@ public: text.append("#define "); fixLine(def); - Processes.push_back("D"); + Processes.push_back("define-macro "); Processes.back().append(def); // The first "=" needs to turn into a space @@ -222,7 +222,7 @@ public: text.append("#undef "); fixLine(undef); - Processes.push_back("U"); + Processes.push_back("undef-macro "); Processes.back().append(undef); text.append(undef); @@ -500,6 +500,13 @@ void ProcessArguments(std::vector>& workItem } else Error("expects vulkan100 or opengl100", lowerword.c_str()); bumpArg(); + } else if (lowerword == "define-macro" || + lowerword == "d") { + if (argc > 1) + UserPreamble.addDef(argv[1]); + else + Error("expects ", argv[0]); + bumpArg(); } else if (lowerword == "dump-builtin-symbols") { DumpBuiltinSymbols = true; } else if (lowerword == "entry-point") { @@ -627,6 +634,13 @@ void ProcessArguments(std::vector>& workItem "spirv1.0, spirv1.1, spirv1.2, spirv1.3, spirv1.4, or spirv1.5"); } bumpArg(); + } else if (lowerword == "undef-macro" || + lowerword == "u") { + if (argc > 1) + UserPreamble.addUndef(argv[1]); + else + Error("expects ", argv[0]); + bumpArg(); } else if (lowerword == "variable-name" || // synonyms lowerword == "vn") { Options |= EOptionOutputHexadecimal; @@ -649,7 +663,7 @@ void ProcessArguments(std::vector>& workItem if (argv[0][2] == 0) Options |= EOptionReadHlsl; else - UserPreamble.addDef(getStringOperand("-D macro name")); + UserPreamble.addDef(getStringOperand("-D")); break; case 'u': uniformLocationOverrides.push_back(getUniformOverride()); @@ -692,7 +706,7 @@ void ProcessArguments(std::vector>& workItem bumpArg(); break; case 'U': - UserPreamble.addUndef(getStringOperand("-U: macro name")); + UserPreamble.addUndef(getStringOperand("-U")); break; case 'V': setVulkanSpv(); @@ -1502,8 +1516,8 @@ void usage() "Options:\n" " -C cascading errors; risk crash from accumulation of error recoveries\n" " -D input is HLSL (this is the default when any suffix is .hlsl)\n" - " -D\n" - " -D define a pre-processor macro\n" + " -D | --define-macro | --D \n" + " define a pre-processor macro\n" " -E print pre-processed GLSL; cannot be used with -l;\n" " errors will appear on stderr\n" " -G[ver] create SPIR-V binary, under OpenGL semantics; turns on -l;\n" @@ -1519,7 +1533,8 @@ void usage() " -Os optimizes SPIR-V to minimize size\n" " -S uses specified stage rather than parsing the file extension\n" " choices for are vert, tesc, tese, geom, frag, or comp\n" - " -U undefine a pre-processor macro\n" + " -U | --undef-macro | --U \n" + " undefine a pre-processor macro\n" " -V[ver] create SPIR-V binary, under Vulkan semantics; turns on -l;\n" " default file name is .spv (-o overrides this)\n" " 'ver', when present, is the version of the input semantics,\n" diff --git a/Test/runtests b/Test/runtests index 23406dc..d1ca221 100755 --- a/Test/runtests +++ b/Test/runtests @@ -176,9 +176,9 @@ diff -b $BASEDIR/hlsl.pp.line3.frag.out $TARGETDIR/hlsl.pp.line3.frag.out || HAS # Testing -D and -U # echo "Testing -D and -U" -$EXE -DUNDEFED -UIN_SHADER -DFOO=200 -i -l -UUNDEFED -DMUL=FOO*2 glsl.-D-U.frag > $TARGETDIR/glsl.-D-U.frag.out +$EXE -DUNDEFED -UIN_SHADER -DFOO=200 -i -l --U UNDEFED --define-macro MUL=FOO*2 glsl.-D-U.frag > $TARGETDIR/glsl.-D-U.frag.out diff -b $BASEDIR/glsl.-D-U.frag.out $TARGETDIR/glsl.-D-U.frag.out || HASERROR=1 -$EXE -D -Od -e main -V -i -DUNDEFED -UIN_SHADER -DFOO=200 -UUNDEFED -Od hlsl.-D-U.frag > $TARGETDIR/hlsl.-D-U.frag.out +$EXE -D -Od -e main -V -i -DUNDEFED -UIN_SHADER --D FOO=200 --undef-macro UNDEFED -Od hlsl.-D-U.frag > $TARGETDIR/hlsl.-D-U.frag.out diff -b $BASEDIR/hlsl.-D-U.frag.out $TARGETDIR/hlsl.-D-U.frag.out || HASERROR=1 #