-
Notifications
You must be signed in to change notification settings - Fork 980
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New
local-recipes-index
feature (#13930)
* proposal for adding a conan-center-index clone as remote * urls * wip * raise on uploads * remove file:/// protocol, use explicit --type=local * wip * review * fix boost * wip * add hook * review * fixes * wip * wip * Update conan/internal/api/new/oss_recipe.py Co-authored-by: Carlos Zoido <mrgalleta@gmail.com> * Update conan/internal/api/new/oss_recipe.py Co-authored-by: Carlos Zoido <mrgalleta@gmail.com> * fix * strip-root * not warn remote-add * test_package in template and remove clone in conan remote remove * fix export patches * cover patches export too * fix remove * refactor add/remove remote * fix * removed git type * unused imports * review and automatic deduction * renaming all --------- Co-authored-by: Carlos Zoido <mrgalleta@gmail.com>
- Loading branch information
1 parent
7f0f1b2
commit 8541d44
Showing
11 changed files
with
833 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
from conan.internal.api.new.cmake_lib import test_conanfile_v2, test_cmake_v2 | ||
|
||
config_yml = """\ | ||
versions: | ||
"{{version}}": | ||
folder: all | ||
""" | ||
|
||
conandata_yml = """\ | ||
sources: | ||
"{{version}}": | ||
url: | ||
{% if url is defined -%} | ||
- "{{url}}" | ||
{% else -%} | ||
- "http://put/here/the/url/to/release.1.2.3.zip" | ||
{% endif %} | ||
{% if sha256 is defined -%} | ||
sha256: "{{sha256}}" | ||
{%- else -%} | ||
sha256: "Put here your tarball sha256" | ||
{% endif -%} | ||
""" | ||
|
||
|
||
conanfile = """\ | ||
from conan import ConanFile | ||
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps | ||
from conan.tools.files import apply_conandata_patches, export_conandata_patches, get | ||
class {{package_name}}Recipe(ConanFile): | ||
name = "{{name}}" | ||
package_type = "library" | ||
# Optional metadata | ||
license = "<Put the package license here>" | ||
author = "<Put your name here> <And your email here>" | ||
url = "<Package recipe repository url here, for issues about the package>" | ||
description = "<Description of {{ name }} package here>" | ||
topics = ("<Put some tag here>", "<here>", "<and here>") | ||
# Binary configuration | ||
settings = "os", "compiler", "build_type", "arch" | ||
options = {"shared": [True, False], "fPIC": [True, False]} | ||
default_options = {"shared": False, "fPIC": True} | ||
def config_options(self): | ||
if self.settings.os == "Windows": | ||
self.options.rm_safe("fPIC") | ||
def configure(self): | ||
if self.options.shared: | ||
self.options.rm_safe("fPIC") | ||
def export_sources(self): | ||
export_conandata_patches(self) | ||
def source(self): | ||
get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, | ||
strip_root=True) | ||
apply_conandata_patches(self) | ||
def layout(self): | ||
cmake_layout(self, src_folder="src") | ||
def generate(self): | ||
deps = CMakeDeps(self) | ||
deps.generate() | ||
tc = CMakeToolchain(self) | ||
tc.generate() | ||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
def package(self): | ||
cmake = CMake(self) | ||
cmake.install() | ||
def package_info(self): | ||
self.cpp_info.libs = ["{{name}}"] | ||
{% if requires is defined -%} | ||
def requirements(self): | ||
{% for require in requires -%} | ||
self.requires("{{ require }}") | ||
{% endfor %} | ||
{%- endif %} | ||
{% if tool_requires is defined -%} | ||
def build_requirements(self): | ||
{% for require in tool_requires -%} | ||
self.tool_requires("{{ require }}") | ||
{% endfor %} | ||
{%- endif %} | ||
""" | ||
|
||
|
||
test_main = """#include "{{name}}.h" | ||
int main() { | ||
{{package_name}}(); | ||
} | ||
""" | ||
|
||
local_recipes_index_files = {"recipes/{{name}}/config.yml": config_yml, | ||
"recipes/{{name}}/all/conandata.yml": conandata_yml, | ||
"recipes/{{name}}/all/conanfile.py": conanfile, | ||
"recipes/{{name}}/all/test_package/conanfile.py": test_conanfile_v2, | ||
"recipes/{{name}}/all/test_package/CMakeLists.txt": test_cmake_v2, | ||
"recipes/{{name}}/all/test_package/src/example.cpp": test_main} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.