Skip to content

Commit f384b67

Browse files
committed
makefile: move code out of make into bash
A step in the right direction to getting rid of makefile dependency Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
1 parent ea570f4 commit f384b67

File tree

11 files changed

+231
-156
lines changed

11 files changed

+231
-156
lines changed

flow/Makefile

Lines changed: 44 additions & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,24 @@ DESIGN_CONFIG ?= ./designs/nangate45/gcd/config.mk
8989
# in this file. This allows the DESIGN_CONFIG to set different defaults than
9090
# this file.
9191
include $(DESIGN_CONFIG)
92+
export DESIGN_NICKNAME?=$(DESIGN_NAME)
93+
export FLOW_VARIANT?=base
94+
ifneq ($(BLOCKS),)
95+
# Normally this comes from variables.yaml, but we need it here to set up these variables
96+
# which are part of the DESIGN_CONFIG. BLOCKS is a Makefile specific concept.
97+
$(foreach block,$(BLOCKS),$(eval BLOCK_LEFS += ./results/$(PLATFORM)/$(DESIGN_NICKNAME)_$(block)/$(FLOW_VARIANT)/${block}.lef))
98+
$(foreach block,$(BLOCKS),$(eval BLOCK_LIBS += ./results/$(PLATFORM)/$(DESIGN_NICKNAME)_$(block)/$(FLOW_VARIANT)/${block}.lib))
99+
$(foreach block,$(BLOCKS),$(eval BLOCK_GDS += ./results/$(PLATFORM)/$(DESIGN_NICKNAME)_$(block)/$(FLOW_VARIANT)/6_final.gds))
100+
$(foreach block,$(BLOCKS),$(eval BLOCK_CDL += ./results/$(PLATFORM)/$(DESIGN_NICKNAME)_$(block)/$(FLOW_VARIANT)/6_final.cdl))
101+
$(foreach block,$(BLOCKS),$(eval BLOCK_LOG_FOLDERS += ./logs/$(PLATFORM)/$(DESIGN_NICKNAME)_$(block)/$(FLOW_VARIANT)/))
102+
export ADDITIONAL_LEFS += $(BLOCK_LEFS)
103+
export ADDITIONAL_LIBS += $(BLOCK_LIBS)
104+
export ADDITIONAL_GDS += $(BLOCK_GDS)
105+
export GDS_FILES += $(BLOCK_GDS)
106+
ifneq ($(CDL_FILES),)
107+
export CDL_FILES += $(BLOCK_CDL)
108+
endif
109+
endif
92110

93111
# If we are running headless use offscreen rendering for save_image
94112
ifeq ($(DISPLAY),)
@@ -117,151 +135,40 @@ MAKEFLAGS += --no-builtin-rules
117135
SHELL := /usr/bin/env bash
118136
.SHELLFLAGS := -o pipefail -c
119137

120-
#-------------------------------------------------------------------------------
121-
# Setup variables to point to root / head of the OpenROAD directory
122-
# - the following settings allowed user to point OpenROAD binaries to different
123-
# location
124-
# - default is current install / clone directory
125138
ifeq ($(origin FLOW_HOME), undefined)
126139
FLOW_HOME := $(abspath $(dir $(firstword $(MAKEFILE_LIST))))
127140
endif
128141
export FLOW_HOME
129142

