Skip to content

Commit

Permalink
Replace Python script with Unix Shell and Powershell script.
Browse files Browse the repository at this point in the history
Fixes #246.
  • Loading branch information
MikuAuahDark committed Nov 25, 2023
1 parent 86dbfff commit abd98a1
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 54 deletions.
15 changes: 12 additions & 3 deletions love/src/jni/Android.mk
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
LOVE_JNI_DIR := $(call my-dir)
IS_NDK_R17 := $(shell python ${LOVE_JNI_DIR}/detect_ndkrel.py $(NDK_ROOT)/source.properties 17)
IS_ANDROID_21 := $(shell python ${LOVE_JNI_DIR}/detect_androidapi.py $(TARGET_PLATFORM) 21)
HAS_LOVE := $(shell python ${LOVE_JNI_DIR}/detect_love.py ${LOVE_JNI_DIR})

ifeq ($(OS),Windows_NT)
SHELL_EXECUTOR := powershell -executionpolicy unrestricted
SCRIPT_EXTENSION := ps1
else
SHELL_EXECUTOR := sh
SCRIPT_EXTENSION := sh
endif

IS_NDK_R17 := $(shell ${SHELL_EXECUTOR} ${LOVE_JNI_DIR}/detect_ndkrel.${SCRIPT_EXTENSION} $(NDK_ROOT)/source.properties 17)
IS_ANDROID_21 := $(shell ${SHELL_EXECUTOR} ${LOVE_JNI_DIR}/detect_androidapi.${SCRIPT_EXTENSION} $(TARGET_PLATFORM) 21)
HAS_LOVE := $(shell ${SHELL_EXECUTOR} ${LOVE_JNI_DIR}/detect_love.${SCRIPT_EXTENSION} ${LOVE_JNI_DIR})

ifneq (${HAS_LOVE},yes)
$(error Missing LOVE. Make sure to initialize the submodule correctly!)
Expand Down
13 changes: 13 additions & 0 deletions love/src/jni/detect_androidapi.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
if ($args.Length -gt 1) {
# $args[0] = android-%d
# $args[1] = %d
$found = $args[0] -match 'android-(\d+)'

if ($found -and $matches[1] -ge $args[1]) {
Write-Output "yes"
} else {
Write-Output "no"
}
} else {
Write-Output "unknown"
}
17 changes: 0 additions & 17 deletions love/src/jni/detect_androidapi.py

This file was deleted.

15 changes: 15 additions & 0 deletions love/src/jni/detect_androidapi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

if [ $# -gt 1 ]; then
# $1 = android-%d
# $2 = %d
version=$(echo $1 | grep -o 'android-[0-9]*' | grep -o '[0-9]*')

if [ $version -ge $2 ]; then
echo "yes"
else
echo "no"
fi
else
echo "unknown"
fi
7 changes: 7 additions & 0 deletions love/src/jni/detect_love.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
$path = $args[0]

if (Test-Path -Path "$path/love/Android.mk") {
Write-Output "yes"
} else {
Write-Output "no"
}
14 changes: 0 additions & 14 deletions love/src/jni/detect_love.py

This file was deleted.

7 changes: 7 additions & 0 deletions love/src/jni/detect_love.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

if [ -d "$1/love" ] && [ -f "$1/love/Android.mk" ]; then
echo "yes"
else
echo "no"
fi
15 changes: 15 additions & 0 deletions love/src/jni/detect_ndkrel.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# $args[0] = source.properties
# $args[1] = NDK version to be checked

if ($args.Count -ne 2) {
Write-Output "unknown"
exit 1
}

$ndkVersion = (Select-String -Pattern "Pkg.Revision = (\d+)" -Path $args[0] | ForEach-Object { $_.Matches[0].Groups[1].Value })

if ($ndkVersion -ge $args[1]) {
Write-Output "yes"
} else {
Write-Output "no"
}
20 changes: 0 additions & 20 deletions love/src/jni/detect_ndkrel.py

This file was deleted.

15 changes: 15 additions & 0 deletions love/src/jni/detect_ndkrel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# $1 = source.properties
# $2 = NDK version to be checked

if [ $# -ne 2 ]; then
echo "unknown"
exit 1
fi

ndkVersion=$(grep -Po 'Pkg.Revision = (\d+)' "$1" | grep -Po '\d+')

if [ "$ndkVersion" -ge "$2" ]; then
echo "yes"
else
echo "no"
fi

0 comments on commit abd98a1

Please sign in to comment.