Skip to content

Commit

Permalink
Update directory structure of server/core
Browse files Browse the repository at this point in the history
  • Loading branch information
paxbun committed Oct 25, 2021
1 parent 76c5d25 commit f3ba21a
Show file tree
Hide file tree
Showing 15 changed files with 39 additions and 27 deletions.
5 changes: 3 additions & 2 deletions server/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fn main() -> Result<()> {
// Configure and build the CMake project
run_cmake("core", "laplace-eq-therm-server-core");
// Generate bindings from core/Lib.hh
generate_bindings("core/Lib.hh")
generate_bindings("./core/Public/leth/Lib.hh", "-I./core/Public")
}

#[cfg(target_os = "windows")]
Expand Down Expand Up @@ -78,10 +78,11 @@ fn run_cmake(source_dir: &str, target_name: &str) {
println!("cargo:rustc-link-lib=static={}", target_name);
}

fn generate_bindings(header_path: &str) -> Result<()> {
fn generate_bindings(header_path: &str, include_path: &str) -> Result<()> {
// generate bindings
let bindings = bindgen::Builder::default()
.header(header_path)
.clang_arg(include_path)
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
.generate_comments(false)
.generate()
Expand Down
17 changes: 11 additions & 6 deletions server/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@ set(CMAKE_CXX_EXTENSIONS OFF)

add_library(
laplace-eq-therm-server-core
${CMAKE_SOURCE_DIR}/Config.cc
${CMAKE_SOURCE_DIR}/Server.cc
${CMAKE_SOURCE_DIR}/Source/Config.cc
${CMAKE_SOURCE_DIR}/Source/Server.cc

# Spaces
${CMAKE_SOURCE_DIR}/MatrixSpace.cc
${CMAKE_SOURCE_DIR}/MonteCarloSpace.cc
${CMAKE_SOURCE_DIR}/SuccessiveOverRelaxationSpace.cc
${CMAKE_SOURCE_DIR}/Source/MatrixSpace.cc
${CMAKE_SOURCE_DIR}/Source/MonteCarloSpace.cc
${CMAKE_SOURCE_DIR}/Source/SuccessiveOverRelaxationSpace.cc
)

target_include_directories(
laplace-eq-therm-server-core
PUBLIC ${CMAKE_SOURCE_DIR}/Public
)

install(
Expand All @@ -46,7 +51,7 @@ if (ENABLE_LAPLACE_EQ_THERM_SERVER_CORE_TEST)
string(REGEX REPLACE "([^-])([A-Z][a-z]+)" "\\1-\\2" EXE_NAME "${EXE_NAME}")
string(TOLOWER "${EXE_NAME}" EXE_NAME)

add_executable(${EXE_NAME} "Tests/${FILE_NAME}.cc")
add_executable(${EXE_NAME} "${CMAKE_SOURCE_DIR}/Tests/${FILE_NAME}.cc")
target_link_libraries(${EXE_NAME} GTest::gtest_main laplace-eq-therm-server-core)
add_test(NAME ${TEST_NAME} COMMAND ${EXE_NAME})

Expand Down
File renamed without changes.
5 changes: 3 additions & 2 deletions server/core/Lib.hh → server/core/Public/leth/Lib.hh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
#ifndef LAPLACE_EQ_THERM_SERVER_CORE_LIB_HH
#define LAPLACE_EQ_THERM_SERVER_CORE_LIB_HH

#include "IntegerTypes.hh"
#include "Point.hh"
#include <leth/IntegerTypes.hh>
#include <leth/Point.hh>

#include <cstdint>

using ServerHandle = void*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
#ifndef LAPLACE_EQ_THERM_SERVER_CORE_MATRIX_SPACE_HH
#define LAPLACE_EQ_THERM_SERVER_CORE_MATRIX_SPACE_HH

#include "Space.hh"
#include <leth/Space.hh>

#include <random>
#include <vector>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
#ifndef LAPLACE_EQ_THERM_SERVER_CORE_MONTE_CARLO_SPACE_HH
#define LAPLACE_EQ_THERM_SERVER_CORE_MONTE_CARLO_SPACE_HH

#include "Space.hh"
#include <leth/Space.hh>

#include <random>

class MonteCarloSpace : public Space
Expand Down
File renamed without changes.
5 changes: 3 additions & 2 deletions server/core/Server.hh → server/core/Public/leth/Server.hh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
#ifndef LAPLACE_EQ_THERM_SERVER_CORE_SERVER_HH
#define LAPLACE_EQ_THERM_SERVER_CORE_SERVER_HH

#include "IntegerTypes.hh"
#include "Space.hh"
#include <leth/IntegerTypes.hh>
#include <leth/Space.hh>

#include <atomic>
#include <cstdint>
#include <deque>
Expand Down
5 changes: 3 additions & 2 deletions server/core/Space.hh → server/core/Public/leth/Space.hh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
#ifndef LAPLACE_EQ_THERM_SERVER_CORE_SPACE_HH
#define LAPLACE_EQ_THERM_SERVER_CORE_SPACE_HH

#include "IntegerTypes.hh"
#include "Point.hh"
#include <leth/IntegerTypes.hh>
#include <leth/Point.hh>

#include <cstddef>
#include <cstdint>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
#ifndef LAPLACE_EQ_THERM_SERVER_CORE_SUCCESSIVE_OVER_RELAXATION_SPACE_HH
#define LAPLACE_EQ_THERM_SERVER_CORE_SUCCESSIVE_OVER_RELAXATION_SPACE_HH

#include "MatrixSpace.hh"
#include <leth/MatrixSpace.hh>

#include <vector>

class SuccessiveOverRelaxationSpace : public MatrixSpace
Expand Down
8 changes: 4 additions & 4 deletions server/core/Config.cc → server/core/Source/Config.cc
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Copyright (c) 2021 Chanjung Kim. All rights reserved.
// Licensed under the MIT License.

#include "Lib.hh"
#include "Server.hh"
#include <leth/Lib.hh>
#include <leth/Server.hh>

// Spaces
#include "MonteCarloSpace.hh"
#include "SuccessiveOverRelaxationSpace.hh"
#include <leth/MonteCarloSpace.hh>
#include <leth/SuccessiveOverRelaxationSpace.hh>

ServerHandle leth_create(uint16_t width, uint16_t height) noexcept
try
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) 2021 Chanjung Kim. All rights reserved.
// Licensed under the MIT License.

#include "MatrixSpace.hh"
#include <leth/MatrixSpace.hh>

#include <limits>
#include <random>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) 2021 Chanjung Kim. All rights reserved.
// Licensed under the MIT License.

#include "MonteCarloSpace.hh"
#include <leth/MonteCarloSpace.hh>

#include <limits>
#include <random>
Expand Down
6 changes: 3 additions & 3 deletions server/core/Server.cc → server/core/Source/Server.cc
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright (c) 2021 Chanjung Kim. All rights reserved.
// Licensed under the MIT License.

#include "Server.hh"
#include <leth/Lib.hh>
#include <leth/Point.hh>
#include <leth/Server.hh>

#include "Lib.hh"
#include "Point.hh"
#include <cstring>

#define CAST_SERVER() \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) 2021 Chanjung Kim. All rights reserved.
// Licensed under the MIT License.

#include "SuccessiveOverRelaxationSpace.hh"
#include <leth/SuccessiveOverRelaxationSpace.hh>

char const* SuccessiveOverRelaxationSpace::GetName() noexcept
{
Expand Down

0 comments on commit f3ba21a

Please sign in to comment.