Skip to content

Commit

Permalink
merge to main (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
nam20485 authored Oct 25, 2023
2 parents 505e084 + b446e8d commit 77064eb
Show file tree
Hide file tree
Showing 15 changed files with 3,123 additions and 120 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ jobs:
# preset: python-linux-release

steps:

- uses: actions/checkout@v3

- name: Checkout Repository
uses: actions/checkout@v3

# add problem matchers by compiler
- name: Add Problem Matchers
Expand Down Expand Up @@ -190,6 +191,9 @@ jobs:

steps:

- name: Checkout Repository
uses: actions/checkout@v3

# download the artifacts
- name: "Download artifacts"
uses: "actions/download-artifact@v2"
Expand All @@ -212,7 +216,7 @@ jobs:
mv ${{ github.workspace }}/artifacts/macos-12-artifacts/artifacts-macos-12.zip ${{ github.workspace }}/artifacts/OdbDesign-MacOS-x64.zip
# create a release
- name: "Create GH Release"
- name: "Create GitHub Release"
uses: "actions/github-script@v6"
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
Expand Down
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,4 @@ build/
ssl/
Testing/Temporary/
artifacts/
/.github/workflows/create-release.js
/scripts/compress-artifacts.ps1
/scripts/compress-artifacts.sh
doxygen/docs/
26 changes: 26 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,29 @@ add_subdirectory("OdbDesignLib")
add_subdirectory("OdbDesignServer")
add_subdirectory("Utils")
add_subdirectory("OdbDesignTests")

#
# Doxygen
#

# look for Doxygen package
find_package(Doxygen)

if (DOXYGEN_FOUND)
# set input and output files
set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/doxygen/Doxyfile.in)
set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile.out)

# request to configure the file
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
message("Doxygen build started")

