From: Carl Hetherington Date: Sat, 28 Apr 2018 23:37:13 +0000 (+0100) Subject: Allow command-line configuration of config location (#1284). X-Git-Tag: v2.13.19~1 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=04badd0c82d3ce82ee87c07e120e585899d4acff Allow command-line configuration of config location (#1284). --- diff --git a/ChangeLog b/ChangeLog index 304c9d3d8..fa080842d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2018-04-29 Carl Hetherington + + * Add command-line option to specify directory containing config (#1284). + 2018-04-27 Carl Hetherington * Fix incorrect container size when loading a OV/VF combination into the player. diff --git a/src/lib/config.cc b/src/lib/config.cc index 2ae7939a9..e2f2bbeb9 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -68,7 +68,7 @@ int const Config::_current_version = 3; boost::signals2::signal Config::FailedToLoad; boost::signals2::signal Config::Warning; boost::signals2::signal Config::BadSignerChain; -boost::optional Config::test_path; +boost::optional Config::override_path; /** Construct default configuration */ Config::Config () @@ -456,8 +456,8 @@ boost::filesystem::path Config::path (string file, bool create_directories) { boost::filesystem::path p; - if (test_path) { - p = test_path.get(); + if (override_path) { + p = *override_path; } else { #ifdef DCPOMATIC_OSX p /= g_get_home_dir (); diff --git a/src/lib/config.h b/src/lib/config.h index 2fca9699c..c625e9242 100644 --- a/src/lib/config.h +++ b/src/lib/config.h @@ -721,8 +721,9 @@ public: static bool have_existing (std::string); static boost::filesystem::path config_file (); - static boost::optional test_path; - + /** If set, this overrides the standard path (in home, Library, AppData or wherever) for config.xml and cinemas.xml */ + static boost::optional override_path; + private: Config (); static boost::filesystem::path path (std::string file, bool create_directories = true); diff --git a/src/tools/dcpomatic_cli.cc b/src/tools/dcpomatic_cli.cc index 788594f0c..7fc5ed55d 100644 --- a/src/tools/dcpomatic_cli.cc +++ b/src/tools/dcpomatic_cli.cc @@ -65,6 +65,7 @@ help (string n) << " -s, --servers specify servers to use in a text file\n" << " -l, --list-servers just display a list of encoding servers that DCP-o-matic is configured to use; don't encode\n" << " -d, --dcp-path echo DCP's path to stdout on successful completion (implies -n)\n" + << " -c, --config directory containing config.xml and cinemas.xml\n" << " --dump just dump a summary of the film's settings; don't encode\n" << "\n" << " is the film directory.\n"; @@ -195,6 +196,7 @@ main (int argc, char* argv[]) optional servers; bool list_servers_ = false; bool dcp_path = false; + optional config; int option_index = 0; while (true) { @@ -210,12 +212,13 @@ main (int argc, char* argv[]) { "servers", required_argument, 0, 's' }, { "list-servers", no_argument, 0, 'l' }, { "dcp-path", no_argument, 0, 'd' }, + { "config", required_argument, 0, 'c' }, /* Just using A, B, C ... from here on */ { "dump", no_argument, 0, 'A' }, { 0, 0, 0, 0 } }; - int c = getopt_long (argc, argv, "vhfnrt:j:kAs:ld", long_options, &option_index); + int c = getopt_long (argc, argv, "vhfnrt:j:kAs:ldc:", long_options, &option_index); if (c == -1) { break; @@ -259,9 +262,16 @@ main (int argc, char* argv[]) dcp_path = true; progress = false; break; + case 'c': + config = optarg; + break; } } + if (config) { + Config::override_path = *config; + } + if (servers) { FILE* f = fopen_boost (*servers, "r"); if (!f) { diff --git a/src/tools/dcpomatic_create.cc b/src/tools/dcpomatic_create.cc index a9d1165f1..5c6fc3567 100644 --- a/src/tools/dcpomatic_create.cc +++ b/src/tools/dcpomatic_create.cc @@ -30,6 +30,7 @@ #include "lib/image_content.h" #include "lib/video_content.h" #include "lib/cross.h" +#include "lib/config.h" #include "lib/dcp_content.h" #include #include @@ -66,6 +67,7 @@ syntax (string n) << " --standard SMPTE or interop (default SMPTE)\n" << " --no-use-isdcf-name do not use an ISDCF name; use the specified name unmodified\n" << " --no-sign do not sign the DCP\n" + << " --config directory containing config.xml and cinemas.xml\n" << " -o, --output output directory\n"; } @@ -105,6 +107,7 @@ main (int argc, char* argv[]) optional output; bool sign = true; bool use_isdcf_name = true; + optional config; int option_index = 0; while (true) { @@ -122,10 +125,11 @@ main (int argc, char* argv[]) { "no-use-isdcf-name", no_argument, 0, 'D'}, { "no-sign", no_argument, 0, 'E'}, { "output", required_argument, 0, 'o'}, + { "config", required_argument, 0, 'F'}, { 0, 0, 0, 0} }; - int c = getopt_long (argc, argv, "vhn:f:c:f:A:B:C:s:o:DE", long_options, &option_index); + int c = getopt_long (argc, argv, "vhn:f:c:f:A:B:C:s:o:DEF:", long_options, &option_index); if (c == -1) { break; } @@ -185,6 +189,9 @@ main (int argc, char* argv[]) case 'E': sign = false; break; + case 'F': + config = optarg; + break; case 's': still_length = atoi (optarg); break; @@ -202,6 +209,10 @@ main (int argc, char* argv[]) exit (EXIT_FAILURE); } + if (config) { + Config::override_path = *config; + } + if (!content_ratio) { cerr << argv[0] << ": missing required option --content-ratio.\n"; exit (EXIT_FAILURE); diff --git a/test/config_test.cc b/test/config_test.cc index dad545a48..14cceb6a0 100644 --- a/test/config_test.cc +++ b/test/config_test.cc @@ -31,7 +31,7 @@ rewrite_bad_config () boost::system::error_code ec; boost::filesystem::remove ("build/test/config.xml", ec); - Config::test_path = "build/test"; + Config::override_path = "build/test"; ofstream f ("build/test/config.xml"); f << "\n" << "\n"