Skip to content

Commit 7911900

Browse files
authored
Auto update GMA deps on iOS. (#1191)
* Update dependencies script. * Add code for ignoring old admob cppsdk versions.
1 parent 21f954f commit 7911900

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

scripts/update_android_ios_dependencies.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -316,14 +316,16 @@ def get_pod_files(dirs_and_files):
316316
RE_PODFILE_VERSION = re.compile(
317317
r"\s+pod '(?P<pod_name>.+)', '(?P<version>.+)'\n")
318318

319-
def modify_pod_file(pod_file, pod_version_map, dryrun=True):
319+
def modify_pod_file(pod_file, pod_version_map, dryrun=True, ignore_ios_versions=[]):
320320
"""Update pod versions in specified podfile.
321321
322322
Args:
323323
pod_file (str): Absolute path to a podfile.
324324
pod_version_map (dict): Map of podnames to their respective version.
325325
dryrun (bool, optional): Just print the substitutions.
326326
Do not write to file. Defaults to True.
327+
ignore_ios_versions (set): If the old version number for a pod
328+
matches one of these, don't update it.
327329
"""
328330
global logfile_lines
329331
to_update = False
@@ -341,9 +343,14 @@ def modify_pod_file(pod_file, pod_version_map, dryrun=True):
341343
match = re.match(RE_PODFILE_VERSION, line)
342344
if match:
343345
pod_name = match['pod_name']
346+
skip_line = False
347+
# Check if the old version matches anything in ignore_ios_versions
348+
for ignore_version in ignore_ios_versions:
349+
if ignore_version in match['version']:
350+
skip_line = True
344351
# Firebase/Auth -> Firestore (due to being a subspec)
345352
pod_name_key = re.sub(r'/.*$', '', pod_name)
346-
if pod_name_key in pod_version_map:
353+
if pod_name_key in pod_version_map and not skip_line:
347354
latest_version = pod_version_map[pod_name_key]
348355
substituted_line = line.replace(match['version'], latest_version)
349356
if substituted_line != line:
@@ -690,10 +697,12 @@ def parse_cmdline_args():
690697
parser.add_argument('--skip_ios', action='store_true',
691698
help='Skip iOS pod version update completely.')
692699
# TODO: remove default values when Ads SDK does not need to be pinned.
693-
parser.add_argument('--ignore_ios_pods', nargs='+',
694-
default=('Google-Mobile-Ads-SDK',),
700+
parser.add_argument('--ignore_ios_pods', nargs='+', default=(),
695701
help='Ignore iOS pods which have any of the items specified in '
696702
'this list as substrings.')
703+
parser.add_argument('--ignore_ios_versions', nargs='+', default=('cppsdk',),
704+
help='Do not update any iOS pods when the old version contains '
705+
'any of the items specified in this list as substrings.')
697706
parser.add_argument('--podfiles', nargs='+', default=(os.getcwd(),),
698707
help= 'List of pod files or directories containing podfiles')
699708
parser.add_argument('--specs_repo',
@@ -755,7 +764,8 @@ def main():
755764
pod_files = get_files(args.podfiles, file_extension='', file_name='Podfile',
756765
ignore_directories=set(args.ignore_directories))
757766
for pod_file in pod_files:
758-
modify_pod_file(pod_file, latest_pod_versions_map, args.dryrun)
767+
modify_pod_file(pod_file, latest_pod_versions_map, args.dryrun,
768+
args.ignore_ios_versions)
759769
for readme_file in readme_files:
760770
modify_readme_file_pods(readme_file, latest_pod_versions_map, args.dryrun)
761771

0 commit comments

Comments
 (0)