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

makefile-project-workspace-creator: migrate to Conan v2 #18938

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 32 additions & 18 deletions recipes/makefile-project-workspace-creator/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,51 @@
import os
from conans import ConanFile, tools

from conan import ConanFile
from conan.tools.files import copy, get
from conan.tools.layout import basic_layout

required_conan_version = ">=1.53.0"


class MPCGeneratorConan(ConanFile):
name = "makefile-project-workspace-creator"
description = "The Makefile, Project and Workspace Creator"
license = "BSD-3-Clause"
homepage = "https://objectcomputing.com/"
url = "https://github.com/conan-io/conan-center-index"
topics = ("conan", "makefile-project-workspace-creator", "objectcomputing", "installer")
settings = "os"
homepage = "https://github.com/objectcomputing/MPC"
topics = ("objectcomputing", "installer")

@property
def _source_subfolder(self):
return "source_subfolder"
package_type = "build-scripts"
settings = "os", "arch", "compiler", "build_type"

def requirements(self):
if self.settings.os == "Windows":
self.requires("strawberryperl/5.30.0.1")
def layout(self):
basic_layout(self, src_folder="src")

def build(self):
pass
def package_id(self):
self.info.clear()

def source(self):
tools.get(**self.conan_data["sources"][self.version])
os.rename("MPC-MPC_" + self.version.replace(".", "_"), self._source_subfolder)
def build(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def package(self):
self.copy(pattern="*", src=self._source_subfolder, dst="bin")
self.copy(pattern="LICENSE", src=os.path.join(self._source_subfolder, "docs"), dst="licenses")
copy(self, "*",
src=self.build_folder,
dst=os.path.join(self.package_folder, "bin"),
excludes=["history", "docs", "rpm", "MPC.ico", "PROBLEM-REPORT-FORM", "azure-pipelines.yml", "ChangeLog"])
copy(self, "LICENSE",
src=os.path.join(self.build_folder, "docs"),
dst=os.path.join(self.package_folder, "licenses"))

def package_info(self):
self.cpp_info.frameworkdirs = []
self.cpp_info.libdirs = []
self.cpp_info.resdirs = []
self.cpp_info.includedirs = []

bin_path = os.path.join(self.package_folder, "bin")
self.output.info('Appending PATH environment variable: %s' % bin_path)
# MPC_ROOT: https://github.com/objectcomputing/MPC/blob/5b4c2443871e5e9b6267edef17fed66afc125fa4/docs/USAGE#L243
self.buildenv_info.define("MPC_ROOT", bin_path)

# TODO: Remove after dropping Conan 1.x
self.env_info.PATH.append(bin_path)
self.env_info.MPC_ROOT = bin_path
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
from conans import ConanFile, tools
from conan import ConanFile
from conan.tools.layout import basic_layout
from conan.tools.files import save, load
import os


class DefaultNameConan(ConanFile):
settings = "os"
class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "VirtualBuildEnv", "VirtualRunEnv"
test_type = "explicit"

def build(self):
pass
def layout(self):
basic_layout(self)

def requirements(self):
self.requires(self.tested_reference_str)

def generate(self):
build_vars = self.dependencies[self.tested_reference_str].buildenv_info.vars(self, scope="build")
mpc_root = build_vars["MPC_ROOT"]
save(self, os.path.join(self.build_folder, "mpc_root.txt"), mpc_root)

def test(self):
if not tools.cross_building(self.settings):
self.run("perl -S mpc.pl --version", run_environment=True)
mpc_root = load(self, os.path.join(self.build_folder, "mpc_root.txt"))
assert os.path.exists(os.path.join(mpc_root, 'mpc.pl'))
Loading