Merge "Begin moving code from adb to libadb."
This commit is contained in:
commit
64a5ff963c
7 changed files with 84 additions and 50 deletions
|
|
@ -5,6 +5,35 @@
|
||||||
|
|
||||||
LOCAL_PATH:= $(call my-dir)
|
LOCAL_PATH:= $(call my-dir)
|
||||||
|
|
||||||
|
# libadb
|
||||||
|
# =========================================================
|
||||||
|
|
||||||
|
# Much of adb is duplicated in bootable/recovery/minadb and fastboot. Changes
|
||||||
|
# made to adb rarely get ported to the other two, so the trees have diverged a
|
||||||
|
# bit. We'd like to stop this because it is a maintenance nightmare, but the
|
||||||
|
# divergence makes this difficult to do all at once. For now, we will start
|
||||||
|
# small by moving common files into a static library. Hopefully some day we can
|
||||||
|
# get enough of adb in here that we no longer need minadb. https://b/17626262
|
||||||
|
LIBADB_SRC_FILES :=
|
||||||
|
LIBADB_C_FLAGS := -Wall -Werror -D_XOPEN_SOURCE -D_GNU_SOURCE
|
||||||
|
|
||||||
|
include $(CLEAR_VARS)
|
||||||
|
LOCAL_MODULE := libadb
|
||||||
|
LOCAL_CFLAGS := $(LIBADB_CFLAGS) -DADB_HOST=0
|
||||||
|
LOCAL_SRC_FILES := $(LIBADB_SRC_FILES) fdevent.cpp
|
||||||
|
include $(BUILD_STATIC_LIBRARY)
|
||||||
|
|
||||||
|
include $(CLEAR_VARS)
|
||||||
|
LOCAL_MODULE := libadb
|
||||||
|
LOCAL_CFLAGS := $(LIBADB_CFLAGS) -DADB_HOST=1
|
||||||
|
LOCAL_SRC_FILES := $(LIBADB_SRC_FILES)
|
||||||
|
ifeq ($(HOST_OS),windows)
|
||||||
|
LOCAL_SRC_FILES += sysdeps_wind32.c
|
||||||
|
else
|
||||||
|
LOCAL_SRC_FILES += fdevent.cpp
|
||||||
|
endif
|
||||||
|
include $(BUILD_HOST_STATIC_LIBRARY)
|
||||||
|
|
||||||
# adb host tool
|
# adb host tool
|
||||||
# =========================================================
|
# =========================================================
|
||||||
include $(CLEAR_VARS)
|
include $(CLEAR_VARS)
|
||||||
|
|
@ -37,10 +66,6 @@ ifeq ($(HOST_OS),windows)
|
||||||
USB_SRCS := usb_windows.c
|
USB_SRCS := usb_windows.c
|
||||||
EXTRA_SRCS := get_my_path_windows.c
|
EXTRA_SRCS := get_my_path_windows.c
|
||||||
EXTRA_STATIC_LIBS := AdbWinApi
|
EXTRA_STATIC_LIBS := AdbWinApi
|
||||||
ifneq ($(strip $(USE_CYGWIN)),)
|
|
||||||
# Pure cygwin case
|
|
||||||
LOCAL_LDLIBS += -lpthread -lgdi32
|
|
||||||
endif
|
|
||||||
ifneq ($(strip $(USE_MINGW)),)
|
ifneq ($(strip $(USE_MINGW)),)
|
||||||
# MinGW under Linux case
|
# MinGW under Linux case
|
||||||
LOCAL_LDLIBS += -lws2_32 -lgdi32
|
LOCAL_LDLIBS += -lws2_32 -lgdi32
|
||||||
|
|
@ -66,8 +91,6 @@ LOCAL_SRC_FILES := \
|
||||||
|
|
||||||
ifneq ($(USE_SYSDEPS_WIN32),)
|
ifneq ($(USE_SYSDEPS_WIN32),)
|
||||||
LOCAL_SRC_FILES += sysdeps_win32.c
|
LOCAL_SRC_FILES += sysdeps_win32.c
|
||||||
else
|
|
||||||
LOCAL_SRC_FILES += fdevent.c
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
LOCAL_CFLAGS += -O2 -g -DADB_HOST=1 -Wall -Wno-unused-parameter -Werror
|
LOCAL_CFLAGS += -O2 -g -DADB_HOST=1 -Wall -Wno-unused-parameter -Werror
|
||||||
|
|
@ -75,7 +98,13 @@ LOCAL_CFLAGS += -D_XOPEN_SOURCE -D_GNU_SOURCE
|
||||||
LOCAL_MODULE := adb
|
LOCAL_MODULE := adb
|
||||||
LOCAL_MODULE_TAGS := debug
|
LOCAL_MODULE_TAGS := debug
|
||||||
|
|
||||||
LOCAL_STATIC_LIBRARIES := libzipfile libz libcrypto_static $(EXTRA_STATIC_LIBS)
|
LOCAL_STATIC_LIBRARIES := \
|
||||||
|
libadb \
|
||||||
|
libzipfile \
|
||||||
|
libz \
|
||||||
|
libcrypto_static \
|
||||||
|
$(EXTRA_STATIC_LIBS) \
|
||||||
|
|
||||||
ifeq ($(USE_SYSDEPS_WIN32),)
|
ifeq ($(USE_SYSDEPS_WIN32),)
|
||||||
LOCAL_STATIC_LIBRARIES += libcutils
|
LOCAL_STATIC_LIBRARIES += libcutils
|
||||||
endif
|
endif
|
||||||
|
|
@ -99,7 +128,6 @@ include $(CLEAR_VARS)
|
||||||
|
|
||||||
LOCAL_SRC_FILES := \
|
LOCAL_SRC_FILES := \
|
||||||
adb.c \
|
adb.c \
|
||||||
fdevent.c \
|
|
||||||
transport.c \
|
transport.c \
|
||||||
transport_local.c \
|
transport_local.c \
|
||||||
transport_usb.c \
|
transport_usb.c \
|
||||||
|
|
@ -134,15 +162,14 @@ LOCAL_MODULE := adbd
|
||||||
LOCAL_FORCE_STATIC_EXECUTABLE := true
|
LOCAL_FORCE_STATIC_EXECUTABLE := true
|
||||||
LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT_SBIN)
|
LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT_SBIN)
|
||||||
LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_SBIN_UNSTRIPPED)
|
LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_SBIN_UNSTRIPPED)
|
||||||
LOCAL_C_INCLUDES += system/extras/ext4_utils system/core/fs_mgr/include
|
|
||||||
|
|
||||||
LOCAL_STATIC_LIBRARIES := liblog \
|
LOCAL_STATIC_LIBRARIES := \
|
||||||
libfs_mgr \
|
libadb \
|
||||||
libcutils \
|
liblog \
|
||||||
libc \
|
libcutils \
|
||||||
libmincrypt \
|
libc \
|
||||||
libselinux \
|
libmincrypt \
|
||||||
libext4_utils_static
|
libselinux \
|
||||||
|
|
||||||
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
|
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
|
||||||
|
|
||||||
|
|
@ -168,7 +195,6 @@ LOCAL_SRC_FILES := \
|
||||||
file_sync_client.c \
|
file_sync_client.c \
|
||||||
get_my_path_linux.c \
|
get_my_path_linux.c \
|
||||||
usb_linux.c \
|
usb_linux.c \
|
||||||
fdevent.c
|
|
||||||
|
|
||||||
LOCAL_CFLAGS := \
|
LOCAL_CFLAGS := \
|
||||||
-O2 \
|
-O2 \
|
||||||
|
|
@ -181,7 +207,7 @@ LOCAL_CFLAGS := \
|
||||||
|
|
||||||
LOCAL_MODULE := adb
|
LOCAL_MODULE := adb
|
||||||
|
|
||||||
LOCAL_STATIC_LIBRARIES := libzipfile libz libcutils liblog
|
LOCAL_STATIC_LIBRARIES := libadb libzipfile libz libcutils liblog
|
||||||
|
|
||||||
LOCAL_SHARED_LIBRARIES := libcrypto
|
LOCAL_SHARED_LIBRARIES := libcrypto
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
#include "adb_trace.h"
|
#include "adb_trace.h"
|
||||||
|
#include "fdevent.h"
|
||||||
#include "transport.h" /* readx(), writex() */
|
#include "transport.h" /* readx(), writex() */
|
||||||
|
|
||||||
#define MAX_PAYLOAD 4096
|
#define MAX_PAYLOAD 4096
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,12 @@ static void fdevent_subproc_event_func(int fd, unsigned events, void *userdata);
|
||||||
static fdevent list_pending = {
|
static fdevent list_pending = {
|
||||||
.next = &list_pending,
|
.next = &list_pending,
|
||||||
.prev = &list_pending,
|
.prev = &list_pending,
|
||||||
|
.fd = -1,
|
||||||
|
.force_eof = 0,
|
||||||
|
.state = 0,
|
||||||
|
.events = 0,
|
||||||
|
.func = nullptr,
|
||||||
|
.arg = nullptr,
|
||||||
};
|
};
|
||||||
|
|
||||||
static fdevent **fd_table = 0;
|
static fdevent **fd_table = 0;
|
||||||
|
|
@ -312,7 +318,7 @@ static int fdevent_fd_check(fd_set *fds)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
static inline void dump_all_fds(const char *extra_msg) {}
|
static inline void dump_all_fds(const char* /* extra_msg */) {}
|
||||||
#else
|
#else
|
||||||
static void dump_all_fds(const char *extra_msg)
|
static void dump_all_fds(const char *extra_msg)
|
||||||
{
|
{
|
||||||
|
|
@ -434,7 +440,8 @@ static void fdevent_register(fdevent *fde)
|
||||||
while(fd_table_max <= fde->fd) {
|
while(fd_table_max <= fde->fd) {
|
||||||
fd_table_max *= 2;
|
fd_table_max *= 2;
|
||||||
}
|
}
|
||||||
fd_table = realloc(fd_table, sizeof(fdevent*) * fd_table_max);
|
fd_table = reinterpret_cast<fdevent**>(
|
||||||
|
realloc(fd_table, sizeof(fdevent*) * fd_table_max));
|
||||||
if(fd_table == 0) {
|
if(fd_table == 0) {
|
||||||
FATAL("could not expand fd_table to %d entries\n", fd_table_max);
|
FATAL("could not expand fd_table to %d entries\n", fd_table_max);
|
||||||
}
|
}
|
||||||
|
|
@ -505,7 +512,8 @@ static void fdevent_call_fdfunc(fdevent* fde)
|
||||||
fde->func(fde->fd, events, fde->arg);
|
fde->func(fde->fd, events, fde->arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fdevent_subproc_event_func(int fd, unsigned ev, void *userdata)
|
static void fdevent_subproc_event_func(int fd, unsigned ev,
|
||||||
|
void* /* userdata */)
|
||||||
{
|
{
|
||||||
|
|
||||||
D("subproc handling on fd=%d ev=%04x\n", fd, ev);
|
D("subproc handling on fd=%d ev=%04x\n", fd, ev);
|
||||||
|
|
@ -19,6 +19,10 @@
|
||||||
|
|
||||||
#include <stdint.h> /* for int64_t */
|
#include <stdint.h> /* for int64_t */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
/* events that may be observed */
|
/* events that may be observed */
|
||||||
#define FDE_READ 0x0001
|
#define FDE_READ 0x0001
|
||||||
#define FDE_WRITE 0x0002
|
#define FDE_WRITE 0x0002
|
||||||
|
|
@ -64,20 +68,22 @@ void fdevent_set_timeout(fdevent *fde, int64_t timeout_ms);
|
||||||
*/
|
*/
|
||||||
void fdevent_loop();
|
void fdevent_loop();
|
||||||
|
|
||||||
struct fdevent
|
struct fdevent {
|
||||||
{
|
|
||||||
fdevent *next;
|
fdevent *next;
|
||||||
fdevent *prev;
|
fdevent *prev;
|
||||||
|
|
||||||
int fd;
|
int fd;
|
||||||
int force_eof;
|
int force_eof;
|
||||||
|
|
||||||
unsigned short state;
|
uint16_t state;
|
||||||
unsigned short events;
|
uint16_t events;
|
||||||
|
|
||||||
fd_func func;
|
fd_func func;
|
||||||
void *arg;
|
void *arg;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,6 @@
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
#include "cutils/properties.h"
|
#include "cutils/properties.h"
|
||||||
#include "ext4_sb.h"
|
|
||||||
#include <fs_mgr.h>
|
|
||||||
|
|
||||||
#define FSTAB_PREFIX "/fstab."
|
#define FSTAB_PREFIX "/fstab."
|
||||||
struct fstab *fstab;
|
struct fstab *fstab;
|
||||||
|
|
|
||||||
|
|
@ -26,16 +26,18 @@
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <direct.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <io.h>
|
||||||
|
#include <process.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <ws2tcpip.h>
|
#include <ws2tcpip.h>
|
||||||
#include <process.h>
|
|
||||||
#include <fcntl.h>
|
#include "fdevent.h"
|
||||||
#include <io.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <direct.h>
|
|
||||||
|
|
||||||
#define OS_PATH_SEPARATOR '\\'
|
#define OS_PATH_SEPARATOR '\\'
|
||||||
#define OS_PATH_SEPARATOR_STR "\\"
|
#define OS_PATH_SEPARATOR_STR "\\"
|
||||||
|
|
@ -187,8 +189,6 @@ extern int socket_inaddr_any_server(int port, int type);
|
||||||
#define FDE_ERROR 0x0004
|
#define FDE_ERROR 0x0004
|
||||||
#define FDE_DONT_CLOSE 0x0080
|
#define FDE_DONT_CLOSE 0x0080
|
||||||
|
|
||||||
typedef struct fdevent fdevent;
|
|
||||||
|
|
||||||
typedef void (*fd_func)(int fd, unsigned events, void *userdata);
|
typedef void (*fd_func)(int fd, unsigned events, void *userdata);
|
||||||
|
|
||||||
fdevent *fdevent_create(int fd, fd_func func, void *arg);
|
fdevent *fdevent_create(int fd, fd_func func, void *arg);
|
||||||
|
|
@ -200,20 +200,6 @@ void fdevent_add(fdevent *fde, unsigned events);
|
||||||
void fdevent_del(fdevent *fde, unsigned events);
|
void fdevent_del(fdevent *fde, unsigned events);
|
||||||
void fdevent_loop();
|
void fdevent_loop();
|
||||||
|
|
||||||
struct fdevent {
|
|
||||||
fdevent *next;
|
|
||||||
fdevent *prev;
|
|
||||||
|
|
||||||
int fd;
|
|
||||||
int force_eof;
|
|
||||||
|
|
||||||
unsigned short state;
|
|
||||||
unsigned short events;
|
|
||||||
|
|
||||||
fd_func func;
|
|
||||||
void *arg;
|
|
||||||
};
|
|
||||||
|
|
||||||
static __inline__ void adb_sleep_ms( int mseconds )
|
static __inline__ void adb_sleep_ms( int mseconds )
|
||||||
{
|
{
|
||||||
Sleep( mseconds );
|
Sleep( mseconds );
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,19 @@
|
||||||
#ifndef __TRANSPORT_H
|
#ifndef __TRANSPORT_H
|
||||||
#define __TRANSPORT_H
|
#define __TRANSPORT_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
/* convenience wrappers around read/write that will retry on
|
/* convenience wrappers around read/write that will retry on
|
||||||
** EINTR and/or short read/write. Returns 0 on success, -1
|
** EINTR and/or short read/write. Returns 0 on success, -1
|
||||||
** on error or EOF.
|
** on error or EOF.
|
||||||
*/
|
*/
|
||||||
int readx(int fd, void *ptr, size_t len);
|
int readx(int fd, void *ptr, size_t len);
|
||||||
int writex(int fd, const void *ptr, size_t len);
|
int writex(int fd, const void *ptr, size_t len);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* __TRANSPORT_H */
|
#endif /* __TRANSPORT_H */
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue