Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 11 additions & 53 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -715,9 +715,6 @@ jobs:
steps:
- checkout
- install-rustup
- run:
name: Run uniffi-bindgen
command: make bindgen-python
- run:
name: Python lints
command: make lint-python
Expand Down Expand Up @@ -885,7 +882,7 @@ jobs:
# Upload to GitHub
./ghr -replace ${CIRCLE_TAG} target/wheels

pypi-linux-aarch64-release:
pypi-linux-additional-releases:
docker:
- image: cimg/python:3.13
steps:
Expand All @@ -898,19 +895,21 @@ jobs:
make setup-python
.venv3.13/bin/pip install ziglang
- run:
name: Install aarch64-linux target
name: Install additional targets
command: |
rustup target add aarch64-unknown-linux-gnu
rustup target add aarch64-pc-windows-gnullvm
- run:
name: Build Python package
name: Build Python packages
command: |
# We need a binary with debug symbols, so uniffi-bindgen can extract data
cargo build -p glean-bundle

. .venv3.13/bin/activate
make build-python-wheel GLEAN_BUILD_TARGET=aarch64-unknown-linux-gnu GLEAN_BUILD_EXTRA="--zig"

TARGETS="aarch64-unknown-linux-gnu aarch64-pc-windows-gnullvm"
for target in $TARGETS; do
make build-python-wheel GLEAN_BUILD_TARGET="$target" GLEAN_BUILD_EXTRA="--zig"
done
- run:
name: Upload aarch64-linux wheel
name: Upload wheels
command: |
# Requires that the TWINE_USERNAME and TWINE_PASSWORD environment
# variables are configured in CircleCI's environment variables.
Expand Down Expand Up @@ -979,43 +978,6 @@ jobs:
# Upload to GitHub
./ghr -replace ${CIRCLE_TAG} target/wheels

pypi-windows-aarch64-release:
docker:
- image: cimg/python:3.13
steps:
- install-rustup
- setup-rust-toolchain
- checkout
- run:
name: Setup Python env
command: |
make setup-python
.venv3.13/bin/pip install ziglang
- run:
name: Install aarch64-windows target
command: |
rustup target add aarch64-pc-windows-gnullvm
- run:
name: Build Python package
command: |
# We need a binary with debug symbols, so uniffi-bindgen can extract data
cargo build -p glean-bundle

. .venv3.13/bin/activate
make build-python-wheel GLEAN_BUILD_TARGET=aarch64-pc-windows-gnullvm GLEAN_BUILD_EXTRA="--zig"
- run:
name: Upload aarch64-windows wheel
command: |
# Requires that the TWINE_USERNAME and TWINE_PASSWORD environment
# variables are configured in CircleCI's environment variables.
make upload-wheels
- install-ghr-linux
- run:
name: Publish to GitHub
command: |
# Upload to GitHub
./ghr -replace ${CIRCLE_TAG} target/wheels

###########################################################################
# Docs

Expand Down Expand Up @@ -1215,7 +1177,7 @@ workflows:
requires:
- Python 3_9 tests
filters: *release-filters
- pypi-linux-aarch64-release:
- pypi-linux-additional-releases:
requires:
- Python 3_9 tests
filters: *release-filters
Expand All @@ -1227,10 +1189,6 @@ workflows:
requires:
- Python 3_9 tests
filters: *release-filters
- pypi-windows-aarch64-release:
requires:
- Python 3_9 tests
filters: *release-filters
- iOS build and test:
filters: *release-filters
- iOS Framework release:
Expand Down
3 changes: 2 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ default-members = [
]

[profile.release]
opt-level = "s"
debug = false
opt-level = 2
debug = "line-tables-only"
split-debuginfo = "unpacked"
lto = true

[profile.profiling]
Expand Down
13 changes: 2 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,7 @@ build-python-sdist: setup-python ## Build a Python source distribution
build-xcframework:
./bin/build-xcframework.sh

bindgen-python: glean-core/python/glean/_uniffi/glean.py glean-core/python/glean/_uniffi/__init__.py # Generate the uniffi wrapper code manually

glean-core/python/glean/_uniffi/glean.py: glean-core/src/glean.udl
cargo build -p glean-bundle
cargo uniffi-bindgen generate $< --language python --out-dir $(@D)

glean-core/python/glean/_uniffi/__init__.py:
echo 'from .glean import * # NOQA' > $@

.PHONY: build build-rust build-kotlin build-swift build-apk build-python build-python-wheel build-python-sdist bindgen-python build-xcframework glean-core/python/glean/_uniffi/__init__.py
.PHONY: build build-rust build-kotlin build-swift build-apk build-python build-python-wheel build-python-sdist build-xcframework glean-core/python/glean/_uniffi/__init__.py

# All tests

Expand Down Expand Up @@ -125,7 +116,7 @@ shellcheck: ## Run shellcheck against important shell scripts
shellcheck glean-core/ios/sdk_generator.sh
shellcheck bin/check-artifact.sh

lint-python: setup-python ## Run ruff and mypy to lint Python code
lint-python: build-python ## Run ruff and mypy to lint Python code
$(GLEAN_PYENV)/bin/python3 -m ruff format --diff glean-core/python/glean glean-core/python/tests
$(GLEAN_PYENV)/bin/python3 -m ruff check glean-core/python/glean glean-core/python/tests
$(GLEAN_PYENV)/bin/python3 -m mypy glean-core/python/glean
Expand Down
58 changes: 58 additions & 0 deletions build-scripts/xc-bindgen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash

