diff --git a/.gitignore b/.gitignore index 1fbcf5c..0ac2ce4 100644 --- a/.gitignore +++ b/.gitignore @@ -10,8 +10,9 @@ android/keystore.properties .externalNativeBuild .cxx *.so - -# Added by cargo /target /.cargo/ /app/src/main/jniLibs +/macos/Grim.app/Contents/MacOS/grim-bin +/macos/cert.pem +.intentionally-empty-file.o \ No newline at end of file diff --git a/README.md b/README.md index 080de22..a0049f5 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Install Android SDK / NDK / Platform Tools for your OS according to this [FAQ](h #### Build the project Run Android emulator or connect a real device. Command `adb devices` should show at least one device. -In the root of the repo run `./build_run_android.sh release arch`, where is `arch` is `v7` or `v8` based on device CPU architecture. +In the root of the repo run `./scripts/build_run_android.sh debug|release v7|v8`, where is `v7`, `v8` - device CPU architecture. ## License diff --git a/build_run_linux.sh b/build_run_linux.sh deleted file mode 100755 index 2e5793c..0000000 --- a/build_run_linux.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -case $1 in - debug|release) - ;; - *) - echo "Usage: build_and_run.sh [type] where is type is 'debug' or 'release'" >&2 - exit 1 -esac - -type=$1 -[[ ${type} == "release" ]] && release_param+=(--release) -cargo build ${release_param[@]} --target x86_64-unknown-linux-gnu - -if [ $? -eq 0 ] -then - ./target/x86_64-unknown-linux-gnu/${type}/grim -fi \ No newline at end of file diff --git a/img/128x128.png b/img/128x128.png deleted file mode 100644 index e7e18f9..0000000 Binary files a/img/128x128.png and /dev/null differ diff --git a/img/128x128@2.png b/img/128x128@2.png deleted file mode 100644 index fa97b75..0000000 Binary files a/img/128x128@2.png and /dev/null differ diff --git a/img/icon.png b/img/icon.png index 8bdebeb..87f8a7b 100644 Binary files a/img/icon.png and b/img/icon.png differ diff --git a/macos/Grim.app/Contents/Info.plist b/macos/Grim.app/Contents/Info.plist new file mode 100644 index 0000000..4f2065c --- /dev/null +++ b/macos/Grim.app/Contents/Info.plist @@ -0,0 +1,49 @@ + + + + + CFBundleDevelopmentRegion + en + + CFBundleDisplayName + Grim + + CFBundleExecutable + grim-bin + + CFBundleIconFile + AppIcon + + CFBundleIconName + AppIcon + + CFBundleIdentifier + mw.grin.macos + + CFBundleInfoDictionaryVersion + 6.0 + + CFBundleName + Grim + + CFBundlePackageType + APPL + + CFBundleShortVersionString + 0.1.0 + + CFBundleSupportedPlatforms + + MacOSX + + + CFBundleVersion + 1 + + LSApplicationCategoryType + public.app-category.finance + + NSHumanReadableCopyright + 2024 + + \ No newline at end of file diff --git a/macos/Grim.app/Contents/Resources/AppIcon.icns b/macos/Grim.app/Contents/Resources/AppIcon.icns new file mode 100644 index 0000000..edd9b8d Binary files /dev/null and b/macos/Grim.app/Contents/Resources/AppIcon.icns differ diff --git a/macos/Grim.app/Contents/_CodeSignature/CodeResources b/macos/Grim.app/Contents/_CodeSignature/CodeResources new file mode 100644 index 0000000..09a207a --- /dev/null +++ b/macos/Grim.app/Contents/_CodeSignature/CodeResources @@ -0,0 +1,128 @@ + + + + + files + + Resources/AppIcon.icns + + F0XBdu5xI+eXrj78HQf2Qr9SKio= + + + files2 + + Resources/AppIcon.icns + + hash2 + + ZjAn1LaNzSeTeUtKbWKWE7W2ELzhYyrHjKYOXUkQvcI= + + + + rules + + ^Resources/ + + ^Resources/.*\.lproj/ + + optional + + weight + 1000 + + ^Resources/.*\.lproj/locversion.plist$ + + omit + + weight + 1100 + + ^Resources/Base\.lproj/ + + weight + 1010 + + ^version.plist$ + + + rules2 + + .*\.dSYM($|/) + + weight + 11 + + ^(.*/)?\.DS_Store$ + + omit + + weight + 2000 + + ^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/ + + nested + + weight + 10 + + ^.* + + ^Info\.plist$ + + omit + + weight + 20 + + ^PkgInfo$ + + omit + + weight + 20 + + ^Resources/ + + weight + 20 + + ^Resources/.*\.lproj/ + + optional + + weight + 1000 + + ^Resources/.*\.lproj/locversion.plist$ + + omit + + weight + 1100 + + ^Resources/Base\.lproj/ + + weight + 1010 + + ^[^/]+$ + + nested + + weight + 10 + + ^embedded\.provisionprofile$ + + weight + 20 + + ^version\.plist$ + + weight + 20 + + + + diff --git a/scripts/build_run.sh b/scripts/build_run.sh new file mode 100755 index 0000000..e151ab2 --- /dev/null +++ b/scripts/build_run.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +case $1 in + debug|release) + ;; + *) + echo "Usage: build_run.sh [type] where is type is 'debug' or 'release'" >&2 + exit 1 +esac + +# Setup build directory +BASEDIR=$(cd $(dirname $0) && pwd) +cd ${BASEDIR} +cd .. + +# Build application +type=$1 +[[ ${type} == "release" ]] && release_param+=(--release) +cargo build ${release_param[@]} + +# Start application +if [ $? -eq 0 ] +then + ./target/${type}/grim +fi \ No newline at end of file diff --git a/build_run_android.sh b/scripts/build_run_android.sh similarity index 76% rename from build_run_android.sh rename to scripts/build_run_android.sh index 7742de3..b3bd17b 100755 --- a/build_run_android.sh +++ b/scripts/build_run_android.sh @@ -1,6 +1,6 @@ #!/bin/bash -usage="Usage: build_and_run.sh [type] [platform]\n - type: debug, release\n - platform: v7, v8" +usage="Usage: build_run_android.sh [type] [platform]\n - type: 'debug', 'release'\n - platform: 'v7', 'v8'" case $1 in debug|release) ;; @@ -17,6 +17,11 @@ case $2 in exit 1 esac +# Setup build directory +BASEDIR=$(cd $(dirname $0) && pwd) +cd ${BASEDIR} +cd .. + # Setup release argument type=$1 [[ ${type} == "release" ]] && release_param+=(--release) @@ -33,20 +38,21 @@ type=$1 [[ $2 == "v7" ]] && rustup target install armv7-linux-androideabi [[ $2 == "v8" ]] && rustup target install aarch64-linux-android +# Build native code export CPPFLAGS="-DMDB_USE_ROBUST=0" && export CFLAGS="-DMDB_USE_ROBUST=0" \ && cargo ndk -t ${arch} build ${release_param[@]} +# Build Android application and launch at all connected devices if [ $? -eq 0 ] then yes | mkdir -p android/app/src/main/jniLibs/${arch} && cp -f target/${platform}/${type}/libgrim.so android/app/src/main/jniLibs/${arch} cd android ./gradlew clean - #./gradlew assembleRelease +# ./gradlew assembleRelease ./gradlew build - # Install on several devices for SERIAL in $(adb devices | grep -v List | cut -f 1); do - #adb -s $SERIAL install app/build/outputs/apk/release/app-release.apk +# adb -s $SERIAL install app/build/outputs/apk/release/app-release.apk adb -s $SERIAL install app/build/outputs/apk/debug/app-debug.apk sleep 1s adb -s $SERIAL shell am start -n mw.gri.android/.MainActivity; diff --git a/scripts/release_macos.sh b/scripts/release_macos.sh new file mode 100755 index 0000000..0420860 --- /dev/null +++ b/scripts/release_macos.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +case $1 in + x86|arm) + ;; + *) + echo "Usage: release_macos.sh [platform]\n - platform: 'x86', 'arm'" >&2 + exit 1 +esac + +if [[ ! -v SDKROOT ]]; then + echo "MacOS SDKROOT is not set" + exit 1 +elif [[ -z "SDKROOT" ]]; then + echo "MacOS SDKROOT is set to the empty string" + exit 1 +else + echo "Use MacOS SDK: ${SDKROOT}" +fi + +# Setup build directory +BASEDIR=$(cd $(dirname $0) && pwd) +cd ${BASEDIR} +cd .. + +# Setup platform argument +[[ $1 == "x86" ]] && arch+=(x86_64-apple-darwin) +[[ $1 == "arm" ]] && arch+=(aarch64-apple-darwin) + +# Start release build with zig linker for cross-compilation +cargo install cargo-zigbuild +cargo zigbuild --release --target ${arch} +rm .intentionally-empty-file.o +yes | cp -rf target/${arch}/release/grim macos/Grim.app/Contents/MacOS/grim-bin + +### Sign .app before distribution: +### rcodesign generate-self-signed-certificate +### rcodesign sign --pem-file test.pem macos/Grim.app + +# Create release package +FILE_NAME=Grim-0.1.0-macos-$1.zip +zip ${FILE_NAME} target/${arch}/release/grim macos/Grim.app +mv -f ${FILE_NAME} target/${arch}/release