Skip to content

Commit dbd35f2

Browse files
committed
misc/openlane: patch sed to be cross-platform
sed on BSD and GNU have different behaviour when it comes to the -i flag. They behave the same when a backup file is specified, but differently when no backup is specified. Rework all invocations in order to get this working on osx. Signed-off-by: Sean Cross <[email protected]>
1 parent 2771625 commit dbd35f2

File tree

2 files changed

+185
-0
lines changed

2 files changed

+185
-0
lines changed

misc/openlane/meta.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@ source:
99
git_url: https://github.com/The-OpenROAD-Project/OpenLane
1010
git_rev: master
1111
patches:
12+
<<<<<<< Updated upstream
1213
- handle-unknown-terminal.patch # The-OpenROAD-Project/OpenLane#1662
1314
- disable-version-check.patch # conda versions differ from openlane metadata
15+
=======
16+
- sed-fixup.patch
17+
>>>>>>> Stashed changes
1418

1519
build:
1620
noarch: generic

misc/openlane/sed-fixup.patch

+181
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
diff --git a/Jenkinsfile b/Jenkinsfile
2+
index 712d98ec6..8a93a24d1 100644
3+
--- a/Jenkinsfile
4+
+++ b/Jenkinsfile
5+
@@ -80,7 +80,8 @@ pipeline {
6+
}
7+
stage("${DESIGN} - Update OpenROAD commit") {
8+
script { OLD_SHA = sh (returnStdout: true, script: "python3 dependencies/tool.py -f commit openroad_app").trim(); }
9+
- sh "sed -i s/${OLD_SHA}/${NEW_SHA}/ ./dependencies/tool_metadata.yml"
10+
+ sh "sed -i.bak s/${OLD_SHA}/${NEW_SHA}/ ./dependencies/tool_metadata.yml"
11+
+ sh "rm -f ./dependencies/tool_metadata.yml.bak"
12+
}
13+
stage("${DESIGN} - Run test") {
14+
sh "make OPENLANE_IMAGE_NAME=current:latest TEST_DESIGN=${DESIGN} test";
15+
diff --git a/docker/cvc_rv/Dockerfile b/docker/cvc_rv/Dockerfile
16+
index 108349fd9..f8efff5b4 100644
17+
--- a/docker/cvc_rv/Dockerfile
18+
+++ b/docker/cvc_rv/Dockerfile
19+
@@ -25,7 +25,8 @@ RUN curl -L ${CVC_RV_REPO}/tarball/${CVC_RV_COMMIT} | tar -xzC . --strip-compone
20+
autoreconf -i && \
21+
autoconf && \
22+
./configure --disable-nls --prefix=/build && \
23+
- sed -i 's/api.parser.class/parser_class_name/' src/cdlParser.yy && \
24+
+ sed -i.bak 's/api.parser.class/parser_class_name/' src/cdlParser.yy && \
25+
+ rm -f src/cdlParser.yy.bak && \
26+
make -j$(nproc) install
27+
28+
RUN mkdir -p /build/version/
29+
@@ -39,4 +40,3 @@ ENV PATH /build/bin:$PATH
30+
31+
COPY --from=builder /build /build
32+
COPY --from=builder /build.tar.gz /build.tar.gz
33+
-
34+
diff --git a/docker/klayout/build_klayout.sh b/docker/klayout/build_klayout.sh
35+
index 83ca2f934..45afde32f 100644
36+
--- a/docker/klayout/build_klayout.sh
37+
+++ b/docker/klayout/build_klayout.sh
38+
@@ -15,7 +15,8 @@ pylibdir="$distpackdir/klayout"
39+
# clean bin directory
40+
rm -rf $bininstdir
41+
42+
-sed -i 's/-O2 -g/-O2/' /usr/lib64/qt5/mkspecs/linux-g++/qmake.conf
43+
+sed -i.bak 's/-O2 -g/-O2/' /usr/lib64/qt5/mkspecs/linux-g++/qmake.conf
44+
+rm -f /usr/lib64/qt5/mkspecs/linux-g++/qmake.conf.bak
45+
46+
# do the actual build
47+
./build.sh\
48+
@@ -49,4 +50,4 @@ echo "Stripping..."
49+
strip ${bindir}/*
50+
strip ${pylibdir}/*.so
51+
strip ${libdir}/db_plugins/*.so*
52+
-strip ${libdir}/lay_plugins/*.so*
53+
\ No newline at end of file
54+
+strip ${libdir}/lay_plugins/*.so*
55+
diff --git a/docker/openroad_app/Dockerfile b/docker/openroad_app/Dockerfile
56+
index 340dd4e48..3b6b4b720 100644
57+
--- a/docker/openroad_app/Dockerfile
58+
+++ b/docker/openroad_app/Dockerfile
59+
@@ -75,8 +75,10 @@ COPY ./utils.py .
60+
RUN python3 ./utils.py fetch-submodules-from-tarballs ${OPENROAD_APP_REPO} ${OPENROAD_APP_COMMIT}
61+
62+
# Build OpenROAD
63+
-RUN sed -i "s/GITDIR-NOTFOUND/${OPENROAD_APP_COMMIT}/" cmake/GetGitRevisionDescription.cmake
64+
-RUN sed -i "s/static char Cases/static signed char Cases/" third-party/abc/src/misc/extra/extraUtilMisc.c
65+
+RUN sed -i.bak "s/GITDIR-NOTFOUND/${OPENROAD_APP_COMMIT}/" cmake/GetGitRevisionDescription.cmake
66+
+RUN rm -f cmake/GetGitRevisionDescription.cmake.bak
67+
+RUN sed -i.bak "s/static char Cases/static signed char Cases/" third-party/abc/src/misc/extra/extraUtilMisc.c
68+
+RUN rm -f third-party/abc/src/misc/extra/extraUtilMisc.c.bak
69+
RUN mkdir build && mkdir -p /build/version && mkdir install
70+
RUN cd build && cmake -DCMAKE_INSTALL_PREFIX=$(pwd)/install ..
71+
RUN cd build && make -j$(nproc)
72+
diff --git a/scripts/tcl_commands/all.tcl b/scripts/tcl_commands/all.tcl
73+
index 9e90500a2..91661b8ec 100755
74+
--- a/scripts/tcl_commands/all.tcl
75+
+++ b/scripts/tcl_commands/all.tcl
76+
@@ -46,7 +46,8 @@ proc set_netlist {args} {
77+
set ::env(CURRENT_NETLIST) $netlist
78+
79+
set replace [string map {/ \\/} $::env(CURRENT_NETLIST)]
80+
- try_catch sed -i -e "s/\\(set ::env(CURRENT_NETLIST)\\).*/\\1 $replace/" "$::env(GLB_CFG_FILE)"
81+
+ try_catch sed -i.bak -e "s/\\(set ::env(CURRENT_NETLIST)\\).*/\\1 $replace/" "$::env(GLB_CFG_FILE)"
82+
+ exec rm -f "$::env(GLB_CFG_FILE).bak"
83+
84+
if { [info exists flags_map(-lec)] && $::env(LEC_ENABLE) && [file exists $previous_netlist] } {
85+
logic_equiv_check -lhs $previous_netlist -rhs $netlist
86+
@@ -58,7 +59,8 @@ proc set_def {def} {
87+
puts_verbose "Changing layout to '$def_relative'..."
88+
set ::env(CURRENT_DEF) $def
89+
set replace [string map {/ \\/} $def]
90+
- exec sed -i -e "s/\\(set ::env(CURRENT_DEF)\\).*/\\1 $replace/" "$::env(GLB_CFG_FILE)"
91+
+ exec sed -i.bak -e "s/\\(set ::env(CURRENT_DEF)\\).*/\\1 $replace/" "$::env(GLB_CFG_FILE)"
92+
+ exec rm -f "$::env(GLB_CFG_FILE).bak"
93+
}
94+
95+
proc set_odb {odb} {
96+
@@ -66,7 +68,8 @@ proc set_odb {odb} {
97+
puts_verbose "Changing database to '$odb_relative'..."
98+
set ::env(CURRENT_ODB) $odb
99+
set replace [string map {/ \\/} $odb]
100+
- exec sed -i -e "s/\\(set ::env(CURRENT_ODB)\\).*/\\1 $replace/" "$::env(GLB_CFG_FILE)"
101+
+ exec sed -i.bak -e "s/\\(set ::env(CURRENT_ODB)\\).*/\\1 $replace/" "$::env(GLB_CFG_FILE)"
102+
+ exec rm -f "$::env(GLB_CFG_FILE).bak"
103+
}
104+
105+
proc set_sdc {sdc} {
106+
@@ -74,7 +77,8 @@ proc set_sdc {sdc} {
107+
puts_verbose "Changing timing constraints to '$sdc_relative'..."
108+
set ::env(CURRENT_SDC) $sdc
109+
set replace [string map {/ \\/} $sdc]
110+
- exec sed -i -e "s/\\(set ::env(CURRENT_SDC)\\).*/\\1 $replace/" "$::env(GLB_CFG_FILE)"
111+
+ exec sed -i.bak -e "s/\\(set ::env(CURRENT_SDC)\\).*/\\1 $replace/" "$::env(GLB_CFG_FILE)"
112+
+ exec rm -f "$::env(GLB_CFG_FILE).bak"
113+
}
114+
115+
proc set_guide {guide} {
116+
@@ -82,7 +86,8 @@ proc set_guide {guide} {
117+
puts_verbose "Changing guide to '$guide_relative'..."
118+
set ::env(CURRENT_GUIDE) $guide
119+
set replace [string map {/ \\/} $guide]
120+
- exec sed -i -e "s/\\(set ::env(CURRENT_GUIDE)\\).*/\\1 $replace/" "$::env(GLB_CFG_FILE)"
121+
+ exec sed -i.bak -e "s/\\(set ::env(CURRENT_GUIDE)\\).*/\\1 $replace/" "$::env(GLB_CFG_FILE)"
122+
+ exec rm -f "$::env(GLB_CFG_FILE).bak"
123+
}
124+
125+
proc prep_lefs {args} {
126+
diff --git a/scripts/tcl_commands/magic.tcl b/scripts/tcl_commands/magic.tcl
127+
index 330ba1a5a..70dd27b68 100755
128+
--- a/scripts/tcl_commands/magic.tcl
129+
+++ b/scripts/tcl_commands/magic.tcl
130+
@@ -51,7 +51,8 @@ proc run_magic {args} {
131+
-indexed_log $log
132+
133+
# Only keep the properties section in the file
134+
- try_catch sed -i -n "/^<< properties >>/,/^<< end >>/p" $::env(signoff_tmpfiles)/gds_ptrs.mag
135+
+ try_catch sed -i.bak -n "/^<< properties >>/,/^<< end >>/p" $::env(signoff_tmpfiles)/gds_ptrs.mag
136+
+ exec rm -f $::env(signoff_tmpfiles)/gds_ptrs.mag.bak
137+
}
138+
139+
# If desired, copy GDS_* properties into the mag/ view
140+
diff --git a/scripts/tcl_commands/synthesis.tcl b/scripts/tcl_commands/synthesis.tcl
141+
index 9ec052468..fb8000e9c 100755
142+
--- a/scripts/tcl_commands/synthesis.tcl
143+
+++ b/scripts/tcl_commands/synthesis.tcl
144+
@@ -71,7 +71,8 @@ proc run_yosys {args} {
145+
if { [info exists ::env(SYNTH_EXPLORE)] && $::env(SYNTH_EXPLORE) } {
146+
puts_info "This is a Synthesis Exploration and so no need to remove the defparam lines."
147+
} else {
148+
- try_catch sed -i {/defparam/d} $arg_values(-output)
149+
+ try_catch sed -i.bak {/defparam/d} $arg_values(-output)
150+
+ exec rm -f $arg_values(-output).bak
151+
}
152+
unset ::env(SAVE_NETLIST)
153+
}
154+
diff --git a/scripts/utils/deflef_utils.tcl b/scripts/utils/deflef_utils.tcl
155+
index a2ef69124..9a62019e6 100755
156+
--- a/scripts/utils/deflef_utils.tcl
157+
+++ b/scripts/utils/deflef_utils.tcl
158+
@@ -26,7 +26,8 @@ proc resize_die {args} {
159+
set ury [expr {[lindex $arg_values(-area) 3] * $::env(DEF_UNITS_PER_MICRON)}]
160+
161+
puts_info "Resizing Die to $arg_values(-area)"
162+
- try_catch sed -i -E "0,/^DIEAREA.*$/{s/^DIEAREA.*$/DIEAREA ( $llx $lly ) ( $urx $ury ) ;/}" $arg_values(-def)
163+
+ try_catch sed -i.bak -E "0,/^DIEAREA.*$/{s/^DIEAREA.*$/DIEAREA ( $llx $lly ) ( $urx $ury ) ;/}" $arg_values(-def)
164+
+ try_catch rm -f $arg_values(-def).bak
165+
}
166+
167+
proc get_instance_position {args} {
168+
diff --git a/scripts/utils/utils.tcl b/scripts/utils/utils.tcl
169+
index 4209a3b1a..aa7e9e8a4 100755
170+
--- a/scripts/utils/utils.tcl
171+
+++ b/scripts/utils/utils.tcl
172+
@@ -209,7 +209,8 @@ proc index_file {args} {
173+
set new_file_full_name "$file_path/$fbasename"
174+
set replace [string map {/ \\/} $::env(CURRENT_INDEX)]
175+
if { [info exists ::env(GLB_CFG_FILE)]} {
176+
- exec sed -i -e "s/\\(set ::env(CURRENT_INDEX)\\).*/\\1 $replace/" "$::env(GLB_CFG_FILE)"
177+
+ exec sed -i.bak -e "s/\\(set ::env(CURRENT_INDEX)\\).*/\\1 $replace/" "$::env(GLB_CFG_FILE)"
178+
+ exec rm -f "$::env(GLB_CFG_FILE).bak"
179+
}
180+
return $new_file_full_name
181+
}

0 commit comments

Comments
 (0)