mirror of
https://github.com/Xevion/RimWorld-Hydroponics-Expanded.git
synced 2025-12-06 11:16:15 -06:00
Optimize mod build script to only include necessary files
The mod was around 18MB with a bunch of extra crap, now it's <400 KB. About ready to go for v1.
This commit is contained in:
34
build.py
34
build.py
@@ -1,7 +1,9 @@
|
|||||||
import logging
|
import glob
|
||||||
|
import logging
|
||||||
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from shutil import rmtree, copytree
|
from shutil import rmtree
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -41,13 +43,29 @@ def main(output_directory: Path) -> None:
|
|||||||
else:
|
else:
|
||||||
output_mod_directory.mkdir(parents=False)
|
output_mod_directory.mkdir(parents=False)
|
||||||
|
|
||||||
logger.debug('Beginning folder copying sequence.')
|
patterns: List[str] = [
|
||||||
for folder in pertinents_folders:
|
"About/",
|
||||||
source_directory: Path = PROJECT_DIRECTORY / folder
|
"About/About.xml",
|
||||||
destination_directory: Path = output_mod_directory / folder
|
"About/Preview.png",
|
||||||
|
"Assemblies/",
|
||||||
|
"Assemblies/HydroponicsExpanded.dll",
|
||||||
|
"Defs/**",
|
||||||
|
"Languages/**",
|
||||||
|
"Textures/**"
|
||||||
|
]
|
||||||
|
|
||||||
logger.debug('Copying from "{}" to "{}'.format(source_directory, destination_directory))
|
for pattern in patterns:
|
||||||
copytree(source_directory, destination_directory)
|
paths: List[Path] = list(map(Path, glob.glob(str(PROJECT_DIRECTORY / pattern), recursive=True)))
|
||||||
|
|
||||||
|
for source_path in paths:
|
||||||
|
relative_path: Path = source_path.relative_to(PROJECT_DIRECTORY)
|
||||||
|
destination_path: Path = output_mod_directory / relative_path
|
||||||
|
|
||||||
|
logger.debug("Copying from {} to {}".format(source_path, destination_path))
|
||||||
|
if source_path.is_dir():
|
||||||
|
destination_path.mkdir(exist_ok=True)
|
||||||
|
elif source_path.is_file():
|
||||||
|
shutil.copyfile(source_path, destination_path)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Reference in New Issue
Block a user