Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge to main #40

Merged
merged 32 commits into from
Oct 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
0d5e2d8
add some RouteControllers to encapsulate routing
nam20485 Oct 7, 2023
58d6314
add CrowReturnable class
nam20485 Oct 7, 2023
48dbc8e
refactor extraction code into ExtractDesignPath() for better encapsul…
nam20485 Oct 7, 2023
b813a7b
refactor Build(...) methods to remove unncessary overload
nam20485 Oct 7, 2023
3986cc8
implement cache for holding and lazy-loading on-demand FileArchives a…
nam20485 Oct 7, 2023
3e990ec
first stab at a EdaData controller
nam20485 Oct 7, 2023
0c73160
refactor main
nam20485 Oct 7, 2023
5d6ddf5
add template for /helloworld route
nam20485 Oct 7, 2023
e57ee4a
move linking to Crow library from OdbDesign lib to OdbDesignServer app
nam20485 Oct 7, 2023
2fed6cf
rename enums.h to BoardSide.h since it only has one enum in it
nam20485 Oct 7, 2023
fd1c071
move ExitCode.h to Utils so its accessible by both app targets
nam20485 Oct 7, 2023
f6ae6cd
rename enums.h to BoardSide.h (missed entry in CMakeLists.txt)
nam20485 Oct 7, 2023
dd8e0eb
add Utils library target and link to in all three other targets
nam20485 Oct 7, 2023
cfffbec
export DesignCache class
nam20485 Oct 7, 2023
e0395dd
refactor code in main into a OdbDesignServerApp class
nam20485 Oct 7, 2023
9870045
move file into folder
nam20485 Oct 7, 2023
1b6e451
put ExitCode into Utils namespace
nam20485 Oct 7, 2023
d2a7f1b
comment
nam20485 Oct 7, 2023
2d44031
remove detritus
nam20485 Oct 7, 2023
97ecc9c
add threaded queue loop classes
nam20485 Oct 7, 2023
cd5e222
add custom POST_BUILD command to copy designs/ dir to build output dir
nam20485 Oct 7, 2023
2d1028d
ignore designs/ dir
nam20485 Oct 7, 2023
07a57ea
add cpp.hint file to source control
nam20485 Oct 7, 2023
34ec2d7
change namespace to just Utils
nam20485 Oct 7, 2023
0507280
add to namespace
nam20485 Oct 7, 2023
98dad4d
add empty Logger class
nam20485 Oct 7, 2023
f0a70c2
include header witgh required WINNT definition
nam20485 Oct 7, 2023
248b8ad
basic implementation of Logger
nam20485 Oct 7, 2023
7309607
format log messages better
nam20485 Oct 7, 2023
271ee1b
Update README.md
nam20485 Oct 7, 2023
10e71d8
Update README.md
nam20485 Oct 7, 2023
17356df
Merge branch 'development' of github.com:nam20485/OdbDesign into deve…
nam20485 Oct 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ PyOdbDesignServer/PyOdbDesignLib/
/cmake-build-debug
build/
/vcpkg_installed
/OdbDesignServer/designs/
14 changes: 5 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ set(MY_CXX_STANDARD 17)
set(CXX_STANDARD ${MY_CXX_STANDARD})
set(CMAKE_CXX_STANDARD ${MY_CXX_STANDARD})
set(CMAKE_CXX_STANDARD_REQUIRED True)
#set(CXX_STANDARD_REQUIRED True)

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

Expand All @@ -23,14 +22,6 @@ endif()

project ("OdbDesign")

#if (false AND MSVC)
# # control where the static and shared libraries are built so that on windows
# # we don't need to tinker with the path to run the executable
# set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}")
# set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}")
# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}")
#endif()

# increase warnings in a compiler-specific manner
if (MSVC)
# warning level 4
Expand All @@ -54,7 +45,12 @@ endif()
add_subdirectory("OdbDesignLib")
add_subdirectory("OdbDesignApp")
add_subdirectory("OdbDesignServer")
add_subdirectory("Utils")

# link to OdbDesign library in both executable targets
target_link_libraries(OdbDesignApp PUBLIC OdbDesign)
target_link_libraries(OdbDesignServer PUBLIC OdbDesign)

target_link_libraries(OdbDesignApp PUBLIC Utils)
target_link_libraries(OdbDesignServer PUBLIC Utils)
target_link_libraries(OdbDesign PUBLIC Utils)
2 changes: 1 addition & 1 deletion OdbDesignApp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
#

# Add source to this project's executable.
add_executable (OdbDesignApp "OdbDesignApp.cpp" "OdbDesignApp.h" "ExitCode.h")
add_executable (OdbDesignApp "OdbDesignApp.cpp" "OdbDesignApp.h" )

# TODO: Add tests and install targets if needed.
7 changes: 0 additions & 7 deletions OdbDesignApp/ExitCode.h

This file was deleted.

6 changes: 3 additions & 3 deletions OdbDesignApp/OdbDesignApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ int main()
auto success = TestRigidFlexDesign();
if (!success)
{
return (int) ExitCode::UnknownError;
return (int) Utils::ExitCode::UnknownError;
}

