Skip to content

Commit 99a276f

Browse files
upsuperGabrielMajeri
authored andcommitted
Use cargo metadata for target dir
1 parent 18d6a53 commit 99a276f

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

uefi-test-runner/build.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,23 @@
3333
'ovmf_dir': WORKSPACE_DIR / 'uefi-test-runner',
3434
}
3535

36+
# Path to target directory. If None, it will be initialized with information
37+
# from cargo metadata at the first time target_dir function is invoked.
38+
TARGET_DIR = None
39+
40+
def target_dir():
41+
'Returns the target directory'
42+
global TARGET_DIR
43+
if TARGET_DIR is None:
44+
cmd = ['cargo', 'metadata', '--format-version=1']
45+
result = sp.run(cmd, stdout=sp.PIPE)
46+
result.check_returncode()
47+
TARGET_DIR = Path(json.loads(result.stdout)['target_directory'])
48+
return TARGET_DIR
49+
3650
def build_dir():
3751
'Returns the directory where Cargo places the build artifacts'
38-
return WORKSPACE_DIR / 'target' / SETTINGS['target'] / SETTINGS['config']
52+
return target_dir() / SETTINGS['target'] / SETTINGS['config']
3953

4054
def esp_dir():
4155
'Returns the directory where we will build the emulated UEFI system partition'

0 commit comments

Comments
 (0)