From 152ec3e0a33816a433867a0c0ba8c6c9fc20f5a8 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Tue, 6 Jun 2023 21:05:32 +0200 Subject: fix nix androidsdk fixup for consistency between gitlab-ci and local --- nix/android-shell-shellHook.py | 22 ---------------------- nix/androidsdk-fixup.py | 24 ++++++++++++++++++++++++ nix/androidsdk.nix | 29 +++++++++++++++++++++++++++++ shell.nix | 13 +++---------- 4 files changed, 56 insertions(+), 32 deletions(-) delete mode 100755 nix/android-shell-shellHook.py create mode 100755 nix/androidsdk-fixup.py create mode 100644 nix/androidsdk.nix diff --git a/nix/android-shell-shellHook.py b/nix/android-shell-shellHook.py deleted file mode 100755 index 53a542b..0000000 --- a/nix/android-shell-shellHook.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python - -import sys, os, shutil - -BUILD_TOOLS_PATH = sys.argv[1] -PLATFORMS_PATH = sys.argv[2] -BUILD_TOOLS = [os.path.join(BUILD_TOOLS_PATH, filename) for filename in os.listdir(BUILD_TOOLS_PATH)] -PLATFORMS = [os.path.join(PLATFORMS_PATH, filename) for filename in os.listdir(PLATFORMS_PATH)] - -for build_tool in BUILD_TOOLS: - if os.path.islink(build_tool): - print(f'build-tool "{os.path.basename(build_tool)}" is a symlink. Copying...') - link_src = os.readlink(build_tool) - os.unlink(build_tool) - shutil.copytree(link_src, build_tool) - -for platform in PLATFORMS: - if os.path.islink(platform): - print(f'platform "{os.path.basename(platform)}" is a symlink. Copying...') - link_src = os.readlink(platform) - os.unlink(platform) - shutil.copytree(link_src, platform) diff --git a/nix/androidsdk-fixup.py b/nix/androidsdk-fixup.py new file mode 100755 index 0000000..ab419e6 --- /dev/null +++ b/nix/androidsdk-fixup.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python + +import sys, os, shutil + +ANDROIDSDK_PATH = sys.argv[1] +BUILD_TOOLS_PATH = f'{ANDROIDSDK_PATH}/build-tools' +PLATFORMS_PATH = f'{ANDROIDSDK_PATH}/platforms' + +BUILD_TOOLS = [os.path.join(BUILD_TOOLS_PATH, filename) for filename in os.listdir(BUILD_TOOLS_PATH)] +PLATFORMS = [os.path.join(PLATFORMS_PATH, filename) for filename in os.listdir(PLATFORMS_PATH)] + +for build_tool in BUILD_TOOLS: + if os.path.islink(build_tool): + print(f'build-tool "{os.path.basename(build_tool)}" is a symlink. Copying...') + link_src = os.readlink(build_tool) + os.unlink(build_tool) + shutil.copytree(link_src, build_tool) + +for platform in PLATFORMS: + if os.path.islink(platform): + print(f'platform "{os.path.basename(platform)}" is a symlink. Copying...') + link_src = os.readlink(platform) + os.unlink(platform) + shutil.copytree(link_src, platform) diff --git a/nix/androidsdk.nix b/nix/androidsdk.nix new file mode 100644 index 0000000..cf1ea04 --- /dev/null +++ b/nix/androidsdk.nix @@ -0,0 +1,29 @@ +with (import {}); +let + android-composition = import ./android-composition.nix; +in +stdenv.mkDerivation { + name = "androidsdk"; + + buildInputs = [ + python3Full + ]; + + src = "${android-composition.androidsdk}"; + + dontUnpack = true; + + buildPhase = '' + buildDir=$PWD/android-composition + mkdir $buildDir + + cp -r $src/* $buildDir + + chmod -R +w "$buildDir/libexec/android-sdk" + python ${./androidsdk-fixup.py} "$buildDir/libexec/android-sdk" + ''; + + installPhase = '' + cp -r $buildDir $out + ''; +} diff --git a/shell.nix b/shell.nix index d457038..412b6ac 100644 --- a/shell.nix +++ b/shell.nix @@ -1,26 +1,19 @@ with (import {}); let jdk = jdk11; - android-composition = import ./nix/android-composition.nix; + androidsdk = import ./nix/androidsdk.nix; in mkShell rec { name = "android-shell"; buildInputs = [ - python3Full gnumake jdk - android-composition.androidsdk + androidsdk bazel_4 ]; JAVA_HOME = jdk.home; - ANDROID_SDK_ROOT = "${android-composition.androidsdk}/libexec/android-sdk"; - ANDROID_NDK_ROOT = "${ANDROID_SDK_ROOT}/ndk-bundle"; + ANDROID_SDK_ROOT = "${androidsdk}/libexec/android-sdk"; ANDROID_HOME = "${ANDROID_SDK_ROOT}"; - - shellHook = '' - # TODO: replace with nix builtins - python ./nix/android-shell-shellHook.py ${ANDROID_HOME}/build-tools ${ANDROID_HOME}/platforms - ''; } -- cgit v1.2.3