Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 53daee6a authored by Elliott Hughes's avatar Elliott Hughes
Browse files

Fix the Windows adb build.

It looks like we can't use clang on Windows yet because libc++ isn't ready.
So move back to GCC for the Windows host clang. Work around the mingw
printf format string problems that made us want to switch to clang in the
first place, and #include "sysdeps.h" in adb_utils.cpp to work around the
absence of lstat(2) on Windows.

Change-Id: Icd0797a8c0c2d1d326bdd704ba6bcafcbaeb742f
parent 623aa1c4
Loading
Loading
Loading
Loading
+17 −20
Original line number Diff line number Diff line
@@ -5,7 +5,11 @@

LOCAL_PATH:= $(call my-dir)

ADB_CLANG := true
ifeq ($(HOST_OS),windows)
  adb_host_clang := false  # libc++ for mingw not ready yet.
else
  adb_host_clang := true
endif

# libadb
# =========================================================
@@ -27,6 +31,11 @@ LIBADB_SRC_FILES := \
    transport_local.cpp \
    transport_usb.cpp \

LIBADB_TEST_SRCS := \
    adb_io_test.cpp \
    adb_utils_test.cpp \
    transport_test.cpp \

LIBADB_CFLAGS := \
    -Wall -Werror \
    -Wno-unused-parameter \
@@ -63,7 +72,7 @@ LOCAL_SRC_FILES := \
include $(BUILD_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_CLANG := $(ADB_CLANG)
LOCAL_CLANG := $(adb_host_clang)
LOCAL_MODULE := libadb
LOCAL_CFLAGS := $(LIBADB_CFLAGS) -DADB_HOST=1
LOCAL_SRC_FILES := \
@@ -81,13 +90,8 @@ endif

include $(BUILD_HOST_STATIC_LIBRARY)

LIBADB_TEST_SRCS := \
    adb_io_test.cpp \
    adb_utils_test.cpp \
    transport_test.cpp \

include $(CLEAR_VARS)
LOCAL_CLANG := $(ADB_CLANG)
LOCAL_CLANG := true
LOCAL_MODULE := adbd_test
LOCAL_CFLAGS := -DADB_HOST=0 $(LIBADB_CFLAGS)
LOCAL_SRC_FILES := $(LIBADB_TEST_SRCS)
@@ -96,7 +100,7 @@ LOCAL_SHARED_LIBRARIES := liblog libbase libcutils
include $(BUILD_NATIVE_TEST)

include $(CLEAR_VARS)
LOCAL_CLANG := $(ADB_CLANG)
LOCAL_CLANG := $(adb_host_clang)
LOCAL_MODULE := adb_test
LOCAL_CFLAGS := -DADB_HOST=1 $(LIBADB_CFLAGS)
LOCAL_SRC_FILES := $(LIBADB_TEST_SRCS) services.cpp
@@ -131,15 +135,11 @@ ifeq ($(HOST_OS),darwin)
endif

ifeq ($(HOST_OS),windows)
  EXTRA_STATIC_LIBS := AdbWinApi
  ifneq ($(strip $(USE_MINGW)),)
    # MinGW under Linux case
  LOCAL_LDLIBS += -lws2_32 -lgdi32
    USE_SYSDEPS_WIN32 := 1
  endif
  EXTRA_STATIC_LIBS := AdbWinApi
endif

LOCAL_CLANG := $(ADB_CLANG)
LOCAL_CLANG := $(adb_host_clang)

LOCAL_SRC_FILES := \
    adb_main.cpp \
@@ -162,12 +162,9 @@ LOCAL_STATIC_LIBRARIES := \
    libadb \
    libbase \
    libcrypto_static \
    libcutils \
    $(EXTRA_STATIC_LIBS) \

ifeq ($(USE_SYSDEPS_WIN32),)
    LOCAL_STATIC_LIBRARIES += libcutils
endif

include $(BUILD_HOST_EXECUTABLE)

$(call dist-for-goals,dist_files sdk,$(LOCAL_BUILT_MODULE))
@@ -184,7 +181,7 @@ endif

include $(CLEAR_VARS)

LOCAL_CLANG := $(ADB_CLANG)
LOCAL_CLANG := true

LOCAL_SRC_FILES := \
    adb_main.cpp \
+2 −0
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@
#include <sys/types.h>
#include <unistd.h>

#include "sysdeps.h"

bool getcwd(std::string* s) {
  char* cwd = getcwd(nullptr, 0);
  if (cwd != nullptr) *s = cwd;
+10 −0
Original line number Diff line number Diff line
@@ -1735,7 +1735,11 @@ static int install_multiple_app(transport_type transport, const char* serial, in
        return 1;
    }

#if defined(_WIN32) // Remove when we're using clang for Win32.
    std::string cmd = android::base::StringPrintf("exec:pm install-create -S %u", (unsigned) total_size);
#else
    std::string cmd = android::base::StringPrintf("exec:pm install-create -S %" PRIu64, total_size);
#endif
    for (i = 1; i < first_apk; i++) {
        cmd += " " + escape_arg(argv[i]);
    }
@@ -1775,9 +1779,15 @@ static int install_multiple_app(transport_type transport, const char* serial, in
            goto finalize_session;
        }

#if defined(_WIN32) // Remove when we're using clang for Win32.
        std::string cmd = android::base::StringPrintf(
                "exec:pm install-write -S %u %d %d_%s -",
                (unsigned) sb.st_size, session_id, i, get_basename(file));
#else
        std::string cmd = android::base::StringPrintf(
                "exec:pm install-write -S %" PRIu64 " %d %d_%s -",
                static_cast<uint64_t>(sb.st_size), session_id, i, get_basename(file));
#endif

        int localFd = adb_open(file, O_RDONLY);
        if (localFd < 0) {