Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matter/Chip libraries in Maven #211

Open
jonsmirl opened this issue Apr 16, 2024 · 1 comment
Open

Matter/Chip libraries in Maven #211

jonsmirl opened this issue Apr 16, 2024 · 1 comment

Comments

@jonsmirl
Copy link

https://central.sonatype.com/artifact/com.google.matter/matter-android-demo-sdk/versions

Is there a script to make this? I would find it more useful to have multiple versions of the artifact: Matter 1.0, Matter 1.1, Matter 1.2 and Matter Head. Can you see if the Google Matter developers will put up official build releases in Maven?

@aBozowski
Copy link
Collaborator

aBozowski commented Apr 17, 2024

Hi Jon,

Thanks for your interest and engagement with the sample!

We're not planning to update matter-android-demo-sdk unless updates to the sample app require us to use a new SDK version. This artifact primarily exists for convenience reasons (as compared to hosting the blobs in the GH source tree).

We don’t want to incorporate the build process into the sample offering because supporting potential SDK build issues in different user environments is out of scope for this project.

Here is one possible strategy to build new library versions in case it's helpful to you; you might incorporate a similar script into your project’s build process. Note the below was executed with 01facfdc41b61779387f904325a5101dea871fb6 (CHIP HEAD at time of writing), but you may need subtle changes in earlier versions of the SDK.

Edit these to suit your environment

# Input
chipvers=<Desired SDK hash>
destdir=<The /libs directory of your library in you android app project>

Find a build container

git clone https://github.com/project-chip/connectedhomeip.git
cd connectedhomeip
git checkout $chipvers
buildimage=$(cat .github/workflows/full-android.yaml | grep chip-build-android | head -n 1 | awk '{print $2}')
echo "Using $buildimage"

# Run the build container
docker run -it --rm \
  --mount source=$(pwd),target=/workspace,type=bind \
  --workdir="/workspace" \
  $buildimage /bin/bash

Within the container:

# Execute build
chown -R $(whoami) /workspace
git submodule update -f --init --recursive
source ./scripts/bootstrap.sh
./scripts/build/build_examples.py \
  --target android-arm-chip-tool \
  --target android-arm64-chip-tool \
  --target android-x86-chip-tool \
  --target android-x64-chip-tool \
  build
# Strip for size
ndkpath="$ANDROID_HOME/.."
ndktgt=$(ls -la $ndkpath | awk '{print $NF}' | sort -r | grep ndk | head -n 1)
ndkfq="$ndkpath/$ndktgt/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip"
builddir="/workspace/examples/android/CHIPTool/app/libs/"
echo "Using ndk at $ndkfq to strip .so"
find $builddir -name "*.so" | xargs $ndkfq

Exit the container and copy libs to project tree

srcdir="connectedhomeip/examples/android/CHIPTool/app/libs/"
cp -R $srcdir $destdir

Then in your android lib’s Gradle config, you can simply reference the blobs like this

  sourceSets {
        main {
            jniLibs.srcDirs = ['libs/jniLibs']
        }
    }

The topic of an official release exceeds the scope of this sample app project, but we will work to ensure your feedback is noted where relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants