Skip to content

Commit

Permalink
different exit codes depending on captured error
Browse files Browse the repository at this point in the history
  • Loading branch information
kareefardi committed Oct 18, 2023
1 parent 3f9a6e6 commit 58891ae
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
20 changes: 10 additions & 10 deletions openlane/scripts/odbpy/defutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

from reader import OdbReader, click_odb, click
from typing import Tuple, List
from exception_codes import METAL_LAYER_ERROR, FORMAT_ERROR


@click.group()
Expand Down Expand Up @@ -429,22 +430,21 @@ def parse_obstructions(obstructions):
+ RE_NUMBER
+ r"\s+"
+ RE_NUMBER
+ r")"
+ r") *$"
)

obses = obstructions.split(",")
obs_list = []
for obs in obses:
obs = obs.strip()
m = re.match(RE_OBS, obs)
assert (
m
), "Incorrectly formatted input (%s).\n Format: layer llx lly urx ury, ..." % (
obs
)
layer = m.group("layer")
bbox = [float(x) for x in m.group("bbox").split()]
obs_list.append((layer, bbox))
if m is None:
print("Incorrectly formatted input (%s).\n Format: layer llx lly urx ury, ..." % obs)
sys.exit(FORMAT_ERROR)
else:
layer = m.group("layer")
bbox = [float(x) for x in m.group("bbox").split()]
obs_list.append((layer, bbox))

return obs_list

Expand All @@ -464,7 +464,7 @@ def add_obstructions(reader, input_lefs, obstructions):
odb_layer = reader.tech.findLayer(layer)
if odb_layer is None:
print(f"[ERROR] layer {layer} doesn't exist.", file=sys.stderr)
sys.exit(1)
sys.exit(METAL_LAYER_ERROR)
bbox = obs[1]
dbu = reader.tech.getDbUnitsPerMicron()
bbox = [int(x * dbu) for x in bbox]
Expand Down
16 changes: 16 additions & 0 deletions openlane/scripts/odbpy/exception_codes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2023 Efabless Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

METAL_LAYER_ERROR = 10
FORMAT_ERROR = 11
2 changes: 1 addition & 1 deletion openlane/steps/step.py
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ def start(
f"{self.name}: Interrupted ({Signals(-e.returncode).name})"
)
else:
raise StepError(f"{self.name}: subprocess {e.args} failed")
raise StepError(e.returncode, f"{self.name}: subprocess {e.args} failed")

metrics = GenericImmutableDict(
state_in_result.metrics, overrides=metrics_updates
Expand Down

0 comments on commit 58891ae

Please sign in to comment.