Skip to content

Commit

Permalink
build: switch import from zlib to Crow
Browse files Browse the repository at this point in the history
  • Loading branch information
csirianni committed Oct 11, 2023
1 parent 899e58c commit 448256f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 30 deletions.
8 changes: 4 additions & 4 deletions backend/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.15)
project(compressor)
cmake_minimum_required(VERSION 3.27)
project(backend)

find_package(ZLIB REQUIRED)
find_package(Crow REQUIRED)

add_executable(${PROJECT_NAME} src/main.cpp)
target_link_libraries(${PROJECT_NAME} ZLIB::ZLIB)
target_link_libraries(${PROJECT_NAME} Crow::Crow)
4 changes: 2 additions & 2 deletions backend/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from conan import ConanFile


class CompressorRecipe(ConanFile):
class BackendRecipe(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "CMakeToolchain", "CMakeDeps"

def requirements(self):
self.requires("zlib/1.2.11")
self.requires("crowcpp-crow/1.0+5")

def build_requirements(self):
self.tool_requires("cmake/3.22.6")
25 changes: 1 addition & 24 deletions backend/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,8 @@
#include <stdio.h>
#include <string.h>

#include <zlib.h>
#include "crow.h"

int main(void) {
char buffer_in [256] = {"Conan is a MIT-licensed, Open Source package manager for C and C++ development "
"for C and C++ development, allowing development teams to easily and efficiently "
"manage their packages and dependencies across platforms and build systems."};
char buffer_out [256] = {0};

z_stream defstream;
defstream.zalloc = Z_NULL;
defstream.zfree = Z_NULL;
defstream.opaque = Z_NULL;
defstream.avail_in = (uInt) strlen(buffer_in);
defstream.next_in = (Bytef *) buffer_in;
defstream.avail_out = (uInt) sizeof(buffer_out);
defstream.next_out = (Bytef *) buffer_out;

deflateInit(&defstream, Z_BEST_COMPRESSION);
deflate(&defstream, Z_FINISH);
deflateEnd(&defstream);

printf("Uncompressed size is: %lu\n", strlen(buffer_in));
printf("Compressed size is: %lu\n", strlen(buffer_out));

printf("ZLIB VERSION: %s\n", zlibVersion());

return EXIT_SUCCESS;
}

0 comments on commit 448256f

Please sign in to comment.