Merge pull request #201090 from wegank/android-tools-bump

This commit is contained in:
Sandro 2022-11-20 07:14:01 +01:00 committed by GitHub
commit 41035f2b30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 104 deletions

View file

@ -1,82 +0,0 @@
diff --git a/vendor/adb/client/usb_linux.cpp b/vendor/adb/client/usb_linux.cpp
index 25a50bd..0d09c47 100644
--- a/vendor/adb/client/usb_linux.cpp
+++ b/vendor/adb/client/usb_linux.cpp
@@ -59,8 +59,15 @@ using namespace std::literals;
#define DBGX(x...)
struct usb_handle {
+ usb_handle() : urb_in(0), urb_out(0) {
+ this->urb_in = new usbdevfs_urb;
+ this->urb_out = new usbdevfs_urb;
+ }
+
~usb_handle() {
if (fd != -1) unix_close(fd);
+ delete urb_in;
+ delete urb_out;
}
std::string path;
@@ -72,8 +79,8 @@ struct usb_handle {
unsigned zero_mask;
unsigned writeable = 1;
- usbdevfs_urb urb_in;
- usbdevfs_urb urb_out;
+ usbdevfs_urb *urb_in;
+ usbdevfs_urb *urb_out;
bool urb_in_busy = false;
bool urb_out_busy = false;
@@ -304,7 +311,7 @@ static int usb_bulk_write(usb_handle* h, const void* data, int len) {
std::unique_lock<std::mutex> lock(h->mutex);
D("++ usb_bulk_write ++");
- usbdevfs_urb* urb = &h->urb_out;
+ usbdevfs_urb* urb = h->urb_out;
memset(urb, 0, sizeof(*urb));
urb->type = USBDEVFS_URB_TYPE_BULK;
urb->endpoint = h->ep_out;
@@ -343,7 +350,7 @@ static int usb_bulk_read(usb_handle* h, void* data, int len) {
std::unique_lock<std::mutex> lock(h->mutex);
D("++ usb_bulk_read ++");
- usbdevfs_urb* urb = &h->urb_in;
+ usbdevfs_urb* urb = h->urb_in;
memset(urb, 0, sizeof(*urb));
urb->type = USBDEVFS_URB_TYPE_BULK;
urb->endpoint = h->ep_in;
@@ -388,7 +395,7 @@ static int usb_bulk_read(usb_handle* h, void* data, int len) {
}
D("[ urb @%p status = %d, actual = %d ]", out, out->status, out->actual_length);
- if (out == &h->urb_in) {
+ if (out == h->urb_in) {
D("[ reap urb - IN complete ]");
h->urb_in_busy = false;
if (urb->status != 0) {
@@ -397,7 +404,7 @@ static int usb_bulk_read(usb_handle* h, void* data, int len) {
}
return urb->actual_length;
}
- if (out == &h->urb_out) {
+ if (out == h->urb_out) {
D("[ reap urb - OUT compelete ]");
h->urb_out_busy = false;
h->cv.notify_all();
@@ -501,10 +508,10 @@ void usb_kick(usb_handle* h) {
** but this ensures that a reader blocked on REAPURB
** will get unblocked
*/
- ioctl(h->fd, USBDEVFS_DISCARDURB, &h->urb_in);
- ioctl(h->fd, USBDEVFS_DISCARDURB, &h->urb_out);
- h->urb_in.status = -ENODEV;
- h->urb_out.status = -ENODEV;
+ ioctl(h->fd, USBDEVFS_DISCARDURB, h->urb_in);
+ ioctl(h->fd, USBDEVFS_DISCARDURB, h->urb_out);
+ h->urb_in->status = -ENODEV;
+ h->urb_out->status = -ENODEV;
h->urb_in_busy = false;
h->urb_out_busy = false;
h->cv.notify_all();

View file

@ -1,5 +1,5 @@
{ lib, stdenv, fetchurl, fetchpatch { lib, stdenv, fetchurl, fetchpatch
, cmake, perl, go, python3 , cmake, pkg-config, perl, go, python3
, protobuf, zlib, gtest, brotli, lz4, zstd, libusb1, pcre2 , protobuf, zlib, gtest, brotli, lz4, zstd, libusb1, pcre2
}: }:
@ -9,41 +9,28 @@ in
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "android-tools"; pname = "android-tools";
version = "33.0.3"; version = "33.0.3p1";
src = fetchurl { src = fetchurl {
url = "https://github.com/nmeum/android-tools/releases/download/${version}/android-tools-${version}.tar.xz"; url = "https://github.com/nmeum/android-tools/releases/download/${version}/android-tools-${version}.tar.xz";
hash = "sha256-jOF02reB1d69Ke0PllciMfd3vuGbjvPBZ+M9PqdnC8U="; hash = "sha256-viBHzyVgUWdK9a60u/7SdpiVEvgNEZHihkyRkGH5Ydg=";
}; };
patches = [ patches = [
./android-tools-kernel-headers-6.0.diff (fetchpatch {
name = "add-macos-platform.patch";
url = "https://github.com/nmeum/android-tools/commit/a1ab35b31525966e0f0770047cd82accb36d025b.patch";
hash = "sha256-6O3ekDf0qPdzcfINFF8Ae4XOYgnQWTBhvu9SCFSHkXY=";
})
]; ];
postPatch = lib.optionalString stdenv.isDarwin '' nativeBuildInputs = [ cmake pkg-config perl go ];
sed -i 's/usb_linux/usb_osx/g' vendor/CMakeLists.{adb,fastboot}.txt
sed -i 's/libselinux libsepol/ /g;s#selinux/libselinux/include##g' vendor/CMakeLists.{fastboot,mke2fs}.txt
sed -z -i 's/add_library(libselinux.*selinux\/libsepol\/include)//g' vendor/CMakeLists.fastboot.txt
sed -i 's/e2fsdroid//g' vendor/CMakeLists.txt
sed -z -i 's/add_executable(e2fsdroid.*e2fsprogs\/misc)//g' vendor/CMakeLists.mke2fs.txt
'';
nativeBuildInputs = [ cmake perl go ];
buildInputs = [ protobuf zlib gtest brotli lz4 zstd libusb1 pcre2 ]; buildInputs = [ protobuf zlib gtest brotli lz4 zstd libusb1 pcre2 ];
propagatedBuildInputs = [ pythonEnv ]; propagatedBuildInputs = [ pythonEnv ];
# Don't try to fetch any Go modules via the network: # Don't try to fetch any Go modules via the network:
GOFLAGS = [ "-mod=vendor" ]; GOFLAGS = [ "-mod=vendor" ];
NIX_CFLAGS_COMPILE = lib.optionals stdenv.isDarwin [
"-D_DARWIN_C_SOURCE"
];
NIX_LDFLAGS = lib.optionals stdenv.isDarwin [
"-framework CoreFoundation"
"-framework IOKit"
];
preConfigure = '' preConfigure = ''
export GOCACHE=$TMPDIR/go-cache export GOCACHE=$TMPDIR/go-cache
''; '';