//std::cout << "success!" << std::endl;

success = TestSampleDesign();
if (!success)
{
return (int) ExitCode::UnknownError;
return (int) Utils::ExitCode::UnknownError;
}

//std::cout << "success!" << std::endl;

return (int) ExitCode::Success;
return (int) Utils::ExitCode::Success;
}

bool TestSampleDesign()
Expand Down
File renamed without changes.
12 changes: 3 additions & 9 deletions OdbDesignLib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# CMakeList.txt : CMake project for OdbDesignLib
#

add_library(OdbDesign SHARED "export.h" "ComponentLayerDirectory.cpp" "ComponentLayerDirectory.h" "EdaDataFile.cpp" "EdaDataFile.h" "LayerDirectory.cpp" "LayerDirectory.h" "NetlistFile.cpp" "NetlistFile.h" "FileArchive.cpp" "FileArchive.h" "StepDirectory.cpp" "StepDirectory.h" "string_trim.h" "macros.h" "Net.h" "Net.cpp" "Component.h" "Component.cpp" "Pin.h" "Pin.cpp" "PinConnection.h" "PinConnection.cpp" "Package.h" "Package.cpp" "Part.h" "Part.cpp" "Via.h" "Via.cpp" "Design.h" "Design.cpp" "enums.h" "string_trim.cpp" "ArchiveExtractor.h" "ArchiveExtractor.cpp" "libarchive_extract.h" "libarchive_extract.cpp" "OdbDesign.h")
add_library(OdbDesign SHARED "export.h" "ComponentLayerDirectory.cpp" "ComponentLayerDirectory.h" "EdaDataFile.cpp" "EdaDataFile.h" "LayerDirectory.cpp" "LayerDirectory.h" "NetlistFile.cpp" "NetlistFile.h" "FileArchive.cpp" "FileArchive.h" "StepDirectory.cpp" "StepDirectory.h" "string_trim.h" "macros.h" "Net.h" "Net.cpp" "Component.h" "Component.cpp" "Pin.h" "Pin.cpp" "PinConnection.h" "PinConnection.cpp" "Package.h" "Package.cpp" "Part.h" "Part.cpp" "Via.h" "Via.cpp" "Design.h" "Design.cpp" "BoardSide.h" "string_trim.cpp" "ArchiveExtractor.h" "ArchiveExtractor.cpp" "libarchive_extract.h" "libarchive_extract.cpp" "OdbDesign.h" "DesignCache.h" "DesignCache.cpp" "CrowReturnable.h" "CrowReturnable.cpp")

# required for SWIG
set_property(TARGET OdbDesign PROPERTY POSITION_INDEPENDENT_CODE ON)

# state that anybody linking to us needs to include the current source dir,
Expand All @@ -16,14 +18,6 @@ find_package(LibArchive REQUIRED)
target_include_directories(OdbDesign PRIVATE ${LibArchive_INCLUDE_DIRS})
target_link_libraries(OdbDesign PUBLIC ${LibArchive_LIBRARIES})

# link to Crow
#ADD_DEFINITIONS ("-DCROW_ENABLE_SSL")
#set(CROW_FEATURES ssl compression)
#set(CROW_FEATURES "ssl;compression")
find_package(Crow REQUIRED)
#target_include_directories(OdbDesign PRIVATE Crow::Crow)
target_link_libraries(OdbDesign PUBLIC Crow::Crow)

# Python extension module build settings
if (PYTHON_MODULE_BUILD)
# # run swig to generate wrapper file
Expand Down
2 changes: 1 addition & 1 deletion OdbDesignLib/Component.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <memory>
#include "Pin.h"
#include "Package.h"
#include "enums.h"
#include "BoardSide.h"


namespace Odb::Lib::ProductModel
Expand Down
2 changes: 1 addition & 1 deletion OdbDesignLib/ComponentLayerDirectory.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "LayerDirectory.h"
#include <vector>
#include <string>
#include "enums.h"
#include "BoardSide.h"


namespace Odb::Lib::FileModel::Design
Expand Down
1 change: 1 addition & 0 deletions OdbDesignLib/CrowReturnable.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "CrowReturnable.h"
19 changes: 19 additions & 0 deletions OdbDesignLib/CrowReturnable.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#pragma once

#include "crow.h"


class CrowReturnable : public crow::returnable
{
CrowReturnable()
: returnable("text/plain")
{}

//
virtual std::string as_string() const = 0;

std::string dump() const override
{
return this->as_string();
}
};
14 changes: 5 additions & 9 deletions OdbDesignLib/Design.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ namespace Odb::Lib::ProductModel
{
}

