1 |
|
2 |
|
3 |
|
4 | """
|
5 | Helper to find the path to the correct third_party directory
|
6 | """
|
7 |
|
8 | from os import path
|
9 | import sys
|
10 | import platform
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | def root_path():
|
18 | SCRIPTS_PATH = path.dirname(path.abspath(__file__))
|
19 | ABS_DEVTOOLS_PATH = path.dirname(SCRIPTS_PATH)
|
20 | PARENT_PATH = path.dirname(ABS_DEVTOOLS_PATH)
|
21 |
|
22 | if path.basename(PARENT_PATH) == 'renderer':
|
23 |
|
24 | return path.dirname(path.dirname(path.dirname(PARENT_PATH)))
|
25 | elif path.basename(PARENT_PATH) == 'devtools-frontend' or path.basename(
|
26 | PARENT_PATH) == 'devtools-frontend-internal':
|
27 |
|
28 | return path.dirname(path.dirname(PARENT_PATH))
|
29 | else:
|
30 |
|
31 | return ABS_DEVTOOLS_PATH
|
32 |
|
33 |
|
34 |
|
35 | def third_party_path():
|
36 | return path.join(root_path(), 'third_party')
|
37 |
|
38 |
|
39 |
|
40 | def node_path():
|
41 | try:
|
42 | old_sys_path = sys.path[:]
|
43 | sys.path.append(path.join(third_party_path(), 'node'))
|
44 | import node
|
45 | finally:
|
46 | sys.path = old_sys_path
|
47 | return node.GetBinaryPath()
|
48 |
|
49 |
|
50 | def devtools_root_path():
|
51 | return path.dirname((path.dirname(path.abspath(__file__))))
|
52 |
|
53 |
|
54 | def node_modules_path():
|
55 | return path.join(devtools_root_path(), 'node_modules')
|
56 |
|
57 |
|
58 | def eslint_path():
|
59 | return path.join(node_modules_path(), 'eslint', 'bin', 'eslint.js')
|
60 |
|
61 |
|
62 | def mocha_path():
|
63 | return path.join(node_modules_path(), 'mocha', 'bin', 'mocha')
|
64 |
|
65 |
|
66 | def karma_path():
|
67 | return path.join(node_modules_path(), 'karma', 'bin', 'karma')
|
68 |
|
69 |
|
70 | def typescript_compiler_path():
|
71 | return path.join(node_modules_path(), 'typescript', 'bin', 'tsc')
|
72 |
|
73 |
|
74 | def hosted_mode_script_path():
|
75 | return path.join(devtools_root_path(), 'scripts', 'hosted_mode', 'server.js')
|
76 |
|
77 |
|
78 | def downloaded_chrome_binary_path():
|
79 | return path.abspath(path.join(
|
80 | *{
|
81 | 'Linux': (devtools_root_path(), 'third_party', 'chrome', 'chrome-linux', 'chrome'),
|
82 | 'Darwin': (devtools_root_path(), 'third_party', 'chrome', 'chrome-mac', 'Chromium.app', 'Contents', 'MacOS', 'Chromium'),
|
83 | 'Windows': (devtools_root_path(), 'third_party', 'chrome', 'chrome-win', 'chrome.exe'),
|
84 | }[platform.system()]))
|
85 |
|
86 |
|
87 | def license_checker_path():
|
88 | return path.join(node_modules_path(), 'license-checker', 'bin', 'license-checker')
|
89 |
|
90 |
|
91 | def rollup_path():
|
92 | return path.join(
|
93 | node_modules_path(),
|
94 | 'rollup',
|
95 | 'dist',
|
96 | 'bin',
|
97 | 'rollup',
|
98 | )
|
99 |
|
100 |
|
101 | def package_lock_json_path():
|
102 | return path.join(devtools_root_path(), 'package-lock.json')
|
103 |
|
104 |
|
105 | def package_json_path():
|
106 | return path.join(devtools_root_path(), 'package.json')
|
107 |
|
108 |
|
109 | def browser_protocol_path():
|
110 | return path.join(third_party_path(), 'blink', 'public', 'devtools_protocol', 'browser_protocol.pdl')
|