aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-06-11 06:40:35 +0000
committerFuwn <[email protected]>2024-06-11 06:41:52 +0000
commit970099af7deec70d3689c055ddaa7417e7b0cb7a (patch)
treeeae0d2e752d15c47c86a8eb176ba4feb820d4aa1
parentdocs(readme): add options to docker (diff)
downloadmaple-970099af7deec70d3689c055ddaa7417e7b0cb7a.tar.xz
maple-970099af7deec70d3689c055ddaa7417e7b0cb7a.zip
build: switch from ninja to tup
-rw-r--r--.gitignore16
-rw-r--r--README.md7
-rw-r--r--Tupfile22
-rw-r--r--build.ninja26
-rw-r--r--maple/titan.cc11
5 files changed, 40 insertions, 42 deletions
diff --git a/.gitignore b/.gitignore
index a5707a7..676d40c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,13 +1,13 @@
# Development
*.pem
-out/
-# CMake
-cmake-build-*/
-CMakeLists.txt
+# IDE
+.idea
+.vscode
-# Ninja
-.ninja_*
+# Tup
+.tup
+
+# Build Artifacts
+build
-# IDE
-.idea/
diff --git a/README.md b/README.md
index ac983ea..95f0536 100644
--- a/README.md
+++ b/README.md
@@ -3,6 +3,7 @@
A very simple static Gemini server, now with Titan support!
### Lines-of-code
+
This codebase is now 351 lines of lines-of-code!
The statement "... written within a single file and liberally
@@ -32,9 +33,9 @@ docker run -p 1965:1965 -v ./your_capsules_directory:/maple/.maple fuwn/maple:la
### Executable
-1. Build: `ninja` (requires [Ninja](https://ninja-build.org/))
-2. Run: `out/maple`, or
- `TITAN=1 TITAN_TOKEN=secret TITAN_MAX_SIZE=2048 out/maple`
+1. Build: `tup` (requires [Tup](https://gittup.org/tup/index.html))
+2. Run: `build/maple`, or
+ `TITAN=1 TITAN_TOKEN=secret TITAN_MAX_SIZE=2048 build/maple`
### Certificates
diff --git a/Tupfile b/Tupfile
new file mode 100644
index 0000000..2642dc7
--- /dev/null
+++ b/Tupfile
@@ -0,0 +1,22 @@
+NAME = maple
+
+# Input & Output Directories
+SOURCE_DIRECTORY = $(NAME)
+INCLUDE_DIRECTORY = $(NAME)
+BUILD_DIRECTORY = build
+
+# Compiler Configuration
+CXX = clang++
+CXX_EXTENSION = cc
+CXX_FLAGS = -std=c++23 -I $(INCLUDE_DIRECTORY) -Weverything -Wno-padded -Wno-c++98-compat -MMD -fno-diagnostics-show-note-include-stack -Wno-c++98-compat-pedantic
+LD_FLAGS = -lssl -lcrypto
+
+# Clang-Tidy Configuration
+CLANG_TIDY_CHECKS = '-*,bugprone-*,clang-analyzer-*,concurrency-*,cppcoreguildelines-*,llvm-*,misc-*,modernize-*,performance-*,portability-*,readability-*,-readability-magic-numbers,-llvm-header-guard,-bugprone-suspicious-include,-readability-function-cognitive-complexity,-bugprone-exception-escape'
+CLANG_TIDY_FLAGS = -checks=$(CLANG_TIDY_CHECKS) -warnings-as-errors=* -quiet
+
+# : foreach $(SOURCE_DIRECTORY)/*.$(CXX_EXTENSION) $(INCLUDE_DIRECTORY)/*.hh |> clang-format -i -style=LLVM %f |>
+# : foreach $(SOURCE_DIRECTORY)/*.$(CXX_EXTENSION) |> clang-tidy $(CLANG_TIDY_FLAGS) %f -- $(CXX_FLAGS) |>
+: foreach $(SOURCE_DIRECTORY)/*.$(CXX_EXTENSION) |> ^j^ $(CXX) $(CXX_FLAGS) -MF $(BUILD_DIRECTORY)/%B.d -c %f -o %o |> $(BUILD_DIRECTORY)/%B.o | $(BUILD_DIRECTORY)/%B.d
+: $(BUILD_DIRECTORY)/*.o |> $(CXX) $(LD_FLAGS) %f -o %o |> $(BUILD_DIRECTORY)/$(NAME)
+
diff --git a/build.ninja b/build.ninja
deleted file mode 100644
index 3d31c08..0000000
--- a/build.ninja
+++ /dev/null
@@ -1,26 +0,0 @@
-cc = clang++
-cxxflags = -Weverything -Wno-c++98-compat -std=c++20
-ldflags = -lssl -lcrypto
-out_dir = out
-name = maple
-src_dir = $name
-
-rule compile
- command = $cc $cxxflags -c $in -o $out
-
-rule link
- command = $cc $ldflags $in -o $out
-
-rule clang_format
- command = clang-format -i -style=LLVM $src_dir/*$cc_ext $src_dir/*.hh
-
-build $out_dir/$name.o: compile $src_dir/$name.cc
-build $out_dir/gemini.o: compile $src_dir/gemini.cc
-build $out_dir/titan.o: compile $src_dir/titan.cc
-
-build $out_dir/$name: link $out_dir/$name.o $out_dir/gemini.o $out_dir/titan.o
-
-build _format: clang_format
-build format: phony _format
-
-default $out_dir/$name
diff --git a/maple/titan.cc b/maple/titan.cc
index 7f838f3..03ea19e 100644
--- a/maple/titan.cc
+++ b/maple/titan.cc
@@ -39,15 +39,15 @@ auto parameters_to_map(const std::vector<std::string> &parameters)
parameter.erase(0, parameter_delimiter_position + 1);
// Add the key and value to `parameters_map`
- parameters_map[key] = parameter;
+ parameters_map.at(key) = parameter;
}
return parameters_map;
}
auto handle_client(std::stringstream &response, std::string path,
- const std::string &titan_token, size_t titan_max_size)
- -> void {
+ const std::string &titan_token,
+ size_t titan_max_size) -> void {
std::vector<std::string> parameters;
// Find path in `path`
size_t delimiter_position = path.find(';');
@@ -121,7 +121,8 @@ auto handle_client(std::stringstream &response, std::string path,
}
try {
- size_t body_size = static_cast<size_t>(std::stoi(parameters_map["size"]));
+ size_t body_size =
+ static_cast<size_t>(std::stoi(parameters_map.at("size")));
if (body_size > titan_max_size) {
response << "20 text/gemini\r\nThe server (Maple) received a body "
@@ -141,7 +142,7 @@ auto handle_client(std::stringstream &response, std::string path,
update_path = "/index.gmi";
}
- if (parameters_map["token"] == titan_token) {
+ if (parameters_map.at("token") == titan_token) {
std::ofstream file(".maple/gmi" + update_path);
file << body;