blob: a8b8c2945c743c8bbd346d2e33f85afbf1ab4df7 [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
vidorteg2b675b02019-11-25 09:51:28 -080061def check_localizable_resources_path():
62 return path.join(devtools_root_path(), 'scripts', 'check_localizable_resources.js')
63
64
65def check_localized_strings_path():
66 return path.join(devtools_root_path(), 'scripts', 'check_localizability.js')
67
68
Yang Guod8176982019-10-04 20:30:35 +000069def karma_path():
70 return path.join(node_modules_path(), 'karma', 'bin', 'karma')
71
72
Paul Lewis449ac182019-12-03 10:28:11 +000073def boot_perf_test_path():
74 return path.join(devtools_root_path(), 'test', 'perf', 'bootperf.js')
75
76
77def hosted_mode_script_path():
78 return path.join(devtools_root_path(), 'scripts', 'hosted_mode', 'server.js')
79
80
81def downloaded_chrome_binary_path():
82 return path.abspath(path.join(
83 *{
84 'Linux': (devtools_root_path(), 'third_party', 'chrome', 'chrome-linux', 'chrome'),
85 'Darwin': (devtools_root_path(), 'third_party', 'chrome', 'chrome-mac', 'Chromium.app', 'Contents', 'MacOS', 'Chromium'),
86 'Windows': (devtools_root_path(), 'third_party', 'chrome', 'chrome-win', 'chrome.exe'),
87 }[platform.system()]))
88
89
Paul Lewise184c4c2019-12-02 12:30:15 +000090def license_checker_path():
91 return path.join(node_modules_path(), 'license-checker', 'bin', 'license-checker')
92
93
Tim van der Lippefd903612019-11-07 11:29:06 +000094def rollup_path():
95 return path.join(
96 node_modules_path(),
97 'rollup',
98 'dist',
99 'bin',
100 'rollup',
101 )
102
103
Paul Lewis66e12062019-12-02 12:04:54 +0000104def package_lock_json_path():
105 return path.join(devtools_root_path(), 'package-lock.json')
106
107
Yang Guod8176982019-10-04 20:30:35 +0000108def package_json_path():
Yang Guo75beda92019-10-28 08:29:25 +0100109 return path.join(devtools_root_path(), 'package.json')
Andrey Kosyakovfff69a72019-11-27 01:31:57 +0000110
Paul Lewis66e12062019-12-02 12:04:54 +0000111
Andrey Kosyakovfff69a72019-11-27 01:31:57 +0000112def browser_protocol_path():
113 return path.join(third_party_path(), 'blink', 'public', 'devtools_protocol', 'browser_protocol.pdl')