Skip to content

Commit

Permalink
merge to nam20485 (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
nam20485 authored Dec 24, 2023
2 parents bdbcc49 + 4fc2327 commit 1c98cab
Show file tree
Hide file tree
Showing 27 changed files with 254 additions and 249 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,11 @@ testlog.xml
/OdbDesignTests/CMakeLists_Local.txt
/OdbDesignTests/DesignNameTests_Local.cpp
/output
OdbDesignServer/api/__pycache__/
OdbDesignServer/api/migrations/__pycache__/
OdbDesignServer/OdbDesignServer/__pycache__/
OdbDesignServer/PyOdbDesignLib/__pycache__/
OdbDesignServer/PyOdbDesignLib/PyOdbDesignLib.py
OdbDesignServer/db.sqlite3
OdbDesignServer/PyOdbDesignLib/_PyOdbDesignLib.pyd
/TEST_DATA.zip
65 changes: 28 additions & 37 deletions OdbDesignLib/App/DesignCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,30 +114,26 @@ namespace Odb::Lib::App
for (const auto& entry : directory_iterator(m_directory))
{
if (entry.is_regular_file())
{
//for (const auto& designExt : DESIGN_EXTENSIONS)
//{
//if (entry.path().extension() == designExt)
if (ArchiveExtractor::IsArchiveTypeSupported(entry.path().filename()))
{
if (ArchiveExtractor::IsArchiveTypeSupported(entry.path().filename()))
{
try
{
try
auto pFileArchive = LoadFileArchive(entry.path().stem().string());
if (pFileArchive != nullptr)
{
auto pFileArchive = LoadFileArchive(entry.path().stem().string());
if (pFileArchive != nullptr)
{
loaded++;
}
loaded++;
}
catch (std::exception& e)
{
// continue if we encounter an error loading one
logexception(e);
if (stopOnError) throw e;
}
}
//}
catch (std::exception& e)
{
// continue if we encounter an error loading one
logexception(e);
if (stopOnError) throw e;
}
}
}
}
}

return loaded;
}
Expand All @@ -150,30 +146,25 @@ namespace Odb::Lib::App
{
if (entry.is_regular_file())
{
//for (const auto& designExt : DESIGN_EXTENSIONS)
//{
//auto ext = entry.path().extension().string();
//if (ext == designExt)
if (ArchiveExtractor::IsArchiveTypeSupported(entry.path().filename()))
if (ArchiveExtractor::IsArchiveTypeSupported(entry.path().filename()))
{
try
{
try
auto pDesign = LoadDesign(entry.path().stem().string());
if (pDesign != nullptr)
{
auto pDesign = LoadDesign(entry.path().stem().string());
if (pDesign != nullptr)
{
loaded++;
}
loaded++;
}
catch (std::exception& e)
}
catch (std::exception& e)
{
logexception(e);
if (stopOnError)
{
logexception(e);
if (stopOnError)
{
throw e;
}
throw e;
}
}
//}
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion OdbDesignLib/App/DesignCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace Odb::Lib::App
std::shared_ptr<ProductModel::Design> LoadDesign(const std::string& designName);
std::shared_ptr<FileModel::Design::FileArchive> LoadFileArchive(const std::string& designName);

constexpr inline static const char* DESIGN_EXTENSIONS[] = { "zip", "tgz", "tar.gz", "tar" };
constexpr inline static const char* DESIGN_EXTENSIONS[] = { "zip", "tgz", "tar.gz", "tar", "gzip" , "gz" };

};
}
5 changes: 3 additions & 2 deletions OdbDesignLib/App/OdbServerAppBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ namespace Odb::Lib::App

Utils::ExitCode Run() override;

protected:
crow::SimpleApp m_crowApp;
protected:
RouteController::Vector m_vecControllers;

// implement in subclasses to add route controllers
virtual void add_controllers() = 0;

private:
crow::SimpleApp m_crowApp;

void register_routes();

static constexpr const char* SSL_CERT_FILE = "ssl.crt";
Expand Down
9 changes: 9 additions & 0 deletions OdbDesignLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ target_link_libraries(OdbDesign PUBLIC OpenSSL::SSL OpenSSL::Crypto)
target_compile_definitions(OdbDesign PUBLIC CROW_ENABLE_COMPRESSION)
target_compile_definitions(OdbDesign PUBLIC CROW_ENABLE_SSL)

# link to Crow
find_package(Crow CONFIG REQUIRED)
target_link_libraries(OdbDesign PRIVATE Crow::Crow)

# Link to Protobuf
find_package(Protobuf CONFIG REQUIRED)
#protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS protoc/edadatafile.proto)
Expand All @@ -75,6 +79,11 @@ target_link_libraries(OdbDesign PRIVATE protobuf::libprotobuf)
# add the generated Protobuf C++ files to the target
#target_sources(OdbDesign PRIVATE ${PROTO_SRCS} ${PROTO_HDRS})

# workaround to remove error: "C++ command-line error: invalid macro definition: _CROW_ICD-NOTFOUND"
# (see https://github.com/CrowCpp/Crow/issues/661#issuecomment-1702544225)
list(REMOVE_ITEM _CROW_ICD "_CROW_ICD-NOTFOUND")
set_target_properties(Crow::Crow PROPERTIES INTERFACE_COMPILE_DEFINITIONS "${_CROW_ICD}")

# Python extension module build settings
if (PYTHON_MODULE_BUILD)
# # run swig to generate wrapper file
Expand Down
2 changes: 1 addition & 1 deletion OdbDesignLib/FileModel/Design/AttrListFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace Odb::Lib::FileModel::Design
loginfo("checking for extraction...");

std::filesystem::path featuresFilePath;
for (const std::string featuresFilename : ATTRLIST_FILENAMES)
for (const std::string& featuresFilename : ATTRLIST_FILENAMES)

Check warning on line 47 in OdbDesignLib/FileModel/Design/AttrListFile.cpp

View workflow job for this annotation

GitHub Actions / CMake-Multi-Platform-Build (ubuntu-22.04, linux-release)

loop variable ‘featuresFilename’ of type ‘const string&’ {aka ‘const std::__cxx11::basic_string<char>&’} binds to a temporary constructed from type ‘const char* const’ [-Wrange-loop-construct]
{
loginfo("trying attrlist file: [" + featuresFilename + "]...");

Expand Down
5 changes: 3 additions & 2 deletions OdbDesignLib/FileModel/Design/ComponentsFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ using namespace std::filesystem;
namespace Odb::Lib::FileModel::Design
{
ComponentsFile::ComponentsFile()
: m_id((unsigned int)-1)
: m_id((unsigned int)-1)
, m_side(BoardSide::BsNone)
{
}

Expand Down Expand Up @@ -310,7 +311,7 @@ namespace Odb::Lib::FileModel::Design
loginfo("checking for extraction...");

std::filesystem::path componentsFilePath;
for (const std::string componentsFilename : COMPONENTS_FILENAMES)
for (const std::string& componentsFilename : COMPONENTS_FILENAMES)

Check warning on line 314 in OdbDesignLib/FileModel/Design/ComponentsFile.cpp

View workflow job for this annotation

GitHub Actions / CMake-Multi-Platform-Build (ubuntu-22.04, linux-release)

loop variable ‘componentsFilename’ of type ‘const string&’ {aka ‘const std::__cxx11::basic_string<char>&’} binds to a temporary constructed from type ‘const char* const’ [-Wrange-loop-construct]
{
loginfo("trying components file: [" + componentsFilename + "]...");

Expand Down
19 changes: 9 additions & 10 deletions OdbDesignLib/FileModel/Design/EdaDataFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,8 +618,8 @@ namespace Odb::Lib::FileModel::Design
pCurrentSubnetRecord.reset();
}

m_netRecords.push_back(pCurrentNetRecord);
m_netRecordsByName[pCurrentNetRecord->name] = pCurrentNetRecord;
m_netRecords.push_back(pCurrentNetRecord);
//m_netRecordsByName[pCurrentNetRecord->name] = pCurrentNetRecord;
pCurrentNetRecord.reset();
}

Expand Down Expand Up @@ -835,7 +835,7 @@ namespace Odb::Lib::FileModel::Design
}

m_netRecords.push_back(pCurrentNetRecord);
m_netRecordsByName[pCurrentNetRecord->name] = pCurrentNetRecord;
//m_netRecordsByName[pCurrentNetRecord->name] = pCurrentNetRecord;
pCurrentNetRecord.reset();
}
else if (pCurrentPackageRecord != nullptr)
Expand All @@ -855,7 +855,7 @@ namespace Odb::Lib::FileModel::Design

