2323import re
2424import typing as T
2525import hashlib
26- import copy
2726
2827from .. import build
2928from .. import dependencies
@@ -100,20 +99,18 @@ def __init__(self, source_dir: str, build_dir: str, prefix: str,
10099 self .strip_bin = strip_bin
101100 self .install_umask = install_umask
102101 self .targets : T .List [TargetInstallData ] = []
103- self .headers : 'InstallType' = []
104- self .man : 'InstallType' = []
105- self .data : 'InstallType' = []
106- self .po_package_name : str = ''
107- self .po = []
102+ self .headers : T .List [InstallDataBase ] = []
103+ self .man : T .List [InstallDataBase ] = []
104+ self .data : T .List [InstallDataBase ] = []
108105 self .install_scripts : T .List [ExecutableSerialisation ] = []
109- self .install_subdirs : 'InstallSubdirsType' = []
106+ self .install_subdirs : T . List [ SubdirInstallData ] = []
110107 self .mesonintrospect = mesonintrospect
111108 self .version = version
112109
113110class TargetInstallData :
114111 def __init__ (self , fname : str , outdir : str , aliases : T .Dict [str , str ], strip : bool ,
115112 install_name_mappings : T .Dict , rpath_dirs_to_remove : T .Set [bytes ],
116- install_rpath : str , install_mode : 'FileMode' , optional : bool = False ):
113+ install_rpath : str , install_mode : 'FileMode' , subproject : str , optional : bool = False ):
117114 self .fname = fname
118115 self .outdir = outdir
119116 self .aliases = aliases
@@ -122,8 +119,21 @@ def __init__(self, fname: str, outdir: str, aliases: T.Dict[str, str], strip: bo
122119 self .rpath_dirs_to_remove = rpath_dirs_to_remove
123120 self .install_rpath = install_rpath
124121 self .install_mode = install_mode
122+ self .subproject = subproject
125123 self .optional = optional
126124
125+ class InstallDataBase :
126+ def __init__ (self , path : str , install_path : str , install_mode : 'FileMode' , subproject : str ):
127+ self .path = path
128+ self .install_path = install_path
129+ self .install_mode = install_mode
130+ self .subproject = subproject
131+
132+ class SubdirInstallData (InstallDataBase ):
133+ def __init__ (self , path : str , install_path : str , install_mode : 'FileMode' , exclude , subproject : str ):
134+ super ().__init__ (path , install_path , install_mode , subproject )
135+ self .exclude = exclude
136+
127137class ExecutableSerialisation :
128138 def __init__ (self , cmd_args , env : T .Optional [build .EnvironmentVariables ] = None , exe_wrapper = None ,
129139 workdir = None , extra_paths = None , capture = None ) -> None :
@@ -138,6 +148,7 @@ def __init__(self, cmd_args, env: T.Optional[build.EnvironmentVariables] = None,
138148 self .pickled = False
139149 self .skip_if_destdir = False
140150 self .verbose = False
151+ self .subproject = ''
141152
142153class TestSerialisation :
143154 def __init__ (self , name : str , project : str , suite : str , fname : T .List [str ],
@@ -972,7 +983,7 @@ def generate_depmf_install(self, d: InstallData) -> None:
972983 with open (ifilename , 'w' ) as f :
973984 f .write (json .dumps (mfobj ))
974985 # Copy file from, to, and with mode unchanged
975- d .data .append ((ifilename , ofilename , None ))
986+ d .data .append (InstallDataBase (ifilename , ofilename , None , '' ))
976987
977988 def get_regen_filelist (self ):
978989 '''List of all files whose alteration means that the build
@@ -1297,7 +1308,7 @@ def generate_target_install(self, d: InstallData) -> None:
12971308 i = TargetInstallData (self .get_target_filename (t ), outdirs [0 ],
12981309 t .get_aliases (), should_strip , mappings ,
12991310 t .rpath_dirs_to_remove ,
1300- t .install_rpath , install_mode )
1311+ t .install_rpath , install_mode , t . subproject )
13011312 d .targets .append (i )
13021313
13031314 if isinstance (t , (build .SharedLibrary , build .SharedModule , build .Executable )):
@@ -1315,14 +1326,15 @@ def generate_target_install(self, d: InstallData) -> None:
13151326 # Install the import library; may not exist for shared modules
13161327 i = TargetInstallData (self .get_target_filename_for_linking (t ),
13171328 implib_install_dir , {}, False , {}, set (), '' , install_mode ,
1318- optional = isinstance (t , build .SharedModule ))
1329+ t . subproject , optional = isinstance (t , build .SharedModule ))
13191330 d .targets .append (i )
13201331
13211332 if not should_strip and t .get_debug_filename ():
13221333 debug_file = os .path .join (self .get_target_dir (t ), t .get_debug_filename ())
13231334 i = TargetInstallData (debug_file , outdirs [0 ],
13241335 {}, False , {}, set (), '' ,
1325- install_mode , optional = True )
1336+ install_mode , t .subproject ,
1337+ optional = True )
13261338 d .targets .append (i )
13271339 # Install secondary outputs. Only used for Vala right now.
13281340 if num_outdirs > 1 :
@@ -1331,7 +1343,8 @@ def generate_target_install(self, d: InstallData) -> None:
13311343 if outdir is False :
13321344 continue
13331345 f = os .path .join (self .get_target_dir (t ), output )
1334- i = TargetInstallData (f , outdir , {}, False , {}, set (), None , install_mode )
1346+ i = TargetInstallData (f , outdir , {}, False , {}, set (), None ,
1347+ install_mode , t .subproject )
13351348 d .targets .append (i )
13361349 elif isinstance (t , build .CustomTarget ):
13371350 # If only one install_dir is specified, assume that all
@@ -1345,7 +1358,7 @@ def generate_target_install(self, d: InstallData) -> None:
13451358 for output in t .get_outputs ():
13461359 f = os .path .join (self .get_target_dir (t ), output )
13471360 i = TargetInstallData (f , outdirs [0 ], {}, False , {}, set (), None , install_mode ,
1348- optional = not t .build_by_default )
1361+ t . subproject , optional = not t .build_by_default )
13491362 d .targets .append (i )
13501363 else :
13511364 for output , outdir in zip (t .get_outputs (), outdirs ):
@@ -1354,23 +1367,11 @@ def generate_target_install(self, d: InstallData) -> None:
13541367 continue
13551368 f = os .path .join (self .get_target_dir (t ), output )
13561369 i = TargetInstallData (f , outdir , {}, False , {}, set (), None , install_mode ,
1357- optional = not t .build_by_default )
1370+ t . subproject , optional = not t .build_by_default )
13581371 d .targets .append (i )
13591372
13601373 def generate_custom_install_script (self , d : InstallData ) -> None :
1361- result : T .List [ExecutableSerialisation ] = []
1362- srcdir = self .environment .get_source_dir ()
1363- builddir = self .environment .get_build_dir ()
1364- for i in self .build .install_scripts :
1365- fixed_args = []
1366- for a in i .cmd_args :
1367- a = a .replace ('@SOURCE_ROOT@' , srcdir )
1368- a = a .replace ('@BUILD_ROOT@' , builddir )
1369- fixed_args .append (a )
1370- es = copy .copy (i )
1371- es .cmd_args = fixed_args
1372- result .append (es )
1373- d .install_scripts = result
1374+ d .install_scripts = self .build .install_scripts
13741375
13751376 def generate_header_install (self , d : InstallData ) -> None :
13761377 incroot = self .environment .get_includedir ()
@@ -1387,7 +1388,7 @@ def generate_header_install(self, d: InstallData) -> None:
13871388 msg = 'Invalid header type {!r} can\' t be installed'
13881389 raise MesonException (msg .format (f ))
13891390 abspath = f .absolute_path (srcdir , builddir )
1390- i = (abspath , outdir , h .get_custom_install_mode ())
1391+ i = InstallDataBase (abspath , outdir , h .get_custom_install_mode (), h . subproject )
13911392 d .headers .append (i )
13921393
13931394 def generate_man_install (self , d : InstallData ) -> None :
@@ -1401,7 +1402,7 @@ def generate_man_install(self, d: InstallData) -> None:
14011402 subdir = os .path .join (manroot , 'man' + num )
14021403 srcabs = f .absolute_path (self .environment .get_source_dir (), self .environment .get_build_dir ())
14031404 dstabs = os .path .join (subdir , os .path .basename (f .fname ))
1404- i = (srcabs , dstabs , m .get_custom_install_mode ())
1405+ i = InstallDataBase (srcabs , dstabs , m .get_custom_install_mode (), m . subproject )
14051406 d .man .append (i )
14061407
14071408 def generate_data_install (self , d : InstallData ):
@@ -1416,7 +1417,7 @@ def generate_data_install(self, d: InstallData):
14161417 for src_file , dst_name in zip (de .sources , de .rename ):
14171418 assert (isinstance (src_file , mesonlib .File ))
14181419 dst_abs = os .path .join (subdir , dst_name )
1419- i = (src_file .absolute_path (srcdir , builddir ), dst_abs , de .install_mode )
1420+ i = InstallDataBase (src_file .absolute_path (srcdir , builddir ), dst_abs , de .install_mode , de . subproject )
14201421 d .data .append (i )
14211422
14221423 def generate_subdir_install (self , d : InstallData ) -> None :
@@ -1432,8 +1433,8 @@ def generate_subdir_install(self, d: InstallData) -> None:
14321433 sd .install_dir )
14331434 if not sd .strip_directory :
14341435 dst_dir = os .path .join (dst_dir , os .path .basename (src_dir ))
1435- d . install_subdirs . append (
1436- ( src_dir , dst_dir , sd . install_mode , sd . exclude ) )
1436+ i = SubdirInstallData ( src_dir , dst_dir , sd . install_mode , sd . exclude , sd . subproject )
1437+ d . install_subdirs . append ( i )
14371438
14381439 def get_introspection_data (self , target_id : str , target : build .Target ) -> T .List [T .Dict [str , T .Union [bool , str , T .List [T .Union [str , T .Dict [str , T .Union [str , T .List [str ], bool ]]]]]]]:
14391440 '''
0 commit comments