130-
#-------------------------------------------------------------------------------
131-
# Setup variables to point to other location for the following sub directory
132-
# - designs - default is under current directory
133-
# - platforms - default is under current directory
134-
# - work home - default is current directory
135-
# - utils, scripts, test - default is under current directory
136-
export DESIGN_HOME ?= $(FLOW_HOME)/designs
137-
export PLATFORM_HOME ?= $(FLOW_HOME)/platforms
138-
export WORK_HOME ?= .
139-
140-
export UTILS_DIR ?= $(FLOW_HOME)/util
141-
export SCRIPTS_DIR ?= $(FLOW_HOME)/scripts
142-
export TEST_DIR ?= $(FLOW_HOME)/test
143-
144-
PUBLIC=nangate45 sky130hd sky130hs asap7 ihp-sg13g2 gf180
145-
146-
ifneq ($(wildcard $(PLATFORM_HOME)/$(PLATFORM)),)
147-
export PLATFORM_DIR = $(PLATFORM_HOME)/$(PLATFORM)
148-
else ifneq ($(findstring $(PLATFORM),$(PUBLIC)),)
149-
export PLATFORM_DIR = ./platforms/$(PLATFORM)
150-
else ifneq ($(wildcard ../../$(PLATFORM)),)
151-
export PLATFORM_DIR = ../../$(PLATFORM)
152-
else
153-
$(error [ERROR][FLOW] Platform '$(PLATFORM)' not found.)
154-
endif
155-
156-
include $(PLATFORM_DIR)/config.mk
157-
143+
# The plan is to migrate all variables to .sh so that
144+
# ORFS is no longer dependent on make.
145+
#
146+
# Explicitly enumerate the environment variables we need $SCRIPTS/config.sh
147+
# to see since make doesn't pass its environment to subshells.
148+
#
158149
# __SPACE__ is a workaround for whitespace hell in "foreach"; there
159150
# is no way to escape space in defaults.py and get "foreach" to work.
160-
$(foreach line,$(shell $(SCRIPTS_DIR)/defaults.py),$(eval export $(subst __SPACE__, ,$(line))))
161-
162-
# Not normally adjusted by user
163-
export SYNTH_OPERATIONS_ARGS ?= -extra-map $(FLOW_HOME)/platforms/common/lcu_kogge_stone.v
164-
export SYNTH_FULL_ARGS ?= $(SYNTH_ARGS) $(SYNTH_OPERATIONS_ARGS)
165-
166-
# Setup working directories
167-
export DESIGN_NICKNAME ?= $(DESIGN_NAME)
168-
169-
export DESIGN_CONFIG
170-
export DESIGN_DIR = $(dir $(DESIGN_CONFIG))
171-
export LOG_DIR = $(WORK_HOME)/logs/$(PLATFORM)/$(DESIGN_NICKNAME)/$(FLOW_VARIANT)
172-
export OBJECTS_DIR = $(WORK_HOME)/objects/$(PLATFORM)/$(DESIGN_NICKNAME)/$(FLOW_VARIANT)
173-
export REPORTS_DIR = $(WORK_HOME)/reports/$(PLATFORM)/$(DESIGN_NICKNAME)/$(FLOW_VARIANT)
174-
export RESULTS_DIR = $(WORK_HOME)/results/$(PLATFORM)/$(DESIGN_NICKNAME)/$(FLOW_VARIANT)
175-
176-
ifneq ($(BLOCKS),)
177-
$(foreach block,$(BLOCKS),$(eval BLOCK_LEFS += ./results/$(PLATFORM)/$(DESIGN_NICKNAME)_$(block)/$(FLOW_VARIANT)/${block}.lef))
178-
$(foreach block,$(BLOCKS),$(eval BLOCK_LIBS += ./results/$(PLATFORM)/$(DESIGN_NICKNAME)_$(block)/$(FLOW_VARIANT)/${block}.lib))
179-
$(foreach block,$(BLOCKS),$(eval BLOCK_GDS += ./results/$(PLATFORM)/$(DESIGN_NICKNAME)_$(block)/$(FLOW_VARIANT)/6_final.gds))
180-
$(foreach block,$(BLOCKS),$(eval BLOCK_CDL += ./results/$(PLATFORM)/$(DESIGN_NICKNAME)_$(block)/$(FLOW_VARIANT)/6_final.cdl))
181-
$(foreach block,$(BLOCKS),$(eval BLOCK_LOG_FOLDERS += ./logs/$(PLATFORM)/$(DESIGN_NICKNAME)_$(block)/$(FLOW_VARIANT)/))
182-
export ADDITIONAL_LEFS += $(BLOCK_LEFS)
183-
export ADDITIONAL_LIBS += $(BLOCK_LIBS)
184-
export ADDITIONAL_GDS += $(BLOCK_GDS)
185-
export GDS_FILES += $(BLOCK_GDS)
186-
ifneq ($(CDL_FILES),)
187-
export CDL_FILES += $(BLOCK_CDL)
188-
endif
189-
endif
190-
191-
#-------------------------------------------------------------------------------
192-
ifeq (,$(strip $(NUM_CORES)))
193-
# Linux (utility program)
194-
NUM_CORES := $(shell nproc 2>/dev/null)
195-
196-
ifeq (,$(strip $(NUM_CORES)))
197-
# Linux (generic)
198-
NUM_CORES := $(shell grep -c ^processor /proc/cpuinfo 2>/dev/null)
199-
endif
200-
ifeq (,$(strip $(NUM_CORES)))
201-
# BSD (at least FreeBSD and Mac OSX)
202-
NUM_CORES := $(shell sysctl -n hw.ncpu 2>/dev/null)
203-
endif
204-
ifeq (,$(strip $(NUM_CORES)))
205-
# Fallback
206-
NUM_CORES := 1
207-
endif
208-
endif
209-
export NUM_CORES
210-
211-
YOSYS_FLAGS += -v 3
212-
213-
#-------------------------------------------------------------------------------
214-
# setup all commands used within this flow
215-
export TIME_BIN ?= env time
216-
TIME_CMD = $(TIME_BIN) -f 'Elapsed time: %E[h:]min:sec. CPU time: user %U sys %S (%P). Peak memory: %MKB.'
217-
TIME_TEST = $(shell $(TIME_CMD) echo foo 2>/dev/null)
218-
ifeq (,$(strip $(TIME_TEST)))
219-
TIME_CMD = $(TIME_BIN)
220-
endif
221-
222-
# The following determine the executable location for each tool used by this flow.
223-
# Priority is given to
224-
# 1 user explicit set with variable in Makefile or command line, for instance setting OPENROAD_EXE
225-
# 2 ORFS compiled tools: openroad, yosys
226-
ifneq (${IN_NIX_SHELL},)
227-
export OPENROAD_EXE := $(shell command -v openroad)
228-
else
229-
export OPENROAD_EXE ?= $(abspath $(FLOW_HOME)/../tools/install/OpenROAD/bin/openroad)
151+
$(foreach line,$(shell \
152+
DESIGN_NAME=$(DESIGN_NAME) \
153+
FLOW_HOME=$(FLOW_HOME) \
154+
DESIGN_CONFIG=$(DESIGN_CONFIG) \
155+
PLATFORM=$(PLATFORM) \
156+
FLOW_VARIANT=$(FLOW_VARIANT) \
157+
DESIGN_NICKNAME=$(DESIGN_NICKNAME) \
158+
$(FLOW_HOME)/scripts/env.sh $(FLOW_HOME)/scripts/config.sh),$(eval $(subst __SPACE__, ,$(line))))
159+
160+
# check some critical variables in a loop
161+
$(foreach var,DESIGN_NAME DESIGN_NICKNAME PLATFORM,\
162+
$(if $(strip $($(var))),,$(error $(var) is not set)))
163+
164+
# The plan is to move all config.mk variables into $(PLATFORM_DIR)/config.sh and
165+
# delete this include below
166+
ifneq ($(wildcard $(PLATFORM_DIR)/config.mk),)
167+
include $(PLATFORM_DIR)/config.mk
230168
endif
231-
ifneq (${IN_NIX_SHELL},)
232-
export OPENSTA_EXE := $(shell command -v sta)
233-
else
234-
export OPENSTA_EXE ?= $(abspath $(FLOW_HOME)/../tools/install/OpenROAD/bin/sta)
235-
endif
236-
237-
OPENROAD_ARGS = -no_init -threads $(NUM_CORES) $(OR_ARGS)
238-
OPENROAD_CMD = $(OPENROAD_EXE) -exit $(OPENROAD_ARGS)
239-
OPENROAD_NO_EXIT_CMD = $(OPENROAD_EXE) $(OPENROAD_ARGS)
240-
OPENROAD_GUI_CMD = $(OPENROAD_EXE) -gui $(OR_ARGS)
241-
242-
ifneq (${IN_NIX_SHELL},)
243-
YOSYS_EXE := $(shell command -v yosys)
244-
else
245-
YOSYS_EXE ?= $(abspath $(FLOW_HOME)/../tools/install/yosys/bin/yosys)
246-
endif
247-
248-
# Use locally installed and built klayout if it exists, otherwise use klayout in path
249-
KLAYOUT_DIR = $(abspath $(FLOW_HOME)/../tools/install/klayout/)
250-
KLAYOUT_BIN_FROM_DIR = $(KLAYOUT_DIR)/klayout
251169

