mirror of https://github.com/KLayout/klayout.git
Mitigate the effect of overriding a globally-defined technology with -nn on the command line by creating tech variants
This commit is contained in:
parent
f518d1aa1d
commit
cbc9123db4
|
|
@ -686,28 +686,59 @@ ApplicationBase::init_app ()
|
|||
tc->add_path (*p);
|
||||
}
|
||||
|
||||
tc->load ();
|
||||
|
||||
bool needs_reload = false;
|
||||
|
||||
// disambiguator for tech name
|
||||
std::map<std::string, int> tech_disambiguator;
|
||||
std::map<std::string, std::string> tech_name_for_file;
|
||||
|
||||
for (auto t = db::Technologies::instance ()->begin (); t != db::Technologies::instance ()->end (); ++t) {
|
||||
tech_disambiguator.insert (std::make_pair (t->name (), 0));
|
||||
}
|
||||
|
||||
// import technologies from the command line
|
||||
for (std::vector <std::pair<file_type, std::pair<std::string, std::string> > >::iterator f = m_files.begin (); f != m_files.end (); ++f) {
|
||||
|
||||
if (f->first == layout_file_with_tech_file) {
|
||||
|
||||
const std::string &tech_file = f->second.second;
|
||||
|
||||
if (tl::verbosity () >= 20) {
|
||||
tl::info << "Importing technology from " << f->second.second;
|
||||
}
|
||||
|
||||
db::Technology t;
|
||||
t.load (f->second.second);
|
||||
t.load (tech_file);
|
||||
|
||||
// disambiguate the name, so we do not overwrite technologies with the same name from the config
|
||||
if (tech_name_for_file.find (tech_file) != tech_name_for_file.end ()) {
|
||||
t.set_name (tech_name_for_file [tech_file]);
|
||||
} else if (tech_disambiguator.find (t.name ()) != tech_disambiguator.end ()) {
|
||||
int &index = tech_disambiguator [t.name ()];
|
||||
index += 1;
|
||||
t.set_name (t.name () + tl::sprintf ("[%d]", index));
|
||||
tech_name_for_file.insert (std::make_pair (tech_file, t.name ()));
|
||||
} else {
|
||||
tech_disambiguator.insert (std::make_pair (t.name (), 0));
|
||||
tech_name_for_file.insert (std::make_pair (tech_file, t.name ()));
|
||||
}
|
||||
|
||||
tc->add_temp_tech (t);
|
||||
|
||||
f->first = layout_file_with_tech;
|
||||
f->second.second = t.name ();
|
||||
|
||||
needs_reload = true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
tc->load ();
|
||||
if (needs_reload) {
|
||||
tc->load ();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -609,6 +609,9 @@ TechnologyController::rescan (db::Technologies &technologies)
|
|||
for (std::vector<db::Technology>::const_iterator t = m_temp_tech.begin (); t != m_temp_tech.end (); ++t) {
|
||||
|
||||
db::Technology *tech = new db::Technology (*t);
|
||||
if (tl::verbosity () >= 20) {
|
||||
tl::info << "Registering special technology from " << tech->tech_file_path () << " as " << tech->name ();
|
||||
}
|
||||
tech->set_persisted (false); // don't save that one in the configuration
|
||||
tech->set_tech_file_path (std::string ()); // don't save to a file either
|
||||
tech->set_readonly (true); // don't edit
|
||||
|
|
|
|||
Loading…
Reference in New Issue