Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add all configs in case no configuration is passed to CmdLineExportLib #14

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 14 additions & 21 deletions CmdLineExportLib.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
import os.path
import shutil
import sys
import subprocess
from typing import Dict, Tuple, Sequence, Union, List, Optional

# External Modules
import ASTools
Expand All @@ -26,7 +24,7 @@
def main():

buildStatus = None
libBuildConfig:List[ASTools.Project.buildConfigs] = []
libBuildConfig: list[ASTools.BuildConfig] = []

# Parse arguments from the command line
parser = argparse.ArgumentParser(description='Export libraries from an AS project with command line arguments.')
Expand Down Expand Up @@ -67,31 +65,26 @@ def main():

project = ASTools.Project(args.project)

# TODO: This section of config names to BuildConfig list can probably be improved (next ~85 lines)
# Using something like for each config name project.getConfigByName
for buildConfig in project.buildConfigs:
if args.configuration != None:
if buildConfig.name in args.configuration:
libBuildConfig.append(buildConfig)
if args.configuration is None:
libBuildConfig.extend(project.buildConfigs)
else:
for configuration in args.configuration:
if configuration in project.buildConfigNames:
libBuildConfig.append(project.getConfigByName(configuration))
else:
logging.error('\033[31mNot a configuration in specified project: %s\033[0m', str(configuration))

if not len(libBuildConfig):
logging.error('\033[31mNot a configration in specified project: %s\033[0m', str(args.configuration))
if not libBuildConfig:
sys.exit('Configuration passed in is not part of AS project')

libBuildConfigNames:List[str] = [config.name for config in libBuildConfig]

for name in args.configuration:
if name not in libBuildConfigNames:
logging.error('Configuration name does not exist in project: %s', name)

if args.buildMode != 'None':
for config in args.configuration:
buildStatus = project.build(config, buildMode=args.buildMode, simulation=False)
for config in libBuildConfig:
buildStatus = project.build(config.name, buildMode=args.buildMode, simulation=False)

if buildStatus.returncode > ASTools.ASReturnCodes['Warnings']:
sys.exit('Build failed for config {config}')
sys.exit(f'Build failed for config {config.name}')
else:
logging.debug('Building of %s Complete!', config)
logging.debug('Building of %s Complete!', config.name)

if args.buildMode == 'None' or buildStatus.returncode <= ASTools.ASReturnCodes['Errors']:
results = project.exportLibraries(args.destination, overwrite=args.overwrite, buildConfigs=libBuildConfig, blacklist=args.blacklist, whitelist=args.whitelist, binary= not args.sourceFile, includeVersion= args.includeVersion )
Expand Down