From 3aba855bd61cae5dc1e065a22ffd8f74a37d590a Mon Sep 17 00:00:00 2001 From: "Michael \"Croydon\" Keck" Date: Wed, 28 Nov 2018 11:25:49 +0100 Subject: [PATCH] Add basic Conan support (#162) * Add Conan support * Conan: Add test_package --- .gitignore | 4 +++ conan/test_package/CMakeLists.txt | 13 +++++++ conan/test_package/conanfile.py | 19 ++++++++++ conan/test_package/test_package.cpp | 55 +++++++++++++++++++++++++++++ conanfile.py | 23 ++++++++++++ 5 files changed, 114 insertions(+) create mode 100644 conan/test_package/CMakeLists.txt create mode 100644 conan/test_package/conanfile.py create mode 100644 conan/test_package/test_package.cpp create mode 100644 conanfile.py diff --git a/.gitignore b/.gitignore index 8a9d35c88..12a380463 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,5 @@ *.user +conan/test_package/build + +# IDEs +.idea diff --git a/conan/test_package/CMakeLists.txt b/conan/test_package/CMakeLists.txt new file mode 100644 index 000000000..2e9fedb74 --- /dev/null +++ b/conan/test_package/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.7.2) +project(test_package) + +set(CMAKE_VERBOSE_MAKEFILE TRUE) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/conan/test_package/conanfile.py b/conan/test_package/conanfile.py new file mode 100644 index 000000000..d63f4088c --- /dev/null +++ b/conan/test_package/conanfile.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from conans import ConanFile, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/conan/test_package/test_package.cpp b/conan/test_package/test_package.cpp new file mode 100644 index 000000000..3cfac879c --- /dev/null +++ b/conan/test_package/test_package.cpp @@ -0,0 +1,55 @@ +#include +#include +#include + +struct position { + float x; + float y; +}; + +struct velocity { + float dx; + float dy; +}; + +void update(entt::registry<> ®istry) { + auto view = registry.view(); + + for(auto entity: view) { + // gets only the components that are going to be used ... + + auto &vel = view.get(entity); + + vel.dx = 0.; + vel.dy = 0.; + + // ... + } +} + +void update(std::uint64_t dt, entt::registry<> ®istry) { + registry.view().each([dt](const auto, auto &pos, auto &vel) { + // gets all the components of the view at once ... + + pos.x += vel.dx * dt; + pos.y += vel.dy * dt; + + // ... + }); +} + +int main() { + entt::registry<> registry; + std::uint64_t dt = 16; + + for(auto i = 0; i < 10; ++i) { + auto entity = registry.create(); + registry.assign(entity, i * 1.f, i * 1.f); + if(i % 2 == 0) { registry.assign(entity, i * .1f, i * .1f); } + } + + update(dt, registry); + update(registry); + + return EXIT_SUCCESS; +} diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 000000000..08176d3f8 --- /dev/null +++ b/conanfile.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +from conans import ConanFile + + +class EnttConan(ConanFile): + name = "entt" + description = "Gaming meets modern C++ - a fast and reliable entity-component system (ECS) and much more " + topics = ("conan," "entt", "gaming", "entity", "ecs") + url = "https://github.com/skypjack/entt" + homepage = url + author = "Michele Caini " + license = "MIT" + exports = ["LICENSE"] + exports_sources = ["src/*"] + no_copy_source = True + + def package(self): + self.copy(pattern="LICENSE", dst="licenses") + self.copy(pattern="*", dst="include", src="src", keep_path=True) + + def package_id(self): + self.info.header_only()