From fcc2184e16aa1783bf9b60873080930fda1e7510 Mon Sep 17 00:00:00 2001 From: Mou Date: Mon, 3 Apr 2023 15:38:27 -0700 Subject: [PATCH 01/59] test workflow --- .../Sources/ModelDownloadTask.swift | 2 +- .../Sources/ModelDownloader.swift | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/FirebaseMLModelDownloader/Sources/ModelDownloadTask.swift b/FirebaseMLModelDownloader/Sources/ModelDownloadTask.swift index 05256933f29..8157dd1a0fb 100644 --- a/FirebaseMLModelDownloader/Sources/ModelDownloadTask.swift +++ b/FirebaseMLModelDownloader/Sources/ModelDownloadTask.swift @@ -15,7 +15,7 @@ import Foundation /// Task to download model file to device. -class ModelDownloadTask { +final class ModelDownloadTask { /// Name of the app associated with this instance of ModelDownloadTask. private let appName: String diff --git a/FirebaseMLModelDownloader/Sources/ModelDownloader.swift b/FirebaseMLModelDownloader/Sources/ModelDownloader.swift index 6094ae02b9e..43632de851a 100644 --- a/FirebaseMLModelDownloader/Sources/ModelDownloader.swift +++ b/FirebaseMLModelDownloader/Sources/ModelDownloader.swift @@ -27,7 +27,7 @@ public enum ModelDownloadType { } /// Downloader to manage custom model downloads. -public class ModelDownloader { +public struct ModelDownloader { /// Name of the app associated with this instance of ModelDownloader. private let appName: String @@ -96,13 +96,21 @@ public class ModelDownloader { } /// Model downloader with default app. - public static func modelDownloader() -> ModelDownloader { + public static func modelDownloader() -> ModelDownloader? { guard let defaultApp = FirebaseApp.app() else { fatalError(ModelDownloader.ErrorDescription.defaultAppNotConfigured) } return modelDownloader(app: defaultApp) } + /// Model downloader with default app. + public static func modelDownloaderNullable() -> ModelDownloader? { + guard let defaultApp = FirebaseApp.app() else { + fatalError(ModelDownloader.ErrorDescription.defaultAppNotConfigured) + } + return nil + } + /// Model Downloader with custom app. public static func modelDownloader(app: FirebaseApp) -> ModelDownloader { if let downloader = modelDownloaderDictionary[app.name] { From 684c947cf1fe8eff6e17e8a9fa9f2e2393cb1777 Mon Sep 17 00:00:00 2001 From: Mou Date: Mon, 3 Apr 2023 15:42:56 -0700 Subject: [PATCH 02/59] test workflow --- .github/workflows/api_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/api_report.yml b/.github/workflows/api_report.yml index c981d2ee3db..7ec71d585a2 100644 --- a/.github/workflows/api_report.yml +++ b/.github/workflows/api_report.yml @@ -17,7 +17,7 @@ jobs: run: mkdir ~/diff - name: List changed files - run: git diff --name-only ${{ github.base_ref }}) + run: git diff --name-only ${{ github.base_ref }} - name: Checkout master uses: actions/checkout@v3 From 461a328649021f7e347b283b3d8744d16d524186 Mon Sep 17 00:00:00 2001 From: Mou Date: Mon, 3 Apr 2023 16:09:57 -0700 Subject: [PATCH 03/59] test workflow --- .github/workflows/api_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/api_report.yml b/.github/workflows/api_report.yml index 7ec71d585a2..ed15fbf539e 100644 --- a/.github/workflows/api_report.yml +++ b/.github/workflows/api_report.yml @@ -17,7 +17,7 @@ jobs: run: mkdir ~/diff - name: List changed files - run: git diff --name-only ${{ github.base_ref }} + run: git diff --name-only ${{ github.ref }} ${{ github.base_ref }} - name: Checkout master uses: actions/checkout@v3 From f47aebf423ff0817deef6aa0c8544275a8393b66 Mon Sep 17 00:00:00 2001 From: Mou Date: Mon, 3 Apr 2023 16:14:53 -0700 Subject: [PATCH 04/59] test workflow --- .github/workflows/api_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/api_report.yml b/.github/workflows/api_report.yml index ed15fbf539e..88f1d382159 100644 --- a/.github/workflows/api_report.yml +++ b/.github/workflows/api_report.yml @@ -17,7 +17,7 @@ jobs: run: mkdir ~/diff - name: List changed files - run: git diff --name-only ${{ github.ref }} ${{ github.base_ref }} + run: git diff --name-only ${{ github.head_ref }} `git merge-base ${{ github.head_ref }} ${{ github.base_ref }}` - name: Checkout master uses: actions/checkout@v3 From d7c48f835bde89231c83f3dc07afc1eda92d9fc8 Mon Sep 17 00:00:00 2001 From: Mou Date: Mon, 3 Apr 2023 16:21:21 -0700 Subject: [PATCH 05/59] test workflow --- .github/workflows/api_report.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/api_report.yml b/.github/workflows/api_report.yml index 88f1d382159..a1106e7409e 100644 --- a/.github/workflows/api_report.yml +++ b/.github/workflows/api_report.yml @@ -12,13 +12,15 @@ jobs: - name: Checkout PR branch uses: actions/checkout@v3 + with: + fetch-depth: 2 + + - name: Get changes + run: git diff --name-only -r HEAD^1 HEAD - name: Make diff directory run: mkdir ~/diff - - name: List changed files - run: git diff --name-only ${{ github.head_ref }} `git merge-base ${{ github.head_ref }} ${{ github.base_ref }}` - - name: Checkout master uses: actions/checkout@v3 with: From ba50f3b846c85a89a9def36c7121ec0dba7601b2 Mon Sep 17 00:00:00 2001 From: Mou Date: Mon, 3 Apr 2023 17:32:52 -0700 Subject: [PATCH 06/59] test workflow --- .github/workflows/api_report.yml | 8 +++---- scripts/api_diff_report/api_info.py | 37 +++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 scripts/api_diff_report/api_info.py diff --git a/.github/workflows/api_report.yml b/.github/workflows/api_report.yml index a1106e7409e..15f9cbf4b95 100644 --- a/.github/workflows/api_report.yml +++ b/.github/workflows/api_report.yml @@ -15,11 +15,11 @@ jobs: with: fetch-depth: 2 - - name: Get changes - run: git diff --name-only -r HEAD^1 HEAD + - id: get_changed_files + run: echo "file_list=$(git diff --name-only -r HEAD^1 HEAD)" >> $GITHUB_OUTPUT - - name: Make diff directory - run: mkdir ~/diff + - name: Generate API files for PR branch + run: python scripts/api_diff_report/api_info.py -f ${{ steps.get_changed_files.outputs.file_list }} - name: Checkout master uses: actions/checkout@v3 diff --git a/scripts/api_diff_report/api_info.py b/scripts/api_diff_report/api_info.py new file mode 100644 index 00000000000..06b13626a39 --- /dev/null +++ b/scripts/api_diff_report/api_info.py @@ -0,0 +1,37 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the 'License'); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an 'AS IS' BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import json +import argparse +import logging +import os + +def main(): + logging.getLogger().setLevel(logging.INFO) + + args = parse_cmdline_args() + logging.info(args) + logging.info(args.file_list) + + +def parse_cmdline_args(): + parser = argparse.ArgumentParser() + parser.add_argument('-f', '--file_list', nargs='+', default=[]) + + args = parser.parse_args() + return args + + +if __name__ == '__main__': + main() \ No newline at end of file From 749f5512cd3cce630219e44dc77d6d3c83a9a8b8 Mon Sep 17 00:00:00 2001 From: Mou Date: Mon, 3 Apr 2023 17:39:49 -0700 Subject: [PATCH 07/59] test workflow --- .github/workflows/api_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/api_report.yml b/.github/workflows/api_report.yml index 15f9cbf4b95..2d07a9fbcaf 100644 --- a/.github/workflows/api_report.yml +++ b/.github/workflows/api_report.yml @@ -16,7 +16,7 @@ jobs: fetch-depth: 2 - id: get_changed_files - run: echo "file_list=$(git diff --name-only -r HEAD^1 HEAD)" >> $GITHUB_OUTPUT + run: echo "file_list=$(git diff --name-only -r HEAD^1 HEAD | tr '\n' ' ')" >> $GITHUB_OUTPUT - name: Generate API files for PR branch run: python scripts/api_diff_report/api_info.py -f ${{ steps.get_changed_files.outputs.file_list }} From bb5e213179a51ea3637ef7969d6aaed733a6ad0f Mon Sep 17 00:00:00 2001 From: Mou Date: Mon, 3 Apr 2023 17:52:31 -0700 Subject: [PATCH 08/59] test workflow --- .github/workflows/api_report.yml | 5 ++++- scripts/api_diff_report/api_info.py | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/.github/workflows/api_report.yml b/.github/workflows/api_report.yml index 2d07a9fbcaf..090859492d7 100644 --- a/.github/workflows/api_report.yml +++ b/.github/workflows/api_report.yml @@ -19,9 +19,12 @@ jobs: run: echo "file_list=$(git diff --name-only -r HEAD^1 HEAD | tr '\n' ' ')" >> $GITHUB_OUTPUT - name: Generate API files for PR branch - run: python scripts/api_diff_report/api_info.py -f ${{ steps.get_changed_files.outputs.file_list }} + run: python scripts/api_diff_report/api_info.py -f ${{ steps.get_changed_files.outputs.file_list }} -o "merge_branch" - name: Checkout master uses: actions/checkout@v3 with: ref: ${{ github.base_ref }} + + - name: Generate API files for PR branch + run: python scripts/api_diff_report/api_info.py -f ${{ steps.get_changed_files.outputs.file_list }} -o "base_branch" diff --git a/scripts/api_diff_report/api_info.py b/scripts/api_diff_report/api_info.py index 06b13626a39..46ab3830e8b 100644 --- a/scripts/api_diff_report/api_info.py +++ b/scripts/api_diff_report/api_info.py @@ -16,18 +16,32 @@ import argparse import logging import os +import subprocess def main(): logging.getLogger().setLevel(logging.INFO) args = parse_cmdline_args() logging.info(args) - logging.info(args.file_list) + + for file in args.file_list: + if file.endswith('.swift'): + result = subprocess.run( + args=["sourcekitten", "doc", "--single-file", file], + capture_output=True, + text=True, + check=False) + logging.info(file) + logging.info(result.stdout) + report_file_path = os.path.join(args.output_dir, os.path.join(os.path.basename(file), ".json")) + with open(report_file_path, 'w') as f: + f.write(result.stdout) def parse_cmdline_args(): parser = argparse.ArgumentParser() parser.add_argument('-f', '--file_list', nargs='+', default=[]) + parser.add_argument('-o', '--output_dir', default="") args = parser.parse_args() return args From 7dae76553e1419d2f39187fe7d131697b7310f8e Mon Sep 17 00:00:00 2001 From: Mou Date: Mon, 3 Apr 2023 17:58:28 -0700 Subject: [PATCH 09/59] test workflow --- .github/workflows/api_report.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/api_report.yml b/.github/workflows/api_report.yml index 090859492d7..61b2f76d355 100644 --- a/.github/workflows/api_report.yml +++ b/.github/workflows/api_report.yml @@ -17,6 +17,11 @@ jobs: - id: get_changed_files run: echo "file_list=$(git diff --name-only -r HEAD^1 HEAD | tr '\n' ' ')" >> $GITHUB_OUTPUT + + - name: Setup python + uses: actions/setup-python@v4 + with: + python-version: 3.7 - name: Generate API files for PR branch run: python scripts/api_diff_report/api_info.py -f ${{ steps.get_changed_files.outputs.file_list }} -o "merge_branch" From 626180433d0f12f3cf9001a452f78164cd78e5a9 Mon Sep 17 00:00:00 2001 From: Mou Date: Mon, 3 Apr 2023 18:04:00 -0700 Subject: [PATCH 10/59] test workflow --- scripts/api_diff_report/api_info.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/api_diff_report/api_info.py b/scripts/api_diff_report/api_info.py index 46ab3830e8b..1a2e6db84e5 100644 --- a/scripts/api_diff_report/api_info.py +++ b/scripts/api_diff_report/api_info.py @@ -24,6 +24,10 @@ def main(): args = parse_cmdline_args() logging.info(args) + isExist = os.path.exists(args.output_dir) + if not isExist: + os.makedirs(args.output_dir) + for file in args.file_list: if file.endswith('.swift'): result = subprocess.run( @@ -33,7 +37,7 @@ def main(): check=False) logging.info(file) logging.info(result.stdout) - report_file_path = os.path.join(args.output_dir, os.path.join(os.path.basename(file), ".json")) + report_file_path = os.path.join(args.output_dir, os.path.basename(file) + ".json") with open(report_file_path, 'w') as f: f.write(result.stdout) From fa40cee7119c3ccd5f495ffbe5b95bace709af9f Mon Sep 17 00:00:00 2001 From: Mou Date: Mon, 3 Apr 2023 18:10:18 -0700 Subject: [PATCH 11/59] test workflow --- .github/workflows/api_report.yml | 15 +++++++++++++-- scripts/api_diff_report/api_info.py | 4 ++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/api_report.yml b/.github/workflows/api_report.yml index 61b2f76d355..35f74b3a541 100644 --- a/.github/workflows/api_report.yml +++ b/.github/workflows/api_report.yml @@ -24,7 +24,10 @@ jobs: python-version: 3.7 - name: Generate API files for PR branch - run: python scripts/api_diff_report/api_info.py -f ${{ steps.get_changed_files.outputs.file_list }} -o "merge_branch" + run: cp scripts/api_diff_report/api_info.py my_test/api_info.py + + - name: Generate API files for PR branch + run: python my_test/api_info.py -f ${{ steps.get_changed_files.outputs.file_list }} -o "merge_branch" - name: Checkout master uses: actions/checkout@v3 @@ -32,4 +35,12 @@ jobs: ref: ${{ github.base_ref }} - name: Generate API files for PR branch - run: python scripts/api_diff_report/api_info.py -f ${{ steps.get_changed_files.outputs.file_list }} -o "base_branch" + run: python my_test/api_info.py -f ${{ steps.get_changed_files.outputs.file_list }} -o "base_branch" + + - uses: actions/upload-artifact@v3 + with: + name: api_info + path: | + merge_branch + base_branch + retention-days: 1 diff --git a/scripts/api_diff_report/api_info.py b/scripts/api_diff_report/api_info.py index 1a2e6db84e5..d4d90aead76 100644 --- a/scripts/api_diff_report/api_info.py +++ b/scripts/api_diff_report/api_info.py @@ -35,8 +35,8 @@ def main(): capture_output=True, text=True, check=False) - logging.info(file) - logging.info(result.stdout) + # logging.info(file) + # logging.info(result.stdout) report_file_path = os.path.join(args.output_dir, os.path.basename(file) + ".json") with open(report_file_path, 'w') as f: f.write(result.stdout) From 846b6aba94a6be0f636ff7a87701bcd6fe141e03 Mon Sep 17 00:00:00 2001 From: Mou Date: Mon, 3 Apr 2023 18:12:20 -0700 Subject: [PATCH 12/59] test workflow --- .github/workflows/api_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/api_report.yml b/.github/workflows/api_report.yml index 35f74b3a541..59b60fb0741 100644 --- a/.github/workflows/api_report.yml +++ b/.github/workflows/api_report.yml @@ -24,7 +24,7 @@ jobs: python-version: 3.7 - name: Generate API files for PR branch - run: cp scripts/api_diff_report/api_info.py my_test/api_info.py + run: mkdir my_test && cp scripts/api_diff_report/api_info.py my_test/api_info.py - name: Generate API files for PR branch run: python my_test/api_info.py -f ${{ steps.get_changed_files.outputs.file_list }} -o "merge_branch" From 7d30347d4e1ba39317b56e55a7f7df93a953d251 Mon Sep 17 00:00:00 2001 From: Mou Date: Mon, 3 Apr 2023 18:15:11 -0700 Subject: [PATCH 13/59] test workflow --- .github/workflows/api_report.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/api_report.yml b/.github/workflows/api_report.yml index 59b60fb0741..053dd59fbb1 100644 --- a/.github/workflows/api_report.yml +++ b/.github/workflows/api_report.yml @@ -24,10 +24,10 @@ jobs: python-version: 3.7 - name: Generate API files for PR branch - run: mkdir my_test && cp scripts/api_diff_report/api_info.py my_test/api_info.py + run: cp scripts/api_diff_report/api_info.py ${{ github.workspace }}/api_info.py - name: Generate API files for PR branch - run: python my_test/api_info.py -f ${{ steps.get_changed_files.outputs.file_list }} -o "merge_branch" + run: python ${{ github.workspace }}/api_info.py -f ${{ steps.get_changed_files.outputs.file_list }} -o "merge_branch" - name: Checkout master uses: actions/checkout@v3 @@ -35,7 +35,7 @@ jobs: ref: ${{ github.base_ref }} - name: Generate API files for PR branch - run: python my_test/api_info.py -f ${{ steps.get_changed_files.outputs.file_list }} -o "base_branch" + run: python ${{ github.workspace }}/api_info.py -f ${{ steps.get_changed_files.outputs.file_list }} -o "base_branch" - uses: actions/upload-artifact@v3 with: From 50e7f4afba8665a25752a7948b601b73303b2f12 Mon Sep 17 00:00:00 2001 From: Mou Date: Mon, 3 Apr 2023 18:15:38 -0700 Subject: [PATCH 14/59] test workflow --- .github/workflows/api_report.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/api_report.yml b/.github/workflows/api_report.yml index 053dd59fbb1..6074bad116c 100644 --- a/.github/workflows/api_report.yml +++ b/.github/workflows/api_report.yml @@ -27,7 +27,7 @@ jobs: run: cp scripts/api_diff_report/api_info.py ${{ github.workspace }}/api_info.py - name: Generate API files for PR branch - run: python ${{ github.workspace }}/api_info.py -f ${{ steps.get_changed_files.outputs.file_list }} -o "merge_branch" + run: python ${{ github.workspace }}/api_info.py -f ${{ steps.get_changed_files.outputs.file_list }} -o "${{ github.workspace }}/merge_branch" - name: Checkout master uses: actions/checkout@v3 @@ -35,12 +35,12 @@ jobs: ref: ${{ github.base_ref }} - name: Generate API files for PR branch - run: python ${{ github.workspace }}/api_info.py -f ${{ steps.get_changed_files.outputs.file_list }} -o "base_branch" + run: python ${{ github.workspace }}/api_info.py -f ${{ steps.get_changed_files.outputs.file_list }} -o "${{ github.workspace }}/base_branch" - uses: actions/upload-artifact@v3 with: name: api_info path: | - merge_branch - base_branch + ${{ github.workspace }}/merge_branch + ${{ github.workspace }}/base_branch retention-days: 1 From bc2f2a19a7150d9e470f7145a89751765cfec9c6 Mon Sep 17 00:00:00 2001 From: Mou Date: Mon, 3 Apr 2023 18:20:25 -0700 Subject: [PATCH 15/59] test workflow --- .github/workflows/api_report.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/api_report.yml b/.github/workflows/api_report.yml index 6074bad116c..d1b240508b3 100644 --- a/.github/workflows/api_report.yml +++ b/.github/workflows/api_report.yml @@ -23,24 +23,24 @@ jobs: with: python-version: 3.7 - - name: Generate API files for PR branch - run: cp scripts/api_diff_report/api_info.py ${{ github.workspace }}/api_info.py + - name: Copy script + run: cp scripts/api_diff_report/api_info.py ~/api_info.py - name: Generate API files for PR branch - run: python ${{ github.workspace }}/api_info.py -f ${{ steps.get_changed_files.outputs.file_list }} -o "${{ github.workspace }}/merge_branch" + run: python ~/api_info.py -f ${{ steps.get_changed_files.outputs.file_list }} -o "~/merge_branch" - name: Checkout master uses: actions/checkout@v3 with: ref: ${{ github.base_ref }} - - name: Generate API files for PR branch - run: python ${{ github.workspace }}/api_info.py -f ${{ steps.get_changed_files.outputs.file_list }} -o "${{ github.workspace }}/base_branch" + - name: Generate API files for Base branch + run: python ~/api_info.py -f ${{ steps.get_changed_files.outputs.file_list }} -o "~/base_branch" - uses: actions/upload-artifact@v3 with: name: api_info path: | - ${{ github.workspace }}/merge_branch - ${{ github.workspace }}/base_branch + ~/merge_branch + ~/base_branch retention-days: 1 From c3e9c736f75ee40af07152ad6ed700923a44ef8a Mon Sep 17 00:00:00 2001 From: Mou Date: Mon, 3 Apr 2023 18:24:07 -0700 Subject: [PATCH 16/59] test workflow --- scripts/api_diff_report/api_info.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/api_diff_report/api_info.py b/scripts/api_diff_report/api_info.py index d4d90aead76..25ae8df0420 100644 --- a/scripts/api_diff_report/api_info.py +++ b/scripts/api_diff_report/api_info.py @@ -35,10 +35,11 @@ def main(): capture_output=True, text=True, check=False) - # logging.info(file) - # logging.info(result.stdout) - report_file_path = os.path.join(args.output_dir, os.path.basename(file) + ".json") - with open(report_file_path, 'w') as f: + logging.info(file) + logging.info(result.stdout) + file_path = os.path.join(args.output_dir, os.path.basename(file) + ".json") + logging.info(file_path) + with open(file_path, 'w') as f: f.write(result.stdout) From 65425a43249a691c7e2c8af0339789aed8099e6b Mon Sep 17 00:00:00 2001 From: Mou Date: Mon, 3 Apr 2023 18:27:41 -0700 Subject: [PATCH 17/59] test workflow --- .github/workflows/api_report.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/api_report.yml b/.github/workflows/api_report.yml index d1b240508b3..31c9f7fc1ec 100644 --- a/.github/workflows/api_report.yml +++ b/.github/workflows/api_report.yml @@ -37,6 +37,9 @@ jobs: - name: Generate API files for Base branch run: python ~/api_info.py -f ${{ steps.get_changed_files.outputs.file_list }} -o "~/base_branch" + - name: Check + run: ls ~/merge_branch + - uses: actions/upload-artifact@v3 with: name: api_info From 62bebb2dc93ddb3d6719b39a798a314f3c66d9ae Mon Sep 17 00:00:00 2001 From: Mou Date: Mon, 3 Apr 2023 18:33:11 -0700 Subject: [PATCH 18/59] test workflow --- scripts/api_diff_report/api_info.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/api_diff_report/api_info.py b/scripts/api_diff_report/api_info.py index 25ae8df0420..5249828b342 100644 --- a/scripts/api_diff_report/api_info.py +++ b/scripts/api_diff_report/api_info.py @@ -24,9 +24,10 @@ def main(): args = parse_cmdline_args() logging.info(args) - isExist = os.path.exists(args.output_dir) + output_dir = os.path.expanduser(args.output_dir) + isExist = os.path.exists(output_dir) if not isExist: - os.makedirs(args.output_dir) + os.makedirs(output_dir) for file in args.file_list: if file.endswith('.swift'): @@ -36,8 +37,8 @@ def main(): text=True, check=False) logging.info(file) - logging.info(result.stdout) - file_path = os.path.join(args.output_dir, os.path.basename(file) + ".json") + # logging.info(result.stdout) + file_path = os.path.join(output_dir, os.path.basename(file) + ".json") logging.info(file_path) with open(file_path, 'w') as f: f.write(result.stdout) From 774899216fb6d0c016bd2393f7c82b23f06f2733 Mon Sep 17 00:00:00 2001 From: Mou Date: Mon, 3 Apr 2023 18:51:33 -0700 Subject: [PATCH 19/59] test workflow --- .github/workflows/api_report.yml | 4 +- scripts/api_diff_report/api_diff.py | 61 +++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 scripts/api_diff_report/api_diff.py diff --git a/.github/workflows/api_report.yml b/.github/workflows/api_report.yml index 31c9f7fc1ec..823a1d57e48 100644 --- a/.github/workflows/api_report.yml +++ b/.github/workflows/api_report.yml @@ -37,8 +37,8 @@ jobs: - name: Generate API files for Base branch run: python ~/api_info.py -f ${{ steps.get_changed_files.outputs.file_list }} -o "~/base_branch" - - name: Check - run: ls ~/merge_branch + - name: Diff + run: python scripts/api_diff_report/api_diff.py/api_diff.py -m "~/merge_branch" -b "~/base_branch" - uses: actions/upload-artifact@v3 with: diff --git a/scripts/api_diff_report/api_diff.py b/scripts/api_diff_report/api_diff.py new file mode 100644 index 00000000000..c21e614bff7 --- /dev/null +++ b/scripts/api_diff_report/api_diff.py @@ -0,0 +1,61 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the 'License'); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an 'AS IS' BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import json +import argparse +import logging +import os +import subprocess + +def main(): + logging.getLogger().setLevel(logging.INFO) + + args = parse_cmdline_args() + logging.info(args) + + merged_branch = os.path.expanduser(args.merged_branch) + base_branch = os.path.expanduser(args.base_branch) + + result = subprocess.run( + args=["diff", "-wEburN", "--word-diff", merged_branch, base_branch], + capture_output=True, + text=True, + check=False) + logging.info(result.stdout) + logging.info("------------") + + for merged_file in os.listdir(merged_branch): + file_name = os.path.basename(merged_file) + base_file = os.path.join(base_branch, file_name) + result = subprocess.run( + args=["git", "diff", "--no-index", "--word-diff", file_name, base_file], + capture_output=True, + text=True, + check=False) + logging.info(result.stdout) + pr_api = json.load(open(merged_file)) + base_api = json.load(open(base_file)) + + +def parse_cmdline_args(): + parser = argparse.ArgumentParser() + parser.add_argument('-m', '--merged_branch') + parser.add_argument('-b', '--base_branch') + + args = parser.parse_args() + return args + + +if __name__ == '__main__': + main() \ No newline at end of file From da76aa28cb1af5d8d5d939ea98c172da2f350321 Mon Sep 17 00:00:00 2001 From: Mou Date: Mon, 3 Apr 2023 18:53:41 -0700 Subject: [PATCH 20/59] test workflow --- .github/workflows/api_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/api_report.yml b/.github/workflows/api_report.yml index 823a1d57e48..1a19548b057 100644 --- a/.github/workflows/api_report.yml +++ b/.github/workflows/api_report.yml @@ -38,7 +38,7 @@ jobs: run: python ~/api_info.py -f ${{ steps.get_changed_files.outputs.file_list }} -o "~/base_branch" - name: Diff - run: python scripts/api_diff_report/api_diff.py/api_diff.py -m "~/merge_branch" -b "~/base_branch" + run: python scripts/api_diff_report/api_diff.py -m "~/merge_branch" -b "~/base_branch" - uses: actions/upload-artifact@v3 with: From 68106133da71ca1665fa8a8cbfb0ffa48219bc0e Mon Sep 17 00:00:00 2001 From: Mou Date: Mon, 3 Apr 2023 18:56:53 -0700 Subject: [PATCH 21/59] test workflow --- .github/workflows/api_report.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/api_report.yml b/.github/workflows/api_report.yml index 1a19548b057..7828b12682c 100644 --- a/.github/workflows/api_report.yml +++ b/.github/workflows/api_report.yml @@ -24,7 +24,9 @@ jobs: python-version: 3.7 - name: Copy script - run: cp scripts/api_diff_report/api_info.py ~/api_info.py + run: | + cp scripts/api_diff_report/api_info.py ~/api_info.py + cp scripts/api_diff_report/api_diff.py ~/api_diff.py - name: Generate API files for PR branch run: python ~/api_info.py -f ${{ steps.get_changed_files.outputs.file_list }} -o "~/merge_branch" @@ -38,7 +40,7 @@ jobs: run: python ~/api_info.py -f ${{ steps.get_changed_files.outputs.file_list }} -o "~/base_branch" - name: Diff - run: python scripts/api_diff_report/api_diff.py -m "~/merge_branch" -b "~/base_branch" + run: python ~/api_diff.py -m "~/merge_branch" -b "~/base_branch" - uses: actions/upload-artifact@v3 with: From e3ce84dafdae6e65dcb8ee916de95498bdb578d9 Mon Sep 17 00:00:00 2001 From: Mou Date: Mon, 3 Apr 2023 19:09:15 -0700 Subject: [PATCH 22/59] test workflow --- scripts/api_diff_report/api_diff.py | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/scripts/api_diff_report/api_diff.py b/scripts/api_diff_report/api_diff.py index c21e614bff7..e51a62f3ab9 100644 --- a/scripts/api_diff_report/api_diff.py +++ b/scripts/api_diff_report/api_diff.py @@ -26,24 +26,17 @@ def main(): merged_branch = os.path.expanduser(args.merged_branch) base_branch = os.path.expanduser(args.base_branch) - - result = subprocess.run( - args=["diff", "-wEburN", "--word-diff", merged_branch, base_branch], - capture_output=True, - text=True, - check=False) - logging.info(result.stdout) - logging.info("------------") - for merged_file in os.listdir(merged_branch): - file_name = os.path.basename(merged_file) - base_file = os.path.join(base_branch, file_name) + for file in os.listdir(merged_branch): + merged_file = os.path.join(merged_branch, file) + base_file = os.path.join(base_branch, file) result = subprocess.run( - args=["git", "diff", "--no-index", "--word-diff", file_name, base_file], + args=["git", "diff", "--no-index", "--word-diff", merged_file, base_file], capture_output=True, text=True, check=False) logging.info(result.stdout) + logging.info("------------") pr_api = json.load(open(merged_file)) base_api = json.load(open(base_file)) From 2cbde2b77eb23ab163ee6e48edf1dceb287516db Mon Sep 17 00:00:00 2001 From: Mou Date: Mon, 3 Apr 2023 19:37:08 -0700 Subject: [PATCH 23/59] test objc --- .../FirebaseAppDistribution/FIRAppDistribution.h | 5 ++--- .../Sources/ModelDownloadTask.swift | 2 +- scripts/api_diff_report/api_info.py | 16 +++++++++++++++- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/FirebaseAppDistribution/Sources/Public/FirebaseAppDistribution/FIRAppDistribution.h b/FirebaseAppDistribution/Sources/Public/FirebaseAppDistribution/FIRAppDistribution.h index 3b491729805..ff0553414f6 100644 --- a/FirebaseAppDistribution/Sources/Public/FirebaseAppDistribution/FIRAppDistribution.h +++ b/FirebaseAppDistribution/Sources/Public/FirebaseAppDistribution/FIRAppDistribution.h @@ -41,14 +41,13 @@ NS_SWIFT_NAME(AppDistribution) /** * Sign-in the App Distribution tester */ -- (void)signInTesterWithCompletion:(void (^)(NSError *_Nullable error))completion +- (void)signInTesterWithCompletion:(void (^)(NSError * error))completion NS_SWIFT_NAME(signInTester(completion:)); /** * Check to see whether a new distribution is available */ -- (void)checkForUpdateWithCompletion:(void (^)(FIRAppDistributionRelease *_Nullable_result release, - NSError *_Nullable error))completion +- (void)checkForUpdateWithCompletion:(void (^)(FIRAppDistributionRelease *_Nullable_result release))completion NS_SWIFT_NAME(checkForUpdate(completion:)); /** diff --git a/FirebaseMLModelDownloader/Sources/ModelDownloadTask.swift b/FirebaseMLModelDownloader/Sources/ModelDownloadTask.swift index 8157dd1a0fb..b3be129303d 100644 --- a/FirebaseMLModelDownloader/Sources/ModelDownloadTask.swift +++ b/FirebaseMLModelDownloader/Sources/ModelDownloadTask.swift @@ -15,7 +15,7 @@ import Foundation /// Task to download model file to device. -final class ModelDownloadTask { +public final class ModelDownloadTask { /// Name of the app associated with this instance of ModelDownloadTask. private let appName: String diff --git a/scripts/api_diff_report/api_info.py b/scripts/api_diff_report/api_info.py index 5249828b342..21d8f615002 100644 --- a/scripts/api_diff_report/api_info.py +++ b/scripts/api_diff_report/api_info.py @@ -36,12 +36,26 @@ def main(): capture_output=True, text=True, check=False) + logging.info("------------") logging.info(file) - # logging.info(result.stdout) + logging.info(result.stdout) file_path = os.path.join(output_dir, os.path.basename(file) + ".json") logging.info(file_path) with open(file_path, 'w') as f: f.write(result.stdout) + elif file.endswith('.h'): + result = subprocess.Popen(f"sourcekitten doc --objc {file} -- -x objective-c -isysroot $(xcrun --show-sdk-path) -I $(pwd)", + universal_newlines=True, + shell=True, + stdout=subprocess.PIPE) + logging.info("------------") + logging.info(file) + logging.info(result.stdout.read()) + file_path = os.path.join(output_dir, os.path.basename(file) + ".json") + logging.info(file_path) + with open(file_path, 'w') as f: + f.write(result.stdout.read()) + def parse_cmdline_args(): From 3bdbe25880a11449080984f41698bf54ab71fc68 Mon Sep 17 00:00:00 2001 From: Mou Date: Mon, 3 Apr 2023 19:47:07 -0700 Subject: [PATCH 24/59] test objc --- .github/workflows/api_report.yml | 1 + scripts/api_diff_report/api_info.py | 17 ++++++++--------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/api_report.yml b/.github/workflows/api_report.yml index 7828b12682c..bd30b61d9b0 100644 --- a/.github/workflows/api_report.yml +++ b/.github/workflows/api_report.yml @@ -43,6 +43,7 @@ jobs: run: python ~/api_diff.py -m "~/merge_branch" -b "~/base_branch" - uses: actions/upload-artifact@v3 + if: ${{ !cancelled() }} with: name: api_info path: | diff --git a/scripts/api_diff_report/api_info.py b/scripts/api_diff_report/api_info.py index 21d8f615002..18e97d2c345 100644 --- a/scripts/api_diff_report/api_info.py +++ b/scripts/api_diff_report/api_info.py @@ -29,29 +29,28 @@ def main(): if not isExist: os.makedirs(output_dir) - for file in args.file_list: - if file.endswith('.swift'): + for file_name in args.file_list: + logging.info(file_name) + if file_name.endswith('.swift'): result = subprocess.run( - args=["sourcekitten", "doc", "--single-file", file], + args=["sourcekitten", "doc", "--single-file", file_name], capture_output=True, text=True, check=False) logging.info("------------") - logging.info(file) logging.info(result.stdout) - file_path = os.path.join(output_dir, os.path.basename(file) + ".json") + file_path = os.path.join(output_dir, os.path.basename(file_name) + ".json") logging.info(file_path) with open(file_path, 'w') as f: f.write(result.stdout) - elif file.endswith('.h'): - result = subprocess.Popen(f"sourcekitten doc --objc {file} -- -x objective-c -isysroot $(xcrun --show-sdk-path) -I $(pwd)", + elif file_name.endswith('.h'): + result = subprocess.Popen(f"sourcekitten doc --objc {file_name} -- -x objective-c -isysroot $(xcrun --show-sdk-path) -I $(pwd)", universal_newlines=True, shell=True, stdout=subprocess.PIPE) logging.info("------------") - logging.info(file) logging.info(result.stdout.read()) - file_path = os.path.join(output_dir, os.path.basename(file) + ".json") + file_path = os.path.join(output_dir, os.path.basename(file_name) + ".json") logging.info(file_path) with open(file_path, 'w') as f: f.write(result.stdout.read()) From 3e6f4c98d748700cf52689dd14a7d0a02706f23e Mon Sep 17 00:00:00 2001 From: Mou Date: Mon, 3 Apr 2023 19:59:23 -0700 Subject: [PATCH 25/59] test objc --- scripts/api_diff_report/api_diff.py | 7 ++++--- scripts/api_diff_report/api_info.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/api_diff_report/api_diff.py b/scripts/api_diff_report/api_diff.py index e51a62f3ab9..264c6177a7d 100644 --- a/scripts/api_diff_report/api_diff.py +++ b/scripts/api_diff_report/api_diff.py @@ -27,9 +27,10 @@ def main(): merged_branch = os.path.expanduser(args.merged_branch) base_branch = os.path.expanduser(args.base_branch) - for file in os.listdir(merged_branch): - merged_file = os.path.join(merged_branch, file) - base_file = os.path.join(base_branch, file) + for file_name in os.listdir(merged_branch): + logging.info(file_name) + merged_file = os.path.join(merged_branch, file_name) + base_file = os.path.join(base_branch, file_name) result = subprocess.run( args=["git", "diff", "--no-index", "--word-diff", merged_file, base_file], capture_output=True, diff --git a/scripts/api_diff_report/api_info.py b/scripts/api_diff_report/api_info.py index 18e97d2c345..8aa0be095fa 100644 --- a/scripts/api_diff_report/api_info.py +++ b/scripts/api_diff_report/api_info.py @@ -53,7 +53,7 @@ def main(): file_path = os.path.join(output_dir, os.path.basename(file_name) + ".json") logging.info(file_path) with open(file_path, 'w') as f: - f.write(result.stdout.read()) + f.write(str(result.stdout.read())) From 49b0076c7ede38c3e8b84677510cfaa746ffbcc0 Mon Sep 17 00:00:00 2001 From: Mou Date: Mon, 3 Apr 2023 20:02:24 -0700 Subject: [PATCH 26/59] test objc --- scripts/api_diff_report/api_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/api_diff_report/api_info.py b/scripts/api_diff_report/api_info.py index 8aa0be095fa..092fe084e08 100644 --- a/scripts/api_diff_report/api_info.py +++ b/scripts/api_diff_report/api_info.py @@ -53,7 +53,7 @@ def main(): file_path = os.path.join(output_dir, os.path.basename(file_name) + ".json") logging.info(file_path) with open(file_path, 'w') as f: - f.write(str(result.stdout.read())) + f.write(str(result.stdout.read(), 'UTF-8')) From 2af340fc050070d032840e78c7a032d7305d831e Mon Sep 17 00:00:00 2001 From: Mou Date: Mon, 3 Apr 2023 23:59:03 -0700 Subject: [PATCH 27/59] test objc --- scripts/api_diff_report/api_info.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/api_diff_report/api_info.py b/scripts/api_diff_report/api_info.py index 092fe084e08..8c27222cad6 100644 --- a/scripts/api_diff_report/api_info.py +++ b/scripts/api_diff_report/api_info.py @@ -38,22 +38,24 @@ def main(): text=True, check=False) logging.info("------------") - logging.info(result.stdout) + api_info = result.stdout + logging.info(api_info) file_path = os.path.join(output_dir, os.path.basename(file_name) + ".json") logging.info(file_path) with open(file_path, 'w') as f: - f.write(result.stdout) + f.write(api_info) elif file_name.endswith('.h'): result = subprocess.Popen(f"sourcekitten doc --objc {file_name} -- -x objective-c -isysroot $(xcrun --show-sdk-path) -I $(pwd)", universal_newlines=True, shell=True, stdout=subprocess.PIPE) logging.info("------------") - logging.info(result.stdout.read()) + api_info = result.stdout.read() + logging.info(api_info) file_path = os.path.join(output_dir, os.path.basename(file_name) + ".json") logging.info(file_path) with open(file_path, 'w') as f: - f.write(str(result.stdout.read(), 'UTF-8')) + f.write(api_info) From efbba344c816f5ea3004099a64b0e29d7e20c09f Mon Sep 17 00:00:00 2001 From: Mou Date: Tue, 4 Apr 2023 00:17:55 -0700 Subject: [PATCH 28/59] test objc --- scripts/api_diff_report/api_diff.py | 36 +++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/scripts/api_diff_report/api_diff.py b/scripts/api_diff_report/api_diff.py index 264c6177a7d..24cdcfa9705 100644 --- a/scripts/api_diff_report/api_diff.py +++ b/scripts/api_diff_report/api_diff.py @@ -31,15 +31,33 @@ def main(): logging.info(file_name) merged_file = os.path.join(merged_branch, file_name) base_file = os.path.join(base_branch, file_name) - result = subprocess.run( - args=["git", "diff", "--no-index", "--word-diff", merged_file, base_file], - capture_output=True, - text=True, - check=False) - logging.info(result.stdout) - logging.info("------------") - pr_api = json.load(open(merged_file)) - base_api = json.load(open(base_file)) + api_diff(merged_file, base_file) + + + +def api_diff(merged_file, base_file): + # result = subprocess.run( + # args=["git", "diff", "--no-index", "--word-diff", merged_file, base_file], + # capture_output=True, + # text=True, + # check=False) + # logging.info(result.stdout) + # logging.info("------------") + pr_apis = get_apis(json.load(open(merged_file))) + logging.info(pr_apis) + base_apis = get_apis(json.load(open(base_file))) + logging.info(base_apis) + + +def get_apis(api_json): + if isinstance(api_json, list): + for _, value in api_json[0]: + return value["key.substructure"]["key.substructure"] + elif isinstance(api_json, dict): + for _, value in api_json: + return value["key.substructure"]["key.substructure"] + + def parse_cmdline_args(): From de15fd1cf149073b1a5bed181b03e4e88bbc0aa8 Mon Sep 17 00:00:00 2001 From: Mou Date: Tue, 4 Apr 2023 00:31:18 -0700 Subject: [PATCH 29/59] test swift diff --- scripts/api_diff_report/api_diff.py | 18 ++++++++++++++++-- scripts/api_diff_report/api_info.py | 24 ++++++++++++------------ 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/scripts/api_diff_report/api_diff.py b/scripts/api_diff_report/api_diff.py index 24cdcfa9705..28eff76500e 100644 --- a/scripts/api_diff_report/api_diff.py +++ b/scripts/api_diff_report/api_diff.py @@ -47,17 +47,31 @@ def api_diff(merged_file, base_file): logging.info(pr_apis) base_apis = get_apis(json.load(open(base_file))) logging.info(base_apis) + pr_only_apis = get_diff(pr_apis, base_apis) + base_only_apis = get_diff(base_apis, pr_apis) def get_apis(api_json): if isinstance(api_json, list): - for _, value in api_json[0]: + for _, value in api_json[0].items(): return value["key.substructure"]["key.substructure"] elif isinstance(api_json, dict): - for _, value in api_json: + for _, value in api_json.items(): return value["key.substructure"]["key.substructure"] +def get_diff(target, base): + diff = [] + for t in target: + if t["key.accessibility"] == "source.lang.swift.accessibility.public": + for b in base: + if t["key.kind"] == b["key.kind"] and t["key.name"] == b["key.name"] and t["key.typename"] == b["key.typename"]: + break + else: + diff.append(t) + logging.info(t) + return diff + def parse_cmdline_args(): diff --git a/scripts/api_diff_report/api_info.py b/scripts/api_diff_report/api_info.py index 8c27222cad6..b317827d7bf 100644 --- a/scripts/api_diff_report/api_info.py +++ b/scripts/api_diff_report/api_info.py @@ -44,18 +44,18 @@ def main(): logging.info(file_path) with open(file_path, 'w') as f: f.write(api_info) - elif file_name.endswith('.h'): - result = subprocess.Popen(f"sourcekitten doc --objc {file_name} -- -x objective-c -isysroot $(xcrun --show-sdk-path) -I $(pwd)", - universal_newlines=True, - shell=True, - stdout=subprocess.PIPE) - logging.info("------------") - api_info = result.stdout.read() - logging.info(api_info) - file_path = os.path.join(output_dir, os.path.basename(file_name) + ".json") - logging.info(file_path) - with open(file_path, 'w') as f: - f.write(api_info) + # elif file_name.endswith('.h'): + # result = subprocess.Popen(f"sourcekitten doc --objc {file_name} -- -x objective-c -isysroot $(xcrun --show-sdk-path) -I $(pwd)", + # universal_newlines=True, + # shell=True, + # stdout=subprocess.PIPE) + # logging.info("------------") + # api_info = result.stdout.read() + # logging.info(api_info) + # file_path = os.path.join(output_dir, os.path.basename(file_name) + ".json") + # logging.info(file_path) + # with open(file_path, 'w') as f: + # f.write(api_info) From 63c30537711bf554a3562985aec877e3f703a6b3 Mon Sep 17 00:00:00 2001 From: Mou Date: Tue, 4 Apr 2023 00:36:45 -0700 Subject: [PATCH 30/59] test swift diff --- scripts/api_diff_report/api_diff.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/api_diff_report/api_diff.py b/scripts/api_diff_report/api_diff.py index 28eff76500e..1eade4d29c0 100644 --- a/scripts/api_diff_report/api_diff.py +++ b/scripts/api_diff_report/api_diff.py @@ -57,7 +57,7 @@ def get_apis(api_json): return value["key.substructure"]["key.substructure"] elif isinstance(api_json, dict): for _, value in api_json.items(): - return value["key.substructure"]["key.substructure"] + return value["key.substructure"][0]["key.substructure"] def get_diff(target, base): From 4c2f0c9fd6c2fe335290ecd40fa0ddb593fe7d7a Mon Sep 17 00:00:00 2001 From: Mou Date: Tue, 4 Apr 2023 00:46:04 -0700 Subject: [PATCH 31/59] test swift diff --- scripts/api_diff_report/api_diff.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/api_diff_report/api_diff.py b/scripts/api_diff_report/api_diff.py index 1eade4d29c0..04cf1645c52 100644 --- a/scripts/api_diff_report/api_diff.py +++ b/scripts/api_diff_report/api_diff.py @@ -63,13 +63,13 @@ def get_apis(api_json): def get_diff(target, base): diff = [] for t in target: - if t["key.accessibility"] == "source.lang.swift.accessibility.public": + if "key.accessibility" in t and t["key.accessibility"] == "source.lang.swift.accessibility.public": for b in base: if t["key.kind"] == b["key.kind"] and t["key.name"] == b["key.name"] and t["key.typename"] == b["key.typename"]: break else: diff.append(t) - logging.info(t) + logging.info(json.dumps(t, indent=2)) return diff From 70aaa6dcdb71cb05c55db52851c7d76579cef0c9 Mon Sep 17 00:00:00 2001 From: Mou Date: Tue, 4 Apr 2023 00:50:30 -0700 Subject: [PATCH 32/59] test swift diff --- scripts/api_diff_report/api_diff.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/api_diff_report/api_diff.py b/scripts/api_diff_report/api_diff.py index 04cf1645c52..2bbf2f19db0 100644 --- a/scripts/api_diff_report/api_diff.py +++ b/scripts/api_diff_report/api_diff.py @@ -69,7 +69,7 @@ def get_diff(target, base): break else: diff.append(t) - logging.info(json.dumps(t, indent=2)) + print(json.dumps(t, indent=2)) return diff From d68141eecc47c3e1471eb88079e3b9857f3f894e Mon Sep 17 00:00:00 2001 From: Mou Date: Wed, 5 Apr 2023 13:53:19 -0700 Subject: [PATCH 33/59] test objc --- scripts/api_diff_report/api_diff.py | 79 ++++++++++++++++++++--------- scripts/api_diff_report/api_info.py | 24 ++++----- 2 files changed, 67 insertions(+), 36 deletions(-) diff --git a/scripts/api_diff_report/api_diff.py b/scripts/api_diff_report/api_diff.py index 2bbf2f19db0..69bac0de27c 100644 --- a/scripts/api_diff_report/api_diff.py +++ b/scripts/api_diff_report/api_diff.py @@ -18,6 +18,9 @@ import os import subprocess +OBJC_EXTENSION = "h" +SWIFT_EXTENSION = "swift" + def main(): logging.getLogger().setLevel(logging.INFO) @@ -27,11 +30,11 @@ def main(): merged_branch = os.path.expanduser(args.merged_branch) base_branch = os.path.expanduser(args.base_branch) - for file_name in os.listdir(merged_branch): - logging.info(file_name) - merged_file = os.path.join(merged_branch, file_name) - base_file = os.path.join(base_branch, file_name) - api_diff(merged_file, base_file) + # for file_name in os.listdir(merged_branch): + # logging.info(file_name) + # merged_file = os.path.join(merged_branch, file_name) + # base_file = os.path.join(base_branch, file_name) + # api_diff(merged_file, base_file) @@ -43,36 +46,64 @@ def api_diff(merged_file, base_file): # check=False) # logging.info(result.stdout) # logging.info("------------") - pr_apis = get_apis(json.load(open(merged_file))) - logging.info(pr_apis) - base_apis = get_apis(json.load(open(base_file))) - logging.info(base_apis) + file_extension = merged_file.split(".")[1] + print(file_extension) + pr_apis = get_public_apis(json.load(open(merged_file)), file_extension) + # print(json.dumps(pr_apis, indent=2)) + base_apis = get_public_apis(json.load(open(base_file)), file_extension) + # print(json.dumps(base_apis, indent=2)) + pr_only_apis = get_diff(pr_apis, base_apis) base_only_apis = get_diff(base_apis, pr_apis) + print("pr_only_apis") + print_diff(pr_only_apis) + print("base_only_apis") + print_diff(base_only_apis) - -def get_apis(api_json): - if isinstance(api_json, list): +def get_public_apis(api_json, file_extension): + if file_extension == OBJC_EXTENSION: for _, value in api_json[0].items(): return value["key.substructure"]["key.substructure"] - elif isinstance(api_json, dict): - for _, value in api_json.items(): - return value["key.substructure"][0]["key.substructure"] + elif file_extension == SWIFT_EXTENSION: + # key: file name + # value: all classes and functions + # only one key, value pair + for key, value in api_json.items(): + # filter out non-public classes + public_apis = [sc for sc in value["key.substructure"] if "key.accessibility" in sc and sc["key.accessibility"] == "source.lang.swift.accessibility.public"] + for sc in public_apis: + # filter out non-public functions + sc["key.substructure"] = [f for f in sc["key.substructure"] if "key.accessibility" in f and f["key.accessibility"] == "source.lang.swift.accessibility.public"] + return public_apis def get_diff(target, base): - diff = [] - for t in target: - if "key.accessibility" in t and t["key.accessibility"] == "source.lang.swift.accessibility.public": - for b in base: - if t["key.kind"] == b["key.kind"] and t["key.name"] == b["key.name"] and t["key.typename"] == b["key.typename"]: - break - else: - diff.append(t) - print(json.dumps(t, indent=2)) + diff = {"class":[], "function":[]} + + for tc in target: + for bc in base: + # check for same public classes + if tc["key.kind"] == bc["key.kind"] and tc["key.name"] == bc["key.name"]: + # check for same public functions + for tf in tc["key.substructure"]: + if "key.typename" in tf: + for bf in bc["key.substructure"]: + if tf["key.kind"] == bf["key.kind"] and tf["key.name"] == bf["key.name"] and tf["key.typename"] == bf["key.typename"]: + break + else: + diff["function"].append(tf) + break + else: + diff["class"].append(tc) return diff +def print_diff(diff): + for c in diff["class"]: + logging.info(f'Class {c["key.kind"]} {c["key.name"]}') + for f in diff["function"]: + logging.info(f'Function {f["key.kind"]} {f["key.name"]} {f["key.typename"]}') + def parse_cmdline_args(): parser = argparse.ArgumentParser() diff --git a/scripts/api_diff_report/api_info.py b/scripts/api_diff_report/api_info.py index b317827d7bf..8c27222cad6 100644 --- a/scripts/api_diff_report/api_info.py +++ b/scripts/api_diff_report/api_info.py @@ -44,18 +44,18 @@ def main(): logging.info(file_path) with open(file_path, 'w') as f: f.write(api_info) - # elif file_name.endswith('.h'): - # result = subprocess.Popen(f"sourcekitten doc --objc {file_name} -- -x objective-c -isysroot $(xcrun --show-sdk-path) -I $(pwd)", - # universal_newlines=True, - # shell=True, - # stdout=subprocess.PIPE) - # logging.info("------------") - # api_info = result.stdout.read() - # logging.info(api_info) - # file_path = os.path.join(output_dir, os.path.basename(file_name) + ".json") - # logging.info(file_path) - # with open(file_path, 'w') as f: - # f.write(api_info) + elif file_name.endswith('.h'): + result = subprocess.Popen(f"sourcekitten doc --objc {file_name} -- -x objective-c -isysroot $(xcrun --show-sdk-path) -I $(pwd)", + universal_newlines=True, + shell=True, + stdout=subprocess.PIPE) + logging.info("------------") + api_info = result.stdout.read() + logging.info(api_info) + file_path = os.path.join(output_dir, os.path.basename(file_name) + ".json") + logging.info(file_path) + with open(file_path, 'w') as f: + f.write(api_info) From c95123ef48c60cfbbc2e628cfd16c82fabb441dd Mon Sep 17 00:00:00 2001 From: Mou Date: Wed, 5 Apr 2023 14:38:22 -0700 Subject: [PATCH 34/59] test both objc & swift --- .../Sources/ModelDownloader.swift | 2 +- scripts/api_diff_report/api_diff.py | 122 +++++++++++------- 2 files changed, 79 insertions(+), 45 deletions(-) diff --git a/FirebaseMLModelDownloader/Sources/ModelDownloader.swift b/FirebaseMLModelDownloader/Sources/ModelDownloader.swift index 43632de851a..55702a5abef 100644 --- a/FirebaseMLModelDownloader/Sources/ModelDownloader.swift +++ b/FirebaseMLModelDownloader/Sources/ModelDownloader.swift @@ -27,7 +27,7 @@ public enum ModelDownloadType { } /// Downloader to manage custom model downloads. -public struct ModelDownloader { +public class ModelDownloader { /// Name of the app associated with this instance of ModelDownloader. private let appName: String diff --git a/scripts/api_diff_report/api_diff.py b/scripts/api_diff_report/api_diff.py index 69bac0de27c..fbf235ab5c8 100644 --- a/scripts/api_diff_report/api_diff.py +++ b/scripts/api_diff_report/api_diff.py @@ -30,54 +30,52 @@ def main(): merged_branch = os.path.expanduser(args.merged_branch) base_branch = os.path.expanduser(args.base_branch) - # for file_name in os.listdir(merged_branch): - # logging.info(file_name) - # merged_file = os.path.join(merged_branch, file_name) - # base_file = os.path.join(base_branch, file_name) - # api_diff(merged_file, base_file) + for file_name in os.listdir(merged_branch): + logging.info(f"\n\nDetect API changes in {file_name}") + merged_file = os.path.join(merged_branch, file_name) + base_file = os.path.join(base_branch, file_name) + api_diff(merged_file, base_file) def api_diff(merged_file, base_file): - # result = subprocess.run( - # args=["git", "diff", "--no-index", "--word-diff", merged_file, base_file], - # capture_output=True, - # text=True, - # check=False) - # logging.info(result.stdout) - # logging.info("------------") file_extension = merged_file.split(".")[1] - print(file_extension) - pr_apis = get_public_apis(json.load(open(merged_file)), file_extension) - # print(json.dumps(pr_apis, indent=2)) - base_apis = get_public_apis(json.load(open(base_file)), file_extension) - # print(json.dumps(base_apis, indent=2)) - - pr_only_apis = get_diff(pr_apis, base_apis) - base_only_apis = get_diff(base_apis, pr_apis) - print("pr_only_apis") - print_diff(pr_only_apis) - print("base_only_apis") - print_diff(base_only_apis) - -def get_public_apis(api_json, file_extension): if file_extension == OBJC_EXTENSION: - for _, value in api_json[0].items(): - return value["key.substructure"]["key.substructure"] + pr_apis = get_objc_public_apis(json.load(open(merged_file))) + base_apis = get_objc_public_apis(json.load(open(base_file))) + + pr_only_apis = get_objc_diff(pr_apis, base_apis) + base_only_apis = get_objc_diff(base_apis, pr_apis) + logging.info("API that only exist in this PR") + print_objc_diff(pr_only_apis) + logging.info("\nAPI that only exist in Master branch") + print_objc_diff(base_only_apis) elif file_extension == SWIFT_EXTENSION: - # key: file name - # value: all classes and functions - # only one key, value pair - for key, value in api_json.items(): - # filter out non-public classes - public_apis = [sc for sc in value["key.substructure"] if "key.accessibility" in sc and sc["key.accessibility"] == "source.lang.swift.accessibility.public"] - for sc in public_apis: - # filter out non-public functions - sc["key.substructure"] = [f for f in sc["key.substructure"] if "key.accessibility" in f and f["key.accessibility"] == "source.lang.swift.accessibility.public"] - return public_apis - - -def get_diff(target, base): + pr_apis = get_swift_public_apis(json.load(open(merged_file))) + base_apis = get_swift_public_apis(json.load(open(base_file))) + + pr_only_apis = get_swift_diff(pr_apis, base_apis) + base_only_apis = get_swift_diff(base_apis, pr_apis) + logging.info("API that only exist in this PR") + print_swift_diff(pr_only_apis) + logging.info("\nAPI that only exist in Master branch") + print_swift_diff(base_only_apis) + + +def get_swift_public_apis(api_json): + # key: file name + # value: all classes and functions + # only one key, value pair + for key, value in api_json.items(): + # filter out non-public classes + public_apis = [sc for sc in value["key.substructure"] if "key.accessibility" in sc and sc["key.accessibility"] == "source.lang.swift.accessibility.public"] + for sc in public_apis: + # filter out non-public functions + sc["key.substructure"] = [f for f in sc["key.substructure"] if "key.accessibility" in f and f["key.accessibility"] == "source.lang.swift.accessibility.public"] + return public_apis + + +def get_swift_diff(target, base): diff = {"class":[], "function":[]} for tc in target: @@ -98,11 +96,47 @@ def get_diff(target, base): return diff -def print_diff(diff): +def print_swift_diff(diff): for c in diff["class"]: - logging.info(f'Class {c["key.kind"]} {c["key.name"]}') + logging.info(f'Class: {c["key.kind"]} {c["key.name"]}') for f in diff["function"]: - logging.info(f'Function {f["key.kind"]} {f["key.name"]} {f["key.typename"]}') + logging.info(f'Function: {f["key.kind"]} {f["key.name"]} {f["key.typename"]}') + + +def get_objc_public_apis(api_json): + for key, value in api_json[0].items(): + return value["key.substructure"] + + +def get_objc_diff(target, base): + diff = {"class":[], "function":[]} + + for tc in target: + for bc in base: + # check for same public classes + if tc["key.kind"] == bc["key.kind"] and tc["key.name"] == bc["key.name"] and tc["key.parsed_declaration"] == bc["key.parsed_declaration"]: + # check for same public functions + if "key.substructure" in tc: + for tf in tc["key.substructure"]: + for bf in bc["key.substructure"]: + if tf["key.kind"] == bf["key.kind"] and tf["key.name"] == bf["key.name"] and tf["key.parsed_declaration"] == bf["key.parsed_declaration"]: + break + else: + diff["function"].append(tf) + break + else: + diff["class"].append(tc) + return diff + + +def print_objc_diff(diff): + for c in diff["class"]: + logging.info(f'Class: {c["key.kind"]} {c["key.name"]}') + for f in diff["function"]: + logging.info(f'OBJC Function: {f["key.parsed_declaration"]}') + for f in diff["function"]: + if "key.swift_declaration" in f: + logging.info(f'SWIFT Function: {f["key.swift_declaration"]}') def parse_cmdline_args(): From 22a5f4b639baa9ea46336ec27ce8c2e7b22d70b4 Mon Sep 17 00:00:00 2001 From: Mou Date: Thu, 6 Apr 2023 10:30:04 -0700 Subject: [PATCH 35/59] test both objc & swift --- scripts/api_diff_report/api_diff.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/scripts/api_diff_report/api_diff.py b/scripts/api_diff_report/api_diff.py index fbf235ab5c8..9f744289841 100644 --- a/scripts/api_diff_report/api_diff.py +++ b/scripts/api_diff_report/api_diff.py @@ -21,6 +21,11 @@ OBJC_EXTENSION = "h" SWIFT_EXTENSION = "swift" +KEY_KIND = { + "source.lang.swift.decl.function.method.instance": "", + "source.lang.swift.decl.function.method.static": "static" +} + def main(): logging.getLogger().setLevel(logging.INFO) @@ -46,9 +51,9 @@ def api_diff(merged_file, base_file): pr_only_apis = get_objc_diff(pr_apis, base_apis) base_only_apis = get_objc_diff(base_apis, pr_apis) - logging.info("API that only exist in this PR") + logging.info("Added APIs") print_objc_diff(pr_only_apis) - logging.info("\nAPI that only exist in Master branch") + logging.info("\nRemoved APIS") print_objc_diff(base_only_apis) elif file_extension == SWIFT_EXTENSION: pr_apis = get_swift_public_apis(json.load(open(merged_file))) @@ -56,9 +61,9 @@ def api_diff(merged_file, base_file): pr_only_apis = get_swift_diff(pr_apis, base_apis) base_only_apis = get_swift_diff(base_apis, pr_apis) - logging.info("API that only exist in this PR") + logging.info("Added APIs") print_swift_diff(pr_only_apis) - logging.info("\nAPI that only exist in Master branch") + logging.info("\nRemoved APIS") print_swift_diff(base_only_apis) @@ -98,9 +103,9 @@ def get_swift_diff(target, base): def print_swift_diff(diff): for c in diff["class"]: - logging.info(f'Class: {c["key.kind"]} {c["key.name"]}') + logging.info(f'{c["key.name"]}') for f in diff["function"]: - logging.info(f'Function: {f["key.kind"]} {f["key.name"]} {f["key.typename"]}') + logging.info(f'Function: public {KEY_KIND[f["key.kind"]]} func {f["key.name"]} -> {f["key.typename"]}') def get_objc_public_apis(api_json): From deb85ab424ff04e7e78eb8ebddb2dd5edc6f0763 Mon Sep 17 00:00:00 2001 From: Mou Date: Mon, 10 Apr 2023 11:45:53 -0700 Subject: [PATCH 36/59] get target --- scripts/api_diff_report/api_info.py | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/scripts/api_diff_report/api_info.py b/scripts/api_diff_report/api_info.py index 8c27222cad6..309da691d7a 100644 --- a/scripts/api_diff_report/api_info.py +++ b/scripts/api_diff_report/api_info.py @@ -17,6 +17,27 @@ import logging import os import subprocess +import re + +PRODUCT_LIST = [ + "ABTesting", + "AppCheck", + "AppDistribution", + "Analytics", + "Authentication", + "Core", + "Crashlytics", + "Database", + "DynamicLinks", + "Firestore", + "Functions", + "InAppMessaging", + "Installations", + "Messaging", + "Performance", + "RemoteConfig", + "Storage" +] def main(): logging.getLogger().setLevel(logging.INFO) @@ -44,7 +65,13 @@ def main(): logging.info(file_path) with open(file_path, 'w') as f: f.write(api_info) - elif file_name.endswith('.h'): + + match = re.search(fr"{os.sep}Firebase(.*?){os.sep}") + if match: + logging.info(match.group()) + else: + logging.info("no matching") + elif file_name.endswith('.h') and "Public" in file_name: result = subprocess.Popen(f"sourcekitten doc --objc {file_name} -- -x objective-c -isysroot $(xcrun --show-sdk-path) -I $(pwd)", universal_newlines=True, shell=True, From 2eec0c4c7cdc5bee312b8f89514b8445dc9085cd Mon Sep 17 00:00:00 2001 From: Mou Date: Mon, 10 Apr 2023 14:17:46 -0700 Subject: [PATCH 37/59] get target --- scripts/api_diff_report/api_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/api_diff_report/api_info.py b/scripts/api_diff_report/api_info.py index 309da691d7a..32039d91ff1 100644 --- a/scripts/api_diff_report/api_info.py +++ b/scripts/api_diff_report/api_info.py @@ -66,7 +66,7 @@ def main(): with open(file_path, 'w') as f: f.write(api_info) - match = re.search(fr"{os.sep}Firebase(.*?){os.sep}") + match = re.search(fr"{os.sep}Firebase(.*?){os.sep}", file_name) if match: logging.info(match.group()) else: From 408cd69087eaffc0dc3364abbbe3e04f7d3107fa Mon Sep 17 00:00:00 2001 From: Mou Date: Mon, 10 Apr 2023 14:26:33 -0700 Subject: [PATCH 38/59] get target --- scripts/api_diff_report/api_info.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/api_diff_report/api_info.py b/scripts/api_diff_report/api_info.py index 32039d91ff1..7c2585583eb 100644 --- a/scripts/api_diff_report/api_info.py +++ b/scripts/api_diff_report/api_info.py @@ -66,7 +66,8 @@ def main(): with open(file_path, 'w') as f: f.write(api_info) - match = re.search(fr"{os.sep}Firebase(.*?){os.sep}", file_name) + logging.info(fr"Firebase(.*?){os.sep}") + match = re.search(fr"Firebase(.*?){os.sep}", file_name) if match: logging.info(match.group()) else: From 9db8d6a369a14d3db94582492924b0e41bb9b592 Mon Sep 17 00:00:00 2001 From: Mou Date: Tue, 11 Apr 2023 10:01:09 -0700 Subject: [PATCH 39/59] get target --- scripts/api_diff_report/api_info.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/api_diff_report/api_info.py b/scripts/api_diff_report/api_info.py index 7c2585583eb..02d63e89f6f 100644 --- a/scripts/api_diff_report/api_info.py +++ b/scripts/api_diff_report/api_info.py @@ -50,6 +50,7 @@ def main(): if not isExist: os.makedirs(output_dir) + swift_to_objc = {} for file_name in args.file_list: logging.info(file_name) if file_name.endswith('.swift'): @@ -69,7 +70,11 @@ def main(): logging.info(fr"Firebase(.*?){os.sep}") match = re.search(fr"Firebase(.*?){os.sep}", file_name) if match: + logging.info(match.groups()) + for g in match.groups(): + logging.info(g) logging.info(match.group()) + logging.info(os.path.splitext(os.path.basename(file_name))[0]) else: logging.info("no matching") elif file_name.endswith('.h') and "Public" in file_name: From 954f62c4ebfd9084ab4055e510fcd2be326ba24b Mon Sep 17 00:00:00 2001 From: Mou Date: Tue, 11 Apr 2023 10:08:44 -0700 Subject: [PATCH 40/59] get target --- scripts/api_diff_report/api_info.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/api_diff_report/api_info.py b/scripts/api_diff_report/api_info.py index 02d63e89f6f..16ef1159b9b 100644 --- a/scripts/api_diff_report/api_info.py +++ b/scripts/api_diff_report/api_info.py @@ -67,10 +67,10 @@ def main(): with open(file_path, 'w') as f: f.write(api_info) - logging.info(fr"Firebase(.*?){os.sep}") - match = re.search(fr"Firebase(.*?){os.sep}", file_name) + logging.info(fr"Firebase(.*){os.sep}") + match = re.search(fr"Firebase(.*){os.sep}", file_name) if match: - logging.info(match.groups()) + logging.info(match.groups()[0]) for g in match.groups(): logging.info(g) logging.info(match.group()) From 0255c5be74a509e7bed89346246c2aaf909637e1 Mon Sep 17 00:00:00 2001 From: Mou Date: Tue, 11 Apr 2023 10:16:11 -0700 Subject: [PATCH 41/59] get target --- scripts/api_diff_report/api_info.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/scripts/api_diff_report/api_info.py b/scripts/api_diff_report/api_info.py index 16ef1159b9b..7875eeebe17 100644 --- a/scripts/api_diff_report/api_info.py +++ b/scripts/api_diff_report/api_info.py @@ -67,16 +67,14 @@ def main(): with open(file_path, 'w') as f: f.write(api_info) - logging.info(fr"Firebase(.*){os.sep}") - match = re.search(fr"Firebase(.*){os.sep}", file_name) + logging.info(fr"Firebase(.*?){os.sep}") + match = re.search(fr"Firebase(.*?){os.sep}", file_name) if match: logging.info(match.groups()[0]) - for g in match.groups(): - logging.info(g) logging.info(match.group()) logging.info(os.path.splitext(os.path.basename(file_name))[0]) else: - logging.info("no matching") + logging.error("no matching") elif file_name.endswith('.h') and "Public" in file_name: result = subprocess.Popen(f"sourcekitten doc --objc {file_name} -- -x objective-c -isysroot $(xcrun --show-sdk-path) -I $(pwd)", universal_newlines=True, From ef5aac623cf4c599b219fc5117c3a1911a7e5289 Mon Sep 17 00:00:00 2001 From: Mou Date: Tue, 11 Apr 2023 11:09:26 -0700 Subject: [PATCH 42/59] build target --- scripts/api_diff_report/api_info.py | 48 ++++++++++++++++++----------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/scripts/api_diff_report/api_info.py b/scripts/api_diff_report/api_info.py index 7875eeebe17..504f75e3225 100644 --- a/scripts/api_diff_report/api_info.py +++ b/scripts/api_diff_report/api_info.py @@ -51,43 +51,55 @@ def main(): os.makedirs(output_dir) swift_to_objc = {} - for file_name in args.file_list: - logging.info(file_name) - if file_name.endswith('.swift'): + for file_path in args.file_list: + logging.info(file_path) + if file_path.endswith('.swift'): result = subprocess.run( - args=["sourcekitten", "doc", "--single-file", file_name], + args=["sourcekitten", "doc", "--single-file", file_path], capture_output=True, text=True, check=False) logging.info("------------") api_info = result.stdout logging.info(api_info) - file_path = os.path.join(output_dir, os.path.basename(file_name) + ".json") - logging.info(file_path) - with open(file_path, 'w') as f: + output_path = os.path.join(output_dir, os.path.basename(file_path) + ".json") + logging.info(output_path) + with open(output_path, 'w') as f: f.write(api_info) - logging.info(fr"Firebase(.*?){os.sep}") - match = re.search(fr"Firebase(.*?){os.sep}", file_name) + match = re.search(fr"Firebase(.*?){os.sep}", file_path) if match: - logging.info(match.groups()[0]) - logging.info(match.group()) - logging.info(os.path.splitext(os.path.basename(file_name))[0]) + target = f"firebase{match.groups()[0]}" + file_name = os.path.splitext(os.path.basename(file_path))[0] + if target not in swift_to_objc: + swift_to_objc[target] = [] + swift_to_objc[target].append(file_name) else: - logging.error("no matching") - elif file_name.endswith('.h') and "Public" in file_name: - result = subprocess.Popen(f"sourcekitten doc --objc {file_name} -- -x objective-c -isysroot $(xcrun --show-sdk-path) -I $(pwd)", + logging.error(f"no target matching file: {file_path}") + elif file_path.endswith('.h') and "Public" in file_path: + result = subprocess.Popen(f"sourcekitten doc --objc {file_path} -- -x objective-c -isysroot $(xcrun --show-sdk-path) -I $(pwd)", universal_newlines=True, shell=True, stdout=subprocess.PIPE) logging.info("------------") api_info = result.stdout.read() logging.info(api_info) - file_path = os.path.join(output_dir, os.path.basename(file_name) + ".json") - logging.info(file_path) - with open(file_path, 'w') as f: + output_path = os.path.join(output_dir, os.path.basename(file_path) + ".json") + logging.info(output_path) + with open(output_path, 'w') as f: f.write(api_info) + for target, files in swift_to_objc.items(): + result = subprocess.Popen(f"swift build --target {target}", + universal_newlines=True, + shell=True, + stdout=subprocess.PIPE) + logging.info("------------") + build_info = result.stdout.read() + logging.info(build_info) + + + def parse_cmdline_args(): From 5277ac78ec4ee1d985d06109af436ea3fc7f1d77 Mon Sep 17 00:00:00 2001 From: Mou Date: Tue, 11 Apr 2023 11:17:38 -0700 Subject: [PATCH 43/59] build target --- scripts/api_diff_report/api_info.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/scripts/api_diff_report/api_info.py b/scripts/api_diff_report/api_info.py index 504f75e3225..4d0378d84a7 100644 --- a/scripts/api_diff_report/api_info.py +++ b/scripts/api_diff_report/api_info.py @@ -54,14 +54,12 @@ def main(): for file_path in args.file_list: logging.info(file_path) if file_path.endswith('.swift'): - result = subprocess.run( - args=["sourcekitten", "doc", "--single-file", file_path], - capture_output=True, - text=True, - check=False) + result = subprocess.Popen(f"sourcekitten doc --single-file {file_path}", + universal_newlines=True, + shell=True, + stdout=subprocess.PIPE) logging.info("------------") - api_info = result.stdout - logging.info(api_info) + api_info = result.stdout.read() output_path = os.path.join(output_dir, os.path.basename(file_path) + ".json") logging.info(output_path) with open(output_path, 'w') as f: @@ -69,7 +67,7 @@ def main(): match = re.search(fr"Firebase(.*?){os.sep}", file_path) if match: - target = f"firebase{match.groups()[0]}" + target = f"Firebase{match.groups()[0]}" file_name = os.path.splitext(os.path.basename(file_path))[0] if target not in swift_to_objc: swift_to_objc[target] = [] From c9fd70d005b1a20c24ba50214c87c1a1a2bdeb0a Mon Sep 17 00:00:00 2001 From: Mou Date: Tue, 11 Apr 2023 11:29:17 -0700 Subject: [PATCH 44/59] build target --- .github/workflows/api_report.yml | 5 ++++- scripts/api_diff_report/api_info.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/api_report.yml b/.github/workflows/api_report.yml index bd30b61d9b0..6232f129b52 100644 --- a/.github/workflows/api_report.yml +++ b/.github/workflows/api_report.yml @@ -29,7 +29,10 @@ jobs: cp scripts/api_diff_report/api_diff.py ~/api_diff.py - name: Generate API files for PR branch - run: python ~/api_info.py -f ${{ steps.get_changed_files.outputs.file_list }} -o "~/merge_branch" + run: | + brew install tree + python ~/api_info.py -f ${{ steps.get_changed_files.outputs.file_list }} -o "~/merge_branch" + tree "~/merge_branch" - name: Checkout master uses: actions/checkout@v3 diff --git a/scripts/api_diff_report/api_info.py b/scripts/api_diff_report/api_info.py index 4d0378d84a7..007db9cc252 100644 --- a/scripts/api_diff_report/api_info.py +++ b/scripts/api_diff_report/api_info.py @@ -88,7 +88,7 @@ def main(): f.write(api_info) for target, files in swift_to_objc.items(): - result = subprocess.Popen(f"swift build --target {target}", + result = subprocess.Popen(f"swift build --target {target} BUILD_DIR={output_dir}", universal_newlines=True, shell=True, stdout=subprocess.PIPE) From 60fad46ee6309b47ee89a18d4599289ac92d0eaf Mon Sep 17 00:00:00 2001 From: Mou Date: Tue, 11 Apr 2023 11:34:39 -0700 Subject: [PATCH 45/59] build target --- .github/workflows/api_report.yml | 4 ++-- scripts/api_diff_report/api_info.py | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/api_report.yml b/.github/workflows/api_report.yml index 6232f129b52..3c5b736f1c6 100644 --- a/.github/workflows/api_report.yml +++ b/.github/workflows/api_report.yml @@ -30,9 +30,9 @@ jobs: - name: Generate API files for PR branch run: | - brew install tree + # brew install tree python ~/api_info.py -f ${{ steps.get_changed_files.outputs.file_list }} -o "~/merge_branch" - tree "~/merge_branch" + # tree "~/merge_branch" - name: Checkout master uses: actions/checkout@v3 diff --git a/scripts/api_diff_report/api_info.py b/scripts/api_diff_report/api_info.py index 007db9cc252..355f71627c0 100644 --- a/scripts/api_diff_report/api_info.py +++ b/scripts/api_diff_report/api_info.py @@ -81,14 +81,13 @@ def main(): stdout=subprocess.PIPE) logging.info("------------") api_info = result.stdout.read() - logging.info(api_info) output_path = os.path.join(output_dir, os.path.basename(file_path) + ".json") logging.info(output_path) with open(output_path, 'w') as f: f.write(api_info) for target, files in swift_to_objc.items(): - result = subprocess.Popen(f"swift build --target {target} BUILD_DIR={output_dir}", + result = subprocess.Popen(f"swift build --target {target} --vv", universal_newlines=True, shell=True, stdout=subprocess.PIPE) From 8a475130065f74807bd8447782781de68260699a Mon Sep 17 00:00:00 2001 From: Mou Date: Tue, 11 Apr 2023 11:47:29 -0700 Subject: [PATCH 46/59] build target --- .github/workflows/api_report.yml | 4 ++-- scripts/api_diff_report/api_info.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/api_report.yml b/.github/workflows/api_report.yml index 3c5b736f1c6..2112fb41fc4 100644 --- a/.github/workflows/api_report.yml +++ b/.github/workflows/api_report.yml @@ -30,9 +30,9 @@ jobs: - name: Generate API files for PR branch run: | - # brew install tree + brew install tree python ~/api_info.py -f ${{ steps.get_changed_files.outputs.file_list }} -o "~/merge_branch" - # tree "~/merge_branch" + tree -a - name: Checkout master uses: actions/checkout@v3 diff --git a/scripts/api_diff_report/api_info.py b/scripts/api_diff_report/api_info.py index 355f71627c0..cde9e838580 100644 --- a/scripts/api_diff_report/api_info.py +++ b/scripts/api_diff_report/api_info.py @@ -87,7 +87,7 @@ def main(): f.write(api_info) for target, files in swift_to_objc.items(): - result = subprocess.Popen(f"swift build --target {target} --vv", + result = subprocess.Popen(f"swift build --target {target}", universal_newlines=True, shell=True, stdout=subprocess.PIPE) From f53bf7dcdd9e86e0382061ed8a94cae472751c56 Mon Sep 17 00:00:00 2001 From: Mou Date: Tue, 11 Apr 2023 12:28:37 -0700 Subject: [PATCH 47/59] build target --- .github/workflows/api_report.yml | 2 +- scripts/api_diff_report/api_info.py | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/api_report.yml b/.github/workflows/api_report.yml index 2112fb41fc4..0ddd53b7339 100644 --- a/.github/workflows/api_report.yml +++ b/.github/workflows/api_report.yml @@ -32,7 +32,7 @@ jobs: run: | brew install tree python ~/api_info.py -f ${{ steps.get_changed_files.outputs.file_list }} -o "~/merge_branch" - tree -a + tree -a "~/merge_branch" - name: Checkout master uses: actions/checkout@v3 diff --git a/scripts/api_diff_report/api_info.py b/scripts/api_diff_report/api_info.py index cde9e838580..899e545a8ce 100644 --- a/scripts/api_diff_report/api_info.py +++ b/scripts/api_diff_report/api_info.py @@ -67,7 +67,7 @@ def main(): match = re.search(fr"Firebase(.*?){os.sep}", file_path) if match: - target = f"Firebase{match.groups()[0]}" + target = f"Firebase{match.groups()[0]}Unit" file_name = os.path.splitext(os.path.basename(file_path))[0] if target not in swift_to_objc: swift_to_objc[target] = [] @@ -87,7 +87,14 @@ def main(): f.write(api_info) for target, files in swift_to_objc.items(): - result = subprocess.Popen(f"swift build --target {target}", + result = subprocess.Popen("scripts/setup_spm_tests.sh", + universal_newlines=True, + shell=True, + stdout=subprocess.PIPE) + logging.info("------------") + build_info = result.stdout.read() + logging.info(build_info) + result = subprocess.Popen(f"xcodebuild -scheme {target} -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 11' ONLY_ACTIVE_ARCH=YES CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=YES COMPILER_INDEX_STORE_ENABLE=NO CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ IPHONEOS_DEPLOYMENT_TARGET=13.0 TVOS_DEPLOYMENT_TARGET=13.0 BUILD_DIR={output_dir}", universal_newlines=True, shell=True, stdout=subprocess.PIPE) From fb5468bd7478fb103b90cb4feae3eac52f9d6ab8 Mon Sep 17 00:00:00 2001 From: Mou Date: Tue, 11 Apr 2023 13:25:55 -0700 Subject: [PATCH 48/59] build target --- .github/workflows/api_report.yml | 5 +---- scripts/api_diff_report/api_info.py | 29 +++++++++++++++++++++-------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/.github/workflows/api_report.yml b/.github/workflows/api_report.yml index 0ddd53b7339..bd30b61d9b0 100644 --- a/.github/workflows/api_report.yml +++ b/.github/workflows/api_report.yml @@ -29,10 +29,7 @@ jobs: cp scripts/api_diff_report/api_diff.py ~/api_diff.py - name: Generate API files for PR branch - run: | - brew install tree - python ~/api_info.py -f ${{ steps.get_changed_files.outputs.file_list }} -o "~/merge_branch" - tree -a "~/merge_branch" + run: python ~/api_info.py -f ${{ steps.get_changed_files.outputs.file_list }} -o "~/merge_branch" - name: Checkout master uses: actions/checkout@v3 diff --git a/scripts/api_diff_report/api_info.py b/scripts/api_diff_report/api_info.py index 899e545a8ce..be95d4f7aa8 100644 --- a/scripts/api_diff_report/api_info.py +++ b/scripts/api_diff_report/api_info.py @@ -67,11 +67,11 @@ def main(): match = re.search(fr"Firebase(.*?){os.sep}", file_path) if match: - target = f"Firebase{match.groups()[0]}Unit" + scheme = f"Firebase{match.groups()[0]}" file_name = os.path.splitext(os.path.basename(file_path))[0] - if target not in swift_to_objc: - swift_to_objc[target] = [] - swift_to_objc[target].append(file_name) + if scheme not in swift_to_objc: + swift_to_objc[scheme] = [] + swift_to_objc[scheme].append(f"{file_name}-Swift.h") else: logging.error(f"no target matching file: {file_path}") elif file_path.endswith('.h') and "Public" in file_path: @@ -86,7 +86,7 @@ def main(): with open(output_path, 'w') as f: f.write(api_info) - for target, files in swift_to_objc.items(): + for scheme, files in swift_to_objc.items(): result = subprocess.Popen("scripts/setup_spm_tests.sh", universal_newlines=True, shell=True, @@ -94,16 +94,29 @@ def main(): logging.info("------------") build_info = result.stdout.read() logging.info(build_info) - result = subprocess.Popen(f"xcodebuild -scheme {target} -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 11' ONLY_ACTIVE_ARCH=YES CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=YES COMPILER_INDEX_STORE_ENABLE=NO CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ IPHONEOS_DEPLOYMENT_TARGET=13.0 TVOS_DEPLOYMENT_TARGET=13.0 BUILD_DIR={output_dir}", + result = subprocess.Popen(f"xcodebuild -scheme {scheme} -sdk iphonesimulator ONLY_ACTIVE_ARCH=YES CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=YES COMPILER_INDEX_STORE_ENABLE=NO CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ IPHONEOS_DEPLOYMENT_TARGET=13.0 TVOS_DEPLOYMENT_TARGET=13.0 BUILD_DIR={output_dir}", universal_newlines=True, shell=True, stdout=subprocess.PIPE) logging.info("------------") build_info = result.stdout.read() logging.info(build_info) - - + for file_dir, _, file_names in os.walk(output_dir): + for file_name in file_names: + if file_name in files: + logging.info(file_path) + file_path = os.path.join(file_dir, file_name) + result = subprocess.Popen(f"sourcekitten doc --objc {file_path} -- -x objective-c -isysroot $(xcrun --show-sdk-path) -I $(pwd)", + universal_newlines=True, + shell=True, + stdout=subprocess.PIPE) + logging.info("------------") + api_info = result.stdout.read() + output_path = os.path.join(output_dir, file_name + ".json") + logging.info(output_path) + with open(output_path, 'w') as f: + f.write(api_info) def parse_cmdline_args(): From 655f4d70a4580ee96080cca4c088798379692188 Mon Sep 17 00:00:00 2001 From: Mou Date: Tue, 11 Apr 2023 13:54:26 -0700 Subject: [PATCH 49/59] build target --- scripts/api_diff_report/api_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/api_diff_report/api_info.py b/scripts/api_diff_report/api_info.py index be95d4f7aa8..938b34eba66 100644 --- a/scripts/api_diff_report/api_info.py +++ b/scripts/api_diff_report/api_info.py @@ -94,7 +94,7 @@ def main(): logging.info("------------") build_info = result.stdout.read() logging.info(build_info) - result = subprocess.Popen(f"xcodebuild -scheme {scheme} -sdk iphonesimulator ONLY_ACTIVE_ARCH=YES CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=YES COMPILER_INDEX_STORE_ENABLE=NO CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ IPHONEOS_DEPLOYMENT_TARGET=13.0 TVOS_DEPLOYMENT_TARGET=13.0 BUILD_DIR={output_dir}", + result = subprocess.Popen(f"xcodebuild -scheme {scheme} -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 11' ONLY_ACTIVE_ARCH=YES CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=YES COMPILER_INDEX_STORE_ENABLE=NO CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ IPHONEOS_DEPLOYMENT_TARGET=13.0 TVOS_DEPLOYMENT_TARGET=13.0 BUILD_DIR={output_dir}", universal_newlines=True, shell=True, stdout=subprocess.PIPE) From 14b0ef1412a381eb15619729953dfae77c469c1d Mon Sep 17 00:00:00 2001 From: Mou Date: Tue, 11 Apr 2023 14:07:41 -0700 Subject: [PATCH 50/59] build target --- scripts/api_diff_report/api_info.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/api_diff_report/api_info.py b/scripts/api_diff_report/api_info.py index 938b34eba66..606f0de399e 100644 --- a/scripts/api_diff_report/api_info.py +++ b/scripts/api_diff_report/api_info.py @@ -86,6 +86,7 @@ def main(): with open(output_path, 'w') as f: f.write(api_info) + build_dir = "build_dir" for scheme, files in swift_to_objc.items(): result = subprocess.Popen("scripts/setup_spm_tests.sh", universal_newlines=True, @@ -93,17 +94,19 @@ def main(): stdout=subprocess.PIPE) logging.info("------------") build_info = result.stdout.read() - logging.info(build_info) - result = subprocess.Popen(f"xcodebuild -scheme {scheme} -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 11' ONLY_ACTIVE_ARCH=YES CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=YES COMPILER_INDEX_STORE_ENABLE=NO CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ IPHONEOS_DEPLOYMENT_TARGET=13.0 TVOS_DEPLOYMENT_TARGET=13.0 BUILD_DIR={output_dir}", + # logging.info(build_info) + result = subprocess.Popen(f"xcodebuild -scheme {scheme} -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 11' ONLY_ACTIVE_ARCH=YES CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=YES COMPILER_INDEX_STORE_ENABLE=NO CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ IPHONEOS_DEPLOYMENT_TARGET=13.0 TVOS_DEPLOYMENT_TARGET=13.0 BUILD_DIR={build_dir}", universal_newlines=True, shell=True, stdout=subprocess.PIPE) logging.info("------------") build_info = result.stdout.read() - logging.info(build_info) + # logging.info(build_info) - for file_dir, _, file_names in os.walk(output_dir): + logging.info(files) + for file_dir, _, file_names in os.walk(build_dir): for file_name in file_names: + logging.info(file_name) if file_name in files: logging.info(file_path) file_path = os.path.join(file_dir, file_name) From 28e60c47ce62bfb6942b7377e8d61d17fc84ece3 Mon Sep 17 00:00:00 2001 From: Mou Date: Tue, 11 Apr 2023 14:23:33 -0700 Subject: [PATCH 51/59] build target --- scripts/api_diff_report/api_info.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/api_diff_report/api_info.py b/scripts/api_diff_report/api_info.py index 606f0de399e..d022667bddd 100644 --- a/scripts/api_diff_report/api_info.py +++ b/scripts/api_diff_report/api_info.py @@ -86,7 +86,6 @@ def main(): with open(output_path, 'w') as f: f.write(api_info) - build_dir = "build_dir" for scheme, files in swift_to_objc.items(): result = subprocess.Popen("scripts/setup_spm_tests.sh", universal_newlines=True, @@ -95,7 +94,8 @@ def main(): logging.info("------------") build_info = result.stdout.read() # logging.info(build_info) - result = subprocess.Popen(f"xcodebuild -scheme {scheme} -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 11' ONLY_ACTIVE_ARCH=YES CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=YES COMPILER_INDEX_STORE_ENABLE=NO CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ IPHONEOS_DEPLOYMENT_TARGET=13.0 TVOS_DEPLOYMENT_TARGET=13.0 BUILD_DIR={build_dir}", + derived_data_path = f"DerivedData/{scheme}" + result = subprocess.Popen(f"xcodebuild -scheme {scheme} -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 11' ONLY_ACTIVE_ARCH=YES CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=YES COMPILER_INDEX_STORE_ENABLE=NO CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ IPHONEOS_DEPLOYMENT_TARGET=13.0 TVOS_DEPLOYMENT_TARGET=13.0 -derivedDataPath={derived_data_path}", universal_newlines=True, shell=True, stdout=subprocess.PIPE) @@ -104,12 +104,12 @@ def main(): # logging.info(build_info) logging.info(files) - for file_dir, _, file_names in os.walk(build_dir): + for file_dir, _, file_names in os.walk(derived_data_path): for file_name in file_names: logging.info(file_name) - if file_name in files: - logging.info(file_path) + if file_name.endswith("-Swift.h"): file_path = os.path.join(file_dir, file_name) + logging.info(file_path) result = subprocess.Popen(f"sourcekitten doc --objc {file_path} -- -x objective-c -isysroot $(xcrun --show-sdk-path) -I $(pwd)", universal_newlines=True, shell=True, From ff137dcc430a19168f79d6e9734b680e690b83fd Mon Sep 17 00:00:00 2001 From: Mou Date: Tue, 11 Apr 2023 14:35:04 -0700 Subject: [PATCH 52/59] build target --- scripts/api_diff_report/api_info.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/scripts/api_diff_report/api_info.py b/scripts/api_diff_report/api_info.py index d022667bddd..4936757b788 100644 --- a/scripts/api_diff_report/api_info.py +++ b/scripts/api_diff_report/api_info.py @@ -68,10 +68,8 @@ def main(): match = re.search(fr"Firebase(.*?){os.sep}", file_path) if match: scheme = f"Firebase{match.groups()[0]}" - file_name = os.path.splitext(os.path.basename(file_path))[0] if scheme not in swift_to_objc: - swift_to_objc[scheme] = [] - swift_to_objc[scheme].append(f"{file_name}-Swift.h") + swift_to_objc[scheme] = f"{scheme}-Swift.h" else: logging.error(f"no target matching file: {file_path}") elif file_path.endswith('.h') and "Public" in file_path: @@ -94,8 +92,7 @@ def main(): logging.info("------------") build_info = result.stdout.read() # logging.info(build_info) - derived_data_path = f"DerivedData/{scheme}" - result = subprocess.Popen(f"xcodebuild -scheme {scheme} -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 11' ONLY_ACTIVE_ARCH=YES CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=YES COMPILER_INDEX_STORE_ENABLE=NO CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ IPHONEOS_DEPLOYMENT_TARGET=13.0 TVOS_DEPLOYMENT_TARGET=13.0 -derivedDataPath={derived_data_path}", + result = subprocess.Popen(f"xcodebuild -scheme {scheme} -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 11' ONLY_ACTIVE_ARCH=YES CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=YES COMPILER_INDEX_STORE_ENABLE=NO CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ IPHONEOS_DEPLOYMENT_TARGET=13.0 TVOS_DEPLOYMENT_TARGET=13.0", universal_newlines=True, shell=True, stdout=subprocess.PIPE) @@ -104,10 +101,11 @@ def main(): # logging.info(build_info) logging.info(files) + derived_data_path = os.path.expanduser("~/Library/Developer/Xcode/DerivedData/") for file_dir, _, file_names in os.walk(derived_data_path): for file_name in file_names: logging.info(file_name) - if file_name.endswith("-Swift.h"): + if file_name.endswith("-Swift.h") and file_name==swift_to_objc[scheme]: file_path = os.path.join(file_dir, file_name) logging.info(file_path) result = subprocess.Popen(f"sourcekitten doc --objc {file_path} -- -x objective-c -isysroot $(xcrun --show-sdk-path) -I $(pwd)", From a421ea0265eb84342b88ebee8d97e68f57f98746 Mon Sep 17 00:00:00 2001 From: Mou Date: Tue, 11 Apr 2023 14:51:48 -0700 Subject: [PATCH 53/59] build target --- scripts/api_diff_report/api_info.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/scripts/api_diff_report/api_info.py b/scripts/api_diff_report/api_info.py index 4936757b788..1a2193b5c31 100644 --- a/scripts/api_diff_report/api_info.py +++ b/scripts/api_diff_report/api_info.py @@ -84,7 +84,7 @@ def main(): with open(output_path, 'w') as f: f.write(api_info) - for scheme, files in swift_to_objc.items(): + for scheme, objc_header in swift_to_objc.items(): result = subprocess.Popen("scripts/setup_spm_tests.sh", universal_newlines=True, shell=True, @@ -92,20 +92,18 @@ def main(): logging.info("------------") build_info = result.stdout.read() # logging.info(build_info) - result = subprocess.Popen(f"xcodebuild -scheme {scheme} -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 11' ONLY_ACTIVE_ARCH=YES CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=YES COMPILER_INDEX_STORE_ENABLE=NO CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ IPHONEOS_DEPLOYMENT_TARGET=13.0 TVOS_DEPLOYMENT_TARGET=13.0", + project_sys_root = os.path.expanduser("~/{scheme}/build/") + result = subprocess.Popen(f"xcodebuild -scheme {scheme} -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 11' ONLY_ACTIVE_ARCH=YES CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=YES COMPILER_INDEX_STORE_ENABLE=NO CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ IPHONEOS_DEPLOYMENT_TARGET=13.0 TVOS_DEPLOYMENT_TARGET=13.0 SYMROOT={project_sys_root}", universal_newlines=True, shell=True, stdout=subprocess.PIPE) logging.info("------------") build_info = result.stdout.read() - # logging.info(build_info) + logging.info(build_info) - logging.info(files) - derived_data_path = os.path.expanduser("~/Library/Developer/Xcode/DerivedData/") - for file_dir, _, file_names in os.walk(derived_data_path): + for file_dir, _, file_names in os.walk(project_sys_root): for file_name in file_names: - logging.info(file_name) - if file_name.endswith("-Swift.h") and file_name==swift_to_objc[scheme]: + if file_name == objc_header: file_path = os.path.join(file_dir, file_name) logging.info(file_path) result = subprocess.Popen(f"sourcekitten doc --objc {file_path} -- -x objective-c -isysroot $(xcrun --show-sdk-path) -I $(pwd)", From 6c5bd34d3614ef6a2803d625b8bae352bbec15aa Mon Sep 17 00:00:00 2001 From: Mou Date: Tue, 11 Apr 2023 15:18:07 -0700 Subject: [PATCH 54/59] build target --- scripts/api_diff_report/api_info.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/scripts/api_diff_report/api_info.py b/scripts/api_diff_report/api_info.py index 1a2193b5c31..5d3c9bd21d6 100644 --- a/scripts/api_diff_report/api_info.py +++ b/scripts/api_diff_report/api_info.py @@ -92,8 +92,13 @@ def main(): logging.info("------------") build_info = result.stdout.read() # logging.info(build_info) - project_sys_root = os.path.expanduser("~/{scheme}/build/") - result = subprocess.Popen(f"xcodebuild -scheme {scheme} -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 11' ONLY_ACTIVE_ARCH=YES CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=YES COMPILER_INDEX_STORE_ENABLE=NO CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ IPHONEOS_DEPLOYMENT_TARGET=13.0 TVOS_DEPLOYMENT_TARGET=13.0 SYMROOT={project_sys_root}", + derived_data_location = os.path.expanduser(f"~/{scheme}/build/") + subprocess.Popen(f"defaults write com.apple.dt.Xcode IDECustomDerivedDataLocation {derived_data_location}", + universal_newlines=True, + shell=True, + stdout=subprocess.PIPE) + + result = subprocess.Popen(f"xcodebuild -scheme {scheme} -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 11' ONLY_ACTIVE_ARCH=YES CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=YES COMPILER_INDEX_STORE_ENABLE=NO CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ IPHONEOS_DEPLOYMENT_TARGET=13.0 TVOS_DEPLOYMENT_TARGET=13.0", universal_newlines=True, shell=True, stdout=subprocess.PIPE) @@ -101,7 +106,7 @@ def main(): build_info = result.stdout.read() logging.info(build_info) - for file_dir, _, file_names in os.walk(project_sys_root): + for file_dir, _, file_names in os.walk(derived_data_location): for file_name in file_names: if file_name == objc_header: file_path = os.path.join(file_dir, file_name) From 77cc52d58d3290d7bf05b676e87af81781b109f2 Mon Sep 17 00:00:00 2001 From: Mou Date: Tue, 11 Apr 2023 15:31:30 -0700 Subject: [PATCH 55/59] build target --- scripts/api_diff_report/api_info.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/scripts/api_diff_report/api_info.py b/scripts/api_diff_report/api_info.py index 5d3c9bd21d6..b0d773e05f2 100644 --- a/scripts/api_diff_report/api_info.py +++ b/scripts/api_diff_report/api_info.py @@ -92,11 +92,11 @@ def main(): logging.info("------------") build_info = result.stdout.read() # logging.info(build_info) - derived_data_location = os.path.expanduser(f"~/{scheme}/build/") - subprocess.Popen(f"defaults write com.apple.dt.Xcode IDECustomDerivedDataLocation {derived_data_location}", - universal_newlines=True, - shell=True, - stdout=subprocess.PIPE) + # derived_data_location = os.path.expanduser(f"~/{scheme}/build/") + # subprocess.Popen(f"defaults write com.apple.dt.Xcode IDECustomDerivedDataLocation {derived_data_location}", + # universal_newlines=True, + # shell=True, + # stdout=subprocess.PIPE) result = subprocess.Popen(f"xcodebuild -scheme {scheme} -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 11' ONLY_ACTIVE_ARCH=YES CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=YES COMPILER_INDEX_STORE_ENABLE=NO CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ IPHONEOS_DEPLOYMENT_TARGET=13.0 TVOS_DEPLOYMENT_TARGET=13.0", universal_newlines=True, @@ -106,11 +106,16 @@ def main(): build_info = result.stdout.read() logging.info(build_info) + derived_data_location = os.path.expanduser("~/Library/Developer/Xcode/DerivedData/") for file_dir, _, file_names in os.walk(derived_data_location): for file_name in file_names: if file_name == objc_header: file_path = os.path.join(file_dir, file_name) logging.info(file_path) + subprocess.Popen(f"cp {file_path} {os.path.join(output_dir, file_name)}", + universal_newlines=True, + shell=True, + stdout=subprocess.PIPE) result = subprocess.Popen(f"sourcekitten doc --objc {file_path} -- -x objective-c -isysroot $(xcrun --show-sdk-path) -I $(pwd)", universal_newlines=True, shell=True, From 1d531be2976dd0b159affe85a49979562fcd9c4f Mon Sep 17 00:00:00 2001 From: Mou Date: Tue, 11 Apr 2023 15:41:05 -0700 Subject: [PATCH 56/59] test more type of APIs --- .../Sources/Public/FirebaseCore/FIRApp.h | 5 +- .../Public/FirebaseCore/FIRLoggerLevel.h | 1 + .../Sources/Public/FirebaseCore/FIRVersion.h | 2 +- scripts/api_diff_report/api_info.py | 82 +++++++++---------- 4 files changed, 47 insertions(+), 43 deletions(-) diff --git a/FirebaseCore/Sources/Public/FirebaseCore/FIRApp.h b/FirebaseCore/Sources/Public/FirebaseCore/FIRApp.h index 58ef2a62594..3122d35938e 100644 --- a/FirebaseCore/Sources/Public/FirebaseCore/FIRApp.h +++ b/FirebaseCore/Sources/Public/FirebaseCore/FIRApp.h @@ -24,6 +24,9 @@ NS_ASSUME_NONNULL_BEGIN typedef void (^FIRAppVoidBoolCallback)(BOOL success) NS_SWIFT_UNAVAILABLE("Use Swift's closure syntax instead."); +typedef void (^FIRAppVoidBoolCallbackTest)(BOOL success) + NS_SWIFT_UNAVAILABLE("Use Swift's closure syntax instead."); + /** * The entry point of Firebase SDKs. * @@ -61,7 +64,7 @@ NS_SWIFT_NAME(FirebaseApp) * * @param options The Firebase application options used to configure the service. */ -+ (void)configureWithOptions:(FIROptions *)options NS_SWIFT_NAME(configure(options:)); ++ (void)configureWithOptions:(FIROptions *__nullable)options NS_SWIFT_NAME(configure(options:)); /** * Configures a Firebase app with the given name and options. Raises an exception if any diff --git a/FirebaseCore/Sources/Public/FirebaseCore/FIRLoggerLevel.h b/FirebaseCore/Sources/Public/FirebaseCore/FIRLoggerLevel.h index dca3aa0b01f..5582f3fd487 100644 --- a/FirebaseCore/Sources/Public/FirebaseCore/FIRLoggerLevel.h +++ b/FirebaseCore/Sources/Public/FirebaseCore/FIRLoggerLevel.h @@ -21,6 +21,7 @@ * The log levels used by internal logging. */ typedef NS_ENUM(NSInteger, FIRLoggerLevel) { + FIRLoggerLevelTest = 999, /** Error level, matches ASL_LEVEL_ERR. */ FIRLoggerLevelError = 3, /** Warning level, matches ASL_LEVEL_WARNING. */ diff --git a/FirebaseCore/Sources/Public/FirebaseCore/FIRVersion.h b/FirebaseCore/Sources/Public/FirebaseCore/FIRVersion.h index 651edaf5c8b..217f8b8aeb0 100644 --- a/FirebaseCore/Sources/Public/FirebaseCore/FIRVersion.h +++ b/FirebaseCore/Sources/Public/FirebaseCore/FIRVersion.h @@ -20,6 +20,6 @@ NS_ASSUME_NONNULL_BEGIN /** Returns the current version of Firebase. */ NS_SWIFT_NAME(FirebaseVersion()) -NSString* FIRFirebaseVersion(void); +NSString* FIRFirebaseVersion(NSString *); NS_ASSUME_NONNULL_END diff --git a/scripts/api_diff_report/api_info.py b/scripts/api_diff_report/api_info.py index b0d773e05f2..617a2079408 100644 --- a/scripts/api_diff_report/api_info.py +++ b/scripts/api_diff_report/api_info.py @@ -84,48 +84,48 @@ def main(): with open(output_path, 'w') as f: f.write(api_info) - for scheme, objc_header in swift_to_objc.items(): - result = subprocess.Popen("scripts/setup_spm_tests.sh", - universal_newlines=True, - shell=True, - stdout=subprocess.PIPE) - logging.info("------------") - build_info = result.stdout.read() - # logging.info(build_info) - # derived_data_location = os.path.expanduser(f"~/{scheme}/build/") - # subprocess.Popen(f"defaults write com.apple.dt.Xcode IDECustomDerivedDataLocation {derived_data_location}", - # universal_newlines=True, - # shell=True, - # stdout=subprocess.PIPE) - - result = subprocess.Popen(f"xcodebuild -scheme {scheme} -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 11' ONLY_ACTIVE_ARCH=YES CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=YES COMPILER_INDEX_STORE_ENABLE=NO CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ IPHONEOS_DEPLOYMENT_TARGET=13.0 TVOS_DEPLOYMENT_TARGET=13.0", - universal_newlines=True, - shell=True, - stdout=subprocess.PIPE) - logging.info("------------") - build_info = result.stdout.read() - logging.info(build_info) + # for scheme, objc_header in swift_to_objc.items(): + # result = subprocess.Popen("scripts/setup_spm_tests.sh", + # universal_newlines=True, + # shell=True, + # stdout=subprocess.PIPE) + # logging.info("------------") + # build_info = result.stdout.read() + # # logging.info(build_info) + # # derived_data_location = os.path.expanduser(f"~/{scheme}/build/") + # # subprocess.Popen(f"defaults write com.apple.dt.Xcode IDECustomDerivedDataLocation {derived_data_location}", + # # universal_newlines=True, + # # shell=True, + # # stdout=subprocess.PIPE) + + # result = subprocess.Popen(f"xcodebuild -scheme {scheme} -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 11' ONLY_ACTIVE_ARCH=YES CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=YES COMPILER_INDEX_STORE_ENABLE=NO CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ IPHONEOS_DEPLOYMENT_TARGET=13.0 TVOS_DEPLOYMENT_TARGET=13.0", + # universal_newlines=True, + # shell=True, + # stdout=subprocess.PIPE) + # logging.info("------------") + # build_info = result.stdout.read() + # logging.info(build_info) - derived_data_location = os.path.expanduser("~/Library/Developer/Xcode/DerivedData/") - for file_dir, _, file_names in os.walk(derived_data_location): - for file_name in file_names: - if file_name == objc_header: - file_path = os.path.join(file_dir, file_name) - logging.info(file_path) - subprocess.Popen(f"cp {file_path} {os.path.join(output_dir, file_name)}", - universal_newlines=True, - shell=True, - stdout=subprocess.PIPE) - result = subprocess.Popen(f"sourcekitten doc --objc {file_path} -- -x objective-c -isysroot $(xcrun --show-sdk-path) -I $(pwd)", - universal_newlines=True, - shell=True, - stdout=subprocess.PIPE) - logging.info("------------") - api_info = result.stdout.read() - output_path = os.path.join(output_dir, file_name + ".json") - logging.info(output_path) - with open(output_path, 'w') as f: - f.write(api_info) + # derived_data_location = os.path.expanduser("~/Library/Developer/Xcode/DerivedData/") + # for file_dir, _, file_names in os.walk(derived_data_location): + # for file_name in file_names: + # if file_name == objc_header: + # file_path = os.path.join(file_dir, file_name) + # logging.info(file_path) + # subprocess.Popen(f"cp {file_path} {os.path.join(output_dir, file_name)}", + # universal_newlines=True, + # shell=True, + # stdout=subprocess.PIPE) + # result = subprocess.Popen(f"sourcekitten doc --objc {file_path} -- -x objective-c -isysroot $(xcrun --show-sdk-path) -I $(pwd)", + # universal_newlines=True, + # shell=True, + # stdout=subprocess.PIPE) + # logging.info("------------") + # api_info = result.stdout.read() + # output_path = os.path.join(output_dir, file_name + ".json") + # logging.info(output_path) + # with open(output_path, 'w') as f: + # f.write(api_info) def parse_cmdline_args(): From d9669f6208b37f6c5cd1f1fc85ec0cdab971e47f Mon Sep 17 00:00:00 2001 From: Mou Date: Tue, 11 Apr 2023 22:11:38 -0700 Subject: [PATCH 57/59] text diff --- scripts/api_diff_report/api_diff.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/api_diff_report/api_diff.py b/scripts/api_diff_report/api_diff.py index 9f744289841..f479a4d7933 100644 --- a/scripts/api_diff_report/api_diff.py +++ b/scripts/api_diff_report/api_diff.py @@ -40,8 +40,18 @@ def main(): merged_file = os.path.join(merged_branch, file_name) base_file = os.path.join(base_branch, file_name) api_diff(merged_file, base_file) + text_diff(merged_file, base_file) +def text_diff(merged_file, base_file): + result = subprocess.Popen(f"git diff --no-index --word-diff {merged_file} {base_file}", + universal_newlines=True, + shell=True, + stdout=subprocess.PIPE) + logging.info("------------") + api_info = result.stdout.read() + logging.info(api_info) + def api_diff(merged_file, base_file): file_extension = merged_file.split(".")[1] From 7280d2983ce821e9146feb58611fc73419e3d37a Mon Sep 17 00:00:00 2001 From: Mou Date: Tue, 11 Apr 2023 22:18:58 -0700 Subject: [PATCH 58/59] text diff for -Swift.h --- scripts/api_diff_report/api_info.py | 80 ++++++++++++++--------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/scripts/api_diff_report/api_info.py b/scripts/api_diff_report/api_info.py index 617a2079408..2e3c2379d8e 100644 --- a/scripts/api_diff_report/api_info.py +++ b/scripts/api_diff_report/api_info.py @@ -84,48 +84,48 @@ def main(): with open(output_path, 'w') as f: f.write(api_info) - # for scheme, objc_header in swift_to_objc.items(): - # result = subprocess.Popen("scripts/setup_spm_tests.sh", - # universal_newlines=True, - # shell=True, - # stdout=subprocess.PIPE) - # logging.info("------------") - # build_info = result.stdout.read() - # # logging.info(build_info) - # # derived_data_location = os.path.expanduser(f"~/{scheme}/build/") - # # subprocess.Popen(f"defaults write com.apple.dt.Xcode IDECustomDerivedDataLocation {derived_data_location}", - # # universal_newlines=True, - # # shell=True, - # # stdout=subprocess.PIPE) + for scheme, objc_header in swift_to_objc.items(): + result = subprocess.Popen("scripts/setup_spm_tests.sh", + universal_newlines=True, + shell=True, + stdout=subprocess.PIPE) + logging.info("------------") + build_info = result.stdout.read() + # logging.info(build_info) + # derived_data_location = os.path.expanduser(f"~/{scheme}/build/") + # subprocess.Popen(f"defaults write com.apple.dt.Xcode IDECustomDerivedDataLocation {derived_data_location}", + # universal_newlines=True, + # shell=True, + # stdout=subprocess.PIPE) - # result = subprocess.Popen(f"xcodebuild -scheme {scheme} -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 11' ONLY_ACTIVE_ARCH=YES CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=YES COMPILER_INDEX_STORE_ENABLE=NO CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ IPHONEOS_DEPLOYMENT_TARGET=13.0 TVOS_DEPLOYMENT_TARGET=13.0", - # universal_newlines=True, - # shell=True, - # stdout=subprocess.PIPE) - # logging.info("------------") - # build_info = result.stdout.read() - # logging.info(build_info) + result = subprocess.Popen(f"xcodebuild -scheme {scheme} -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 11' ONLY_ACTIVE_ARCH=YES CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=YES COMPILER_INDEX_STORE_ENABLE=NO CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ IPHONEOS_DEPLOYMENT_TARGET=13.0 TVOS_DEPLOYMENT_TARGET=13.0", + universal_newlines=True, + shell=True, + stdout=subprocess.PIPE) + logging.info("------------") + build_info = result.stdout.read() + logging.info(build_info) - # derived_data_location = os.path.expanduser("~/Library/Developer/Xcode/DerivedData/") - # for file_dir, _, file_names in os.walk(derived_data_location): - # for file_name in file_names: - # if file_name == objc_header: - # file_path = os.path.join(file_dir, file_name) - # logging.info(file_path) - # subprocess.Popen(f"cp {file_path} {os.path.join(output_dir, file_name)}", - # universal_newlines=True, - # shell=True, - # stdout=subprocess.PIPE) - # result = subprocess.Popen(f"sourcekitten doc --objc {file_path} -- -x objective-c -isysroot $(xcrun --show-sdk-path) -I $(pwd)", - # universal_newlines=True, - # shell=True, - # stdout=subprocess.PIPE) - # logging.info("------------") - # api_info = result.stdout.read() - # output_path = os.path.join(output_dir, file_name + ".json") - # logging.info(output_path) - # with open(output_path, 'w') as f: - # f.write(api_info) + derived_data_location = os.path.expanduser("~/Library/Developer/Xcode/DerivedData/") + for file_dir, _, file_names in os.walk(derived_data_location): + for file_name in file_names: + if file_name == objc_header: + file_path = os.path.join(file_dir, file_name) + logging.info(file_path) + subprocess.Popen(f"cp {file_path} {os.path.join(output_dir, file_name)}", + universal_newlines=True, + shell=True, + stdout=subprocess.PIPE) + result = subprocess.Popen(f"sourcekitten doc --objc {file_path} -- -x objective-c -isysroot $(xcrun --show-sdk-path) -I $(pwd)", + universal_newlines=True, + shell=True, + stdout=subprocess.PIPE) + logging.info("------------") + api_info = result.stdout.read() + output_path = os.path.join(output_dir, file_name + ".json") + logging.info(output_path) + with open(output_path, 'w') as f: + f.write(api_info) def parse_cmdline_args(): From b255f311d4e619a35f7324d58a47853a575f79e0 Mon Sep 17 00:00:00 2001 From: Mou Date: Tue, 11 Apr 2023 22:30:53 -0700 Subject: [PATCH 59/59] text diff for -Swift.h --- scripts/api_diff_report/api_info.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/api_diff_report/api_info.py b/scripts/api_diff_report/api_info.py index 2e3c2379d8e..4abebfe77bd 100644 --- a/scripts/api_diff_report/api_info.py +++ b/scripts/api_diff_report/api_info.py @@ -91,12 +91,12 @@ def main(): stdout=subprocess.PIPE) logging.info("------------") build_info = result.stdout.read() - # logging.info(build_info) - # derived_data_location = os.path.expanduser(f"~/{scheme}/build/") - # subprocess.Popen(f"defaults write com.apple.dt.Xcode IDECustomDerivedDataLocation {derived_data_location}", - # universal_newlines=True, - # shell=True, - # stdout=subprocess.PIPE) + logging.info(build_info) + derived_data_location = os.path.expanduser(f"~/{args.output_dir}/{scheme}/build/") + subprocess.Popen(f"defaults write com.apple.dt.Xcode IDECustomDerivedDataLocation {derived_data_location}", + universal_newlines=True, + shell=True, + stdout=subprocess.PIPE) result = subprocess.Popen(f"xcodebuild -scheme {scheme} -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 11' ONLY_ACTIVE_ARCH=YES CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=YES COMPILER_INDEX_STORE_ENABLE=NO CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ IPHONEOS_DEPLOYMENT_TARGET=13.0 TVOS_DEPLOYMENT_TARGET=13.0", universal_newlines=True, @@ -106,7 +106,7 @@ def main(): build_info = result.stdout.read() logging.info(build_info) - derived_data_location = os.path.expanduser("~/Library/Developer/Xcode/DerivedData/") + # derived_data_location = os.path.expanduser("~/Library/Developer/Xcode/DerivedData/") for file_dir, _, file_names in os.walk(derived_data_location): for file_name in file_names: if file_name == objc_header: