device_options.cpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Copyright (c) 2012-2015 Daniele Bartolini and individual contributors.
  3. * License: https://github.com/taylor001/crown/blob/master/LICENSE
  4. */
  5. #include "device_options.h"
  6. #include "command_line.h"
  7. namespace crown
  8. {
  9. static void help(const char* msg = NULL)
  10. {
  11. if (msg)
  12. {
  13. printf("Error: %s\n", msg);
  14. }
  15. printf(
  16. "Usage: crown [options]\n"
  17. "Options:\n\n"
  18. " -h --help Show this help.\n"
  19. " -v --version Show version informations.\n"
  20. " --bundle-dir <path> Use <path> as the source directory for compiled resources.\n"
  21. " --console-port <port> Set port of the console.\n"
  22. " --parent-window <handle> Set the parent window <handle> of the main window.\n"
  23. " Used only by tools.\n"
  24. "\nAvailable only in debug and development builds:\n\n"
  25. " --source-dir <path> Use <path> as the source directory for resource compilation.\n"
  26. " --project <name> Start the project <name>.\n"
  27. " --compile Do a full compile of the resources.\n"
  28. " --platform <platform> Compile resources for the given <platform>.\n"
  29. " Possible values for <platform> are:\n"
  30. " linux\n"
  31. " windows\n"
  32. " android\n"
  33. " --continue Continue the execution after the resource compilation step.\n"
  34. " --wait-console Wait for a console connection before starting up.\n"
  35. );
  36. }
  37. DeviceOptions::DeviceOptions(int argc, char** argv)
  38. : _source_dir(NULL)
  39. , _bundle_dir(NULL)
  40. , _project(NULL)
  41. , _platform(NULL)
  42. , _wait_console(false)
  43. , _do_compile(false)
  44. , _do_continue(false)
  45. , _parent_window(0)
  46. , _console_port(CROWN_DEFAULT_CONSOLE_PORT)
  47. , _window_x(0)
  48. , _window_y(0)
  49. , _window_width(CROWN_DEFAULT_WINDOW_WIDTH)
  50. , _window_height(CROWN_DEFAULT_WINDOW_HEIGHT)
  51. {
  52. CommandLine cmd(argc, argv);
  53. _source_dir = cmd.get_parameter("source-dir");
  54. _bundle_dir = cmd.get_parameter("bundle-dir");
  55. _project = cmd.get_parameter("project");
  56. _platform = cmd.get_parameter("platform");
  57. _wait_console = cmd.has_argument("wait-console");
  58. _do_compile = cmd.has_argument("compile");
  59. _do_continue = cmd.has_argument("continue");
  60. const char* parent = cmd.get_parameter("parent-window");
  61. if (parent)
  62. _parent_window = parse_uint(parent);
  63. const char* port = cmd.get_parameter("console-port");
  64. if (port)
  65. _console_port = parse_uint(port);
  66. }
  67. }