// finish up any current (previous) package records
m_packageRecords.push_back(pCurrentPackageRecord);
m_packageRecordsByName[pCurrentPackageRecord->name] = pCurrentPackageRecord;
//m_packageRecordsByName[pCurrentPackageRecord->name] = pCurrentPackageRecord;
pCurrentPackageRecord.reset();
}

Expand Down Expand Up @@ -1087,7 +1087,7 @@ namespace Odb::Lib::FileModel::Design
}

m_netRecords.push_back(pCurrentNetRecord);
m_netRecordsByName[pCurrentNetRecord->name] = pCurrentNetRecord;
//m_netRecordsByName[pCurrentNetRecord->name] = pCurrentNetRecord;
pCurrentNetRecord.reset();
}
else if (pCurrentPackageRecord != nullptr)
Expand All @@ -1107,7 +1107,7 @@ namespace Odb::Lib::FileModel::Design

// finish up any current (previous) package records
m_packageRecords.push_back(pCurrentPackageRecord);
m_packageRecordsByName[pCurrentPackageRecord->name] = pCurrentPackageRecord;
//m_packageRecordsByName[pCurrentPackageRecord->name] = pCurrentPackageRecord;
pCurrentPackageRecord.reset();
}
else if (pCurrentFeatureGroupRecord != nullptr)
Expand Down Expand Up @@ -1507,7 +1507,7 @@ namespace Odb::Lib::FileModel::Design
}

