44Packager script for RemoteTech-Complete.
55
66Prerequisites:
7- - Expect built assemblies (*.dll) in RemoteTech-Complete\src\output
8- - can be overridden with --input-dir.
7+ - Expect built assemblies (*.dll) and assoicated files in
8+ RemoteTech-Complete\src\[sub repositories] directories.
9+
10+ - Expect RemoteTech-Complete.json of specific files and directories
11+ of the sub repositories to include into the final output
12+ directory.
13+
14+ - Expect GameData folder as final output directory.
915
1016 - Working directory is the root directory of the repository
1117 (RemoteTech-Complete/) unless changed with the --cwd command line
2026
2127import packager_config
2228
29+ PACKAGER_VERSION = 0.3
30+ """str: program versioning"""
31+
2332LOGGING_LEVELS = {
2433 'debug' : logging .DEBUG ,
2534 'info' : logging .INFO ,
3342SOURCE_DIR = "src"
3443"""str: name of the source directory (relative to the root folder)."""
3544
36- DEFAULT_OUTPUT_DIR = "{0}{1}GameData{1} RemoteTech" .format (SOURCE_DIR , os .sep )
45+ DEFAULT_OUTPUT_DIR = "GameData {0}RemoteTech" .format (os .sep )
3746"""str: default output directory for the packager.
3847
3948 This is the location where the final package is put."""
4049
50+ DEFAULT_ZIP_INPUT_DIR = "GameData" .format (os .sep )
51+ """str: default input directory (relative to the root folder) to zip."""
52+
53+ DEFAULT_ZIP_OUTPUT_DIR = "output" .format (os .sep )
54+ """str: default output directory (relative to the root folder) for the packager.
55+
56+ This is the location where the zipped final package is deposited in."""
57+
58+ DEFAULT_ZIP_FILENAME = "RemoteTech"
59+ """str: default filename for a zipped file."""
4160
4261class Packager (object ):
4362 def __init__ (self , config_file_path : str , packaging_type : str ):
@@ -225,7 +244,7 @@ def handle_copyable_directories(
225244 if not os .path .isdir (dst_dir ):
226245 shutil .copytree (
227246 src_dir , dst_dir ,
228- ignore = shutil .ignore_patterns (directory .exception_list ))
247+ ignore = shutil .ignore_patterns (* directory .exception_list ))
229248 else :
230249 self .copy_by_pattern (src_dir , dst_dir , directory .copy_list )
231250
@@ -254,6 +273,8 @@ def package_release(self):
254273def main (args ):
255274 logging .info ("Starting packaging script." )
256275
276+ logging .info ("Arguments: {}" .format (args ))
277+
257278 packager = Packager (args .config , args .packaging_type )
258279
259280 # set up directories (cwd, input, output)
@@ -268,6 +289,21 @@ def main(args):
268289 # do the actual release packaging
269290 packager .package_release ()
270291
292+ # perform zip if required
293+ if args .zip :
294+ logging .info ("Zipping {0} as {1}{2}{3}.zip"
295+ .format (args .zip_input_dir ,
296+ args .zip_output_dir ,
297+ os .sep ,
298+ DEFAULT_ZIP_FILENAME ))
299+
300+ shutil .make_archive ("{0}{1}{2}"
301+ .format (args .zip_output_dir ,
302+ os .sep ,
303+ DEFAULT_ZIP_FILENAME ),
304+ 'zip' ,
305+ args .zip_input_dir )
306+
271307 logging .info ("Job done. Quitting!" )
272308
273309
@@ -307,12 +343,24 @@ def main(args):
307343 help = "Packaging type: debug or release [default: release]." )
308344
309345 parser .add_argument (
310- "--version" , action = "version" , version = "%(prog)s 0.2" )
346+ "--version" , action = "version" , version = "%(prog)s {}" . format ( PACKAGER_VERSION ) )
311347
312348 parser .add_argument (
313349 "-z" , "--zip" , action = "store_true" , default = False ,
314350 help = "Also zip the package [output in default output directory]." )
315351
352+ parser .add_argument (
353+ "-zi" , "--zip-input-dir" , action = "store" , dest = "zip_input_dir" ,
354+ default = DEFAULT_ZIP_INPUT_DIR ,
355+ help = "Input directory to zip."
356+ "[default: {}]" .format (DEFAULT_ZIP_INPUT_DIR ))
357+
358+ parser .add_argument (
359+ "-zo" , "--zip-output-dir" , action = "store" , dest = "zip_output_dir" ,
360+ default = DEFAULT_ZIP_OUTPUT_DIR ,
361+ help = "Output directory where to place the zipped package."
362+ "[default: {}]" .format (DEFAULT_ZIP_OUTPUT_DIR ))
363+
316364 # parse arguments
317365 parsed_args = parser .parse_args ()
318366
0 commit comments