Skip to content

Commit a67198d

Browse files
authored
Add Generate SWIG files GHA that can be used to quickly generate code (#565)
* Initial generate swig workflow * Update generate_swig.yml * Add gen_swig_only flag * Add cmake target logic * Update build_zips.py * Try not requiring Unity * Update generate_swig.yml * Update FindUnity.cmake * Update FindUnity.cmake * Add more logic to * Updates to not need Unity * Update generate_swig.yml * Update the other products
1 parent e9e2dba commit a67198d

File tree

17 files changed

+217
-116
lines changed

17 files changed

+217
-116
lines changed

.github/workflows/generate_swig.yml

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,11 @@ on:
1414
default: ''
1515
required: false
1616
type: string
17-
unity_branch:
18-
description: 'Unity branch to build against, empty means current branch'
19-
default: ''
20-
type: string
2117
apis:
2218
description: 'CSV of apis to build and test'
2319
default: 'analytics,auth,crashlytics,database,dynamic_links,firestore,functions,installations,messaging,remote_config,storage'
2420
required: true
2521
type: string
26-
unity_platform_name:
27-
description: 'The platform name Unity should install with'
28-
default: ''
29-
required: true
30-
type: string
3122
# Additional CMake flags to use
3223
additional_cmake_flags:
3324
description: 'Additional flags to pass into CMake'
@@ -46,7 +37,6 @@ jobs:
4637
- uses: actions/checkout@v3
4738
with:
4839
submodules: true
49-
ref: ${{ inputs.unity_branch }}
5040

5141
- uses: actions/checkout@v3
5242
with:
@@ -77,13 +67,6 @@ jobs:
7767
run: |
7868
sudo apt install openssl
7969
80-
- id: unity_setup
81-
uses: ./gha/unity
82-
timeout-minutes: 30
83-
with:
84-
version: ${{ inputs.unity_version }}
85-
platforms: ${{ inputs.unity_platform_name }}
86-
8770
- name: Setup Swig Env
8871
shell: bash
8972
run: |
@@ -96,30 +79,18 @@ jobs:
9679
shell: bash
9780
run: |
9881
# TODO add handling cmake_extras
99-
python scripts/build_scripts/build_zips.py --gha --platform=linux --use_boringssl=true --unity_root=$UNITY_ROOT_DIR --apis=${{ inputs.apis }} --gen_documentation_zip
82+
python scripts/build_scripts/build_zips.py --gha --platform=linux --apis=${{ inputs.apis }} --gen_swig_only
10083
10184
- name: Check zip files
10285
shell: bash
10386
run: |
104-
if [ -f linux_unity/*Linux.zip ]; then
105-
echo "linux_unity zip created."
106-
else
107-
echo "Fail to create linux_unity zip."
108-
exit 1
109-
fi
11087
if [ -f linux_unity/documentation_sources.zip ]; then
11188
echo "documentation_sources zip created."
11289
else
11390
echo "Fail to create documentation_sources zip."
11491
exit 1
11592
fi
11693
117-
- name: Upload Build
118-
uses: actions/upload-artifact@v3
119-
with:
120-
name: linux_unity
121-
path: linux_unity/*Linux.zip
122-
12394
- name: Upload Documentation Sources
12495
uses: actions/upload-artifact@v3
12596
with:

CMakeLists.txt

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ option(FIREBASE_UNITY_BUILD_TESTS
7575
option(FIREBASE_GITHUB_ACTION_BUILD
7676
"Indicates that this build was created from a GitHub Action" OFF)
7777

78+
option(FIREBASE_GENERATE_SWIG_ONLY
79+
"Indicates that this build is only intending to generate the swig files" OFF)
80+
7881
# These options allow selecting what built outputs go into the CPack zip file
7982
# as we merge the different platform zip's together for unity package
8083
# For example: only packing dotnet libraries on linux builds
@@ -242,11 +245,12 @@ endif()
242245
# Includes platform which needs to be invoked first
243246
add_subdirectory(app)
244247
set(TARGET_LINK_LIB_NAMES "firebase_app" "firebase_app_swig")
248+
set(DOCUMENTATION_ONLY_LIB_NAMES "firebase_app_swig")
245249
set(PROJECT_LIST_HEADER "#define PROJECT_LIST(X)")
246250
list(APPEND PROJECT_LIST_HEADER " X(App)")
247251

248252
# Include Firebase editor tools.
249-
if (DESKTOP AND APPLE AND FIREBASE_INCLUDE_EDITOR_TOOL)
253+
if (DESKTOP AND APPLE AND FIREBASE_INCLUDE_EDITOR_TOOL AND NOT FIREBASE_GENERATE_SWIG_ONLY)
250254
add_subdirectory(editor)
251255
endif()
252256

@@ -258,56 +262,67 @@ endif()
258262
if (FIREBASE_INCLUDE_ANALYTICS)
259263
add_subdirectory(analytics)
260264
list(APPEND TARGET_LINK_LIB_NAMES "firebase_analytics" "firebase_analytics_swig")
265+
list(APPEND DOCUMENTATION_ONLY_LIB_NAMES "firebase_analytics_swig")
261266
list(APPEND PROJECT_LIST_HEADER " X(Analytics)")
262267
endif()
263268
if (FIREBASE_INCLUDE_AUTH)
264269
add_subdirectory(auth)
265270
list(APPEND TARGET_LINK_LIB_NAMES "firebase_auth" "firebase_auth_swig")
271+
list(APPEND DOCUMENTATION_ONLY_LIB_NAMES "firebase_auth_swig")
266272
list(APPEND PROJECT_LIST_HEADER " X(Auth)")
267273
endif()
268274
if (FIREBASE_INCLUDE_CRASHLYTICS AND FIREBASE_INCLUDE_UNITY)
269275
add_subdirectory(crashlytics)
270276
list(APPEND TARGET_LINK_LIB_NAMES "firebase_crashlytics" "firebase_crashlytics_swig")
277+
list(APPEND DOCUMENTATION_ONLY_LIB_NAMES "firebase_crashlytics_swig")
271278
list(APPEND PROJECT_LIST_HEADER " X(Crashlytics)")
272279
endif()
273280
if (FIREBASE_INCLUDE_DATABASE)
274281
add_subdirectory(database)
275282
list(APPEND TARGET_LINK_LIB_NAMES "firebase_database" "firebase_database_swig")
283+
list(APPEND DOCUMENTATION_ONLY_LIB_NAMES "firebase_database_swig")
276284
list(APPEND PROJECT_LIST_HEADER " X(Database)")
277285
endif()
278286
if (FIREBASE_INCLUDE_DYNAMIC_LINKS)
279287
add_subdirectory(dynamic_links)
280288
list(APPEND TARGET_LINK_LIB_NAMES "firebase_dynamic_links" "firebase_dynamic_links_swig")
289+
list(APPEND DOCUMENTATION_ONLY_LIB_NAMES "firebase_dynamic_links_swig")
281290
list(APPEND PROJECT_LIST_HEADER " X(DynamicLinks)")
282291
endif()
283292
if (FIREBASE_INCLUDE_INSTALLATIONS)
284293
add_subdirectory(installations)
285294
list(APPEND TARGET_LINK_LIB_NAMES "firebase_installations" "firebase_installations_swig")
295+
list(APPEND DOCUMENTATION_ONLY_LIB_NAMES "firebase_installations_swig")
286296
list(APPEND PROJECT_LIST_HEADER " X(Installations)")
287297
endif()
288298
if (FIREBASE_INCLUDE_FIRESTORE)
289299
add_subdirectory(firestore)
290300
list(APPEND TARGET_LINK_LIB_NAMES "firebase_firestore" "firebase_firestore_swig")
301+
list(APPEND DOCUMENTATION_ONLY_LIB_NAMES "firebase_firestore_swig")
291302
list(APPEND PROJECT_LIST_HEADER " X(Firestore)")
292303
endif()
293304
if (FIREBASE_INCLUDE_FUNCTIONS)
294305
add_subdirectory(functions)
295306
list(APPEND TARGET_LINK_LIB_NAMES "firebase_functions" "firebase_functions_swig")
307+
list(APPEND DOCUMENTATION_ONLY_LIB_NAMES "firebase_functions_swig")
296308
list(APPEND PROJECT_LIST_HEADER " X(Functions)")
297309
endif()
298310
if (FIREBASE_INCLUDE_MESSAGING)
299311
add_subdirectory(messaging)
300312
list(APPEND TARGET_LINK_LIB_NAMES "firebase_messaging" "firebase_messaging_swig")
313+
list(APPEND DOCUMENTATION_ONLY_LIB_NAMES "firebase_messaging_swig")
301314
list(APPEND PROJECT_LIST_HEADER " X(Messaging)")
302315
endif()
303316
if (FIREBASE_INCLUDE_REMOTE_CONFIG)
304317
add_subdirectory(remote_config)
305318
list(APPEND TARGET_LINK_LIB_NAMES "firebase_remote_config" "firebase_remote_config_swig")
319+
list(APPEND DOCUMENTATION_ONLY_LIB_NAMES "firebase_remote_config_swig")
306320
list(APPEND PROJECT_LIST_HEADER " X(RemoteConfig)")
307321
endif()
308322
if (FIREBASE_INCLUDE_STORAGE)
309323
add_subdirectory(storage)
310324
list(APPEND TARGET_LINK_LIB_NAMES "firebase_storage" "firebase_storage_swig")
325+
list(APPEND DOCUMENTATION_ONLY_LIB_NAMES "firebase_storage_swig")
311326
list(APPEND PROJECT_LIST_HEADER " X(Storage)")
312327
endif()
313328

@@ -322,6 +337,11 @@ if(FIREBASE_UNI_LIBRARY)
322337
endif()
323338
endif()
324339

340+
add_custom_target(firebase_swig_targets
341+
DEPENDS
342+
${DOCUMENTATION_ONLY_LIB_NAMES}
343+
)
344+
325345
if(FIREBASE_INCLUDE_MONO)
326346
add_subdirectory(samples/mono_app)
327347
endif()

analytics/CMakeLists.txt

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,19 @@ firebase_swig_add_library(firebase_analytics_swig
3636
firebase_analytics
3737
)
3838

39+
unity_pack_documentation_sources(analytics
40+
DOCUMENTATION_SOURCES
41+
${firebase_analytics_src}
42+
${firebase_analytics_swig_gen_src}
43+
)
44+
if (FIREBASE_GENERATE_SWIG_ONLY)
45+
unity_pack_documentation_sources(analytics
46+
DOCUMENTATION_SOURCES
47+
${firebase_analytics_swig_gen_cpp_src}
48+
)
49+
return()
50+
endif()
51+
3952
mono_add_library(firebase_analytics_cs
4053
MODULE
4154
Firebase.Analytics
@@ -71,12 +84,6 @@ if (FIREBASE_INCLUDE_UNITY)
7184
)
7285
endif()
7386

74-
unity_pack_documentation_sources(analytics
75-
DOCUMENTATION_SOURCES
76-
${firebase_analytics_src}
77-
${firebase_analytics_swig_gen_src}
78-
)
79-
8087
set_property(TARGET firebase_analytics_cs
8188
PROPERTY FOLDER
8289
"Firebase ${FIREBASE_PLATFORM_NAME}"

app/CMakeLists.txt

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ else()
2323
set(firebase_platform_task_lib "")
2424
endif()
2525

26-
add_subdirectory(platform)
27-
add_subdirectory(task_extension)
26+
if (NOT FIREBASE_GENERATE_SWIG_ONLY)
27+
add_subdirectory(platform)
28+
add_subdirectory(task_extension)
29+
endif()
2830

2931
set(FIREBASE_PLATFORM_REF
3032
"firebase_app_cs"
@@ -81,6 +83,20 @@ firebase_swig_add_library(firebase_app_swig
8183
firebase_app
8284
)
8385

86+
unity_pack_documentation_sources(app
87+
DOCUMENTATION_SOURCES
88+
${firebase_app_src_documented}
89+
${firebase_app_swig_gen_src}
90+
task_extension/TaskExtension.cs
91+
)
92+
if (FIREBASE_GENERATE_SWIG_ONLY)
93+
unity_pack_documentation_sources(app
94+
DOCUMENTATION_SOURCES
95+
${firebase_app_swig_gen_cpp_src}
96+
)
97+
return()
98+
endif()
99+
84100
if(FIREBASE_UNI_LIBRARY AND NOT FIREBASE_IOS_BUILD)
85101
set(firebase_native_library firebase_app_uni)
86102
else()
@@ -115,13 +131,6 @@ if (FIREBASE_INCLUDE_UNITY)
115131
)
116132
endif()
117133

118-
unity_pack_documentation_sources(app
119-
DOCUMENTATION_SOURCES
120-
${firebase_app_src_documented}
121-
${firebase_app_swig_gen_src}
122-
task_extension/TaskExtension.cs
123-
)
124-
125134
set_property(TARGET firebase_app_cs
126135
PROPERTY FOLDER
127136
"Firebase ${FIREBASE_PLATFORM_NAME}"

auth/CMakeLists.txt

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,19 @@ firebase_swig_add_library(firebase_auth_swig
5050
${EXTERNAL_LIB_NAMES}
5151
)
5252

53+
unity_pack_documentation_sources(auth
54+
DOCUMENTATION_SOURCES
55+
${firebase_auth_src}
56+
${firebase_auth_swig_gen_src}
57+
)
58+
if (FIREBASE_GENERATE_SWIG_ONLY)
59+
unity_pack_documentation_sources(auth
60+
DOCUMENTATION_SOURCES
61+
${firebase_auth_swig_gen_cpp_src}
62+
)
63+
return()
64+
endif()
65+
5366
mono_add_library(firebase_auth_cs
5467
MODULE
5568
Firebase.Auth
@@ -85,12 +98,6 @@ if (FIREBASE_INCLUDE_UNITY)
8598
)
8699
endif()
87100

88-
unity_pack_documentation_sources(auth
89-
DOCUMENTATION_SOURCES
90-
${firebase_auth_src}
91-
${firebase_auth_swig_gen_src}
92-
)
93-
94101
set_property(TARGET firebase_auth_cs
95102
PROPERTY FOLDER
96103
"Firebase ${FIREBASE_PLATFORM_NAME}"

cmake/FindUnity.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616

1717
find_package(Mono REQUIRED)
1818

19+
if (FIREBASE_GENERATE_SWIG_ONLY)
20+
return()
21+
endif()
22+
1923
if (NOT EXISTS "${UNITY_ROOT_DIR}")
2024
# Make our best attempt to find the latest unity installed on the system.
2125
# Note that Unity <=2018 include mono 2.x which causes compilation errors.

cmake/unity_mono.cmake

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ endmacro()
146146
#
147147
macro(mono_add_external_dll name dllpath)
148148

149+
if(FIREBASE_GENERATE_SWIG_ONLY)
150+
add_custom_target(${name})
151+
return()
152+
endif()
153+
149154
if(NOT EXISTS ${dllpath})
150155
message(FATAL_ERROR "Expected ${name} file to already exist for mono_add_external_dll(${dllpath})")
151156
endif()
@@ -210,14 +215,18 @@ endmacro()
210215
# * If no guid is provided a new guid will be generated each time
211216
#
212217
macro(mono_add_library name)
213-
mono_add_internal(${name} "Library" ${ARGN})
214-
set_target_properties(${name} PROPERTIES FOLDER "Mono Dll")
218+
if (NOT FIREBASE_GENERATE_SWIG_ONLY)
219+
mono_add_internal(${name} "Library" ${ARGN})
220+
set_target_properties(${name} PROPERTIES FOLDER "Mono Dll")
221+
endif()
215222
endmacro()
216223

217224
# Creates and executable library. See mono_add_library for args
218225
macro(mono_add_executable name)
219-
mono_add_internal(${name} "Exe" ${ARGN})
220-
set_target_properties(${name} PROPERTIES FOLDER "Mono Bin")
226+
if (NOT FIREBASE_GENERATE_SWIG_ONLY)
227+
mono_add_internal(${name} "Exe" ${ARGN})
228+
set_target_properties(${name} PROPERTIES FOLDER "Mono Bin")
229+
endif()
221230
endmacro()
222231

223232
# Internal helper function for mono_add_library and mono_add_executable

crashlytics/CMakeLists.txt

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,19 @@ firebase_swig_add_library(firebase_crashlytics_swig
8080
${EXTERNAL_LIB_NAMES}
8181
)
8282

83+
unity_pack_documentation_sources(crashlytics
84+
DOCUMENTATION_SOURCES
85+
${firebase_crashlytics_src_documented}
86+
)
87+
if (FIREBASE_GENERATE_SWIG_ONLY)
88+
unity_pack_documentation_sources(crashlytics
89+
DOCUMENTATION_SOURCES
90+
${firebase_crashlytics_swig_gen_src}
91+
${firebase_crashlytics_swig_gen_cpp_src}
92+
)
93+
return()
94+
endif()
95+
8396
mono_add_library(firebase_crashlytics_cs
8497
MODULE
8598
Firebase.Crashlytics
@@ -117,11 +130,6 @@ if (FIREBASE_INCLUDE_UNITY)
117130
)
118131
endif()
119132

120-
unity_pack_documentation_sources(crashlytics
121-
DOCUMENTATION_SOURCES
122-
${firebase_crashlytics_src_documented}
123-
)
124-
125133
set_property(TARGET firebase_crashlytics_cs
126134
PROPERTY FOLDER
127135
"Firebase ${FIREBASE_PLATFORM_NAME}"

0 commit comments

Comments
 (0)