m_netRecords.push_back(pCurrentNetRecord);
m_netRecordsByName[pCurrentNetRecord->name] = pCurrentNetRecord;
//m_netRecordsByName[pCurrentNetRecord->name] = pCurrentNetRecord;
pCurrentNetRecord.reset();
}
else if (pCurrentPackageRecord != nullptr)
Expand All @@ -1527,7 +1527,7 @@ namespace Odb::Lib::FileModel::Design

// finish up any current (previous) package records
m_packageRecords.push_back(pCurrentPackageRecord);
m_packageRecordsByName[pCurrentPackageRecord->name] = pCurrentPackageRecord;
//m_packageRecordsByName[pCurrentPackageRecord->name] = pCurrentPackageRecord;
pCurrentPackageRecord.reset();
}
else if (pCurrentFeatureGroupRecord != nullptr)
Expand Down Expand Up @@ -1611,8 +1611,7 @@ namespace Odb::Lib::FileModel::Design
{
auto pPinRecord = std::make_shared<PinRecord>();
pPinRecord->from_protobuf(pinRecordMessage);
m_pinRecords.push_back(pPinRecord);
m_pinRecordsByName[pPinRecord->name] = pPinRecord;
m_pinRecords.push_back(pPinRecord);
}

for (const auto& kvPinRecordMessage : message.pinrecordsbyname())
Expand Down
7 changes: 2 additions & 5 deletions OdbDesignLib/FileModel/Design/EdaDataFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,7 @@ namespace Odb::Lib::FileModel::Design

~NetRecord();

std::string name;
//std::string attributesIdString;
// TODO: store index of records
std::string name;
unsigned int index;

SubnetRecord::Vector m_subnetRecords;
Expand Down Expand Up @@ -245,8 +243,7 @@ namespace Odb::Lib::FileModel::Design
std::string name;
float pitch;
float xMin, yMin;
float xMax, yMax;
//std::string attributesIdString;
float xMax, yMax;
unsigned int index;

OutlineRecord::Vector m_outlineRecords;
Expand Down
2 changes: 1 addition & 1 deletion OdbDesignLib/FileModel/Design/FeaturesFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace Odb::Lib::FileModel::Design
}

std::filesystem::path featuresFilePath;
for (const std::string featuresFilename : filenames)
for (const std::string& featuresFilename : filenames)
{
loginfo("trying features file: [" + featuresFilename + "]...");

Expand Down
6 changes: 4 additions & 2 deletions OdbDesignLib/FileModel/Design/NetlistFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
namespace Odb::Lib::FileModel::Design
{
NetlistFile::NetlistFile(std::filesystem::path path)
: m_path(path), m_optimized(false), m_staggered(Staggered::Unknown)
: m_path(path)
, m_optimized(false)
, m_staggered(Staggered::Unknown)
{
}

Expand Down Expand Up @@ -219,7 +221,7 @@ namespace Odb::Lib::FileModel::Design
pNetRecord->serialNumber = unSerialNumber;
pNetRecord->netName = netName;
m_netRecords.push_back(pNetRecord);
m_netRecordsByName[pNetRecord->netName] = pNetRecord;
//m_netRecordsByName[pNetRecord->netName] = pNetRecord;
}
else // NetPointRecord (starts with an unsigned int, netNumber)
{
Expand Down
4 changes: 2 additions & 2 deletions OdbDesignLib/FileModel/Design/NetlistFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ namespace Odb::Lib::FileModel::Design
void from_protobuf(const Odb::Lib::Protobuf::NetlistFile::NetPointRecord& message) override;

typedef std::vector<std::shared_ptr<NetPointRecord>> Vector;
};
}; // NetPointRecord

enum class Staggered
{
Expand Down Expand Up @@ -111,5 +111,5 @@ namespace Odb::Lib::FileModel::Design
inline constexpr static const char* COMMENT_TOKEN = "#";
inline constexpr static const char* HEADER_TOKEN = "H";

};
}; // NetlistFile
}
8 changes: 6 additions & 2 deletions OdbDesignLib/OdbDesign.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
// include headers for linking to library

#include "FileModel/Design/FileArchive.h"
#include "ProductModel/Design.h"
#include "App/DesignCache.h"
#include "FileModel/parse_error.h"
#include "FileModel/invalid_odb_error.h"

#include "ProductModel/Design.h"

#include "App/DesignCache.h"
#include "App/OdbAppBase.h"
#include "App/OdbServerAppBase.h"


Loading

0 comments on commit 1c98cab

Please sign in to comment.