Skip to content

Commit

Permalink
Merge branch 'development' into dependabot/docker/debian-bookworm-202…
Browse files Browse the repository at this point in the history
…40722-slim
  • Loading branch information
nam20485 authored Jan 18, 2025
2 parents 5fe1e67 + a87a2f8 commit 5076d87
Show file tree
Hide file tree
Showing 172 changed files with 41,678 additions and 35,927 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- os: ubuntu-22.04
preset: linux-release
# MacOS x64 Release
- os: macos-12
- os: macos-14
preset: macos-release
# Linux mingw x64 Release
# - os: ubuntu-22.04
Expand Down Expand Up @@ -164,6 +164,7 @@ jobs:
id: cmake-test
env:
ODB_TEST_DATA_DIR: ${{github.workspace}}/OdbDesignTestData/TEST_DATA
ODB_TEST_ENVIRONMENT_VARIABLE: ${{vars.ODB_TEST_ENVIRONMENT_VARIABLE}}
run: ctest --test-dir ./out/build/${{matrix.preset}}/OdbDesignTests --output-log ${{github.workspace}}/testlog.txt --output-junit ${{github.workspace}}/testlog.xml --output-on-failure
# let the report step fail the job if it finds failed tests...
continue-on-error: true
Expand Down Expand Up @@ -194,7 +195,7 @@ jobs:
zip -r ./artifacts-${{matrix.os}}.zip ./*.so ./OdbDesignServer
- name: Compress Artifacts (MacOS)
if: matrix.os == 'macos-12'
if: matrix.os == 'macos-14'
run: |
mkdir ${{env.ARTIFACTS_DIR}}
cp ./out/build/${{matrix.preset}}/OdbDesignLib/*.dylib ${{env.ARTIFACTS_DIR}}
Expand Down
8 changes: 5 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ set(CMAKE_CXX_STANDARD ${MY_CXX_STANDARD})
set(CMAKE_CXX_STANDARD_REQUIRED True)

# only use ccache locally, i.e. not in CI
if (NOT DEFINED ENV{CI})
#if (NOT DEFINED ENV{CI})
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_EXE}")
endif()
#endif()

#
# GoogleTest support
Expand All @@ -28,6 +28,8 @@ FetchContent_Declare(
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)

enable_testing()

# Enable Hot Reload for MSVC compilers if supported.
if (POLICY CMP0141)
cmake_policy(SET CMP0141 NEW)
Expand Down Expand Up @@ -67,7 +69,7 @@ endif()

# Include sub-projects.
add_subdirectory("OdbDesignLib")
#add_subdirectory("OdbDesignApp")
add_subdirectory("OdbDesignApp")
add_subdirectory("OdbDesignServer")
add_subdirectory("Utils")
add_subdirectory("OdbDesignTests")
20 changes: 18 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ RUN apt-get update && \
tar \
pkg-config \
mono-complete \
linux-libc-dev \
linux-libc-dev \
python3 \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# install vcpkg
Expand Down Expand Up @@ -71,14 +73,28 @@ FROM --platform=$BUILDPLATFORM debian:bookworm-20240722-slim@sha256:5f7d5664eae4
# ARG ODBDESIGN_SERVER_REQUEST_PASSWORD=""
LABEL org.opencontainers.image.source=https://github.com/nam20485/OdbDesign \
org.opencontainers.image.authors=https://github.com/nam20485 \
org.opencontainers.image.description="A free open source cross-platform C++ library for parsing ODB++ Design archives and accessing their data. Exposed via a REST API and packaged inside of a Docker image. The OdbDesign Docker image runs the OdbDesignServer REST API server executable, listening on port 8888." \
org.opencontainers.image.description="A free open source cross-platform C++ library for parsing ODB++ Design archives and accessing their data. Exposed via a REST API packaged inside of a Docker image. The OdbDesign Docker image runs the OdbDesignServer REST API server executable, listening on port 8888." \
org.opencontainers.image.licenses=MIT \
org.opencontainers.image.url=https://nam20485.github.io/OdbDesign \
org.opencontainers.image.documentation=https://github.com/nam20485/OdbDesign?tab=readme-ov-file \
org.opencontainers.image.title="OdbDesign Server"

EXPOSE 8888

# install dependencies (7z command)
RUN apt-get update && \
apt-get install -y -q --no-install-recommends \
curl \
apt-transport-https \
ca-certificates \
p7zip-full \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# test 7z install
RUN 7z -h

RUN mkdir --parents /OdbDesign/bin
WORKDIR /OdbDesign

Expand Down
9 changes: 9 additions & 0 deletions OdbDesignApp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,13 @@
# Add source to this project's executable.
add_executable (OdbDesignApp "OdbDesignApp.cpp" "OdbDesignApp.h" )

## PCH
#if (NOT DEFINED ENV{CI})
file (GLOB_RECURSE ODBDESIGN_APP_HEADER_FILES "*.h")
target_precompile_headers(OdbDesignApp PRIVATE ${ODBDESIGN_APP_HEADER_FILES})
#endif()

# link to OdbDesign library
target_link_libraries(OdbDesignApp PRIVATE OdbDesign)

# TODO: Add tests and install targets if needed.
17 changes: 8 additions & 9 deletions OdbDesignApp/OdbDesignApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include "macros.h"
#include "ExitCode.h"
#include <iostream>
#include <FileModel/Design/LayerDirectory.h>
#include <FileModel/Design/EdaDataFile.h>


bool TestRigidFlexDesign();
Expand Down Expand Up @@ -39,7 +41,7 @@ int main()
bool TestSampleDesign()
{
std::string sampleDesignPath;
if (Odb::Lib::IsMsvc())
if (Utils::IsWindows())
{
sampleDesignPath = R"(C:\Users\nmill\OneDrive\Documents\ODB++\Samples\sample_design.tgz)";
}
Expand All @@ -63,7 +65,7 @@ bool TestSampleDesign()
bool TestRigidFlexDesign()
{
std::string rigidFlexDesignPath;
if (Odb::Lib::IsMsvc())
if (Utils::IsWindows())
{
rigidFlexDesignPath = R"(C:\Users\nmill\OneDrive\Documents\ODB++\Samples\designodb_rigidflex.tgz)";
}
Expand Down Expand Up @@ -119,7 +121,7 @@ bool TestRigidFlexDesign()

// layers
auto& layersByName = pStep->GetLayersByName();
auto layerFind = layersByName.find(Odb::Lib::FileModel::Design::LayerDirectory::TOP_COMPONENTS_LAYER_NAME);
auto layerFind = layersByName.find(Odb::Lib::FileModel::Design::ComponentsFile::TOP_COMPONENTS_LAYER_NAME);
if (layerFind != layersByName.end())
{
auto& pLayer = layerFind->second;
Expand All @@ -133,13 +135,10 @@ bool TestRigidFlexDesign()
{
auto& pNetlist = netlistFind->second;
auto netlistName = pNetlist->GetName();
auto& netNames = pNetlist->GetNetNames();
for (auto& netName : netNames)
auto& netRecords = pNetlist->GetNetRecords();
for (auto& pNetRecord : netRecords)

Check warning on line 139 in OdbDesignApp/OdbDesignApp.cpp

View workflow job for this annotation

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

unused variable ‘pNetRecord’ [-Wunused-variable]
{
if (netName == "")
{

}

}
}
}
Expand Down
26 changes: 12 additions & 14 deletions OdbDesignLib/App/BasicRequestAuthentication.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#include "BasicRequestAuthentication.h"
#include <string>
#include "macros.h"

using namespace Utils;
#include <cstdlib>
#include "RequestAuthenticationBase.h"

namespace Odb::Lib::App
{
Expand All @@ -17,21 +16,20 @@ namespace Odb::Lib::App
if (resp.code != crow::status::OK)
{
const auto& authHeader = req.get_header_value(AUTHORIZATION_HEADER_NAME);
if (authHeader.empty()) return crow::response(401, "Unauthorized");
if (authHeader.empty()) return crow::response(crow::status::UNAUTHORIZED, "Unauthorized");

auto authValue = authHeader.substr(6);
if (authValue.empty()) return crow::response(401, "Unauthorized");
if (authValue.empty()) return crow::response(crow::status::UNAUTHORIZED, "Unauthorized");

auto authValueDecoded = crow::utility::base64decode(authValue, authValue.size());
if (authValueDecoded.empty()) return crow::response(401, "Unauthorized");
if (authValueDecoded.empty()) return crow::response(crow::status::UNAUTHORIZED, "Unauthorized");

auto seperatorPos = authValueDecoded.find(':');
if (seperatorPos == std::string::npos) return crow::response(401, "Unauthorized");
if (seperatorPos == std::string::npos) return crow::response(crow::status::UNAUTHORIZED, "Unauthorized");

auto username = authValueDecoded.substr(0, seperatorPos);
auto password = authValueDecoded.substr(seperatorPos + 1);

//if (! VerifyCredentials(username, password)) return crow::response(403, "Invalid username or password");
resp = VerifyCredentials(username, password);
}
return resp;
Expand All @@ -40,15 +38,15 @@ namespace Odb::Lib::App
crow::response BasicRequestAuthentication::VerifyCredentials(const std::string& username, const std::string& password)
{
// 500 - Internal Server Error
auto validUsername = std::getenv(USERNAME_ENV_NAME);
if (validUsername == nullptr) //return crow::response(500, "Failed retrieving credentials");
std::string validUsername = std::getenv(USERNAME_ENV_NAME);

Check warning on line 41 in OdbDesignLib/App/BasicRequestAuthentication.cpp

View workflow job for this annotation

GitHub Actions / CMake-Multi-Platform-Build (windows-2022, x64-release)

'getenv': This function or variable may be unsafe. Consider using _dupenv_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
if (validUsername.empty()) //return crow::response(500, "Failed retrieving credentials");
{
// default username if none supplied in environment
validUsername = "odb";
}

auto validPassword = std::getenv(PASSWORD_ENV_NAME);
if (validPassword == nullptr) //return crow::response(500, "Failed retrieving credentials");
std::string validPassword = std::getenv(PASSWORD_ENV_NAME);

Check warning on line 48 in OdbDesignLib/App/BasicRequestAuthentication.cpp

View workflow job for this annotation

GitHub Actions / CMake-Multi-Platform-Build (windows-2022, x64-release)

'getenv': This function or variable may be unsafe. Consider using _dupenv_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
if (validPassword.empty()) //return crow::response(500, "Failed retrieving credentials");
{
// default password if none supplied in environment
validPassword = "plusplus";
Expand All @@ -58,10 +56,10 @@ namespace Odb::Lib::App
if (username != validUsername ||
password != validPassword)
{
return crow::response(403, "Invalid username or password");
return crow::response(crow::status::FORBIDDEN, "Invalid username or password");
}

// 200 Authorized!
return crow::response(200, "Authorized");
return crow::response(crow::status::OK, "Authorized");
}
}
43 changes: 33 additions & 10 deletions OdbDesignLib/App/DesignCache.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
#include "DesignCache.h"
#include "DesignCache.h"
#include "ArchiveExtractor.h"
#include "DesignCache.h"
#include "Logger.h"
#include <exception>
#include <filesystem>
#include <utility>
#include <vector>
#include "../FileModel/Design/FileArchive.h"
#include <memory>
#include "../ProductModel/Design.h"
#include <iosfwd>
#include <string>
#include <type_traits>
#include <StringVector.h>

using namespace Utils;
using namespace std::filesystem;
Expand Down Expand Up @@ -62,12 +71,31 @@ namespace Odb::Lib::App
return m_fileArchivesByName[designName];
}

void DesignCache::AddFileArchive(const std::string& designName, std::shared_ptr<FileModel::Design::FileArchive> fileArchive, bool save)
{
m_fileArchivesByName[designName] = fileArchive;
if (save)
{
SaveFileArchive(designName);
}
}

bool DesignCache::SaveFileArchive(const std::string& designName)
{
auto fileArchive = GetFileArchive(designName);
if (fileArchive != nullptr)
{
return fileArchive->SaveFileModel(m_directory);
}
return false;
}

std::vector<std::string> DesignCache::getLoadedDesignNames(const std::string& filter) const
{
std::vector<std::string> loadedDesigns;
for (const auto& kv : m_designsByName)
{
loadedDesigns.push_back(kv.second->GetFileModel()->GetProductName());
loadedDesigns.push_back(kv.first);
}
return loadedDesigns;
}
Expand All @@ -77,7 +105,7 @@ namespace Odb::Lib::App
std::vector<std::string> loadedFileArchives;
for (const auto& kv : m_fileArchivesByName)
{
loadedFileArchives.push_back(kv.second->GetProductName());
loadedFileArchives.push_back(kv.first);
}
return loadedFileArchives;
}
Expand Down Expand Up @@ -229,11 +257,6 @@ namespace Odb::Lib::App
return m_directory;
}

//bool DesignCache::isQueryValid(const std::string& query) const
//{
// return false;
//}

void DesignCache::Clear()
{
m_fileArchivesByName.clear();
Expand All @@ -255,7 +278,7 @@ namespace Odb::Lib::App
if (pDesign->Build(pFileModel))
{
// overwrite any existing design with the same name
m_designsByName[pFileModel->GetProductName()] = pDesign;
m_designsByName[designName] = pDesign;
return pDesign;
}
else
Expand Down Expand Up @@ -294,7 +317,7 @@ namespace Odb::Lib::App
if (pFileArchive->ParseFileModel())
{
// overwrite any existing file archive with the same name
m_fileArchivesByName[pFileArchive->GetProductName()] = pFileArchive;
m_fileArchivesByName[designName] = pFileArchive;
return pFileArchive;
}
else
Expand Down
11 changes: 8 additions & 3 deletions OdbDesignLib/App/DesignCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
#include "../ProductModel/Design.h"
#include "../odbdesign_export.h"
#include "StringVector.h"
#include <memory>
#include <vector>
#include <string>


namespace Odb::Lib::App
Expand All @@ -17,6 +20,10 @@ namespace Odb::Lib::App
std::shared_ptr<ProductModel::Design> GetDesign(const std::string& designName);
std::shared_ptr<FileModel::Design::FileArchive> GetFileArchive(const std::string& designName);

void AddFileArchive(const std::string& designName, std::shared_ptr<FileModel::Design::FileArchive> fileArchive, bool save);

bool SaveFileArchive(const std::string& designName);

std::vector<std::string> getLoadedDesignNames(const std::string& filter = "") const;
std::vector<std::string> getLoadedFileArchiveNames(const std::string& filter = "") const;
std::vector<std::string> getUnloadedDesignNames(const std::string& filter = "") const;
Expand All @@ -27,9 +34,7 @@ namespace Odb::Lib::App
int loadDesigns(const Utils::StringVector& names);

void setDirectory(const std::string& directory);
const std::string& getDirectory() const;

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

void Clear();

Expand Down
Loading

0 comments on commit 5076d87

Please sign in to comment.