bool Design::Build(std::string designDirectory)
bool Design::Build(std::string path)
{
auto pFileModel = std::make_shared<FileModel::Design::FileArchive>(designDirectory);
auto pFileModel = std::make_shared<FileModel::Design::FileArchive>(path);
if (pFileModel->ParseFileModel())
{
return Build(pFileModel);
Expand All @@ -22,14 +22,10 @@ namespace Odb::Lib::ProductModel
}

bool Design::Build(std::shared_ptr<FileModel::Design::FileArchive> pFileModel)
{
m_pFileModel = pFileModel;
return Build();
}
{
if (pFileModel == nullptr) return false;

bool Design::Build()
{
if (m_pFileModel == nullptr) return false;
m_pFileModel = pFileModel;

if (! BuildNets()) return false;
if (! BuildPackages()) return false;
Expand Down
12 changes: 7 additions & 5 deletions OdbDesignLib/Design.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@ namespace Odb::Lib::ProductModel
Design();
~Design();

bool Build(std::string designDirectory);
bool Build(std::shared_ptr<FileModel::Design::FileArchive> pFileModel);
bool Build(std::string path);
bool Build(std::shared_ptr<FileModel::Design::FileArchive> pFileModel);

typedef std::vector<std::shared_ptr<Design>> Vector;
typedef std::map<std::string, std::shared_ptr<Design>> StringMap;

private:
std::string m_productModel;
std::string m_name;

std::string m_designDirectory;
std::string m_path;
std::shared_ptr<FileModel::Design::FileArchive> m_pFileModel;

Net::Vector m_nets;
Expand All @@ -39,8 +42,7 @@ namespace Odb::Lib::ProductModel
Component::StringMap m_componentsByName;

Part::StringMap m_partsByName;

bool Build();

bool BuildNets();
bool BuildPackages();
bool BuildParts();
Expand Down
92 changes: 92 additions & 0 deletions OdbDesignLib/DesignCache.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#include "DesignCache.h"
#include <filesystem>


namespace Odb::Lib
{
DesignCache::DesignCache()
: DesignCache(".")
{
}

DesignCache::DesignCache(std::string directory) :
m_directory(directory)
{
}

DesignCache::~DesignCache()
{
m_fileArchivesByName.clear();
m_designsByName.clear();
}

std::shared_ptr<ProductModel::Design> DesignCache::GetDesign(std::string designName)
{
auto findIt = m_designsByName.find(designName);
if (findIt == m_designsByName.end())
{
auto pDesign = LoadDesign(designName);
return pDesign;
}

return m_designsByName[designName];
}

std::shared_ptr<FileModel::Design::FileArchive> DesignCache::GetFileArchive(std::string designName)
{
auto findIt = m_fileArchivesByName.find(designName);
if (findIt == m_fileArchivesByName.end())
{
auto pFileArchive = LoadFileArchive(designName);
return pFileArchive;
}

return m_fileArchivesByName[designName];
}

std::shared_ptr<ProductModel::Design> DesignCache::LoadDesign(std::string designName)
{
std::filesystem::path dir(m_directory);

for (const auto& entry : std::filesystem::directory_iterator(dir))
{
if (entry.is_regular_file())
{
if (entry.path().stem() == designName)
{
auto pDesign = std::make_shared<ProductModel::Design>();
if (pDesign->Build(entry.path().string()))
{
m_designsByName.emplace(designName, pDesign);
return pDesign;
}
}
}
}

return nullptr;
}

std::shared_ptr<FileModel::Design::FileArchive> DesignCache::LoadFileArchive(std::string designName)
{
std::filesystem::path dir(m_directory);

for (const auto& entry : std::filesystem::directory_iterator(dir))
{
if (entry.is_regular_file())
{
if (entry.path().stem() == designName)
{
auto pFileArchive = std::make_shared<FileModel::Design::FileArchive>(entry.path().string());
if (pFileArchive->ParseFileModel())
{
m_fileArchivesByName.emplace(designName, pFileArchive);
return pFileArchive;
}
}
}
}

return nullptr;
}
}
30 changes: 30 additions & 0 deletions OdbDesignLib/DesignCache.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#pragma once

#include "FileArchive.h"
#include "Design.h"
#include "export.h"


namespace Odb::Lib
{
class DECLSPEC DesignCache
{
public:
DesignCache();
DesignCache(std::string directory);
~DesignCache();

std::shared_ptr<ProductModel::Design> GetDesign(std::string designName);
std::shared_ptr<FileModel::Design::FileArchive> GetFileArchive(std::string designName);

private:
std::string m_directory;

FileModel::Design::FileArchive::StringMap m_fileArchivesByName;
ProductModel::Design::StringMap m_designsByName;

std::shared_ptr<ProductModel::Design> LoadDesign(std::string designName);
std::shared_ptr<FileModel::Design::FileArchive> LoadFileArchive(std::string designName);

};
}
2 changes: 1 addition & 1 deletion OdbDesignLib/EdaDataFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <fstream>
#include <sstream>
#include "string_trim.h"
#include "enums.h"
#include "BoardSide.h"


namespace Odb::Lib::FileModel::Design
Expand Down
2 changes: 1 addition & 1 deletion OdbDesignLib/EdaDataFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <vector>
#include <map>
#include "export.h"
#include "enums.h"
#include "BoardSide.h"


namespace Odb::Lib::FileModel::Design
Expand Down
Loading
Loading