# what to pass to cargo build -p, e.g. glean_ffi
FFI_TARGET=$1
# path to Glean root
GLEAN_ROOT=$2
# buildvariant from our xcconfigs
BUILDVARIANT=$3

RELMODE=debug
if [[ "$BUILDVARIANT" != "debug" ]]; then
RELMODE=release
fi

set -euvx

IS_SIMULATOR=0
if [ "${LLVM_TARGET_TRIPLE_SUFFIX-}" = "-simulator" ]; then
IS_SIMULATOR=1
fi

TARGET=

for arch in $ARCHS; do
case "$arch" in
x86_64)
# Intel iOS simulator
TARGET="x86_64-apple-ios"
break
;;

arm64)
if [ $IS_SIMULATOR -eq 0 ]; then
# Hardware iOS targets
TARGET=aarch64-apple-ios
else
# M1 iOS simulator
TARGET=aarch64-apple-ios-sim
fi
break
;;
esac
done

if [[ -z "$TARGET" ]]; then
echo "Missing TARGET. No suitable arch in ${ARCHS}"
exit 2
fi

LIBRARY_PATH="${GLEAN_ROOT}/target/${TARGET}/${RELMODE}/lib${FFI_TARGET}.a"

bash "${GLEAN_ROOT}/build-scripts/xc-cargo.sh" cargo run --package uniffi-bindgen -- \
generate \
--language swift \
--config "${GLEAN_ROOT}/../bundle/uniffi.toml" \
--out-dir "${GLEAN_ROOT}/glean-core/ios/Glean/Generated/uniffi" \
--library "$LIBRARY_PATH" \
--no-format
2 changes: 1 addition & 1 deletion build-scripts/xc-universal-binary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fi

# what to pass to cargo build -p, e.g. glean_ffi
FFI_TARGET=$1
# path to app services root
# path to Glean root
GLEAN_ROOT=$2
# buildvariant from our xcconfigs
BUILDVARIANT=$3
Expand Down
15 changes: 13 additions & 2 deletions glean-core/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,25 @@ apply from: "$rootDir/publish.gradle"
ext.configurePublish()

def generateUniffiBindings = tasks.register("generateUniffiBindings") {
def udlFilePath = "../src/glean.udl"
def gleanNative = configurations.getByName("gleanNative")
doFirst {
def libraryPath = gleanNative.asFileTree.matching {
include "${nativeRustTarget}/libxul.*"
}.singleFile

if (libraryPath == null) {
throw new GradleException("libglean_ffi dynamic library path not found")
}

exec {
workingDir project.rootDir
commandLine 'cargo', 'uniffi-bindgen', 'generate', '--no-format', "${project.projectDir}/${udlFilePath}", '--language', 'kotlin', '--out-dir', UNIFFI_OUT_DIR.get()
commandLine 'cargo', 'uniffi-bindgen', 'generate', '--no-format', '--library', libraryPath, '--language', 'kotlin', '--out-dir', UNIFFI_OUT_DIR.get()
}
}

outputs.dir UNIFFI_OUT_DIR
// Re-generate if native changes
inputs.files gleanNative
// Re-generate if the interface definition changes.
inputs.file "${project.projectDir}/../src/glean.udl"
// Re-generate if the uniffi config changes.
Expand Down
3 changes: 2 additions & 1 deletion glean-core/ios/Glean.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@
);
inputPaths = (
"$(SRCROOT)/../src/glean.udl",
"$(SRCROOT)/../../build-scripts/xc-cargo.sh",
);
name = "Run UniFFI bindgen";
outputFileListPaths = (
Expand All @@ -598,7 +599,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if [ \"$ACTION\" = \"indexbuild\" ]; then\n echo \"Skipping code generation in 'indexbuild' build. See https://bugzilla.mozilla.org/show_bug.cgi?id=1744504 for more info.\"\n exit 0\nfi\nbash $PWD/../../build-scripts/xc-cargo.sh cargo run --package uniffi-bindgen -- generate $INPUT_FILE_PATH --language swift --out-dir $SRCROOT/Glean/Generated/uniffi --no-format $SCRIPT_INPUT_FILE_0\n";
shellScript = "if [ \"$ACTION\" = \"indexbuild\" ]; then\n echo \"Skipping code generation in 'indexbuild' build. See https://bugzilla.mozilla.org/show_bug.cgi?id=1744504 for more info.\"\n exit 0\nfi\nbash $PWD/../../build-scripts/xc-bindgen.sh glean_ffi $PWD/../.. $buildvariant\n";
};
/* End PBXShellScriptBuildPhase section */

Expand Down
2 changes: 1 addition & 1 deletion glean-core/python/requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ semver==2.13.0
setuptools-git==1.2
twine==6.0.1
wheel==0.45.1
maturin==1.9.6
maturin==1.10.1
patchelf>=0.17; sys_platform == "linux"
4 changes: 2 additions & 2 deletions tools/embedded-uniffi-bindgen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ publish = false
[dependencies]
anyhow = "1"
camino = "1.1.1"
uniffi = { version = "0.29.3", default-features = false, features = ["bindgen"] }
glob = "0.3.2"
uniffi = { version = "0.29.3", default-features = false, features = ["bindgen", "cargo-metadata"] }
cargo_metadata = { version = "0.19" }

[lib]
test = false
Expand Down
Loading