33import os
44from pathlib import Path
55import platform
6+ from tempfile import TemporaryDirectory
67
78from tc_build .builder import Builder
89from tc_build .source import SourceManager
@@ -28,6 +29,7 @@ def __init__(self):
2829 '--quiet' ,
2930 '--with-system-zlib' ,
3031 ]
32+
3133 self .configure_vars = {
3234 'CC' : 'gcc' ,
3335 'CXX' : 'g++' ,
@@ -54,18 +56,24 @@ def build(self):
5456 self .folders .build .mkdir (exist_ok = True , parents = True )
5557 tc_build .utils .print_header (f"Building { self .target } binutils" )
5658
57- configure_cmd = [
58- Path ( self . folders . source , 'configure' ),
59- * self . configure_flags ,
60- ] + [ f" { var } = { val } " for var , val in self . configure_vars . items ()]
61- self .run_cmd ( configure_cmd , cwd = self . folders . build )
59+ # Binutils does not provide a configuration flag to disable installation of documentation directly.
60+ # Instead, we redirect generated docs to a temporary directory, deleting them after installation.
61+ with TemporaryDirectory () as tmpdir :
62+ doc_dirs = ( 'info' , 'html' , 'pdf' , 'man' )
63+ self .configure_flags += [ f"-- { doc } dir= { tmpdir } " for doc in doc_dirs ]
6264
63- make_cmd = ['make' , '-C' , self .folders .build , '-s' , f"-j{ os .cpu_count ()} " , 'V=0' ]
64- self .run_cmd (make_cmd )
65+ configure_cmd = [
66+ Path (self .folders .source , 'configure' ),
67+ * self .configure_flags ,
68+ ] + [f"{ var } ={ val } " for var , val in self .configure_vars .items ()]
69+ self .run_cmd (configure_cmd , cwd = self .folders .build )
6570
66- if self .folders .install :
67- self .run_cmd ([* make_cmd , 'install' ])
68- tc_build .utils .create_gitignore (self .folders .install )
71+ make_cmd = ['make' , '-C' , self .folders .build , '-s' , f"-j{ os .cpu_count ()} " , 'V=0' ]
72+ self .run_cmd (make_cmd )
73+
74+ if self .folders .install :
75+ self .run_cmd ([* make_cmd , 'install' ])
76+ tc_build .utils .create_gitignore (self .folders .install )
6977
7078
7179class StandardBinutilsBuilder (BinutilsBuilder ):
0 commit comments