252-
ifeq ($(wildcard $(KLAYOUT_BIN_FROM_DIR)), $(KLAYOUT_BIN_FROM_DIR))
253-
KLAYOUT_CMD ?= sh -c 'LD_LIBRARY_PATH=$(dir $(KLAYOUT_BIN_FROM_DIR)) $$0 "$$@"' $(KLAYOUT_BIN_FROM_DIR)
254-
else
255-
ifeq ($(KLAYOUT_CMD),)
256-
KLAYOUT_CMD := $(shell command -v klayout)
257-
endif
258-
endif
259170
KLAYOUT_FOUND = $(if $(KLAYOUT_CMD),,$(error KLayout not found in PATH))
260171

261-
ifneq ($(shell command -v stdbuf),)
262-
STDBUF_CMD ?= stdbuf -o L
263-
endif
264-
265172
#-------------------------------------------------------------------------------
266173
WRAPPED_LEFS = $(foreach lef,$(notdir $(WRAP_LEFS)),$(OBJECTS_DIR)/lef/$(lef:.lef=_mod.lef))
267174
WRAPPED_LIBS = $(foreach lib,$(notdir $(WRAP_LIBS)),$(OBJECTS_DIR)/$(lib:.lib=_mod.lib))
@@ -432,10 +339,6 @@ memory:
432339

