3 # Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
31 The list where `one-XXXX` finds its backends
32 - `bin` folder where `one-XXXX` exists
35 NOTE If there are backends of the same name in different places,
36 the closer to the top in the list, the higher the priority.
40 def get_list(cmdname):
41 dir_path = os.path.dirname(os.path.realpath(__file__))
45 files = [f for f in glob.glob(dir_path + '/../*-' + cmdname)]
49 for f in glob.glob(dir_path + '/../../backends/**/*-' + cmdname, recursive=True)
51 # TODO find backends in `$PATH`
55 base = ntpath.basename(cand)
56 if (not base in backend_set) and os.path.isfile(cand) and os.access(
59 backends_list.append(cand)
64 def search_driver(driver):
65 dir_path = os.path.dirname(os.path.realpath(__file__))
67 # CASE 1: one/bin/{driver} is found
68 driver_path = dir_path + '/../' + driver
69 if os.path.isfile(driver_path) and os.access(driver_path, os.X_OK):
72 # CASE 2: one/backends/**/bin/{driver} is found
73 for driver_path in glob.glob(
74 dir_path + '/../../backends/**/bin/' + driver, recursive=True):
75 if os.path.isfile(driver_path) and os.access(driver_path, os.X_OK):
78 # CASE 3: {driver} is found in nowhere