blob: 6848179025789f4b78eeef693a163eef88476f67 [file] [log] [blame]
Yang Guod8176982019-10-04 20:30:351# Copyright 2019 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4"""
5Helper to find the path to the correct third_party directory
6"""
7
8from os import path
9import sys
Paul Lewis449ac182019-12-03 10:28:1110import platform
Yang Guod8176982019-10-04 20:30:3511
12
13# Find the root path of the checkout.
14# In the Chromium repository, this is the src/chromium directory.
15# In the external repository, standalone build, this is the devtools-frontend directory.
16# In the external repository, integrated build, this is the src/chromium directory.
17def 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 # TODO(1011259): remove Chromium repository handling
22 if path.basename(PARENT_PATH) == 'renderer':
23 # Chromium repository
24 return path.dirname(path.dirname(path.dirname(PARENT_PATH)))
Alex Rudenko413451a2021-07-22 15:36:3725 elif path.basename(PARENT_PATH) == 'devtools-frontend' or path.basename(
26 PARENT_PATH) == 'devtools-frontend-internal':
Yang Guod8176982019-10-04 20:30:3527 # External repository, integrated build
Yang Guo4fd355c2019-09-19 08:59:0328 return path.dirname(path.dirname(PARENT_PATH))
Yang Guod8176982019-10-04 20:30:3529 else:
30 # External repository, standalone build
31 return ABS_DEVTOOLS_PATH
32
33
34# This is the third_party path relative to the root of the checkout.
35def third_party_path():
36 return path.join(root_path(), 'third_party')
37
38
39# This points to the node binary downloaded as part of the checkout.
40def 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
Yang Guo75beda92019-10-28 07:29:2550def devtools_root_path():
51 return path.dirname((path.dirname(path.abspath(__file__))))
Yang Guod8176982019-10-04 20:30:3552
53
54def node_modules_path():
Yang Guo75beda92019-10-28 07:29:2555 return path.join(devtools_root_path(), 'node_modules')
Yang Guod8176982019-10-04 20:30:3556
57
58def eslint_path():
59 return path.join(node_modules_path(), 'eslint', 'bin', 'eslint.js')
60
61
Tim van der Lippe869374b2020-04-20 10:12:3162def mocha_path():
63 return path.join(node_modules_path(), 'mocha', 'bin', 'mocha')
64
65
Yang Guod8176982019-10-04 20:30:3566def karma_path():
67 return path.join(node_modules_path(), 'karma', 'bin', 'karma')
68
69
Paul Lewisb8b38012020-01-22 17:18:4770def typescript_compiler_path():
71 return path.join(node_modules_path(), 'typescript', 'bin', 'tsc')
72
73
Paul Lewis449ac182019-12-03 10:28:1174def hosted_mode_script_path():
75 return path.join(devtools_root_path(), 'scripts', 'hosted_mode', 'server.js')
76
77
Takuto Ikuta95a359d2022-01-24 01:38:2978def esbuild_path():
79 return path.join(devtools_root_path(), 'third_party', 'esbuild', 'esbuild')
80
81
Paul Lewis449ac182019-12-03 10:28:1182def downloaded_chrome_binary_path():
Mathias Bynens5c9b5f12023-07-18 14:05:5283 return path.abspath(
84 path.join(
85 *{
86 'Linux': (devtools_root_path(), 'third_party', 'chromium',
87 'chrome-linux', 'chrome'),
88 'Darwin': (devtools_root_path(), 'third_party', 'chromium',
89 'chrome-mac', 'Chromium.app', 'Contents', 'MacOS',
90 'Chromium'),
91 'Windows': (devtools_root_path(), 'third_party', 'chromium',
92 'chrome-win', 'chrome.exe'),
93 }[platform.system()]))
Paul Lewis449ac182019-12-03 10:28:1194
95
Paul Lewise184c4c2019-12-02 12:30:1596def license_checker_path():
97 return path.join(node_modules_path(), 'license-checker', 'bin', 'license-checker')
98
99
Tim van der Lippefd903612019-11-07 11:29:06100def rollup_path():
101 return path.join(
102 node_modules_path(),
103 'rollup',
104 'dist',
105 'bin',
106 'rollup',
107 )
108
109
Paul Lewis66e12062019-12-02 12:04:54110def package_lock_json_path():
111 return path.join(devtools_root_path(), 'package-lock.json')
112
113
Yang Guod8176982019-10-04 20:30:35114def package_json_path():
Yang Guo75beda92019-10-28 07:29:25115 return path.join(devtools_root_path(), 'package.json')
Andrey Kosyakovfff69a72019-11-27 01:31:57116
Paul Lewis66e12062019-12-02 12:04:54117
Andrey Kosyakovfff69a72019-11-27 01:31:57118def browser_protocol_path():
119 return path.join(third_party_path(), 'blink', 'public', 'devtools_protocol', 'browser_protocol.pdl')