# Note: do not put "ALL" - this builds docs together with application EVERY TIME!
add_custom_target( docs
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM )
else (DOXYGEN_FOUND)
message("Doxygen need to be installed to generate the doxygen documentation")
endif (DOXYGEN_FOUND)
6 changes: 3 additions & 3 deletions Dockerfile_OdbDesignServer
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ RUN apt-get update && \
tar \
pkg-config \
mono-complete \
&& \
&& \
rm -rf /var/lib/apt/lists/*

# install vcpkg
Expand Down Expand Up @@ -68,8 +68,8 @@ RUN cmake --build --preset linux-release
# much smaller runtime image
FROM debian:bookworm-20231009-slim AS run
LABEL org.opencontainers.image.source=https://github.com/nam20485/OdbDesign
LABEL org.opencontainers.image.authors="https://github.com/nam20485"
LABEL org.opencontainers.image.description = "The OdbDesign Docker image runs the OdbDesignServer REST API server executable, listening on port 8888."
LABEL org.opencontainers.image.authors=https://github.com/nam20485
LABEL org.opencontainers.image.description="The OdbDesign Docker image runs the OdbDesignServer REST API server executable, listening on port 8888."
LABEL org.opencontainers.image.licenses=MIT
EXPOSE 8888

Expand Down
5 changes: 2 additions & 3 deletions OdbDesignLib/Design.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ namespace Odb::Lib::ProductModel
std::string m_productModel;
std::string m_name;

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

Net::Vector m_nets;
Expand All @@ -49,8 +48,8 @@ namespace Odb::Lib::ProductModel
bool BuildPackages();
bool BuildParts();
bool BuildComponents();
bool BuildLayerComponents(std::shared_ptr<Odb::Lib::FileModel::Design::ComponentLayerDirectory>& pTopComponentsLayerDir);
bool BuildLayerParts(std::shared_ptr<Odb::Lib::FileModel::Design::ComponentLayerDirectory>& pTopComponentsLayerDir);
bool BuildLayerComponents(std::shared_ptr<Odb::Lib::FileModel::Design::ComponentLayerDirectory>& pComponentsLayerDir);
bool BuildLayerParts(std::shared_ptr<Odb::Lib::FileModel::Design::ComponentLayerDirectory>& pComponentsLayerDir);
bool BuildPlacements();
bool BuildLayerPlacements(std::shared_ptr<Odb::Lib::FileModel::Design::ComponentLayerDirectory>& pTopComponentsLayerDir);

Expand Down
45 changes: 28 additions & 17 deletions OdbDesignLib/DesignCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ namespace Odb::Lib
std::vector<std::string> loadedDesigns;
for (const auto& kv : m_designsByName)
{
loadedDesigns.push_back(kv.second->GetFileModel()->GetFilename());
loadedDesigns.push_back(kv.second->GetFileModel()->GetProductName());
}
return loadedDesigns;
}
Expand All @@ -73,12 +73,12 @@ namespace Odb::Lib
std::vector<std::string> loadedFileArchives;
for (const auto& kv : m_fileArchivesByName)
{
loadedFileArchives.push_back(kv.second->GetFilename());
loadedFileArchives.push_back(kv.second->GetProductName());
}
return loadedFileArchives;
}

std::vector<std::string> DesignCache::getUnloadedNames(const std::string& filter) const
std::vector<std::string> DesignCache::getUnloadedDesignNames(const std::string& filter) const
{
std::vector<std::string> unloadedNames;

Expand All @@ -87,7 +87,7 @@ namespace Odb::Lib
{
if (entry.is_regular_file())
{
unloadedNames.push_back(entry.path().filename().string());
unloadedNames.push_back(entry.path().stem().string());
}
}

Expand All @@ -107,28 +107,38 @@ namespace Odb::Lib

std::shared_ptr<ProductModel::Design> DesignCache::LoadDesign(const std::string& designName)
{
// no FileArchive with the same name is loaded, so load the Design from file
std::filesystem::path dir(m_directory);

for (const auto& entry : std::filesystem::directory_iterator(dir))
try
{
if (entry.is_regular_file())
// no FileArchive with the same name is loaded, so load the Design from file
std::filesystem::path dir(m_directory);

for (const auto& entry : std::filesystem::directory_iterator(dir))
{
if (entry.path().stem() == designName)
if (entry.is_regular_file())
{
auto pFileModel = GetFileArchive(designName);
if (pFileModel != nullptr)
if (entry.path().stem() == designName)
{
auto pDesign = std::make_shared<ProductModel::Design>();
if (pDesign->Build(pFileModel))
auto pFileModel = GetFileArchive(designName);
if (pFileModel != nullptr)
{
m_designsByName.emplace(designName, pDesign);
return pDesign;
auto pDesign = std::make_shared<ProductModel::Design>();
if (pDesign->Build(pFileModel))
{
// overwrite any existing design with the same name
m_designsByName[pFileModel->GetProductName()] = pDesign;
return pDesign;
}
}
}
}
}
}
catch (std::filesystem::filesystem_error& fe)
{
logexception(fe);
// re-throw it so we get a HTTP 500 response to the client
throw fe;
}

return nullptr;
}
Expand All @@ -150,7 +160,8 @@ namespace Odb::Lib
auto pFileArchive = std::make_shared<FileModel::Design::FileArchive>(entry.path().string());
if (pFileArchive->ParseFileModel())
{
m_fileArchivesByName.emplace(designName, pFileArchive);
// overwrite any existing file archive with the same name
m_fileArchivesByName[pFileArchive->GetProductName()] = pFileArchive;
return pFileArchive;
}
}
Expand Down
2 changes: 1 addition & 1 deletion OdbDesignLib/DesignCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace Odb::Lib

std::vector<std::string> getLoadedDesignNames(const std::string& filter = "") const;
std::vector<std::string> getLoadedFileArchiveNames(const std::string& filter = "") const;
std::vector<std::string> getUnloadedNames(const std::string& filter = "") const;
std::vector<std::string> getUnloadedDesignNames(const std::string& filter = "") const;

bool isQueryValid(const std::string& query) const;

Expand Down
2 changes: 1 addition & 1 deletion OdbDesignLib/FileArchive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ namespace Odb::Lib::FileModel::Design
else if (!std::filesystem::is_directory(path)) return false;

// TODO: this should use path.stem() instead of path.filename()
m_productName = path.filename().string();
m_productName = path.stem().string();

auto stepsPath = path / "steps";
for (auto& d : std::filesystem::directory_iterator(stepsPath))
Expand Down
Loading

0 comments on commit 77064eb

Please sign in to comment.