@@ -112,8 +112,9 @@ class Action(enum.Enum):
112112 CONFIGURE = 'configure'
113113 PACKAGE = 'package'
114114 ALL = 'all'
115- # The 'test' phase is not part of 'all'
115+ # The 'test' and 'package-src' phases are not part of 'all'
116116 TEST = 'test'
117+ PACKAGE_SRC = 'package-src'
117118
118119
119120@enum .unique
@@ -256,30 +257,19 @@ def _default_target(self):
256257 return 'aarch64-none-elf'
257258 return None
258259
259- def _fill_args (self , args : argparse .Namespace ):
260- if 'all' in args .variants :
261- variant_names = LIBRARY_SPECS .keys ()
262- else :
263- variant_names = set (args .variants )
264- self .variants = [LIBRARY_SPECS [v ] for v in sorted (variant_names )]
265-
260+ def _configure_actions (self , args : argparse .Namespace ):
266261 if not args .actions or Action .ALL .value in args .actions :
262+ # Actions that are not part of the "ALL" action:
263+ exclude_from_all = [Action .ALL , Action .TEST , Action .PACKAGE_SRC ]
267264 self .actions = set (action for action in Action
268- if action not in (Action .ALL , Action .TEST ))
269- if Action .TEST .value in args .actions :
270- self .actions .add (Action .TEST )
265+ if action not in exclude_from_all )
266+ for action in [Action .TEST , Action .PACKAGE_SRC ]:
267+ if action .value in args .actions :
268+ self .actions .add (action )
271269 else :
272270 self .actions = set (Action (act_str ) for act_str in args .actions )
273271
274- self .default_target = self ._default_target ()
275-
276- rev = args .revision
277- self .revision = rev
278- self .source_dir = os .path .abspath (args .source_dir )
279- self .repos_dir = _assign_dir (args .repositories_dir , 'repos' , rev )
280- self .build_dir = _assign_dir (args .build_dir , 'build' , rev )
281- self .install_dir = _assign_dir (args .install_dir , 'install' , rev )
282- self .package_dir = os .path .abspath (args .package_dir )
272+ def _configure_toolchains (self , args : argparse .Namespace ):
283273 # According to
284274 # https://docs.python.org/3.6/library/enum.html#using-a-custom-new:
285275 # "The __new__() method, if defined, is used during creation of the
@@ -296,15 +286,33 @@ def _fill_args(self, args: argparse.Namespace):
296286 native_toolchain_dir = os .path .abspath (args .native_toolchain_dir )
297287 self .native_toolchain = Toolchain (native_toolchain_dir ,
298288 native_toolchain_kind )
289+
290+ self .is_using_mingw = self .host_toolchain .kind == ToolchainKind .MINGW
291+ self .is_windows = self .is_using_mingw
292+ self .is_cross_compiling = (os .name == 'posix' and self .is_windows )
293+
294+ def _fill_args (self , args : argparse .Namespace ):
295+ if 'all' in args .variants :
296+ variant_names = LIBRARY_SPECS .keys ()
297+ else :
298+ variant_names = set (args .variants )
299+ self .variants = [LIBRARY_SPECS [v ] for v in sorted (variant_names )]
300+
301+ self .default_target = self ._default_target ()
302+
303+ rev = args .revision
304+ self .revision = rev
305+ self .source_dir = os .path .abspath (args .source_dir )
306+ self .repos_dir = _assign_dir (args .repositories_dir , 'repos' , rev )
307+ self .build_dir = _assign_dir (args .build_dir , 'build' , rev )
308+ self .install_dir = _assign_dir (args .install_dir , 'install' , rev )
309+ self .package_dir = os .path .abspath (args .package_dir )
299310 self .checkout_mode = CheckoutMode (args .checkout_mode )
300311 self .build_mode = BuildMode (args .build_mode )
301312
302- is_using_mingw = self .host_toolchain .kind == ToolchainKind .MINGW
303- is_windows = is_using_mingw
304-
305313 copy_runtime = CopyRuntime (args .copy_runtime_dlls )
306314 self .ask_copy_runtime_dlls = True
307- if is_using_mingw :
315+ if self . is_using_mingw :
308316 self .ask_copy_runtime_dlls = (copy_runtime == CopyRuntime .ASK )
309317 if not self .ask_copy_runtime_dlls :
310318 self ._copy_runtime_dlls = (copy_runtime == CopyRuntime .YES )
@@ -316,7 +324,7 @@ def _fill_args(self, args: argparse.Namespace):
316324 self ._copy_runtime_dlls = False
317325
318326 if args .package_format is None :
319- self .package_format = (PackageFormat .ZIP if is_windows else
327+ self .package_format = (PackageFormat .ZIP if self . is_windows else
320328 PackageFormat .TGZ )
321329 else :
322330 self .package_format = PackageFormat (args .package_format )
@@ -344,9 +352,6 @@ def _fill_inferred(self):
344352 join = os .path .join
345353 self .llvm_repo_dir = join (self .repos_dir , 'llvm.git' )
346354 self .newlib_repo_dir = join (self .repos_dir , 'newlib.git' )
347- is_using_mingw = self .host_toolchain .kind == ToolchainKind .MINGW
348- self .is_cross_compiling = (os .name == 'posix' and is_using_mingw )
349- self .is_windows = is_using_mingw
350355 self .cmake_generator = 'Ninja' if self .use_ninja else 'Unix Makefiles'
351356 self .release_mode = self .revision != 'HEAD'
352357 if self .release_mode :
@@ -358,10 +363,14 @@ def _fill_inferred(self):
358363 self .version_string = now .strftime ('%Y-%m-%d-%H:%M:%S' )
359364 self .skip_reconfigure = self .build_mode == BuildMode .INCREMENTAL
360365 product_name = 'LLVMEmbeddedToolchainForArm'
361- self .package_base_name = product_name + version_suffix
366+ self .bin_package_base_name = product_name + version_suffix
367+ self .src_package_base_name = product_name + version_suffix + '-src'
362368 self .target_llvm_dir = join (
363369 self .install_dir ,
364370 '{}-{}' .format (product_name , self .revision ))
371+ self .install_src_subdir = join (
372+ self .install_dir ,
373+ '{}-{}-src' .format (product_name , self .revision ))
365374 if self .is_cross_compiling :
366375 self .native_llvm_build_dir = join (self .build_dir , 'native-llvm' )
367376 self .native_llvm_dir = join (self .install_dir , 'native-llvm' )
@@ -377,5 +386,7 @@ def _fill_inferred(self):
377386
378387 def __init__ (self , args : argparse .Namespace ):
379388 self ._copy_runtime_dlls = None
389+ self ._configure_actions (args )
390+ self ._configure_toolchains (args )
380391 self ._fill_args (args )
381392 self ._fill_inferred ()
0 commit comments