433340
# Run Synthesis using yosys
434341
#-------------------------------------------------------------------------------
435-
436-
export SYNTH_SCRIPT ?= $(SCRIPTS_DIR)/synth.tcl
437-
export SDC_FILE_CLOCK_PERIOD = $(RESULTS_DIR)/clock_period.txt
438-
439342
$(SDC_FILE_CLOCK_PERIOD): $(SDC_FILE)
440343
mkdir -p $(dir $@)
441344
echo $(ABC_CLOCK_PERIOD_IN_PS) > $@
@@ -447,13 +350,11 @@ yosys-dependencies: $(YOSYS_DEPENDENCIES)
447350

448351
.PHONY: do-yosys
449352
do-yosys: $(DONT_USE_SC_LIB)
450-
mkdir -p $(RESULTS_DIR) $(LOG_DIR) $(REPORTS_DIR) $(OBJECTS_DIR)
451-
($(TIME_CMD) $(YOSYS_EXE) $(YOSYS_FLAGS) -c $(SYNTH_SCRIPT)) 2>&1 | tee $(abspath $(LOG_DIR)/1_1_yosys.log)
353+
$(SCRIPTS_DIR)/synth.sh $(SYNTH_SCRIPT) $(LOG_DIR)/1_1_yosys.log
452354

453355
.PHONY: do-yosys-canonicalize
454356
do-yosys-canonicalize: yosys-dependencies $(DONT_USE_SC_LIB)
455-
mkdir -p $(RESULTS_DIR) $(LOG_DIR) $(REPORTS_DIR) $(OBJECTS_DIR)
456-
($(TIME_CMD) $(YOSYS_EXE) $(YOSYS_FLAGS) -c $(SCRIPTS_DIR)/synth_canonicalize.tcl) 2>&1 | tee $(abspath $(LOG_DIR)/1_1_yosys_canonicalize.log)
357+
$(SCRIPTS_DIR)/synth.sh $(SCRIPTS_DIR)/synth_canonicalize.tcl $(LOG_DIR)/1_1_yosys_canonicalize.log
457358

458359
$(RESULTS_DIR)/1_synth.rtlil: $(YOSYS_DEPENDENCIES)
459360
$(UNSET_AND_MAKE) do-yosys-canonicalize
@@ -560,13 +461,7 @@ endif
560461

561462
.PHONY: do-$(1)
562463
do-$(1): $(OBJECTS_DIR)/copyright.txt
563-
@mkdir -p $(RESULTS_DIR) $(LOG_DIR) $(REPORTS_DIR) $(OBJECTS_DIR)
564-
@echo Running $(3).tcl, stage $(1)
565-
@(set -eo pipefail; \
566-
trap 'mv $(LOG_DIR)/$(1).tmp.log $(LOG_DIR)/$(1).log' EXIT; \
567-
$(OPENROAD_EXE) $(OPENROAD_ARGS) -exit $(SCRIPTS_DIR)/noop.tcl 2>&1 >$(LOG_DIR)/$(1).tmp.log; \
568-
$(TIME_CMD) $(OPENROAD_CMD) -no_splash $(SCRIPTS_DIR)/$(3).tcl -metrics $(LOG_DIR)/$(1).json 2>&1 | \
569-
tee -a $(abspath $(LOG_DIR)/$(1).tmp.log))
464+
$(SCRIPTS_DIR)/flow.sh $(1) $(3)
570465
endef
571466

