Skip to content

Commit 31a59c9

Browse files
committed
Allow targets to be reloaded using set_targets_json_location()
1 parent a7a9325 commit 31a59c9

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

tools/targets.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,22 @@ class Target:
6464
# List of targets that were added dynamically using "add_py_targets" (see below)
6565
__py_targets = set()
6666

67-
# Location of the 'targets.json' file
68-
__targets_json_location = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'hal', 'targets.json')
67+
# Default location of the 'targets.json' file
68+
__targets_json_location_default = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'hal', 'targets.json')
69+
70+
# Current/new location of the 'targets.json' file
71+
__targets_json_location = None
6972

7073
# Load the description of JSON target data
7174
@staticmethod
7275
@cached
7376
def get_json_target_data():
74-
return json_file_to_dict(Target.__targets_json_location)
77+
return json_file_to_dict(Target.__targets_json_location or Target.__targets_json_location_default)
7578

7679
# Set the location of the targets.json file
7780
@staticmethod
78-
def set_targets_json_location(location):
79-
Target.__targets_json_location = location
81+
def set_targets_json_location(location=None):
82+
Target.__targets_json_location = location or Target.__targets_json_location_default
8083
# Invalidate caches, since the location of the JSON file changed
8184
caches.clear()
8285

@@ -410,7 +413,7 @@ def get_target_detect_codes():
410413
return result
411414

412415
# Sets the location of the JSON file that contains the targets
413-
def set_targets_json_location(location):
416+
def set_targets_json_location(location=None):
414417
# First instruct Target about the new location
415418
Target.set_targets_json_location(location)
416419
# Then re-initialize TARGETS, TARGET_MAP and TARGET_NAMES

0 commit comments

Comments
 (0)