Setup options from cmd-line and internal options.
(docopt_args)
| 160 | |
| 161 | |
| 162 | def setup_options(docopt_args): |
| 163 | """Setup options from cmd-line and internal options.""" |
| 164 | |
| 165 | # Populate Options using command line arguments |
| 166 | for key in docopt_args: |
| 167 | value = docopt_args[key] |
| 168 | key2 = key.replace("--", "").replace("-", "_") |
| 169 | if hasattr(Options, key2) and value is not None: |
| 170 | setattr(Options, key2, value) |
| 171 | |
| 172 | Options.tools_dir = os.path.dirname(os.path.realpath(__file__)) |
| 173 | Options.cefpython_dir = os.path.dirname(Options.tools_dir) |
| 174 | |
| 175 | if not Options.cef_git_url: |
| 176 | Options.cef_git_url = CEF_UPSTREAM_GIT_URL |
| 177 | |
| 178 | # If --cef-branch is specified will use latest CEF commit from that |
| 179 | # branch. Otherwise get cef branch/commit from src/version/. |
| 180 | if not Options.cef_branch: |
| 181 | # Use branch/commit from the src/version/cef_version_*.h file |
| 182 | Options.cef_branch = get_cefpython_version()["CHROME_VERSION_BUILD"] |
| 183 | Options.cef_commit = get_cefpython_version()["CEF_COMMIT_HASH"] |
| 184 | Options.cef_version = get_cefpython_version()["CEF_VERSION"] |
| 185 | |
| 186 | # --gyp-msvs-version |
| 187 | if not Options.gyp_msvs_version: |
| 188 | if int(Options.cef_branch) >= 2704: |
| 189 | Options.gyp_msvs_version = "2015" |
| 190 | else: |
| 191 | Options.gyp_msvs_version = "2013" |
| 192 | |
| 193 | # --build-dir |
| 194 | if Options.build_dir: |
| 195 | Options.build_dir = os.path.realpath(Options.build_dir) |
| 196 | else: |
| 197 | Options.build_dir = os.path.join(Options.cefpython_dir, "build") |
| 198 | if " " in Options.build_dir: |
| 199 | print("[automate.py] ERROR: Build dir cannot contain spaces") |
| 200 | print(">> " + Options.build_dir) |
| 201 | sys.exit(1) |
| 202 | if not os.path.exists(Options.build_dir): |
| 203 | os.makedirs(Options.build_dir) |
| 204 | |
| 205 | # --cef-build-dir |
| 206 | if Options.cef_build_dir: |
| 207 | Options.cef_build_dir = os.path.realpath(Options.cef_build_dir) |
| 208 | else: |
| 209 | Options.cef_build_dir = Options.build_dir |
| 210 | if " " in Options.cef_build_dir: |
| 211 | print("[automate.py] ERROR: CEF build dir cannot contain spaces") |
| 212 | print(">> " + Options.cef_build_dir) |
| 213 | sys.exit(1) |
| 214 | if not os.path.exists(Options.cef_build_dir): |
| 215 | os.makedirs(Options.cef_build_dir) |
| 216 | |
| 217 | # --depot-tools-dir |
| 218 | Options.depot_tools_dir = os.path.join(Options.cef_build_dir, |
| 219 | "depot_tools") |
no test coverage detected