Add the stage2 bundle and sysroot

This commit is contained in:
Sameer Rahmani 2023-04-23 10:29:55 +01:00
parent 0759b72668
commit e53ae5219e
Signed by: lxsameer
GPG Key ID: B0A4AF28AB9FD90B
5 changed files with 226 additions and 0 deletions

View File

@ -0,0 +1,52 @@
# 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.files import get
from conan.tools.cmake import CMakeToolchain
from conf.utils import get_version, copy_template, copy_tree, copy_dependency_tree
class Stage2(ConanFile):
name = "stage2-bundle"
version = get_version("llvm")
settings = "os", "arch"
exports = ("*.cmake",)
def build_requirements(self):
self.requires(f"clang/{get_version('llvm')}@{self.user}/{self.channel}")
self.requires(f"zlib/{get_version('zlib')}@{self.user}/{self.channel}")
self.requires(f"zstd/{get_version('zstd')}@{self.user}/{self.channel}")
self.requires(f"musl/{get_version('musl')}@{self.user}/{self.channel}")
def build(self):
copy_dependency_tree(
self,
["clang", "musl", "zlib", "zstd"],
self.package_folder,
)
toolchain = f"{self.recipe_folder}/toolchain.cmake"
copy_template(
self,
toolchain,
f"{self.package_folder}/toolchain.cmake",
{"TRIPLE": os.environ["TARGET"], "SYSROOT": self.package_folder},
)

View File

@ -0,0 +1,33 @@
# 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/>.
set(CMAKE_SYSTEM_NAME Linux)
set(triple @TRIPLE@)
set(CMAKE_SYSROOT @SYSROOT@)
set(CMAKE_C_COMPILER "clang")
set(CMAKE_CXX_COMPILER "clang++")
set(CMAKE_ASM_COMPILER "clang")
set(CMAKE_C_COMPILER_TARGET ${triple})
set(CMAKE_CXX_COMPILER_TARGET ${triple})
set(CMAKE_ASM_COMPILER_TARGET ${triple})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

View File

@ -0,0 +1,83 @@
# 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.files import get
from conan.tools.cmake import CMakeToolchain
from conf.utils import get_version, copy_template, copy_tree, copy_dependency_tree
class Stage2Sysroot(ConanFile):
name = "stage2-sysroot"
version = get_version("llvm")
settings = "os", "arch"
exports = (
"*.cmake",
"sysroot/*",
)
def build(self):
# sysroot dir is created via the builder script
copy_tree(
f"{self.recipe_folder}/sysroot/{get_version('llvm')}/bin",
f"{self.package_folder}/bin",
)
copy_tree(
f"{self.recipe_folder}/sysroot/{get_version('llvm')}/lib",
f"{self.package_folder}/lib",
)
copy_tree(
f"{self.recipe_folder}/sysroot/{get_version('llvm')}/include",
f"{self.package_folder}/include",
)
toolchain = f"{self.recipe_folder}/toolchain.cmake"
copy_template(
self,
toolchain,
f"{self.package_folder}/toolchain.cmake",
{"TRIPLE": os.environ["TARGET"], "SYSROOT": self.package_folder},
)
def package_info(self):
bindir = Path(self.package_folder) / "bin"
self.runenv_info.prepend_path(
"PATH",
str(bindir),
)
self.buildenv_info.append("sysroot", self.package_folder)
f = os.path.join(self.package_folder, "toolchain.cmake")
self.conf_info.prepend("tools.cmake.cmaketoolchain:user_toolchain", f)
self.conf_info.define("tools.build:sysroot", self.package_folder)
self.buildenv_info.define_path("SYSROOT", self.package_folder)
self.buildenv_info.define("CC", str(bindir / "clang"))
self.buildenv_info.define("CXX", str(bindir / "clang++"))
self.buildenv_info.define("AR", str(bindir / "clang"))
self.buildenv_info.define("NM", str(bindir / "llvm-nm"))
self.buildenv_info.define("RANLIB", str(bindir / "llvm-ranlib"))
self.cpp_info.includedirs = [
f"{self.package_folder}/include/c++/v1",
f"{self.package_folder}/include/",
f"{self.package_folder}/lib/clang/{get_version('llvm_major')}/include",
]

View File

@ -0,0 +1,34 @@
# 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/>.
set(CMAKE_SYSTEM_NAME Linux)
set(triple @TRIPLE@)
set(CMAKE_SYSROOT @SYSROOT@)
set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})
set(CMAKE_C_COMPILER "clang")
set(CMAKE_CXX_COMPILER "clang++")
set(CMAKE_ASM_COMPILER "clang")
set(CMAKE_C_COMPILER_TARGET ${triple})
set(CMAKE_CXX_COMPILER_TARGET ${triple})
set(CMAKE_ASM_COMPILER_TARGET ${triple})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

24
profiles/stage2 Normal file
View File

@ -0,0 +1,24 @@
{% set LLVM_VERSION = os.getenv("LLVM_VERSION") %}
[settings]
os=Linux
arch=x86_64
build_type=RelWithDebInfo
compiler=clang
compiler.version=17
compiler.libcxx=libc++
[buildenv]
CC=clang
CXX=clang++
LD=lld
[options]
*/*:stage=2
cmake/*:libc=musl
ninja/*:libc=musl
[conf]
tools.cmake.cmaketoolchain:generator=Ninja