Skip to content

Commit

Permalink
merge to main (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
nam20485 authored Oct 12, 2023
2 parents 792a3c4 + 37e1e34 commit 9f5bb00
Show file tree
Hide file tree
Showing 83 changed files with 10,027 additions and 565 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ PyOdbDesignServer/PyOdbDesignLib/
build/
/vcpkg_installed
/OdbDesignServer/designs/
/cmake-build-debug-visual-studio
Empty file added BUILD.md
Empty file.
12 changes: 11 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
cmake_minimum_required (VERSION 3.21)

# require C++0x17 compiler
set(MY_CXX_STANDARD 17)
set(MY_CXX_STANDARD 20)
set(CXX_STANDARD ${MY_CXX_STANDARD})
set(CMAKE_CXX_STANDARD ${MY_CXX_STANDARD})
set(CMAKE_CXX_STANDARD_REQUIRED True)

# required for SWIG python wrapper
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

## treat warnings as errors (https://cmake.org/cmake/help/latest/variable/CMAKE_COMPILE_WARNING_AS_ERROR.html#variable:CMAKE_COMPILE_WARNING_AS_ERROR)
Expand All @@ -22,6 +23,14 @@ endif()

project ("OdbDesign")

if (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 Down Expand Up @@ -51,6 +60,7 @@ add_subdirectory("Utils")
target_link_libraries(OdbDesignApp PUBLIC OdbDesign)
target_link_libraries(OdbDesignServer PUBLIC OdbDesign)

# link to Utils lib in all targets
target_link_libraries(OdbDesignApp PUBLIC Utils)
target_link_libraries(OdbDesignServer PUBLIC Utils)
target_link_libraries(OdbDesign PUBLIC Utils)
16 changes: 15 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,21 @@ RUN apt-get update && \
ninja-build \
python3-dev \
# mingw-w64 \
swig
swig \
build-essential \
git \
cmake \
zip \
unzip \
tar && \
rm -rf /var/lib/apt/lists/*

# install vcpkg
# /root/src/github/microsoft/vcpkg/scripts/buildsystems/vcpkg.cmake
WORKDIR /root/src/github/microsoft
RUN git clone https://github.com/Microsoft/vcpkg.git
WORKDIR /root/src/github/microsoft/vcpkg
RUN ./bootstrap-vcpkg.sh

# copy source
COPY . /src/OdbDesign
Expand Down
10 changes: 5 additions & 5 deletions OdbDesignApp/OdbDesignApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ bool TestRigidFlexDesign()
auto subnetType = pSubnetRecord->type;
if (subnetType == Odb::Lib::FileModel::Design::EdaDataFile::NetRecord::SubnetRecord::Type::Toeprint)
{
auto pViaSubnetRecord = std::dynamic_pointer_cast<Odb::Lib::FileModel::Design::EdaDataFile::NetRecord::ToeprintSubnetRecord>(pSubnetRecord);
auto viaType = pViaSubnetRecord->type;
if (viaType == Odb::Lib::FileModel::Design::EdaDataFile::NetRecord::ToeprintSubnetRecord::Type::Via)
{
//auto pToeprintSubnetRecord = pSubnetRecord;
//auto viaType = pToeprintSubnetRecord->type;
//if (viaType == Odb::Lib::FileModel::Design::EdaDataFile::NetRecord::ToeprintSubnetRecord::Type::Via)
//{

}
//}
}
}
}
Expand Down
61 changes: 0 additions & 61 deletions OdbDesignLib/ArchiveExtractor.cpp

This file was deleted.

28 changes: 0 additions & 28 deletions OdbDesignLib/ArchiveExtractor.h

This file was deleted.

52 changes: 28 additions & 24 deletions OdbDesignLib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
# 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" "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")
add_library(OdbDesign SHARED "odbdesign_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" "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" "OdbDesign.h" "DesignCache.h" "DesignCache.cpp" "win.h" "proto/edadatafile.pb.h" "proto/edadatafile.pb.cc" "IProtoBuffable.h" "crow_win.h" "OdbFile.h" "OdbFile.cpp" "OdbFileRecord.h" "OdbFileRecord.cpp" "IOdbServerApp.h" "IOdbServerApp.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,
# while we don't.
# state that anybody linking to us needs to include the current source dir, while we don't.
target_include_directories(OdbDesign
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>)

# Link to LibArchive
find_package(LibArchive REQUIRED)
target_include_directories(OdbDesign PRIVATE ${LibArchive_INCLUDE_DIRS})
target_link_libraries(OdbDesign PUBLIC ${LibArchive_LIBRARIES})
# Link to Protobuf
find_package(Protobuf CONFIG REQUIRED)
#protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS protoc/edadatafile.proto)
#target_link_libraries(OdbDesign PUBLIC protobuf::libprotoc protobuf::libprotobuf protobuf::libprotobuf-lite)
target_link_libraries(OdbDesign PUBLIC protobuf::libprotobuf)
# mark the generated Protofbuf C++ files as generated
#set_source_files_properties(${PROTO_SRC} ${PROTO_HDRS} PROPERTIES GENERATED TRUE)
# add the generated Protobuf C++ files to the target
#target_sources(OdbDesign PRIVATE ${PROTO_SRCS} ${PROTO_HDRS})

# Python extension module build settings
if (PYTHON_MODULE_BUILD)
Expand All @@ -25,23 +29,23 @@ if (PYTHON_MODULE_BUILD)
# PRE_BUILD
# COMMAND scripts/generate-python-module.ps1)

if (MSVC)
# make a copy of output library with name expected by Python module extensions
add_custom_command(TARGET OdbDesign
POST_BUILD
COMMAND ${CMAKE_COMMAND}
ARGS -E copy $<TARGET_FILE:OdbDesign> $<TARGET_FILE_DIR:OdbDesign>/_PyOdbDesignLib.pyd
COMMENT Copying to Python module extension
)
elseif(LINUX)
# make a copy of output library with name expected by Python module extensions
add_custom_command(TARGET OdbDesign
POST_BUILD
COMMAND ${CMAKE_COMMAND}
ARGS -E copy $<TARGET_FILE:OdbDesign> $<TARGET_FILE_DIR:OdbDesign>/_PyOdbDesignLib.so
COMMENT Copying to Python module extension
)
endif()
if (MSVC)
# make a copy of output library with name expected by Python module extensions
add_custom_command(TARGET OdbDesign
POST_BUILD
COMMAND ${CMAKE_COMMAND}
ARGS -E copy $<TARGET_FILE:OdbDesign> $<TARGET_FILE_DIR:OdbDesign>/_PyOdbDesignLib.pyd
COMMENT Copying to Python module extension
)
elseif(LINUX)
# make a copy of output library with name expected by Python module extensions
add_custom_command(TARGET OdbDesign
POST_BUILD
COMMAND ${CMAKE_COMMAND}
ARGS -E copy $<TARGET_FILE:OdbDesign> $<TARGET_FILE_DIR:OdbDesign>/_PyOdbDesignLib.so
COMMENT Copying to Python module extension
)
endif()

target_sources(OdbDesign PRIVATE "OdbDesignLib_wrap.cxx")

Expand Down
4 changes: 2 additions & 2 deletions OdbDesignLib/Component.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "export.h"
#include "odbdesign_export.h"
#include <string>
#include <vector>
#include <map>
Expand All @@ -12,7 +12,7 @@

namespace Odb::Lib::ProductModel
{
class DECLSPEC Component
class ODBDESIGN_EXPORT Component
{
public:
Component(std::string refDes, std::string partName, std::shared_ptr<Package> pPackage, unsigned int index, BoardSide side);
Expand Down
2 changes: 1 addition & 1 deletion OdbDesignLib/ComponentLayerDirectory.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Odb::Lib::FileModel::Design
{
class DECLSPEC ComponentLayerDirectory : public LayerDirectory
class ODBDESIGN_EXPORT ComponentLayerDirectory : public LayerDirectory
{
public:
ComponentLayerDirectory(std::filesystem::path path, BoardSide side);
Expand Down
1 change: 0 additions & 1 deletion OdbDesignLib/CrowReturnable.cpp

This file was deleted.

19 changes: 0 additions & 19 deletions OdbDesignLib/CrowReturnable.h

This file was deleted.

4 changes: 2 additions & 2 deletions OdbDesignLib/Design.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "export.h"
#include "odbdesign_export.h"
#include <string>
#include <memory>
#include "Net.h"
Expand All @@ -13,7 +13,7 @@

namespace Odb::Lib::ProductModel
{
class DECLSPEC Design
class ODBDESIGN_EXPORT Design
{
public:
Design();
Expand Down
11 changes: 9 additions & 2 deletions OdbDesignLib/DesignCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ namespace Odb::Lib

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

std::shared_ptr<ProductModel::Design> DesignCache::GetDesign(std::string designName)
Expand All @@ -34,6 +33,8 @@ namespace Odb::Lib

std::shared_ptr<FileModel::Design::FileArchive> DesignCache::GetFileArchive(std::string designName)
{
std::cout << std::format("Retrieving \"{}\" from cache... ", designName) << std::endl;

auto findIt = m_fileArchivesByName.find(designName);
if (findIt == m_fileArchivesByName.end())
{
Expand All @@ -44,6 +45,12 @@ namespace Odb::Lib
return m_fileArchivesByName[designName];
}

void DesignCache::Clear()
{
m_fileArchivesByName.clear();
m_designsByName.clear();
}

std::shared_ptr<ProductModel::Design> DesignCache::LoadDesign(std::string designName)
{
std::filesystem::path dir(m_directory);
Expand Down
6 changes: 4 additions & 2 deletions OdbDesignLib/DesignCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

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


namespace Odb::Lib
{
class DECLSPEC DesignCache
class ODBDESIGN_EXPORT DesignCache
{
public:
DesignCache();
Expand All @@ -16,6 +16,8 @@ namespace Odb::Lib

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

void Clear();

private:
std::string m_directory;
Expand Down
Loading

0 comments on commit 9f5bb00

Please sign in to comment.