@@ -38,35 +38,30 @@ def parse_args():
3838
3939# Function to parse all rules from 'make -pq' output
4040def _parse_makefile ():
41- try :
42- # Run 'make -pq' and capture its output
43- result = subprocess .run (
44- ['make' , '-pq' ],
45- capture_output = True ,
46- text = True )
41+ # Run 'make -pq' and capture its output
42+ result = subprocess .run (
43+ ['make' , '-pq' ],
44+ capture_output = True ,
45+ text = True )
4746
48- # Initialize an empty dictionary to store the targets and their prerequisites
49- targets = {}
47+ # Initialize an empty dictionary to store the targets and their prerequisites
48+ targets = {}
5049
51- # Split the output by lines
52- make_output = result .stdout .splitlines ()
50+ # Split the output by lines
51+ make_output = result .stdout .splitlines ()
5352
54- # Regex to capture target and its prerequisites
55- target_pattern = re .compile (r'^([^\s]+)\s*:\s*([^\|]*)' )
53+ # Regex to capture target and its prerequisites
54+ target_pattern = re .compile (r'^([^\s]+)\s*:\s*([^\|]*)' )
5655
57- # Parse the make output
58- for line in make_output :
59- match = target_pattern .match (line )
60- if match :
61- target = match .group (1 )
62- prerequisites = match .group (2 ).split ()
63- targets [target ] = prerequisites
56+ # Parse the make output
57+ for line in make_output :
58+ match = target_pattern .match (line )
59+ if match :
60+ target = match .group (1 )
61+ prerequisites = match .group (2 ).split ()
62+ targets [target ] = prerequisites
6463
65- return targets
66-
67- except Exception as e :
68- print (f"An error occurred: { e } " )
69- sys .exit (1 )
64+ return targets
7065
7166
7267# Internal function used for recursion. Takes additional arguments to keep track of state.
@@ -130,8 +125,7 @@ def list_prerequisites(target, recursive=False, debug=False):
130125 return leaf_prerequisites
131126
132127 else :
133- print (f"Target '{ args .target } ' not found in the Makefile." )
134- sys .exit (1 )
128+ raise Exception (f"Target '{ args .target } ' not found in the Makefile." )
135129
136130
137131def hash_files (file_list ):
0 commit comments