Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crow/0.1 #3123

Merged
merged 12 commits into from
Oct 21, 2020
4 changes: 4 additions & 0 deletions recipes/crow/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"0.1":
sha256: 140ca4a4d75ce5996cb103155580cb13b0b27082d1efbc331000a34af55b4390
url: https://github.com/ipkn/crow/archive/v0.1.tar.gz
46 changes: 46 additions & 0 deletions recipes/crow/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from conans import ConanFile, tools, CMake
import os

required_conan_version = ">=1.28.0"
madduci marked this conversation as resolved.
Show resolved Hide resolved

class CrowConan(ConanFile):
name = "crow"
homepage = "https://github.com/ipkn/crow"
description = "Crow is C++ microframework for web. (inspired by Python Flask)"
topics = ("conan", "web", "microframework", "header-only")
url = "https://github.com/conan-io/conan-center-index"
settings = "os", "compiler", "arch", "build_type"
generators = "cmake", "cmake_find_package", "cmake_find_package_multi"
license = "BSD3"
madduci marked this conversation as resolved.
Show resolved Hide resolved
no_copy_source = True

@property
def _source_subfolder(self):
return "source_subfolder"

def requirements(self):
self.requires("openssl/1.1.1h")
self.requires("boost/1.74.0")

def source(self):
tools.get(**self.conan_data["sources"][self.version])
extracted_dir = "crow-" + self.version
os.rename(extracted_dir, self._source_subfolder)

def _configure_cmake(self):
cmake = CMake(self)
cmake.configure(source_folder=self._source_subfolder)
return cmake

def build(self):
cmake = self._configure_cmake()
cmake.build()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this required? it's header only

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The _configure_cmake is only used here if the answer is yes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it creates an "amalgamate" header only file during the CMake process, this it is required.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so remove no_copy_source, because as it suggests, won't copy sources files to build folder

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment, so we dont forget 😃


def package(self):
self.copy(pattern="LICENSE*", dst="licenses", src=self._source_subfolder)
cmake = self._configure_cmake()
cmake.install()
tools.rmdir(os.path.join(self.package_folder, "lib"))

def package_id(self):
self.info.header_only()
11 changes: 11 additions & 0 deletions recipes/crow/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.1)
project(test_package)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

find_package(cpp-jwt REQUIRED)
madduci marked this conversation as resolved.
Show resolved Hide resolved

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} cpp-jwt::cpp-jwt)
madduci marked this conversation as resolved.
Show resolved Hide resolved
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14)
17 changes: 17 additions & 0 deletions recipes/crow/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from conans import ConanFile, CMake, tools
import os


class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake", "cmake_find_package", "cmake_find_package_multi"

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self.settings):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
22 changes: 22 additions & 0 deletions recipes/crow/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include "jwt/jwt.hpp"
madduci marked this conversation as resolved.
Show resolved Hide resolved
#include <iostream>

int main() {
using namespace jwt::params;

auto key = "secret"; // Secret to use for the algorithm
// Create JWT object
jwt::jwt_object obj{algorithm("HS256"), payload({{"some", "payload"}}),
secret(key)};

// Get the encoded string/assertion
auto enc_str = obj.signature();
std::cout << enc_str << std::endl;

// Decode
auto dec_obj = jwt::decode(enc_str, algorithms({"hs256"}), secret(key));
std::cout << dec_obj.header() << std::endl;
std::cout << dec_obj.payload() << std::endl;

return 0;
}
3 changes: 3 additions & 0 deletions recipes/crow/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"0.1":
folder: all