blob: 543cfa6e2dc3098dc6b5299b77c67acef8428417 [file] [log] [blame]
Yang Guod8176982019-10-04 20:30:35 +00001# 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:11 +000010import platform
Yang Guod8176982019-10-04 20:30:35 +000011
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)))
Yang Guo4fd355c2019-09-19 10:59:03 +020025 elif path.basename(PARENT_PATH) == 'devtools-frontend':
Yang Guod8176982019-10-04 20:30:35 +000026 # External repository, integrated build
Yang Guo4fd355c2019-09-19 10:59:03 +020027 return path.dirname(path.dirname(PARENT_PATH))
Yang Guod8176982019-10-04 20:30:35 +000028 else:
29 # External repository, standalone build
30 return ABS_DEVTOOLS_PATH
31
32
33# This is the third_party path relative to the root of the checkout.
34def third_party_path():
35 return path.join(root_path(), 'third_party')
36
37
38# This points to the node binary downloaded as part of the checkout.
39def node_path():
40 try:
41 old_sys_path = sys.path[:]
42 sys.path.append(path.join(third_party_path(), 'node'))
43 import node
44 finally:
45 sys.path = old_sys_path
46 return node.GetBinaryPath()
47
48
Yang Guo75beda92019-10-28 08:29:25 +010049def devtools_root_path():
50 return path.dirname((path.dirname(path.abspath(__file__))))
Yang Guod8176982019-10-04 20:30:35 +000051
52
53def node_modules_path():
Yang Guo75beda92019-10-28 08:29:25 +010054 return path.join(devtools_root_path(), 'node_modules')
Yang Guod8176982019-10-04 20:30:35 +000055
56
57def eslint_path():
58 return path.join(node_modules_path(), 'eslint', 'bin', 'eslint.js')
59
60
Tim van der Lippe869374b2020-04-20 11:12:31 +010061def mocha_path():
62 return path.join(node_modules_path(), 'mocha', 'bin', 'mocha')
63
64
vidorteg2b675b02019-11-25 09:51:28 -080065def check_localizable_resources_path():
Yang Guo6e99c7c2019-12-03 10:41:40 +010066 return path.join(devtools_root_path(), 'scripts', 'localization', 'check_localizable_resources.js')
vidorteg2b675b02019-11-25 09:51:28 -080067
68
69def check_localized_strings_path():
Yang Guo6e99c7c2019-12-03 10:41:40 +010070 return path.join(devtools_root_path(), 'scripts', 'localization', 'check_localizability.js')
vidorteg2b675b02019-11-25 09:51:28 -080071
72
Yang Guod8176982019-10-04 20:30:35 +000073def karma_path():
74 return path.join(node_modules_path(), 'karma', 'bin', 'karma')
75
76
Paul Lewisb8b38012020-01-22 17:18:47 +000077def typescript_compiler_path():
78 return path.join(node_modules_path(), 'typescript', 'bin', 'tsc')
79
80
Paul Lewis449ac182019-12-03 10:28:11 +000081def boot_perf_test_path():
82 return path.join(devtools_root_path(), 'test', 'perf', 'bootperf.js')
83
84
85def hosted_mode_script_path():
86 return path.join(devtools_root_path(), 'scripts', 'hosted_mode', 'server.js')
87
88
89def downloaded_chrome_binary_path():
90 return path.abspath(path.join(
91 *{
92 'Linux': (devtools_root_path(), 'third_party', 'chrome', 'chrome-linux', 'chrome'),
93 'Darwin': (devtools_root_path(), 'third_party', 'chrome', 'chrome-mac', 'Chromium.app', 'Contents', 'MacOS', 'Chromium'),
94 'Windows': (devtools_root_path(), 'third_party', 'chrome', 'chrome-win', 'chrome.exe'),
95 }[platform.system()]))
96
97
Paul Lewise184c4c2019-12-02 12:30:15 +000098def license_checker_path():
99 return path.join(node_modules_path(), 'license-checker', 'bin', 'license-checker')
100
101
Tim van der Lippefd903612019-11-07 11:29:06 +0000102def rollup_path():
103 return path.join(
104 node_modules_path(),
105 'rollup',
106 'dist',
107 'bin',
108 'rollup',
109 )
110
111
Paul Lewis66e12062019-12-02 12:04:54 +0000112def package_lock_json_path():
113 return path.join(devtools_root_path(), 'package-lock.json')
114
115
Yang Guod8176982019-10-04 20:30:35 +0000116def package_json_path():
Yang Guo75beda92019-10-28 08:29:25 +0100117 return path.join(devtools_root_path(), 'package.json')
Andrey Kosyakovfff69a72019-11-27 01:31:57 +0000118
Paul Lewis66e12062019-12-02 12:04:54 +0000119
Andrey Kosyakovfff69a72019-11-27 01:31:57 +0000120def browser_protocol_path():
121 return path.join(third_party_path(), 'blink', 'public', 'devtools_protocol', 'browser_protocol.pdl')