From be62abd646a2bd5976e7f9616e3b3dae21bcec5e Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 9 Nov 2025 09:10:31 +0100 Subject: [PATCH] Added strm2lstr buddy tool --- src/buddies/src/bd/bd.pro | 1 + src/buddies/src/bd/bdWriterOptions.cc | 1 + src/buddies/src/bd/bdWriterOptions.h | 1 + src/buddies/src/bd/strm2lstr.cc | 29 ++++++++++++++++++++++ src/buddies/src/src.pro | 2 ++ src/buddies/src/strm2lstr/strm2lstr.pro | 2 ++ src/buddies/unit_tests/bdConverterTests.cc | 25 +++++++++++++++++++ 7 files changed, 61 insertions(+) create mode 100644 src/buddies/src/bd/strm2lstr.cc create mode 100644 src/buddies/src/strm2lstr/strm2lstr.pro diff --git a/src/buddies/src/bd/bd.pro b/src/buddies/src/bd/bd.pro index 2deeb870f..d3b3faa09 100644 --- a/src/buddies/src/bd/bd.pro +++ b/src/buddies/src/bd/bd.pro @@ -14,6 +14,7 @@ SOURCES = \ strm2cif.cc \ strm2gds.cc \ strm2oas.cc \ + strm2lstr.cc \ strmclip.cc \ strm2dxf.cc \ strm2gdstxt.cc \ diff --git a/src/buddies/src/bd/bdWriterOptions.cc b/src/buddies/src/bd/bdWriterOptions.cc index 2886aef92..fe039106a 100644 --- a/src/buddies/src/bd/bdWriterOptions.cc +++ b/src/buddies/src/bd/bdWriterOptions.cc @@ -89,6 +89,7 @@ GenericWriterOptions::init_from_options (const db::SaveLayoutOptions &save_optio const std::string GenericWriterOptions::gds2_format_name = "GDS2"; const std::string GenericWriterOptions::gds2text_format_name = "GDS2Text"; // no special options const std::string GenericWriterOptions::oasis_format_name = "OASIS"; +const std::string GenericWriterOptions::lstream_format_name = "LStream"; const std::string GenericWriterOptions::dxf_format_name = "DXF"; const std::string GenericWriterOptions::cif_format_name = "CIF"; const std::string GenericWriterOptions::mag_format_name = "MAG"; diff --git a/src/buddies/src/bd/bdWriterOptions.h b/src/buddies/src/bd/bdWriterOptions.h index 6ebf61f99..9319762de 100644 --- a/src/buddies/src/bd/bdWriterOptions.h +++ b/src/buddies/src/bd/bdWriterOptions.h @@ -108,6 +108,7 @@ public: static const std::string gds2_format_name; static const std::string gds2text_format_name; static const std::string oasis_format_name; + static const std::string lstream_format_name; static const std::string cif_format_name; static const std::string dxf_format_name; static const std::string mag_format_name; diff --git a/src/buddies/src/bd/strm2lstr.cc b/src/buddies/src/bd/strm2lstr.cc new file mode 100644 index 000000000..d6a427005 --- /dev/null +++ b/src/buddies/src/bd/strm2lstr.cc @@ -0,0 +1,29 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2025 Matthias Koefferlein + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +*/ + +#include "bdConverterMain.h" +#include "bdWriterOptions.h" + +BD_PUBLIC int strm2lstr (int argc, char *argv[]) +{ + return bd::converter_main (argc, argv, bd::GenericWriterOptions::lstream_format_name); +} diff --git a/src/buddies/src/src.pro b/src/buddies/src/src.pro index eb9777725..9cccfd2cf 100644 --- a/src/buddies/src/src.pro +++ b/src/buddies/src/src.pro @@ -8,6 +8,7 @@ SUBDIRS = \ strm2gds \ strm2gdstxt \ strm2oas \ + strm2lstr \ strm2mag \ strm2txt \ strmclip \ @@ -20,6 +21,7 @@ strm2dxf.depends += bd strm2gds.depends += bd strm2gdstxt.depends += bd strm2oas.depends += bd +strm2lstr.depends += bd strm2mag.depends += bd strm2txt.depends += bd strmclip.depends += bd diff --git a/src/buddies/src/strm2lstr/strm2lstr.pro b/src/buddies/src/strm2lstr/strm2lstr.pro new file mode 100644 index 000000000..e04ca961a --- /dev/null +++ b/src/buddies/src/strm2lstr/strm2lstr.pro @@ -0,0 +1,2 @@ + +include($$PWD/../buddy_app.pri) diff --git a/src/buddies/unit_tests/bdConverterTests.cc b/src/buddies/unit_tests/bdConverterTests.cc index cfbd51e03..9e789de9c 100644 --- a/src/buddies/unit_tests/bdConverterTests.cc +++ b/src/buddies/unit_tests/bdConverterTests.cc @@ -187,6 +187,31 @@ TEST(6) db::compare_layouts (this, layout, input_au, db::WriteGDS2); } +// Testing the converter main implementation (LStream) +TEST(7) +{ + std::string input = tl::testdata (); + input += "/gds/t10.gds"; + + std::string output = this->tmp_file (); + + const char *argv[] = { "x", input.c_str (), output.c_str () }; + + EXPECT_EQ (bd::converter_main (sizeof (argv) / sizeof (argv[0]), (char **) argv, bd::GenericWriterOptions::lstream_format_name), 0); + + db::Layout layout; + + { + tl::InputStream stream (output); + db::LoadLayoutOptions options; + db::Reader reader (stream); + reader.read (layout, options); + EXPECT_EQ (reader.format (), "LStream"); + } + + db::compare_layouts (this, layout, input, db::NoNormalization); +} + // Large LEF/DEF to OAS converter test TEST(10) {