Add the stage1 bundle and sysroot to get rid of dependencies

This commit is contained in:
Sameer Rahmani 2023-04-23 10:29:10 +01:00
parent c3cc284544
commit 0759b72668
Signed by: lxsameer
GPG Key ID: B0A4AF28AB9FD90B
3 changed files with 106 additions and 24 deletions

View File

@ -0,0 +1,55 @@
# 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 Stage1(ConanFile):
name = "stage1-bundle"
version = get_version("llvm")
settings = "os", "arch"
exports = ("*.cmake",)
def build_requirements(self):
self.requires(
f"clang-bootstrap/{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}")
self.requires(f"libcxx/{get_version('llvm')}@{self.user}/{self.channel}")
def build(self):
copy_dependency_tree(
self,
["clang-bootstrap", "musl", "zlib", "zstd", "libcxx"],
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

@ -24,34 +24,28 @@ from conan.tools.cmake import CMakeToolchain
from conf.utils import get_version, copy_template, copy_tree, copy_dependency_tree
class Stage1(ConanFile):
class Stage1Sysroot(ConanFile):
name = "stage1-sysroot"
version = get_version("llvm")
settings = "os", "arch"
exports = ("*.cmake",)
def build_requirements(self):
self.requires(
f"clang-bootstrap/{get_version('llvm')}@{self.user}/{self.channel}"
)
self.requires(
f"zlib/{get_version('zlib')}@{self.user}/{self.channel}", visible=False
)
self.requires(
f"zstd/{get_version('zstd')}@{self.user}/{self.channel}", visible=False
)
self.requires(
f"musl/{get_version('musl')}@{self.user}/{self.channel}", visible=False
)
self.requires(
f"libcxx/{get_version('llvm')}@{self.user}/{self.channel}", visible=False
)
exports = (
"*.cmake",
"sysroot/*",
)
def build(self):
copy_dependency_tree(
self,
["clang-bootstrap", "musl", "zlib", "zstd", "libcxx"],
self.package_folder,
# 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"
@ -59,7 +53,7 @@ class Stage1(ConanFile):
self,
toolchain,
f"{self.package_folder}/toolchain.cmake",
{"TRIPLE": os.environ["TARGET"]},
{"TRIPLE": os.environ["TARGET"], "SYSROOT": self.package_folder},
)
def package_info(self):