Skip to content

Commit

Permalink
enhancement: Enhance Makefile for better build process and fix errors
Browse files Browse the repository at this point in the history
- Removed unnecessary `ls` command in the `cpp-static-lib` target
- Reorganized build targets for clarity and proper execution order
- Ensured that the build directory (`build-cpp`) is created before use
- Fixed issues with missing source files and library paths in the `cpp-static-lib` target
- Remove `println` statement: test_list_authorized_users
  • Loading branch information
irfanghat committed Nov 13, 2024
1 parent f07ccdb commit 5850a67
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 6 deletions.
78 changes: 73 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,82 @@
# Rust target config.
RUST_MANIFEST_PATH = ./render_cdk/Cargo.toml

# Rust targets.
format:
cargo fmt --quiet
cargo fmt --quiet --manifest-path=$(RUST_MANIFEST_PATH)

lint:
cargo clippy
cargo clippy --manifest-path=$(RUST_MANIFEST_PATH)

release:
cargo build --release
cargo build --manifest-path=$(RUST_MANIFEST_PATH) --release

debug:
cargo build
cargo build --manifest-path=$(RUST_MANIFEST_PATH)

run:
cargo run
cargo run --manifest-path=$(RUST_MANIFEST_PATH)

test:
cargo test --manifest-path=$(RUST_MANIFEST_PATH) -- --nocapture


# C++ target config.
CPP_SRC_DIR = ./librender_cdk/src
CPP_BUILD_DIR = build
CPP_LIBRARY_DIR = librender_cdk


# Identifier for the static library.
CPP_LIB_NAME = librender_cdk.a


# Identifier for the shared library.
CPP_SHARED_LIB_NAME = librender_cdk.so


CPP_INCLUDE_DIRS = -I./librender_cdk/cpp-httplib
CPP_FLAGS = -std=c++17


# OpenSSL for HTTPS.
CPP_LIBS = -lssl -lcrypto


# Ensure the C++ build directory exists.
$(CPP_BUILD_DIR):
mkdir -p $(CPP_BUILD_DIR)


# Static library build target.
cpp-static-lib: $(CPP_BUILD_DIR)
ar rcs $(CPP_BUILD_DIR)/$(CPP_LIB_NAME) $(CPP_SRC_DIR)/*.cpp


# Shared library build target.
cpp-shared-lib: $(CPP_BUILD_DIR)
g++ -shared -fPIC $(CPP_FLAGS) $(CPP_INCLUDE_DIRS) $(CPP_SRC_DIR)/*.cpp -o $(CPP_BUILD_DIR)/$(CPP_SHARED_LIB_NAME) $(CPP_LIBS)


# Clean C++ build files and libraries.
cpp-clean:
rm -rf $(CPP_BUILD_DIR)


# Combined targets.
build: debug cpp-static-lib
release-build: release cpp-static-lib


# Optionally build shared library.
build-shared: debug cpp-shared-lib
release-build-shared: release cpp-shared-lib


# Run both Rust and C++ executables.
run-all: build
cargo run


clean: cpp-clean
cargo clean
12 changes: 12 additions & 0 deletions librender_cdk/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include "../cpp-httplib/httplib.h"
#include <iostream>

int main() {
httplib::Client cli("http://example.com");
auto res = cli.Get("/api/v1/resource");

if (res) {
std::cout << "Status: " << res->status << std::endl;
std::cout << "Response Body: " << res->body << std::endl;
}
}
1 change: 0 additions & 1 deletion render_cdk/src/state_management/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ mod state_tests {
let owner_credentials = EnvironmentManager::retrieve_env_config().OWNER_CREDENTIALS;
let result = Owner::list_authorized_users(&owner_credentials, "100").await;

println!("{:?}", result);
// The result should be Ok().
assert!(result.is_ok());
}
Expand Down

0 comments on commit 5850a67

Please sign in to comment.