mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 20:20:10 +01:00
This also switches to a more Bazel-based install layout, skipping the FHS-based synthetic layout. The FHS-based layout is still reconstructed explicitly when building an installable tar-ball. The biggest change is to configure the just-built install as a Bazel toolchain, including allowing it to build its own runtime libraries as native Bazel libraries. This removes the need for a monolithic runtimes build, all of that code logic is removed. This should also pave the way to using the just-built toolchain for doing a full 3-stage bootstrap. Building the 2nd stage is included here as it was a particularly effective way to test that the Bazel integration was fully working. Adding a 3rd-stage check for stability is future work, but should be pretty easy. There is a down-side: this uses the busybox to do the runtimes compilation, which means they will be re-built after ~any change to Carbon. However, the integration with Bazel should largely pay for this, and we can continue to factor the tests away from depending on built runtimes in most cases. Now that we're building and testing the runtimes more directly, this surfaced a problem with the layout of runtimes on macOS that is fixed here. All of the Darwin OSes use a custom layout for their resource directory compared to other targets. We now model this in both the C++ built runtimes and the Bazel built runtimes. Assisted-by: Gemini via Antigravity
74 lines
2.4 KiB
Python
74 lines
2.4 KiB
Python
#!/usr/bin/env python3
|
|
|
|
"""Check that a release tar contains the same files as a prefix root."""
|
|
|
|
__copyright__ = """
|
|
Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
Exceptions. See /LICENSE for license information.
|
|
SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
"""
|
|
|
|
from pathlib import Path
|
|
import os
|
|
import re
|
|
import tarfile
|
|
import unittest
|
|
|
|
|
|
class ToolchainTarTest(unittest.TestCase):
|
|
def test_tar(self) -> None:
|
|
install_data_manifest = Path(os.environ["INSTALL_DATA_MANIFEST"])
|
|
tar_file = Path(os.environ["TAR_FILE"])
|
|
|
|
# Gather install data files.
|
|
with open(install_data_manifest) as manifest:
|
|
# Remove everything up to and including the package path
|
|
# `toolchain/install`.
|
|
install_files = set(
|
|
[
|
|
re.sub("^.*/toolchain/install/", "", entry.strip())
|
|
for entry in manifest.readlines()
|
|
]
|
|
)
|
|
self.assertTrue(install_files, f"`{install_data_manifest}` is empty.")
|
|
|
|
# Gather tar files.
|
|
with tarfile.open(tar_file) as tar:
|
|
# Remove the first path component.
|
|
tar_files = set(
|
|
[
|
|
str(Path(*Path(tarinfo.name).parts[1:]))
|
|
for tarinfo in tar
|
|
if not tarinfo.isdir()
|
|
]
|
|
)
|
|
self.assertTrue(install_files, f"`{install_data_manifest}` is empty.")
|
|
|
|
# Gather tar files.
|
|
with tarfile.open(tar_file) as tar:
|
|
# Remove the first path component.
|
|
tar_files = set(
|
|
[
|
|
str(Path(*Path(tarinfo.name).parts[1:]))
|
|
for tarinfo in tar
|
|
if not tarinfo.isdir()
|
|
]
|
|
)
|
|
self.assertTrue(tar_files, f"`{tar_file}` is empty.")
|
|
|
|
# Check that the `carbon` symlink is in the tar file.
|
|
self.assertIn("bin/carbon", tar_files)
|
|
tar_files.remove("bin/carbon")
|
|
|
|
# Remove the `lib/carbon` prefix which should be on every other file.
|
|
tar_files = set(
|
|
[re.sub("^lib/carbon/", "", entry.strip()) for entry in tar_files]
|
|
)
|
|
|
|
# The install files and the tar files should now be identical.
|
|
self.assertSetEqual(install_files, tar_files)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|