Skip to content

Commit

Permalink
Add option --no-suffix, @axmol-bot [release 1.8.1]
Browse files Browse the repository at this point in the history
  • Loading branch information
halx99 committed Jul 16, 2023
1 parent 5c1b616 commit 2ead452
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Thumbs.db
/.idea/libraries
/build
/build-*
/build_*
/captures


Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ I'll have to write a more detailed documentation but for these are the arguments
-o --output=<Filepath> : Output file
-l --lang=<essl/msl/hlsl/glsl/spirv> : Convert to shader language
-a --automap : This option remove binding and location requirement in shader
-u --no-suffix : This option is for don't add _fs or _vs suffix in output file
-D --defines(=Defines) : Preprocessor definitions, seperated by comma or ';'
-Y --invert-y : Invert position.y in vertex shader
-p --profile=<ProfileVersion> : Shader profile version (HLSL: 40, 50, 60), (ES: 200, 300), (GLSL: 330, 400, 420)
Expand Down
15 changes: 11 additions & 4 deletions src/glslcc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
// Indent with spaces instead Tab when output cvar header file
// Rename shader lang `gles` to `essl`
// Add option -a --automap to remove binding and location requirement in shader
// 1.8.1 Add option -n --no-suffix for don't add _fs or _vs suffix in output files
//
#define _ALLOW_KEYWORD_MACROS

Expand Down Expand Up @@ -321,6 +322,7 @@ struct cmd_args {
int preprocess;
int flatten_ubos;
int automap;
int no_suffix;
int sgs_file;
int reflect;
int compile_bin;
Expand Down Expand Up @@ -1314,10 +1316,14 @@ static int cross_compile(const cmd_args& args, std::vector<uint32_t>& spirv,
cvar_code += get_stage_name(stage);
filepath = args.out_filepath;
} else {
char ext[32];
char basename[512];
sx_os_path_splitext(ext, sizeof(ext), basename, sizeof(basename), args.out_filepath);
filepath = std::string(basename) + std::string("_") + std::string(get_stage_name(stage)) + std::string(ext);
if (!args.no_suffix) {
char ext[32];
char basename[512];
sx_os_path_splitext(ext, sizeof(ext), basename, sizeof(basename), args.out_filepath);
filepath = std::string(basename) + std::string("_") + std::string(get_stage_name(stage)) + std::string(ext);
} else {
filepath = args.out_filepath;
}
}
bool append = !cvar_code.empty() && (file_index > 0);

Expand Down Expand Up @@ -1794,6 +1800,7 @@ int main(int argc, char* argv[])
{ "output", 'o', SX_CMDLINE_OPTYPE_REQUIRED, 0x0, 'o', "Output file", "Filepath" },
{ "lang", 'l', SX_CMDLINE_OPTYPE_REQUIRED, 0x0, 'l', "Convert to shader language", "essl/msl/hlsl/glsl/spirv" },
{ "automap", 'a', SX_CMDLINE_OPTYPE_FLAG_SET, &args.automap, 1, "This option remove binding and location requirement in shader", 0x0 },
{ "no-suffix", 'u', SX_CMDLINE_OPTYPE_FLAG_SET, &args.no_suffix, 1, "This option is for don't add _fs or _vs suffix in output file", 0x0 },
{ "defines", 'D', SX_CMDLINE_OPTYPE_OPTIONAL, 0x0, 'D', "Preprocessor definitions, seperated by comma or ';'", "Defines" },
{ "invert-y", 'Y', SX_CMDLINE_OPTYPE_FLAG_SET, &args.invert_y, 1, "Invert position.y in vertex shader", 0x0 },
{ "profile", 'p', SX_CMDLINE_OPTYPE_REQUIRED, 0x0, 'p', "Shader profile version (HLSL: 40, 50, 60), (ES: 200, 300), (GLSL: 330, 400, 420)", "ProfileVersion" },
Expand Down

0 comments on commit 2ead452

Please sign in to comment.