From caf54bd77b11aad11d798eeecd2c29e4c01a50ba Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 2 Dec 2023 22:10:31 +0100 Subject: [PATCH] Fixed issue #1531 (DEF format not recognized in symlink): use original path to determine format --- src/db/db/dbNetlistSpiceReader.cc | 4 +-- .../lefdef/unit_tests/dbLEFDEFImportTests.cc | 26 +++++++++++++++ src/tl/tl/tlStream.cc | 12 ++++--- testdata/lefdef/issue-1531/au.oas | Bin 0 -> 574 bytes testdata/lefdef/issue-1531/blocks.lef | 31 ++++++++++++++++++ testdata/lefdef/issue-1531/tech.lef | 12 +++++++ testdata/lefdef/issue-1531/tech.map | 6 ++++ testdata/lefdef/issue-1531/top | 10 ++++++ testdata/lefdef/issue-1531/top.def | 1 + 9 files changed, 95 insertions(+), 7 deletions(-) create mode 100644 testdata/lefdef/issue-1531/au.oas create mode 100644 testdata/lefdef/issue-1531/blocks.lef create mode 100644 testdata/lefdef/issue-1531/tech.lef create mode 100644 testdata/lefdef/issue-1531/tech.map create mode 100644 testdata/lefdef/issue-1531/top create mode 120000 testdata/lefdef/issue-1531/top.def diff --git a/src/db/db/dbNetlistSpiceReader.cc b/src/db/db/dbNetlistSpiceReader.cc index 7d5bf2805..1cd64f18e 100644 --- a/src/db/db/dbNetlistSpiceReader.cc +++ b/src/db/db/dbNetlistSpiceReader.cc @@ -183,7 +183,7 @@ SpiceReaderStream::line_number () const std::string SpiceReaderStream::source () const { - return mp_stream->source (); + return mp_stream->absolute_path (); } bool @@ -495,7 +495,7 @@ SpiceCircuitDict::read (tl::InputStream &stream) m_global_net_names.clear (); m_global_nets.clear (); - m_file_id = file_id (stream.source ()); + m_file_id = file_id (stream.absolute_path ()); while (! at_end ()) { read_card (); diff --git a/src/plugins/streamers/lefdef/unit_tests/dbLEFDEFImportTests.cc b/src/plugins/streamers/lefdef/unit_tests/dbLEFDEFImportTests.cc index 38962826f..717e89117 100644 --- a/src/plugins/streamers/lefdef/unit_tests/dbLEFDEFImportTests.cc +++ b/src/plugins/streamers/lefdef/unit_tests/dbLEFDEFImportTests.cc @@ -1017,4 +1017,30 @@ TEST(210_overlaps) run_test (_this, "issue-1499", "map:tech.map+lef:tech.lef+lef:blocks.lef+def:top.def", "au.oas", default_options (), false); } +// issue-1531 +TEST(211_symlinks) +{ + db::Layout ly; + + std::string fn_path (tl::testdata ()); + fn_path += "/lefdef/issue-1531/"; + + db::LEFDEFReaderOptions lefdef_opt = default_options (); + lefdef_opt.set_map_file ("tech.map"); + std::vector lf; + lf.push_back ("tech.lef"); + lf.push_back ("blocks.lef"); + lefdef_opt.set_lef_files (lf); + lefdef_opt.set_read_lef_with_def (false); + db::LoadLayoutOptions opt; + opt.set_options (lefdef_opt); + + { + tl::InputStream is (fn_path + "top.def"); + db::Reader reader (is); + reader.read (ly, opt); + } + + db::compare_layouts (_this, ly, fn_path + "au.oas", db::WriteOAS); +} diff --git a/src/tl/tl/tlStream.cc b/src/tl/tl/tlStream.cc index 5686990b8..3b35ade25 100644 --- a/src/tl/tl/tlStream.cc +++ b/src/tl/tl/tlStream.cc @@ -747,18 +747,20 @@ InputFile::filename () const InputZLibFile::InputZLibFile (const std::string &path) : mp_d (new ZLibFilePrivate ()) { - m_source = tl::absolute_file_path (path); + m_source = path; + std::string source = tl::absolute_file_path (path); + #if defined(_WIN32) - int fd = _wopen (tl::to_wstring (m_source).c_str (), _O_BINARY | _O_RDONLY | _O_SEQUENTIAL); + int fd = _wopen (tl::to_wstring (source).c_str (), _O_BINARY | _O_RDONLY | _O_SEQUENTIAL); if (fd < 0) { - throw FileOpenErrorException (m_source, errno); + throw FileOpenErrorException (source, errno); } mp_d->zs = gzdopen (fd, "rb"); #else - mp_d->zs = gzopen (tl::string_to_system (m_source).c_str (), "rb"); + mp_d->zs = gzopen (tl::string_to_system (source).c_str (), "rb"); #endif if (mp_d->zs == NULL) { - throw FileOpenErrorException (m_source, errno); + throw FileOpenErrorException (source, errno); } } diff --git a/testdata/lefdef/issue-1531/au.oas b/testdata/lefdef/issue-1531/au.oas new file mode 100644 index 0000000000000000000000000000000000000000..02bb446865b5da48a048da26c2f367b86d5e9830 GIT binary patch literal 574 zcmY!lcJ=kt^>+;R4CduxWH!_@V0gjKC?n3q!6L)YEF;ds&!EJR>XUoMnybM;fb~F; z;|1o9>4KX(8~>b$4qRRSKbqrK6n{_8gJqfNT9PTCm&e!2&y8CXr%BhK8*Y3l7Nv6^c|cKbRrjuuK*xyI>9@FQdp|Mur3DRYYzw zFW9UM6afh`2p(XTQD@{}F=Hbm(7KTY7#INc{pia8 literal 0 HcmV?d00001 diff --git a/testdata/lefdef/issue-1531/blocks.lef b/testdata/lefdef/issue-1531/blocks.lef new file mode 100644 index 000000000..1ac45cb8b --- /dev/null +++ b/testdata/lefdef/issue-1531/blocks.lef @@ -0,0 +1,31 @@ +VERSION 5.8 ; + +MACRO a + ORIGIN 0 0 ; + SIZE 600 BY 600 ; + OBS + LAYER M1 ; + RECT 10 10 590 590 ; + END +END a + +MACRO b + ORIGIN -600 0 ; + SIZE 400 BY 500 ; + OBS + LAYER M1 ; + RECT 610 10 990 490 ; + END +END b + +MACRO c + ORIGIN -500 -500 ; + SIZE 500 BY 500 ; + OBS + LAYER M1 ; + POLYGON 510 610 610 610 610 510 990 510 990 990 510 990 ; + LAYER overlap ; + RECT 500 700 1000 1000 ; + POLYGON 500 600 600 600 600 500 1000 500 1000 700 500 700 ; + END +END c diff --git a/testdata/lefdef/issue-1531/tech.lef b/testdata/lefdef/issue-1531/tech.lef new file mode 100644 index 000000000..606730c96 --- /dev/null +++ b/testdata/lefdef/issue-1531/tech.lef @@ -0,0 +1,12 @@ +VERSION 5.8 ; + +LAYER M1 + TYPE ROUTING ; + DIRECTION HORIZONTAL ; + WIDTH 0.1 ; + PITCH 0.1 ; +END M1 + +LAYER overlap + TYPE OVERLAP ; +END overlap diff --git a/testdata/lefdef/issue-1531/tech.map b/testdata/lefdef/issue-1531/tech.map new file mode 100644 index 000000000..e848325a6 --- /dev/null +++ b/testdata/lefdef/issue-1531/tech.map @@ -0,0 +1,6 @@ +DIEAREA ALL 1 0 +#BOUNDARY DIEAREA 1 0 +BOUNDARY MACRO 1 0 +#M1 LEFOBS 2 0 +M1 LEFOBS 3 0 +M1 BLOCKAGE 3 0 diff --git a/testdata/lefdef/issue-1531/top b/testdata/lefdef/issue-1531/top new file mode 100644 index 000000000..1e1cd5c32 --- /dev/null +++ b/testdata/lefdef/issue-1531/top @@ -0,0 +1,10 @@ +VERSION 5.8 ; +DESIGN top ; +UNITS DISTANCE MICRONS 1000 ; +DIEAREA ( 0 0 ) ( 1000000 1000000 ) ; +COMPONENTS 3 ; +- a a + PLACED ( 0 0 ) N ; +- b b + PLACED ( 600000 0 ) N ; +- c c + PLACED ( 500000 500000 ) N ; +END COMPONENTS +END DESIGN diff --git a/testdata/lefdef/issue-1531/top.def b/testdata/lefdef/issue-1531/top.def new file mode 120000 index 000000000..83a3157d1 --- /dev/null +++ b/testdata/lefdef/issue-1531/top.def @@ -0,0 +1 @@ +top \ No newline at end of file