Skip to content

Commit f69fc1a

Browse files
authored
Upgraded build tools (#3)
1 parent 5625488 commit f69fc1a

File tree

14 files changed

+323
-150
lines changed

14 files changed

+323
-150
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ demo/addons
66
demo/android
77
demo/ios
88
build/
9+
release/
910
export.cfg
1011

1112
# General
@@ -15,6 +16,7 @@ export.cfg
1516
# Android
1617
.gradle/
1718
*.jar
19+
!android/gradle/wrapper/gradle-wrapper.jar
1820
*.aar
1921
local.properties
2022

android/config.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ extra.apply {
3434
set("templateDirectory", "../../addon")
3535

3636
// iOS
37+
set("iosPlatformVersion", iosProperties.getProperty("platform_version"))
3738
set("iosFrameworks", iosProperties.getProperty("frameworks"))
3839
set("iosEmbeddedFrameworks", iosProperties.getProperty("embedded_frameworks"))
3940
set("iosLinkerFlags", iosProperties.getProperty("flags"))
59.3 KB
Binary file not shown.

android/inappreview/build.gradle.kts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
// © 2024-present https://github.com/cengiz-pz
33
//
44

5-
import org.apache.tools.ant.filters.ReplaceTokens
65
import com.android.build.gradle.internal.api.LibraryVariantOutputImpl
76

7+
import org.apache.tools.ant.filters.ReplaceTokens
8+
9+
810
plugins {
911
alias(libs.plugins.android.library)
1012
alias(libs.plugins.kotlin.android)
@@ -103,6 +105,7 @@ tasks {
103105
"pluginVersion" to (project.extra["pluginVersion"] as String),
104106
"pluginPackage" to (project.extra["pluginPackageName"] as String),
105107
"androidDependencies" to androidDependencies.joinToString(", ") { "\"$it\"" },
108+
"iosPlatformVersion" to (project.extra["iosPlatformVersion"] as String),
106109
"iosFrameworks" to (project.extra["iosFrameworks"] as String)
107110
.split(",")
108111
.map { it.trim() }
@@ -122,9 +125,27 @@ tasks {
122125
}
123126

124127
register<de.undercouch.gradle.tasks.download.Download>("downloadGodotAar") {
128+
val destFile = file("${project.rootDir}/libs/${project.extra["godotAarFile"]}")
129+
125130
src(project.extra["godotAarUrl"] as String)
126-
dest(file("${project.rootDir}/libs/${project.extra["godotAarFile"]}"))
131+
dest(destFile)
127132
overwrite(false)
133+
134+
onlyIf {
135+
val exists = destFile.exists() && destFile.length() > 0
136+
if (exists) {
137+
println("[DEBUG] File already exists and is non-empty: ${destFile.absolutePath} (${destFile.length()} bytes)")
138+
println("[DEBUG] Skipping download.")
139+
} else {
140+
if (destFile.exists()) {
141+
println("[DEBUG] File exists but is empty: ${destFile.absolutePath}")
142+
} else {
143+
println("[DEBUG] File not found: ${destFile.absolutePath}")
144+
}
145+
println("[DEBUG] Proceeding with download...")
146+
}
147+
!exists // run task only if file does NOT exist or is empty
148+
}
128149
}
129150

130151
named("preBuild") {

common/config.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
#
44

55
pluginNodeName=InappReview
6-
pluginVersion=5.0
7-
godotVersion=4.5
8-
releaseType=beta3
6+
pluginVersion=5.1
7+
godotVersion=4.5.1
8+
releaseType=stable

demo/.godot/uid_cache.bin

0 Bytes
Binary file not shown.

demo/export_presets.cfg

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ custom_template/release=""
2525
gradle_build/use_gradle_build=true
2626
gradle_build/gradle_build_directory=""
2727
gradle_build/android_source_template=""
28+
gradle_build/compress_native_libraries=false
2829
gradle_build/export_format=0
2930
gradle_build/min_sdk=""
3031
gradle_build/target_sdk=""
@@ -53,11 +54,12 @@ shader_baker/enabled=false
5354
xr_features/xr_mode=0
5455
gesture/swipe_to_dismiss=false
5556
screen/immersive_mode=true
57+
screen/edge_to_edge=false
5658
screen/support_small=true
5759
screen/support_normal=true
5860
screen/support_large=true
5961
screen/support_xlarge=true
60-
screen/edge_to_edge=false
62+
screen/background_color=Color(0, 0, 0, 1)
6163
user_data_backup/allow=false
6264
command_line/extra_args=""
6365
apk_expansion/enable=false

ios/config/InappReviewPlugin.gdip

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ deinitialization="@iosDeinitializationMethod@"
1111

1212
use_swift_runtime=true
1313

14-
1514
[dependencies]
1615
linked=[]
1716
embedded=[]

ios/config/config.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
ios_project_name=inapp_review
66
initialization_method=InappReviewPlugin_init
77
deinitialization_method=InappReviewPlugin_deinit
8+
platform_version=16.0
89
frameworks=Foundation.framework,StoreKit.framework
910
embedded_frameworks=
1011
flags=-ObjC,-Wl,-weak-lswiftCore,-weak-lswiftObjectiveC,-weak-lswift_Concurrency
1112
dependencies=
12-
platform_version=16.0
13-
valid_godot_versions=,4.1,4.2,4.3,4.4.1,4.5
13+
valid_godot_versions=,4.5,4.5.1
1414
extra_properties=

ios/script/build.sh

Lines changed: 91 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
# © 2024-present https://github.com/cengiz-pz
44
#
55

6-
set -e
7-
trap "sleep 1; echo" EXIT
6+
set -euo pipefail
87

98
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
109
IOS_DIR=$(realpath $SCRIPT_DIR/..)
@@ -13,22 +12,25 @@ ANDROID_DIR=$ROOT_DIR/android
1312
ADDON_DIR=$ROOT_DIR/addon
1413
GODOT_DIR=$IOS_DIR/godot
1514
IOS_CONFIG_DIR=$IOS_DIR/config
15+
COMMON_DIR=$ROOT_DIR/common
1616
PODS_DIR=$IOS_DIR/Pods
1717
BUILD_DIR=$IOS_DIR/build
1818
DEST_DIR=$BUILD_DIR/release
1919
FRAMEWORK_DIR=$BUILD_DIR/framework
2020
LIB_DIR=$BUILD_DIR/lib
2121
IOS_CONFIG_FILE=$IOS_CONFIG_DIR/config.properties
22-
COMMON_CONFIG_FILE=$ROOT_DIR/common/config.properties
22+
COMMON_CONFIG_FILE=$COMMON_DIR/config.properties
2323

2424
PLUGIN_NODE_NAME=$($SCRIPT_DIR/get_config_property.sh -f $COMMON_CONFIG_FILE pluginNodeName)
2525
PLUGIN_NAME="${PLUGIN_NODE_NAME}Plugin"
2626
PLUGIN_VERSION=$($SCRIPT_DIR/get_config_property.sh -f $COMMON_CONFIG_FILE pluginVersion)
2727
IOS_INITIALIZATION_METHOD=$($SCRIPT_DIR/get_config_property.sh -f $IOS_CONFIG_FILE initialization_method)
2828
IOS_DEINITIALIZATION_METHOD=$($SCRIPT_DIR/get_config_property.sh -f $IOS_CONFIG_FILE deinitialization_method)
29+
IOS_PLATFORM_VERSION=$($SCRIPT_DIR/get_config_property.sh -f $IOS_CONFIG_FILE platform_version)
2930
PLUGIN_PACKAGE_NAME=$($SCRIPT_DIR/get_gradle_property.sh pluginPackageName $ANDROID_DIR/config.gradle.kts)
3031
ANDROID_DEPENDENCIES=$($SCRIPT_DIR/get_android_dependencies.sh)
3132
GODOT_VERSION=$($SCRIPT_DIR/get_config_property.sh -f $COMMON_CONFIG_FILE godotVersion)
33+
GODOT_RELEASE_TYPE=$($SCRIPT_DIR/get_config_property.sh -f $COMMON_CONFIG_FILE releaseType)
3234
IOS_FRAMEWORKS=()
3335
while IFS= read -r line; do
3436
IOS_FRAMEWORKS+=("$line")
@@ -71,29 +73,28 @@ function display_help()
7173
echo_yellow "If plugin version is not set with the -z option, then Godot version will be used."
7274
echo
7375
$ROOT_DIR/script/echocolor.sh -Y "Syntax:"
74-
echo_yellow " $0 [-a|A <godot version>|c|g|G <godot version>|h|H|i|p|P|t <timeout>|z <version>]"
76+
echo_yellow " $0 [-a|A|c|g|G|h|H|i|p|P|t <timeout>|z]"
7577
echo
7678
$ROOT_DIR/script/echocolor.sh -Y "Options:"
7779
echo_yellow " a generate godot headers and build plugin"
78-
echo_yellow " A download specified godot version, generate godot headers, and"
80+
echo_yellow " A download configured godot version, generate godot headers, and"
7981
echo_yellow " build plugin"
8082
echo_yellow " b build plugin"
8183
echo_yellow " c remove any existing plugin build"
8284
echo_yellow " g remove godot directory"
83-
echo_yellow " G download the godot version specified in the option argument"
84-
echo_yellow " into godot directory"
85+
echo_yellow " G download the configured godot version into godot directory"
8586
echo_yellow " h display usage information"
8687
echo_yellow " H generate godot headers"
8788
echo_yellow " i ignore if an unsupported godot version selected and continue"
8889
echo_yellow " p remove pods and pod repo trunk"
8990
echo_yellow " P install pods"
9091
echo_yellow " t change timeout value for godot build"
91-
echo_yellow " z create zip archive with given version added to the file name"
92+
echo_yellow " z create zip archive, include configured version in the file name"
9293
echo
9394
$ROOT_DIR/script/echocolor.sh -Y "Examples:"
9495
echo_yellow " * clean existing build, remove godot, and rebuild all"
95-
echo_yellow " $> $0 -cgA 4.2"
96-
echo_yellow " $> $0 -cgpG 4.2 -HPbz 1.0"
96+
echo_yellow " $> $0 -cgA"
97+
echo_yellow " $> $0 -cgpGHPbz"
9798
echo
9899
echo_yellow " * clean existing build, remove pods and pod repo trunk, and rebuild plugin"
99100
echo_yellow " $> $0 -cpPb"
@@ -102,9 +103,9 @@ function display_help()
102103
echo_yellow " $> $0 -ca"
103104
echo
104105
echo_yellow " * clean existing build and rebuild plugin with custom plugin version"
105-
echo_yellow " $> $0 -cHbz 1.0"
106+
echo_yellow " $> $0 -cHbz"
106107
echo
107-
echo_yellow " * clean existing build and rebuild plugin with custom build timeout"
108+
echo_yellow " * clean existing build and rebuild plugin with custom build-header timeout"
108109
echo_yellow " $> $0 -cHbt 15"
109110
echo
110111
}
@@ -191,20 +192,56 @@ function remove_pods()
191192

192193
function download_godot()
193194
{
194-
if [[ -d "$GODOT_DIR" ]]
195-
then
196-
display_error "Error: $GODOT_DIR directory already exists. Won't download."
197-
exit 1
198-
fi
199-
200-
display_status "downloading godot version $GODOT_VERSION..."
201-
202-
$SCRIPT_DIR/fetch_git_repo.sh -t $GODOT_VERSION-stable https://github.com/godotengine/godot.git $GODOT_DIR
203-
204-
if [[ -d "$GODOT_DIR" ]]
205-
then
206-
echo "$GODOT_VERSION" > $GODOT_DIR/GODOT_VERSION
207-
fi
195+
if [[ -d "$GODOT_DIR" ]]; then
196+
display_error "Error: $GODOT_DIR directory already exists. Remove it first or use a different directory."
197+
exit 1
198+
fi
199+
200+
local filename="godot-${GODOT_VERSION}-${GODOT_RELEASE_TYPE}.tar.xz"
201+
local release_url="https://github.com/godotengine/godot-builds/releases/download/${GODOT_VERSION}-${GODOT_RELEASE_TYPE}/${filename}"
202+
local archive_path="${GODOT_DIR}.tar.xz"
203+
local temp_extract_dir=$(mktemp -d)
204+
205+
display_status "Downloading Godot ${GODOT_VERSION}-${GODOT_RELEASE_TYPE} (official pre-built binary)..."
206+
echo_blue "URL: $release_url"
207+
208+
# Check required tools
209+
if ! command -v curl >/dev/null 2>&1; then
210+
display_error "Error: curl is required to download the archive."
211+
exit 1
212+
fi
213+
if ! command -v tar >/dev/null 2>&1; then
214+
display_error "Error: tar is required to extract the archive."
215+
exit 1
216+
fi
217+
218+
# Download the .tar.xz archive
219+
if ! curl -L --fail --progress-bar -o "$archive_path" "$release_url"; then
220+
rm -f "$archive_path"
221+
display_error "Failed to download Godot binary from:\n $release_url\nPlease verify that GODOT_VERSION (${GODOT_VERSION}) and GODOT_RELEASE_TYPE (${GODOT_RELEASE_TYPE}) are correct."
222+
exit 1
223+
fi
224+
225+
display_status "Extracting $filename ..."
226+
if ! tar -xaf "$archive_path" -C "$temp_extract_dir" --strip-components=1; then
227+
rm -f "$archive_path"
228+
rm -rf "$temp_extract_dir"
229+
display_error "Failed to extract the .tar.xz archive."
230+
exit 1
231+
fi
232+
233+
# Move extracted contents to final destination
234+
mkdir -p "$GODOT_DIR"
235+
mv "$temp_extract_dir"/* "$GODOT_DIR"/
236+
237+
# Cleanup
238+
rm -f "$archive_path"
239+
rm -rf "$temp_extract_dir"
240+
241+
# Write version marker for the rest of the build system
242+
echo "$GODOT_VERSION" > "$GODOT_DIR/GODOT_VERSION"
243+
244+
echo_green "Godot ${GODOT_VERSION}-${GODOT_RELEASE_TYPE} successfully downloaded and extracted to $GODOT_DIR"
208245
}
209246

210247

@@ -233,6 +270,18 @@ function install_pods()
233270

234271
function build_plugin()
235272
{
273+
if [[ ! -d "$PODS_DIR" ]]
274+
then
275+
display_error "Error: Pods directory does not exist. Run 'pod install' first."
276+
exit 1
277+
fi
278+
279+
if [[ ! -d "$GODOT_DIR" ]]
280+
then
281+
display_error "Error: $GODOT_DIR directory does not exist. Can't build plugin."
282+
exit 1
283+
fi
284+
236285
if [[ ! -f "$GODOT_DIR/GODOT_VERSION" ]]
237286
then
238287
display_error "Error: godot wasn't downloaded properly. Can't build plugin."
@@ -304,7 +353,8 @@ function build_plugin()
304353
}
305354

306355

307-
function merge_string_array() {
356+
function merge_string_array()
357+
{
308358
local arr=("$@") # Accept array as input
309359
printf "%s" "${arr[0]}"
310360
for ((i=1; i<${#arr[@]}; i++)); do
@@ -313,19 +363,15 @@ function merge_string_array() {
313363
}
314364

315365

316-
function replace_extra_properties() {
366+
function replace_extra_properties()
367+
{
317368
local file_path="$1"
318-
local -a prop_array=("${@:2}")
319-
320-
# Check if file exists and is readable
321-
if [[ ! -f "$file_path" || ! -r "$file_path" ]]; then
322-
display_error "Error: File '$file_path' does not exist or is not readable"
323-
exit 1
324-
fi
369+
shift
370+
local prop_array=("$@")
325371

326-
# Check if file is empty
372+
# Check if file exists and is not empty
327373
if [[ ! -s "$file_path" ]]; then
328-
echo_blue "Debug: File is empty, no replacements possible"
374+
display_error "Error: File '$file_path' does not exist or is empty, skipping replacements"
329375
return 0
330376
fi
331377

@@ -392,10 +438,10 @@ function create_zip_archive()
392438
{
393439
local zip_file_name="$PLUGIN_NAME-iOS-v$PLUGIN_VERSION.zip"
394440

395-
if [[ -e "$BUILD_DIR/release/$zip_file_name" ]]
441+
if [[ -e "$DEST_DIR/$zip_file_name" ]]
396442
then
397443
display_warning "deleting existing $zip_file_name file..."
398-
rm $BUILD_DIR/release/$zip_file_name
444+
rm $DEST_DIR/$zip_file_name
399445
fi
400446

401447
local tmp_directory=$(mktemp -d)
@@ -430,6 +476,7 @@ function create_zip_archive()
430476
ESCAPED_ANDROID_DEPENDENCIES=$(printf '%s' "$ANDROID_DEPENDENCIES" | sed 's/[\/&]/\\&/g')
431477
ESCAPED_IOS_INITIALIZATION_METHOD=$(printf '%s' "$IOS_INITIALIZATION_METHOD" | sed 's/[\/&]/\\&/g')
432478
ESCAPED_IOS_DEINITIALIZATION_METHOD=$(printf '%s' "$IOS_DEINITIALIZATION_METHOD" | sed 's/[\/&]/\\&/g')
479+
ESCAPED_IOS_PLATFORM_VERSION=$(printf '%s' "$IOS_PLATFORM_VERSION" | sed 's/[\/&]/\\&/g')
433480
ESCAPED_IOS_FRAMEWORKS=$(merge_string_array "${IOS_FRAMEWORKS[@]}" | sed 's/[\/&]/\\&/g')
434481
ESCAPED_IOS_EMBEDDED_FRAMEWORKS=$(merge_string_array "${IOS_EMBEDDED_FRAMEWORKS[@]}" | sed 's/[\/&]/\\&/g')
435482
ESCAPED_IOS_LINKER_FLAGS=$(merge_string_array "${IOS_LINKER_FLAGS[@]}" | sed 's/[\/&]/\\&/g')
@@ -442,12 +489,15 @@ function create_zip_archive()
442489
s|@androidDependencies@|$ESCAPED_ANDROID_DEPENDENCIES|g;
443490
s|@iosInitializationMethod@|$ESCAPED_IOS_INITIALIZATION_METHOD|g;
444491
s|@iosDeinitializationMethod@|$ESCAPED_IOS_DEINITIALIZATION_METHOD|g;
492+
s|@iosPlatformVersion@|$ESCAPED_IOS_PLATFORM_VERSION|g;
445493
s|@iosFrameworks@|$ESCAPED_IOS_FRAMEWORKS|g;
446494
s|@iosEmbeddedFrameworks@|$ESCAPED_IOS_EMBEDDED_FRAMEWORKS|g;
447495
s|@iosLinkerFlags@|$ESCAPED_IOS_LINKER_FLAGS|g
448496
" "$file"
449497

450-
replace_extra_properties $file ${EXTRA_PROPERTIES[@]}
498+
if [[ ${#EXTRA_PROPERTIES[@]} -gt 0 ]]; then
499+
replace_extra_properties "$file" "${EXTRA_PROPERTIES[@]}"
500+
fi
451501
done
452502
else
453503
display_error "Error: '$ADDON_DIR' not found."
@@ -468,7 +518,7 @@ function create_zip_archive()
468518
}
469519

470520

471-
while getopts "aAbcgG:hHipPt:z" option; do
521+
while getopts "aAbcgGhHipPt:z" option; do
472522
case $option in
473523
h)
474524
display_help

0 commit comments

Comments
 (0)