| 102 | } |
| 103 | |
| 104 | int DeviceOptions::parse(bool *quit) |
| 105 | { |
| 106 | CommandLine cl(_argc, _argv); |
| 107 | |
| 108 | if (cl.has_option("help", 'h')) { |
| 109 | help(); |
| 110 | *quit = true; |
| 111 | return EXIT_SUCCESS; |
| 112 | } |
| 113 | |
| 114 | if (cl.has_option("version", 'v')) { |
| 115 | printf("Crown " CROWN_VERSION "\n"); |
| 116 | *quit = true; |
| 117 | return EXIT_SUCCESS; |
| 118 | } |
| 119 | |
| 120 | path::reduce(_source_dir, cl.get_parameter(0, "source-dir")); |
| 121 | path::reduce(_data_dir, cl.get_parameter(0, "data-dir")); |
| 122 | path::reduce(_bundle_dir, cl.get_parameter(0, "bundle-dir")); |
| 123 | |
| 124 | _map_source_dir_name = cl.get_parameter(0, "map-source-dir"); |
| 125 | if (_map_source_dir_name) { |
| 126 | path::reduce(_map_source_dir_prefix, cl.get_parameter(1, "map-source-dir")); |
| 127 | if (_map_source_dir_prefix.empty()) { |
| 128 | help("Mapped source directory must be specified."); |
| 129 | return EXIT_FAILURE; |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | _do_compile = cl.has_option("compile"); |
| 134 | _do_bundle = cl.has_option("bundle"); |
| 135 | if (_do_compile || _do_bundle) { |
| 136 | _platform = cl.get_parameter(0, "platform"); |
| 137 | |
| 138 | // Compile for platform the executable is built for. |
| 139 | if (_platform == NULL) |
| 140 | _platform = CROWN_PLATFORM_NAME; |
| 141 | |
| 142 | if (_source_dir.empty()) { |
| 143 | help("Source dir must be specified."); |
| 144 | return EXIT_FAILURE; |
| 145 | } |
| 146 | |
| 147 | if (_data_dir.empty()) { |
| 148 | _data_dir += _source_dir; |
| 149 | _data_dir += '_'; |
| 150 | _data_dir += _platform; |
| 151 | } |
| 152 | |
| 153 | if (_do_bundle) { |
| 154 | if (_bundle_dir.empty()) { |
| 155 | _bundle_dir += _source_dir; |
| 156 | _bundle_dir += "_bundle_"; |
| 157 | _bundle_dir += _platform; |
| 158 | } |
| 159 | } |
| 160 | } |
| 161 |
nothing calls this directly
no test coverage detected