From 5afa86b48394237250797e8cc871078b9944f8f6 Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Fri, 3 Jun 2022 19:07:28 +0200 Subject: [PATCH] bootstrap: generate missing Setup.hs in dependencies This allows bootstrapping against zlib 0.6.3.0, which ships without Setup.hs. I hope this should generally be a more robust approach than asking maintainers of dependencies to keep Setup.hs. --- bootstrap/bootstrap.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bootstrap/bootstrap.py b/bootstrap/bootstrap.py index 8658dad306b..4145ea4adc6 100755 --- a/bootstrap/bootstrap.py +++ b/bootstrap/bootstrap.py @@ -184,6 +184,12 @@ def install_dep(dep: BootstrapDep, ghc: Compiler) -> None: if dep.revision is not None: shutil.copyfile(cabal_file, sdist_dir / f'{dep.package}.cabal') + # We rely on the presence of Setup.hs + if len(list(sdist_dir.glob('Setup.*hs'))) == 0: + with open(sdist_dir / 'Setup.hs', 'w') as f: + f.write('import Distribution.Simple\n') + f.write('main = defaultMain\n') + elif dep.source == PackageSource.LOCAL: if dep.package == 'Cabal': sdist_dir = Path('Cabal').resolve()