Skip to content

Commit

Permalink
build(deps): Fixes to using OIIO::ArgParse for OIIO 3.0 (AcademySoftw…
Browse files Browse the repository at this point in the history
…areFoundation#1885)

OIIO 3.0 will finally warn aggressviely about some long-deprecated
ArgParse methods. Switch to the newer ones.

Signed-off-by: Larry Gritz <[email protected]>
  • Loading branch information
lgritz authored Oct 13, 2024
1 parent 7210aa5 commit 8e247c7
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 61 deletions.
11 changes: 1 addition & 10 deletions src/liboslexec/llvmutil_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ static int memtest = 0;
static void
getargs(int argc, char* argv[])
{
bool help = false;
OIIO::ArgParse ap;
// clang-format off
ap.intro("llvmutil_test\n" OIIO_INTRO_STRING);
Expand All @@ -35,15 +34,7 @@ getargs(int argc, char* argv[])
ap.arg("--memtest %d:ITERATIONS", &memtest)
.help("Memory test mode");
// clang-format on
if (ap.parse(argc, (const char**)argv) < 0) {
std::cerr << ap.geterror() << std::endl;
ap.usage();
exit(EXIT_FAILURE);
}
if (help) {
ap.usage();
exit(EXIT_FAILURE);
}
ap.parse_args(argc, (const char**)argv);
}


Expand Down
11 changes: 1 addition & 10 deletions src/liboslnoise/oslnoise_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,6 @@ test_hash()
static void
getargs(int argc, const char* argv[])
{
bool help = false;
OIIO::ArgParse ap;
// clang-format off
ap.intro("oslnoise_test (" OSL_INTRO_STRING ")");
Expand All @@ -384,15 +383,7 @@ getargs(int argc, const char* argv[])
.help("Number of trials");
// clang-format on

if (ap.parse(argc, (const char**)argv) < 0) {
std::cerr << ap.geterror() << std::endl;
ap.usage();
exit(EXIT_FAILURE);
}
if (help) {
ap.usage();
exit(EXIT_FAILURE);
}
ap.parse_args(argc, (const char**)argv);
}


Expand Down
9 changes: 3 additions & 6 deletions src/oslinfo/oslinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,9 @@ main(int argc, char* argv[])
.help("Output information about just this parameter");
// clang-format on

if (ap.parse(argc, (const char**)argv) < 0) {
std::cerr << ap.geterror() << std::endl;
ap.usage();
return EXIT_FAILURE;
} else if (filenames.empty()) {
ap.usage();
ap.parse_args(argc, (const char**)argv);
if (filenames.empty()) {
ap.print_help();
return EXIT_SUCCESS;
}

Expand Down
11 changes: 1 addition & 10 deletions src/osltoy/osltoymain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ static std::vector<std::string> include_paths;
static void
getargs(int argc, char* argv[])
{
bool help = false;
OIIO::ArgParse ap;
// clang-format off
ap.intro("osltoy -- interactive OSL plaything\n" OSL_INTRO_STRING);
Expand All @@ -63,15 +62,7 @@ getargs(int argc, char* argv[])
.action([&](cspan<const char*> argv){ include_paths.emplace_back(argv[1]); })
.help("Add DIRPATH to the list of header search paths.");
// clang-format on
if (ap.parse(argc, (const char**)argv) < 0) {
std::cerr << ap.geterror() << std::endl;
ap.usage();
exit(EXIT_FAILURE);
}
if (help) {
ap.usage();
exit(EXIT_FAILURE);
}
ap.parse_args(argc, (const char**)argv);
}


Expand Down
15 changes: 3 additions & 12 deletions src/testrender/testrender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,24 +224,15 @@ getargs(int argc, const char* argv[])
.help("Set extra TextureSystem options");

// clang-format on
if (ap["help"].get<int>()) {
ap.print_help();
ap.abort();
exit(EXIT_SUCCESS);
}
if (ap.parse(argc, argv) < 0) {
std::cerr << ap.geterror() << "\n\n";
ap.usage();
exit(EXIT_FAILURE);
}
ap.parse_args(argc, argv);
if (scenefile.empty()) {
std::cerr << "testrender: Must specify an xml scene file to open\n\n";
ap.usage();
ap.print_help();
exit(EXIT_FAILURE);
}
if (imagefile.empty()) {
std::cerr << "testrender: Must specify a filename for output render\n\n";
ap.usage();
ap.print_help();
exit(EXIT_FAILURE);
}
}
Expand Down
15 changes: 2 additions & 13 deletions src/testshade/testshade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -711,8 +711,6 @@ getargs(int argc, const char* argv[])
ap.arg("filename")
.hidden()
.action([&](cspan<const char*> argv){ stash_shader_arg(argv); });
ap.arg("--help")
.help("Print help message");
ap.arg("-v", &verbose)
.help("Verbose messages");
ap.arg("-t %d:NTHREADS", &num_threads)
Expand Down Expand Up @@ -863,16 +861,7 @@ getargs(int argc, const char* argv[])
.help("journal jbuffer size in MB");

// clang-format on
if (ap.parse(argc, argv) < 0) {
std::cerr << ap.geterror() << std::endl;
ap.usage();
exit(EXIT_FAILURE);
}
if (ap["help"].get<int>()) {
ap.usage();
print_info();
exit(EXIT_SUCCESS);
}
ap.parse_args(argc, argv);
}


Expand Down Expand Up @@ -909,7 +898,7 @@ process_shader_setup_args(int argc, const char* argv[])
.action([&](cspan<const char*> argv){ specify_expr(argv); });

// clang-format on
if (ap.parse(argc, argv) < 0
if (ap.parse_args(argc, argv) < 0
|| (shadernames.empty() && groupspec.empty())) {
std::cerr << "ERROR: No shader or group was specified.\n";
std::cerr << ap.geterror() << std::endl;
Expand Down

0 comments on commit 8e247c7

Please sign in to comment.