xref: /aosp_15_r20/external/toolchain-utils/crosperf/translate_xbuddy.py (revision 760c253c1ed00ce9abd48f8546f08516e57485fe)
1*760c253cSXin Li#!/usr/bin/env python3
2*760c253cSXin Li# -*- coding: utf-8 -*-
3*760c253cSXin Li# Copyright 2020 The ChromiumOS Authors
4*760c253cSXin Li# Use of this source code is governed by a BSD-style license that can be
5*760c253cSXin Li# found in the LICENSE file.
6*760c253cSXin Li
7*760c253cSXin Li"""Module to translate the xbuddy config."""
8*760c253cSXin Li
9*760c253cSXin Li
10*760c253cSXin Liimport os
11*760c253cSXin Liimport sys
12*760c253cSXin Li
13*760c253cSXin Li
14*760c253cSXin Liif "/mnt/host/source/src/third_party/toolchain-utils/crosperf" in sys.path:
15*760c253cSXin Li    dev_path = os.path.expanduser("~/trunk/chromite/lib/xbuddy")
16*760c253cSXin Li    sys.path.append(dev_path)
17*760c253cSXin Lielse:
18*760c253cSXin Li    print(
19*760c253cSXin Li        "This script can only be run from inside a ChromeOS chroot.  Please "
20*760c253cSXin Li        "enter your chroot, go to ~/src/third_party/toolchain-utils/crosperf"
21*760c253cSXin Li        " and try again."
22*760c253cSXin Li    )
23*760c253cSXin Li    sys.exit(0)
24*760c253cSXin Li
25*760c253cSXin Li# pylint: disable=import-error,wrong-import-position
26*760c253cSXin Liimport xbuddy
27*760c253cSXin Li
28*760c253cSXin Li
29*760c253cSXin Lidef Main(xbuddy_string):
30*760c253cSXin Li    if not os.path.exists("./xbuddy_config.ini"):
31*760c253cSXin Li        config_path = os.path.expanduser(
32*760c253cSXin Li            "~/trunk/chromite/lib/xbuddy/xbuddy_config.ini"
33*760c253cSXin Li        )
34*760c253cSXin Li        os.symlink(config_path, "./xbuddy_config.ini")
35*760c253cSXin Li    x = xbuddy.XBuddy(manage_builds=False, static_dir="/tmp/devserver/static")
36*760c253cSXin Li    build_id = x.Translate(os.path.split(xbuddy_string))
37*760c253cSXin Li    return build_id
38*760c253cSXin Li
39*760c253cSXin Li
40*760c253cSXin Liif __name__ == "__main__":
41*760c253cSXin Li    print(Main(sys.argv[1]))
42*760c253cSXin Li    sys.exit(0)
43