Add the musl package

This commit is contained in:
Sameer Rahmani 2023-04-12 19:13:35 +01:00
parent c6c68b1002
commit 579ecb082a
Signed by: lxsameer
GPG Key ID: B0A4AF28AB9FD90B
1 changed files with 81 additions and 0 deletions

View File

@ -0,0 +1,81 @@
# Toolchain builder for the Serene programming language
#
# Copyright (c) 2019-2023 Sameer Rahmani <lxsameer@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
import shutil
from pathlib import Path
from conan import ConanFile
from conan.tools.gnu import AutotoolsToolchain, Autotools
from conan.tools.files import get
from conf.utils import current_dir, get_version
class Musl(ConanFile):
name = "musl"
settings = "os", "arch", "build_type"
version = get_version("musl")
def build_requirements(self):
self.requires(
f"kernel-headers/{get_version('kernel')}@{self.user}/{self.channel}"
)
self.tool_requires(
f"clang-bootstrap/{get_version('llvm')}@{self.user}/{self.channel}"
)
@property
def target(self):
return os.environ["TARGET"]
def source(self):
get(
self,
f"https://git.musl-libc.org/cgit/musl/snapshot/musl-{self.version}.tar.gz",
)
def generate(self):
tc = AutotoolsToolchain(self, prefix=f"{self.package_folder}/")
env = tc.environment()
buildenv = self.dependencies.build["clang-bootstrap"].buildenv_info.vars(self)
tc.update_configure_args(
{
"--enable-shared": "",
"--enable-static": "",
"--disable-wrapper": "",
"--enable-optimize": "",
}
)
libcc_dir = Path(buildenv["LIBCC_GNU"])
if "musl" in self.target:
libcc_dir = Path(buildenv["LIBCC_MUSL"])
env.define("LIBCC", str(libcc_dir / "libclang_rt.builtins.a"))
# We will strip the debug data later
tc.extra_cflags = ["-g", f"--target={self.target}"]
tc.generate(env)
def build(self):
autotools = Autotools(self)
autotools.configure(
build_script_folder=f"{self.source_folder}/musl-{self.version}/"
)
autotools.make()
autotools.make(target="install")