mirror of https://github.com/KLayout/klayout.git
Bd enhancements (#1034)
* Added ability to join files for strmxor * Joined input files also for strm2txt strmclip and strmcmp. Output options for strmxor.
This commit is contained in:
parent
e1443cb961
commit
0eeeb8b6a3
|
|
@ -31,33 +31,6 @@
|
||||||
namespace bd
|
namespace bd
|
||||||
{
|
{
|
||||||
|
|
||||||
static std::string::size_type find_file_sep (const std::string &s, std::string::size_type from)
|
|
||||||
{
|
|
||||||
std::string::size_type p1 = s.find ("+", from);
|
|
||||||
std::string::size_type p2 = s.find (",", from);
|
|
||||||
|
|
||||||
if (p1 == std::string::npos) {
|
|
||||||
return p2;
|
|
||||||
} else if (p2 == std::string::npos) {
|
|
||||||
return p1;
|
|
||||||
} else {
|
|
||||||
return p1 < p2 ? p1 : p2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::vector<std::string> split_file_list (const std::string &infile)
|
|
||||||
{
|
|
||||||
std::vector<std::string> files;
|
|
||||||
|
|
||||||
size_t p = 0;
|
|
||||||
for (size_t pp = 0; (pp = find_file_sep (infile, p)) != std::string::npos; p = pp + 1) {
|
|
||||||
files.push_back (std::string (infile, p, pp - p));
|
|
||||||
}
|
|
||||||
files.push_back (std::string (infile, p));
|
|
||||||
|
|
||||||
return files;
|
|
||||||
}
|
|
||||||
|
|
||||||
int converter_main (int argc, char *argv[], const std::string &format)
|
int converter_main (int argc, char *argv[], const std::string &format)
|
||||||
{
|
{
|
||||||
bd::GenericWriterOptions generic_writer_options;
|
bd::GenericWriterOptions generic_writer_options;
|
||||||
|
|
@ -83,14 +56,7 @@ int converter_main (int argc, char *argv[], const std::string &format)
|
||||||
{
|
{
|
||||||
db::LoadLayoutOptions load_options;
|
db::LoadLayoutOptions load_options;
|
||||||
generic_reader_options.configure (load_options);
|
generic_reader_options.configure (load_options);
|
||||||
|
read_files (layout, infile, load_options);
|
||||||
std::vector<std::string> files = split_file_list (infile);
|
|
||||||
|
|
||||||
for (std::vector<std::string>::const_iterator f = files.begin (); f != files.end (); ++f) {
|
|
||||||
tl::InputStream stream (*f);
|
|
||||||
db::Reader reader (stream);
|
|
||||||
reader.read (layout, load_options);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -833,4 +833,42 @@ GenericReaderOptions::configure (db::LoadLayoutOptions &load_options)
|
||||||
load_options.set_option_by_name ("lefdef_config.macro_layouts", lef_layout_ptrs);
|
load_options.set_option_by_name ("lefdef_config.macro_layouts", lef_layout_ptrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::string::size_type find_file_sep (const std::string &s, std::string::size_type from)
|
||||||
|
{
|
||||||
|
std::string::size_type p1 = s.find ("+", from);
|
||||||
|
std::string::size_type p2 = s.find (",", from);
|
||||||
|
|
||||||
|
if (p1 == std::string::npos) {
|
||||||
|
return p2;
|
||||||
|
} else if (p2 == std::string::npos) {
|
||||||
|
return p1;
|
||||||
|
} else {
|
||||||
|
return p1 < p2 ? p1 : p2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> split_file_list (const std::string &infile)
|
||||||
|
{
|
||||||
|
std::vector<std::string> files;
|
||||||
|
|
||||||
|
size_t p = 0;
|
||||||
|
for (size_t pp = 0; (pp = find_file_sep (infile, p)) != std::string::npos; p = pp + 1) {
|
||||||
|
files.push_back (std::string (infile, p, pp - p));
|
||||||
|
}
|
||||||
|
files.push_back (std::string (infile, p));
|
||||||
|
|
||||||
|
return files;
|
||||||
|
}
|
||||||
|
|
||||||
|
void read_files (db::Layout &layout, const std::string &infile, const db::LoadLayoutOptions &options)
|
||||||
|
{
|
||||||
|
std::vector<std::string> files = split_file_list (infile);
|
||||||
|
|
||||||
|
for (std::vector<std::string>::const_iterator f = files.begin (); f != files.end (); ++f) {
|
||||||
|
tl::InputStream stream (*f);
|
||||||
|
db::Reader reader (stream);
|
||||||
|
reader.read (layout, options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -195,6 +195,13 @@ private:
|
||||||
tl::shared_collection<db::Layout> m_lef_layouts;
|
tl::shared_collection<db::Layout> m_lef_layouts;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief A function to load a sequence of files into the layout with the given options
|
||||||
|
*
|
||||||
|
* "file_path" is a "+" or "," separated list of files read "into" a single layout.
|
||||||
|
*/
|
||||||
|
BD_PUBLIC void read_files (db::Layout &layout, const std::string &infile, const db::LoadLayoutOptions &options);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -47,10 +47,7 @@ BD_PUBLIC int strm2txt (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
db::LoadLayoutOptions load_options;
|
db::LoadLayoutOptions load_options;
|
||||||
generic_reader_options.configure (load_options);
|
generic_reader_options.configure (load_options);
|
||||||
|
bd::read_files (layout, infile, load_options);
|
||||||
tl::InputStream stream (infile);
|
|
||||||
db::Reader reader (stream);
|
|
||||||
reader.read (layout, load_options);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -71,10 +71,7 @@ void clip (ClipData &data)
|
||||||
{
|
{
|
||||||
db::LoadLayoutOptions load_options;
|
db::LoadLayoutOptions load_options;
|
||||||
data.reader_options.configure (load_options);
|
data.reader_options.configure (load_options);
|
||||||
|
bd::read_files (layout, data.file_in, load_options);
|
||||||
tl::InputStream stream (data.file_in);
|
|
||||||
db::Reader reader (stream);
|
|
||||||
reader.read (layout, load_options);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the layers in the target layout as well
|
// create the layers in the target layout as well
|
||||||
|
|
|
||||||
|
|
@ -142,19 +142,13 @@ BD_PUBLIC int strmcmp (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
db::LoadLayoutOptions load_options;
|
db::LoadLayoutOptions load_options;
|
||||||
generic_reader_options_a.configure (load_options);
|
generic_reader_options_a.configure (load_options);
|
||||||
|
bd::read_files (layout_a, infile_a, load_options);
|
||||||
tl::InputStream stream (infile_a);
|
|
||||||
db::Reader reader (stream);
|
|
||||||
reader.read (layout_a, load_options);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
db::LoadLayoutOptions load_options;
|
db::LoadLayoutOptions load_options;
|
||||||
generic_reader_options_b.configure (load_options);
|
generic_reader_options_b.configure (load_options);
|
||||||
|
bd::read_files (layout_b, infile_b, load_options);
|
||||||
tl::InputStream stream (infile_b);
|
|
||||||
db::Reader reader (stream);
|
|
||||||
reader.read (layout_b, load_options);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int flags = 0;
|
unsigned int flags = 0;
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "bdReaderOptions.h"
|
#include "bdReaderOptions.h"
|
||||||
|
#include "bdWriterOptions.h"
|
||||||
#include "dbLayout.h"
|
#include "dbLayout.h"
|
||||||
#include "dbTilingProcessor.h"
|
#include "dbTilingProcessor.h"
|
||||||
#include "dbReader.h"
|
#include "dbReader.h"
|
||||||
|
|
@ -327,6 +328,9 @@ BD_PUBLIC int strmxor (int argc, char *argv[])
|
||||||
generic_reader_options_a.add_options (cmd);
|
generic_reader_options_a.add_options (cmd);
|
||||||
generic_reader_options_b.add_options (cmd);
|
generic_reader_options_b.add_options (cmd);
|
||||||
|
|
||||||
|
bd::GenericWriterOptions writer_options;
|
||||||
|
writer_options.add_options (cmd);
|
||||||
|
|
||||||
cmd << tl::arg ("input_a", &infile_a, "The first input file (any format, may be gzip compressed)")
|
cmd << tl::arg ("input_a", &infile_a, "The first input file (any format, may be gzip compressed)")
|
||||||
<< tl::arg ("input_b", &infile_b, "The second input file (any format, may be gzip compressed)")
|
<< tl::arg ("input_b", &infile_b, "The second input file (any format, may be gzip compressed)")
|
||||||
<< tl::arg ("?output", &output, "The output file to which the XOR differences are written",
|
<< tl::arg ("?output", &output, "The output file to which the XOR differences are written",
|
||||||
|
|
@ -408,10 +412,7 @@ BD_PUBLIC int strmxor (int argc, char *argv[])
|
||||||
|
|
||||||
db::LoadLayoutOptions load_options;
|
db::LoadLayoutOptions load_options;
|
||||||
generic_reader_options_a.configure (load_options);
|
generic_reader_options_a.configure (load_options);
|
||||||
|
bd::read_files (layout_a, infile_a, load_options);
|
||||||
tl::InputStream stream (infile_a);
|
|
||||||
db::Reader reader (stream);
|
|
||||||
reader.read (layout_a, load_options);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
@ -419,10 +420,7 @@ BD_PUBLIC int strmxor (int argc, char *argv[])
|
||||||
|
|
||||||
db::LoadLayoutOptions load_options;
|
db::LoadLayoutOptions load_options;
|
||||||
generic_reader_options_b.configure (load_options);
|
generic_reader_options_b.configure (load_options);
|
||||||
|
bd::read_files (layout_b, infile_b, load_options);
|
||||||
tl::InputStream stream (infile_b);
|
|
||||||
db::Reader reader (stream);
|
|
||||||
reader.read (layout_b, load_options);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (top_a.empty ()) {
|
if (top_a.empty ()) {
|
||||||
|
|
@ -512,6 +510,7 @@ BD_PUBLIC int strmxor (int argc, char *argv[])
|
||||||
|
|
||||||
db::SaveLayoutOptions save_options;
|
db::SaveLayoutOptions save_options;
|
||||||
save_options.set_format_from_filename (output);
|
save_options.set_format_from_filename (output);
|
||||||
|
writer_options.configure (save_options, *output_layout);
|
||||||
|
|
||||||
tl::OutputStream stream (output);
|
tl::OutputStream stream (output);
|
||||||
db::Writer writer (save_options);
|
db::Writer writer (save_options);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue