Skip to content

Commit

Permalink
(#18848) mold: drop 1.3.1, add package_type
Browse files Browse the repository at this point in the history
* mold: migrate 1.3.1 to Conan v2, adjust exported vars

* mold/1.3.1: drop outdated recipe

* mold: tweak conf variable

Co-authored-by: Uilian Ries <uilianries@gmail.com>

---------

Co-authored-by: Uilian Ries <uilianries@gmail.com>
  • Loading branch information
valgur and uilianries authored Nov 17, 2023
1 parent dfb179a commit eb0cfc9
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 149 deletions.
4 changes: 0 additions & 4 deletions recipes/mold/1.3.1/conandata.yml

This file was deleted.

104 changes: 0 additions & 104 deletions recipes/mold/1.3.1/conanfile.py

This file was deleted.

9 changes: 0 additions & 9 deletions recipes/mold/1.3.1/test_package/conanfile.py

This file was deleted.

68 changes: 39 additions & 29 deletions recipes/mold/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,21 @@
from conan.tools.scm import Version
from conan.tools.env import VirtualBuildEnv

required_conan_version = ">=1.47.0"


class MoldConan(ConanFile):
name = "mold"
description = (
"mold is a faster drop-in replacement for existing Unix linkers. "
"It is several times faster than the LLVM lld linker."
)
license = ("AGPL-3.0", "MIT")
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/rui314/mold/"
license = ("AGPL-3.0", "MIT")
description = ("mold is a faster drop-in replacement for existing Unix linkers. It is several times faster than the LLVM lld linker")
topics = ("mold", "ld", "linkage", "compilation")
topics = ("ld", "linkage", "compilation", "pre-built")

package_type = "application"
settings = "os", "arch", "compiler", "build_type"
options = {
"with_mimalloc": [True, False],
Expand All @@ -28,8 +35,22 @@ def configure(self):
else:
self.license = "MIT"

def layout(self):
cmake_layout(self, src_folder="src")

def requirements(self):
self.requires("zlib/[>=1.2.11 <2]")
self.requires("openssl/[>=1.1 <4]")
self.requires("xxhash/0.8.2")
self.requires("onetbb/2021.10.0")
if self.options.with_mimalloc:
self.requires("mimalloc/2.1.2")

def package_id(self):
del self.info.settings.compiler

def validate(self):
#TODO most of these checks should run on validate_build, but the conan-center hooks are broken and fail the PR because they
# TODO most of these checks should run on validate_build, but the conan-center hooks are broken and fail the PR because they
# think we're raising on the build() method
if self.settings.build_type == "Debug":
raise ConanInvalidConfiguration('Mold is a build tool, specify mold:build_type=Release in your build profile, see https://github.com/conan-io/conan-center-index/pull/11536#issuecomment-1195607330')
Expand All @@ -44,26 +65,11 @@ def validate(self):
if self.settings.compiler == "apple-clang" and "armv8" == self.settings.arch :
raise ConanInvalidConfiguration(f'{self.name} is still not supported by Mac M1.')

def layout(self):
cmake_layout(self, src_folder="src")

def package_id(self):
del self.info.settings.compiler

def build_requirements(self):
self.tool_requires("cmake/[>=3.18.0 <4]")

def requirements(self):
self.requires("zlib/1.2.13")
self.requires("openssl/1.1.1q")
self.requires("xxhash/0.8.1")
self.requires("onetbb/2021.3.0")
if self.options.with_mimalloc:
self.requires("mimalloc/2.0.6")

def source(self):
get(self, **self.conan_data["sources"][self.version],
destination=self.source_folder, strip_root=True)
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def generate(self):
tc = CMakeToolchain(self)
Expand Down Expand Up @@ -93,17 +99,21 @@ def package(self):
rmdir(self, os.path.join(self.package_folder, "share"))

def package_info(self):
bindir = os.path.join(self.package_folder, "bin")
mold_location = os.path.join(bindir, "mold")

self.output.info('Appending PATH environment variable: {}'.format(bindir))
self.env_info.PATH.append(bindir)
self.env_info.LD = mold_location
self.buildenv_info.prepend_path("MOLD_ROOT", bindir)
self.cpp_info.includedirs = []
self.cpp_info.libdirs = []
self.cpp_info.frameworkdirs = []
self.cpp_info.resdirs = []

if self.settings.os == "Linux":
self.cpp_info.system_libs.extend(["m", "pthread", "dl"])
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.system_libs = ["m", "pthread", "dl"]

bindir = os.path.join(self.package_folder, "bin")
mold_executable = os.path.join(bindir, "mold")
self.conf_info.define("user.mold:path", mold_executable)
self.buildenv_info.define_path("MOLD_ROOT", bindir)
self.buildenv_info.define("LD", mold_executable)

# For legacy Conan 1.x consumers only:
self.env_info.PATH.append(bindir)
self.env_info.MOLD_ROOT = bindir
self.env_info.LD = mold_executable
1 change: 0 additions & 1 deletion recipes/mold/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ def build_requirements(self):
def test(self):
if can_run(self):
self.run("mold -v")

2 changes: 0 additions & 2 deletions recipes/mold/config.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
versions:
"2.0.0":
folder: all
"1.3.1":
folder: 1.3.1
"1.4.2":
folder: all
"1.5.1":
Expand Down

0 comments on commit eb0cfc9

Please sign in to comment.