572467
# generate make rules to copy a file, if a dependency change and

flow/platforms/asap7/config.mk

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
export PLATFORM = asap7
2-
export PROCESS = 7
3-
41
ifeq ($(LIB_MODEL),)
52
export LIB_MODEL = NLDM
63
endif

flow/platforms/asap7/config.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export PROCESS=7

flow/platforms/nangate45/config.mk

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# Process node
2-
export PROCESS = 45
3-
41
#-----------------------------------------------------
52
# Tech/Libs
63
# ----------------------------------------------------

flow/platforms/nangate45/config.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Process node
2+
export PROCESS=45

flow/scripts/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
Various scripts to support flow as well as utilities.
44

5+
## flow.sh/synth.sh - WORK IN PROGRESS
6+
7+
This script is a low level script used to invoke a flow step. ORFS make or bazel-orfs will set up all the project specific variables before invoking this script where the rest of the variables are set up before invoking OpenROAD.
8+
9+
scripts/flow.sh 2_1_floorplan floorplan
10+
11+
scripts/synth.sh $SYNTH_SCRIPT $LOG_DIR/1_1_yosys.log
12+
513
## make run-yosys
614

715
Sets up all the ORFS environment variables and launches Yosys.

flow/scripts/config.sh

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
#!/bin/bash
2+
set -u
3+
4+
# Set default paths
5+
export PLATFORM_HOME="${PLATFORM_HOME:-${FLOW_HOME}/platforms}"
6+
export WORK_HOME="${WORK_HOME:-.}"
7+
export SCRIPTS_DIR="${SCRIPTS_DIR:-${FLOW_HOME}/scripts}"
8+
9+
# Define public platforms
10+
PUBLIC="nangate45 sky130hd sky130hs asap7 ihp-sg13g2 gf180"
11+
12+
# Determine PLATFORM_DIR based on PLATFORM
13+
if [[ -d "${PLATFORM_HOME}/${PLATFORM}" ]]; then
14+
export PLATFORM_DIR="${PLATFORM_HOME}/${PLATFORM}"
15+
elif [[ " ${PUBLIC} " == *" ${PLATFORM} "* ]]; then
16+
export PLATFORM_DIR="./platforms/${PLATFORM}"
17+
elif [[ -d "../../${PLATFORM}" ]]; then
18+
export PLATFORM_DIR="../../${PLATFORM}"
19+
fi
20+
21+
export DESIGN_HOME="${DESIGN_HOME:-${FLOW_HOME}/designs}"
22+
export UTILS_DIR="${UTILS_DIR:-${FLOW_HOME}/util}"
23+
export SCRIPTS_DIR="${SCRIPTS_DIR:-${FLOW_HOME}/scripts}"
24+
export TEST_DIR="${TEST_DIR:-${FLOW_HOME}/test}"
25+
26+
# if $PLATFORM_DIR/config.sh exists, source it
27+
if [ -f "${PLATFORM_DIR}/config.sh" ]; then
28+
source "${PLATFORM_DIR}/config.sh"
29+
fi
30+
31+
export TIME_BIN="${TIME_BIN:-env time}"
32+
TIME_CMD="$TIME_BIN -f 'Elapsed time: %E[h:]min:sec. CPU time: user %U sys %S (%P). Peak memory: %MKB.'"
33+
if ! TIME_TEST=$(eval "$TIME_CMD echo foo" 2>/dev/null); then
34+
TIME_CMD="$TIME_BIN"
35+
fi
36+
export TIME_CMD
37+
38+
# Setup working directories
39+
export DESIGN_NICKNAME="${DESIGN_NICKNAME:=${DESIGN_NAME}}"
40+
41+
export DESIGN_DIR="$(dirname "${DESIGN_CONFIG}")"
42+
export LOG_DIR="${WORK_HOME}/logs/${PLATFORM}/${DESIGN_NICKNAME}/${FLOW_VARIANT}"
43+
export OBJECTS_DIR="${WORK_HOME}/objects/${PLATFORM}/${DESIGN_NICKNAME}/${FLOW_VARIANT}"
44+
export REPORTS_DIR="${WORK_HOME}/reports/${PLATFORM}/${DESIGN_NICKNAME}/${FLOW_VARIANT}"
45+
export RESULTS_DIR="${WORK_HOME}/results/${PLATFORM}/${DESIGN_NICKNAME}/${FLOW_VARIANT}"
46+
47+
# Run the defaults.py script and process its output
48+
while IFS= read -r line; do
49+
# Replace "__SPACE__" with an actual space in the line
50+
eval "${line//__SPACE__/ }"
51+
done < <("${FLOW_HOME}/scripts/defaults.py")
52+
53+
54+
# Determine the number of cores (NUM_CORES)
55+
if [[ -z "${NUM_CORES:-}" ]]; then
56+
# Linux (utility program)
57+
NUM_CORES=$(nproc 2>/dev/null || true)
58+
59+
if [[ -z "$NUM_CORES" ]]; then
60+
# Linux (generic)
61+
NUM_CORES=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || true)
62+
fi
63+
64+
if [[ -z "$NUM_CORES" ]]; then
65+
# BSD (at least FreeBSD and macOS)
66+
NUM_CORES=$(sysctl -n hw.ncpu 2>/dev/null || true)
67+
fi
68+
69+
if [[ -z "$NUM_CORES" ]]; then
70+
# Fallback
71+
NUM_CORES=1
72+
fi
73+
fi
74+
export NUM_CORES
75+
76+
# Determine the executable location for each tool used by this flow.
77+
# Priority is given to:
78+
# 1. User explicitly setting the variable in the environment or command line (e.g., OPENROAD_EXE).
79+
# 2. Default ORFS compiled tools: openroad, yosys.
80+
81+
# Set default paths for executables if not already set
82+
if [[ -n "${IN_NIX_SHELL:-}" ]]; then
83+
export OPENROAD_EXE=$(command -v openroad)
84+
fi
85+
export OPENROAD_EXE="${OPENROAD_EXE:-$(realpath "${FLOW_HOME}/../tools/install/OpenROAD/bin/openroad")}"
86+
export OPENSTA_EXE="${OPENSTA_EXE:-$(realpath "${FLOW_HOME}/../tools/install/OpenROAD/bin/sta")}"
87+
if [[ -n "${IN_NIX_SHELL:-}" ]]; then
88+
export YOSYS_EXE=$(command -v yosys)
89+
fi
90+
export YOSYS_EXE="${YOSYS_EXE:-$(realpath "${FLOW_HOME}/../tools/install/yosys/bin/yosys")}"
91+
92+
# Define OpenROAD command-line arguments
93+
export OPENROAD_ARGS="-no_init -threads ${NUM_CORES} ${OR_ARGS:-}"
94+
95+
# Define OpenROAD commands
96+
export OPENROAD_CMD="${OPENROAD_EXE} -exit ${OPENROAD_ARGS}"
97+
export OPENROAD_NO_EXIT_CMD="${OPENROAD_EXE} ${OPENROAD_ARGS}"
98+
export OPENROAD_GUI_CMD="${OPENROAD_EXE} -gui ${OR_ARGS:-}"
99+
100+
# Use locally installed and built klayout if it exists, otherwise use klayout in path
101+
KLAYOUT_DIR="$(realpath "${FLOW_HOME}/../tools/install/klayout/")"
102+
KLAYOUT_BIN_FROM_DIR="${KLAYOUT_DIR}/klayout"
103+
104+
if [[ -x "${KLAYOUT_BIN_FROM_DIR}" ]]; then
105+
export KLAYOUT_CMD="sh -c 'LD_LIBRARY_PATH=$(dirname "${KLAYOUT_BIN_FROM_DIR}") \$0 \"\$@\"' ${KLAYOUT_BIN_FROM_DIR}"
106+
else
107+
if [[ -z "${KLAYOUT_CMD:-}" ]]; then
108+
KLAYOUT_CMD="$(command -v klayout || true)"
109+
fi
110+
fi
111+
export KLAYOUT_CMD
112+
113+
# Check if `stdbuf` is available and set STDBUF_CMD
114+
if command -v stdbuf &>/dev/null; then
115+
export STDBUF_CMD="stdbuf -o L"
116+
fi
117+
118+
export SYNTH_SCRIPT="${SYNTH_SCRIPT:-${SCRIPTS_DIR}/synth.tcl}"
119+
export SDC_FILE_CLOCK_PERIOD="${SDC_FILE_CLOCK_PERIOD:-${RESULTS_DIR}/clock_period.txt}"

0 commit comments

Comments
 (0)