Update to upstream git commit c7815d675

- Resolves: rhbz 1535542 1550703 1603379 Switch to clang and ninja
This commit is contained in:
Ivan Afonichev 2018-08-29 03:05:48 +04:00
commit 022a1e0fb4
7 changed files with 197 additions and 1393 deletions

View file

@ -1,5 +1,29 @@
diff --git a/adb/sysdeps/posix/network.cpp b/adb/sysdeps/posix/network.cpp
index ecd1fd24e..07fd8c98e 100644
--- a/adb/sysdeps/posix/network.cpp
+++ b/adb/sysdeps/posix/network.cpp
@@ -19,6 +19,7 @@
#include <errno.h>
#include <netinet/in.h>
#include <sys/socket.h>
+#include <string.h>
#include <string>
diff --git a/adb/types.h b/adb/types.h
index a3e5d4842..bac7181b4 100644
--- a/adb/types.h
+++ b/adb/types.h
@@ -22,6 +22,7 @@
#include <type_traits>
#include <utility>
#include <vector>
+#include <string.h>
#include <android-base/logging.h>
diff --git a/base/errors_unix.cpp b/base/errors_unix.cpp
index 296995e..48269b6 100644
index 296995efe..48269b675 100644
--- a/base/errors_unix.cpp
+++ b/base/errors_unix.cpp
@@ -17,6 +17,7 @@
@ -11,7 +35,7 @@ index 296995e..48269b6 100644
namespace android {
namespace base {
diff --git a/base/file.cpp b/base/file.cpp
index 81b04d7..2fd2b6e 100644
index d6fe753d1..3b10544dd 100644
--- a/base/file.cpp
+++ b/base/file.cpp
@@ -22,6 +22,7 @@
@ -22,15 +46,3 @@ index 81b04d7..2fd2b6e 100644
#include <memory>
#include <mutex>
diff --git a/base/logging.cpp b/base/logging.cpp
index 6357b4b..3c7dbce 100644
--- a/base/logging.cpp
+++ b/base/logging.cpp
@@ -23,6 +23,7 @@
#include <fcntl.h>
#include <libgen.h>
#include <time.h>
+#include <string.h>
// For getprogname(3) or program_invocation_short_name.
#if defined(__ANDROID__) || defined(__APPLE__)

View file

@ -1,40 +0,0 @@
From 5d002b8d6ae0a1eeefe09309ae6687a16e82ed08 Mon Sep 17 00:00:00 2001
From: Yabin Cui <yabinc@google.com>
Date: Tue, 4 Apr 2017 10:29:21 -0700
Subject: [PATCH] adb: don't reset usb when connecting it.
Calling libusb_reset_device() resets the usb connection with device
on linux platform. It can interfere with other usb interfaces and only
works on linux.
Removing it only affects when adb server is killed while doing IO with
device, which will be solved in later patches.
Bug: http://b/32952319
Test: none
Change-Id: I19522435eadd938ff95d49cbae3bcaa5c8f6d184
---
adb/client/usb_libusb.cpp | 8 --------
1 file changed, 8 deletions(-)
diff --git a/adb/client/usb_libusb.cpp b/adb/client/usb_libusb.cpp
index 7adb26213..c48a2517b 100644
--- a/adb/client/usb_libusb.cpp
+++ b/adb/client/usb_libusb.cpp
@@ -306,14 +306,6 @@ static void poll_for_devices() {
}
device_serial.resize(rc);
- // Try to reset the device.
- rc = libusb_reset_device(handle_raw);
- if (rc != 0) {
- LOG(WARNING) << "failed to reset opened device '" << device_serial
- << "': " << libusb_error_name(rc);
- continue;
- }
-
// WARNING: this isn't released via RAII.
rc = libusb_claim_interface(handle.get(), interface_num);
if (rc != 0) {
--
2.14.3

File diff suppressed because it is too large Load diff

View file

@ -1,17 +0,0 @@
diff --git a/libcutils/include/cutils/trace.h b/libcutils/include/cutils/trace.h
index fcbdc9b..4281375 100644
--- a/libcutils/include/cutils/trace.h
+++ b/libcutils/include/cutils/trace.h
@@ -18,7 +18,12 @@
#define _LIBS_CUTILS_TRACE_H
#include <inttypes.h>
+#ifdef __cplusplus
+#include <atomic>
+using namespace std;
+#else
#include <stdatomic.h>
+#endif
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>

View file

@ -0,0 +1,12 @@
diff --git a/adb/adb.cpp b/adb/adb.cpp
index 38c6f62c9..9df41a236 100644
--- a/adb/adb.cpp
+++ b/adb/adb.cpp
@@ -44,7 +44,6 @@
#include <android-base/parsenetaddress.h>
#include <android-base/stringprintf.h>
#include <android-base/strings.h>
-#include <build/version.h>
#include "adb_auth.h"
#include "adb_io.h"

View file

@ -1,12 +1,10 @@
%global date 20170311
%global git_commit e7195be7725a
%global date 20180828
%global git_commit c7815d675
%global packdname core-%{git_commit}
%global extras_git_commit 61f6603
%global extras_packdname extras-%{extras_git_commit}
%global boring_git_commit 7d422bc
%global boring_git_commit fb44824b9
%global boring_packdname boringssl-%{boring_git_commit}
%global mdns_git_commit ca0cba5
%global mdns_git_commit 33e620a7
%global mdns_packdname mdnsresponder-%{mdns_git_commit}
@ -14,19 +12,17 @@
Name: android-tools
Version: %{date}git%{git_commit}
Release: 8%{?dist}
Release: 1%{?dist}
Summary: Android platform tools(adb, fastboot)
Group: Applications/System
# The entire source code is ASL 2.0 except fastboot/ which is BSD
# The entire source code is ASL 2.0 except boringssl which is BSD
License: ASL 2.0 and (ASL 2.0 and BSD)
URL: http://developer.android.com/guide/developing/tools/
# using git archive since upstream hasn't created tarballs.
# git archive --format=tar --prefix=%%{packdname}/ %%{git_commit} adb base fastboot libcrypto_utils libcutils liblog libsparse libutils libziparchive mkbootimg include | xz > %%{packdname}.tar.xz
# git archive --format=tar --prefix=core/ %%{git_commit} adb base diagnose_usb fastboot libcrypto_utils libcutils liblog libsparse libsystem libutils libziparchive mkbootimg include | xz > %%{packdname}.tar.xz
# https://android.googlesource.com/platform/system/core.git
# git archive --format=tar --prefix=extras/ %%{extras_git_commit} ext4_utils f2fs_utils | xz > %%{extras_packdname}.tar.xz
# https://android.googlesource.com/platform/system/extras.git
# git archive --format=tar --prefix=boringssl/ %%{boring_git_commit} src/crypto include src/include | xz > %%{boring_packdname}.tar.xz
# https://android.googlesource.com/platform/external/boringssl
# git archive --format=tar --prefix=mdnsresponder/ %%{mdns_git_commit} mDNSShared | xz > %%{mdns_packdname}.tar.xz
@ -35,7 +31,6 @@ URL: http://developer.android.com/guide/developing/tools/
Source0: %{packdname}.tar.xz
Source1: %{extras_packdname}.tar.xz
Source2: generate_build.rb
Source3: %{boring_packdname}.tar.xz
Source4: %{mdns_packdname}.tar.xz
@ -43,20 +38,18 @@ Source5: 51-android.rules
Source6: adb.service
Patch1: 0001-Add-string-h.patch
Patch2: 0002-libusb-modifications.patch
Patch3: 0003-atomic-fix.patch
Patch3: 0003-buildlib-remove.patch
Patch4: 0004-bz1441234.patch
# https://bugzilla.redhat.com/show_bug.cgi?id=1470740
Patch5: 0001-adb-don-t-reset-usb-when-connecting-it.patch
Patch6: 0001-adb-fix-two-device-offline-problems.patch
Requires(post): systemd
Requires(preun): systemd
Requires(postun): systemd
BuildRequires: gcc-c++
BuildRequires: clang
BuildRequires: ninja-build
BuildRequires: zlib-devel
BuildRequires: openssl-devel
BuildRequires: libselinux-devel
BuildRequires: f2fs-tools-devel
BuildRequires: gtest-devel
BuildRequires: libusbx-devel
BuildRequires: systemd
@ -94,27 +87,31 @@ to read and write the flash partitions. It needs the same USB device
setup between the host and the target phone as adb.
%prep
%setup -q -b 1 -n extras
%setup -q -b 3 -n boringssl
%setup -q -b 4 -n mdnsresponder
%setup -q -b 0 -n %{packdname}
%setup -q -b 0 -n core
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
cp -p %{SOURCE5} 51-android.rules
export CC="clang"
export CXX="clang++"
sed -i 's/android::build::GetBuildNumber().c_str()/"%{git_commit}"/g' adb/adb.cpp
%global optflags %(echo %{optflags} | sed -e 's/-mcet//g' -e 's/-fcf-protection//g')
%build
ruby %{SOURCE2} | tee build.sh
PKGVER=%{git_commit} CXXFLAGS="%{optflags}" CFLAGS="%{optflags}" sh -xe build.sh
cd ..
PKGVER=%{git_commit} CXXFLAGS="%{optflags} -Qunused-arguments" CFLAGS="%{optflags} -Qunused-arguments" ruby %{SOURCE2} > build.ninja
%ninja_build
%install
cd ../
install -d -m 0755 ${RPM_BUILD_ROOT}%{_bindir}
install -d -m 0775 ${RPM_BUILD_ROOT}%{_sharedstatedir}/adb
install -m 0755 -t ${RPM_BUILD_ROOT}%{_bindir} adb/adb fastboot/fastboot libsparse/simg2img libsparse/img2simg
install -m 0755 -t ${RPM_BUILD_ROOT}%{_bindir} adb fastboot simg2img img2simg
install -p -D -m 0644 %{SOURCE6} \
%{buildroot}%{_unitdir}/adb.service
@ -131,15 +128,19 @@ install -p -D -m 0644 %{SOURCE6} \
%doc adb/OVERVIEW.TXT adb/SERVICES.TXT adb/NOTICE adb/protocol.txt 51-android.rules
%{_unitdir}/adb.service
%attr(0755,root,root) %dir %{_sharedstatedir}/adb
#ASL2.0
#ASL2.0 and BSD
%{_bindir}/adb
#ASL2.0
%{_bindir}/simg2img
%{_bindir}/img2simg
#ASL2.0 and BSD.
%{_bindir}/fastboot
%changelog
* Wed Aug 29 2018 Ivan Afonichev <ivan.afonichev@gmail.com> - 20180828gitc7815d675-1
- Update to upstream git commit c7815d675
- Resolves: rhbz 1535542 1550703 1603379 Switch to clang and ninja
* Thu Jul 12 2018 Fedora Release Engineering <releng@fedoraproject.org> - 20170311gite7195be7725a-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild

View file

@ -14,116 +14,168 @@ def compile(sources, cflags)
outputs = []
for s in sources
ext = File.extname(s)
case ext
when '.c'
cc = 'gcc'
lang_flags = '-std=gnu11 $CFLAGS $CPPFLAGS'
cc = 'cc'
lang_flags = '-std=gnu11 $CFLAGS $CPPFLAGS'
when '.cpp', '.cc'
cc = 'g++'
lang_flags = '-std=gnu++14 $CXXFLAGS $CPPFLAGS'
cc = 'cxx'
lang_flags = '-std=gnu++17 $CXXFLAGS $CPPFLAGS'
else
raise "Unknown extension #{ext}"
end
output = s + '.o'
outputs << output
puts "#{cc} -o #{output} #{lang_flags} #{cflags} -c #{s}\n"
puts "build #{output}: #{cc} #{s}\n cflags = #{lang_flags} #{cflags}"
end
return outputs
end
# Links object files
def link(output, objects, ldflags)
puts "g++ -o #{output} #{ldflags} $LDFLAGS #{objects.join(' ')}"
# dir - directory where ninja file is located
# lib - static library path relative to dir
def subninja(dir, lib)
puts "subninja #{dir}build.ninja"
return lib.each{|l| dir + l}
end
# Links object files
def link(output, objects, ldflags)
puts "build #{output}: link #{objects.join(' ')}\n ldflags = #{ldflags} $LDFLAGS"
end
puts "# This set of commands generated by generate_build.rb script\n\n"
puts "CC = #{ENV['CC'] || 'clang'}"
puts "CXX = #{ENV['CXX'] || 'clang++'}\n\n"
puts "CFLAGS = #{ENV['CFLAGS']}"
puts "CXXFLAGS = #{ENV['CXXFLAGS']}"
puts "LDFLAGS = #{ENV['LDFLAGS']}"
puts "PKGVER = #{ENV['PKGVER']}\n\n"
puts """
rule cc
command = $CC $cflags -c $in -o $out
rule cxx
command = $CXX $cflags -c $in -o $out
rule link
command = $CXX $ldflags $LDFLAGS $in -o $out
"""
adbdfiles = %w(
client/usb_dispatch.cpp
client/usb_libusb.cpp
client/usb_linux.cpp
adb.cpp
adb_io.cpp
socket_spec.cpp
adb_listeners.cpp
adb_trace.cpp
adb_utils.cpp
adb_unique_fd.cpp
sockets.cpp
transport.cpp
transport_local.cpp
transport_usb.cpp
services.cpp
adb_trace.cpp
diagnose_usb.cpp
adb_auth_host.cpp
sysdeps_unix.cpp
)
libadbd = compile(expand('adb', adbdfiles), '-DADB_REVISION=\"$PKGVER\" -DADB_HOST=1 -fpermissive -I../boringssl/include -Iadb -Iinclude -Ibase/include -Ilibcrypto_utils/include')
adbshfiles = %w(
fdevent.cpp
shell_service.cpp
shell_service_protocol.cpp
)
libadbsh = compile(expand('adb', adbshfiles), '-DADB_REVISION=\"$PKGVER\" -DADB_HOST=0 -D_Nonnull= -D_Nullable= -fpermissive -Iadb -Iinclude -Ibase/include')
libadbd = compile(expand('core/adb', adbdfiles), '-DADB_HOST=1 -Icore/diagnose_usb/include -Icore/include -Icore/base/include -Icore/adb -Icore/libcrypto_utils/include')
adbfiles = %w(
console.cpp
bugreport.cpp
commandline.cpp
adb_client.cpp
client/auth.cpp
client/console.cpp
socket_spec.cpp
client/bugreport.cpp
client/line_printer.cpp
client/commandline.cpp
client/adb_client.cpp
services.cpp
client/file_sync_client.cpp
sysdeps_unix.cpp
sysdeps/errno.cpp
file_sync_client.cpp
line_printer.cpp
transport_mdns.cpp
sysdeps/posix/network.cpp
client/main.cpp
client/usb_dispatch.cpp
client/usb_linux.cpp
client/usb_libusb.cpp
client/transport_mdns.cpp
)
libadb = compile(expand('adb', adbfiles), '-DADB_REVISION=\"$PKGVER\" -D_GNU_SOURCE -DADB_HOST=1 -D_Nonnull= -D_Nullable= -fpermissive -Iadb -I../mdnsresponder/mDNSShared -Iinclude -Ibase/include')
libadb = compile(expand('core/adb', adbfiles), '-D_GNU_SOURCE -DADB_HOST=1 -Icore/libcrypto_utils/include -Iboringssl/src/include -Icore/include -Icore/base/include -Icore/adb -Imdnsresponder/mDNSShared')
basefiles = %w(
file.cpp
threads.cpp
logging.cpp
parsenetaddress.cpp
stringprintf.cpp
strings.cpp
errors_unix.cpp
test_utils.cpp
)
libbase = compile(expand('base', basefiles), '-DADB_HOST=1 -D_GNU_SOURCE -Ibase/include -Iinclude')
libbase = compile(expand('core/base', basefiles), '-DADB_HOST=1 -Icore/base/include -Icore/include')
logfiles = %w(
logger_write.c
local_logger.c
config_read.c
logprint.c
stderr_write.c
config_write.c
logger_lock.c
logger_name.c
log_event_list.c
log_event_write.c
fake_log_device.c
log_event_list.c
logger_write.c
config_write.c
config_read.c
logger_lock.c
local_logger.c
fake_writer.c
logger_name.c
stderr_write.c
logprint.c
)
liblog = compile(expand('liblog', logfiles), '-DLIBLOG_LOG_TAG=1005 -DFAKE_LOG_DEVICE=1 -D_GNU_SOURCE -Ilog/include -Iinclude')
liblog = compile(expand('core/liblog', logfiles), '-DLIBLOG_LOG_TAG=1006 -D_XOPEN_SOURCE=700 -DFAKE_LOG_DEVICE=1 -Icore/libsystem/include -Icore/liblog/include -Icore/include')
cutilsfiles = %w(
load_file.c
socket_inaddr_any_server_unix.c
socket_local_client_unix.c
socket_local_server_unix.c
socket_loopback_server_unix.c
socket_network_client_unix.c
threads.c
sockets.cpp
fs_config.cpp
canned_fs_config.cpp
android_get_control_file.cpp
socket_network_client_unix.cpp
socket_inaddr_any_server_unix.cpp
sockets.cpp
sockets_unix.cpp
socket_local_client_unix.cpp
socket_local_server_unix.cpp
)
libcutils = compile(expand('libcutils', cutilsfiles), '-D_GNU_SOURCE -Iinclude')
libcutils = compile(expand('core/libcutils', cutilsfiles), '-D_GNU_SOURCE -Icore/libcutils/include -Icore/include -Icore/base/include')
cryptofiles = %w(
diagnoseusbfiles = %w(
diagnose_usb.cpp
)
libdiagnoseusb = compile(expand('core/diagnose_usb', diagnoseusbfiles), '-Icore/diagnose_usb/include -Icore/include -Icore/base/include')
libcryptofiles = %w(
android_pubkey.c
)
libcryptoutils = compile(expand('libcrypto_utils', cryptofiles), '-Ilibcrypto_utils/include -I../boringssl/include -Iinclude')
libcrypto = compile(expand('core/libcrypto_utils', libcryptofiles), '-Icore/libcrypto_utils/include -Iboringssl/src/include')
utilfiles = %w(
FileMap.cpp
Unicode.cpp
SharedBuffer.cpp
String8.cpp
String16.cpp
)
libutil = compile(expand('core/libutils', utilfiles), '-Icore/include')
mdnsfiles = %w(
mDNSShared/dnssd_ipc.c
mDNSShared/dnssd_clientstub.c
)
mdns = compile(expand('mdnsresponder', mdnsfiles), '-D_GNU_SOURCE -DHAVE_IPV6 -DHAVE_LINUX -DNOT_HAVE_SA_LEN -DUSES_NETLINK -UMDNS_DEBUGMSGS -DMDNS_DEBUGMSGS=0 -Imdnsresponder/mDNSShared -Imdnsresponder/mDNSCore -Iinclude')
zipfiles = %w(
zip_archive_stream_entry.cc
zip_archive.cc
)
libzip = compile(expand('core/libziparchive', zipfiles), '-Icore/libziparchive/include -Icore/base/include -Icore/include')
boringcryptofiles = %w(
bn/cmp.c
@ -135,75 +187,48 @@ boringcryptofiles = %w(
bn/convert.c
base64/base64.c
)
boringcrypto = compile(expand('../boringssl/src/crypto', boringcryptofiles), '-I../boringssl/include -Iinclude')
mdnsfiles = %w(
mDNSShared/dnssd_ipc.c
mDNSShared/dnssd_clientstub.c
)
mdns = compile(expand('../mdnsresponder', mdnsfiles), '-D_GNU_SOURCE -DHAVE_IPV6 -DHAVE_LINUX -DNOT_HAVE_SA_LEN -DUSES_NETLINK -UMDNS_DEBUGMSGS -DMDNS_DEBUGMSGS=0 -I../mdnsresponder/mDNSShared -I../mdnsresponder/mDNSCore -Iinclude')
boringcrypto = compile(expand('boringssl/src/crypto', boringcryptofiles), '-Iboringssl/src/include -Iinclude')
link('adb', libbase + liblog + libcutils + libcrypto + libadbd + libadb + libdiagnoseusb + libutil + libzip + mdns + boringcrypto, '-lz -lcrypto -lpthread -lusb-1.0')
link('adb/adb', libbase + liblog + libcutils + boringcrypto + libcryptoutils + libadbd + libadbsh + mdns + libadb, '-lrt -ldl -lpthread -lcrypto -lutil -lusb-1.0')
fastbootfiles = %w(
bootimg_utils.cpp
fs.cpp
socket.cpp
tcp.cpp
udp.cpp
protocol.cpp
engine.cpp
bootimg_utils.cpp
fastboot.cpp
util.cpp
fs.cpp
usb_linux.cpp
util.cpp
main.cpp
engine.cpp
fastboot.cpp
fastboot_driver.cpp
)
libfastboot = compile(expand('fastboot', fastbootfiles), '-DFASTBOOT_REVISION=\"$PKGVER\" -D_GNU_SOURCE -Iadb -Iinclude -Imkbootimg -Ibase/include -Ilibsparse/include -I../extras/ext4_utils/include -I../extras/f2fs_utils')
libfastboot = compile(expand('core/fastboot', fastbootfiles), '-DFASTBOOT_VERSION="\"$PKGVER\"" -D_GNU_SOURCE -D_XOPEN_SOURCE=700 -DUSE_F2FS -Icore/base/include -Icore/include -Icore/adb -Icore/libsparse/include -Icore/mkbootimg/include/bootimg -Icore/libziparchive/include -Icore/diagnose_usb/include')
sparsefiles = %w(
backed_block.c
output_file.c
sparse.c
sparse_crc32.c
sparse_err.c
sparse_read.c
backed_block.cpp
output_file.cpp
sparse.cpp
sparse_crc32.cpp
sparse_err.cpp
sparse_read.cpp
)
libsparse = compile(expand('libsparse', sparsefiles), '-Ilibsparse/include')
libsparse = compile(expand('core/libsparse', sparsefiles), '-Icore/libsparse/include -Icore/base/include')
zipfiles = %w(
zip_archive.cc
)
libzip = compile(expand('libziparchive', zipfiles), '-Ibase/include -Iinclude')
utilfiles = %w(
FileMap.cpp
)
libutil = compile(expand('libutils', utilfiles), '-Iinclude')
ext4files = %w(
make_ext4fs.c
ext4fixup.c
ext4_utils.c
allocate.c
contents.c
extent.c
indirect.c
sha1.c
wipe.c
crc16.c
ext4_sb.c
)
libext4 = compile(expand('../extras/ext4_utils', ext4files), '-Ilibsparse/include -Iinclude -I../extras/ext4_utils/include')
link('fastboot/fastboot', libsparse + libzip + liblog + libutil + libcutils + boringcrypto + libcryptoutils + libbase + libext4 + libfastboot + libadbsh + libadbd, '-lpthread -lselinux -lz -lcrypto -lutil -lusb-1.0')
link('fastboot', libsparse + libzip + libcutils + liblog + libutil + libbase + libfastboot + libdiagnoseusb, '-lz -lpcre2-8 -lpthread -ldl')
simg2imgfiles = %w(
simg2img.c
simg2img.cpp
)
libsimg2img = compile(expand('libsparse', simg2imgfiles), '-Iinclude -Ilibsparse/include')
link('libsparse/simg2img', libsparse + libsimg2img, '-lz')
libsimg2img = compile(expand('core/libsparse', simg2imgfiles), '-Iinclude -Icore/libsparse/include')
link('simg2img', libbase + libsparse + libsimg2img, '-lz')
img2simgfiles = %w(
img2simg.c
img2simg.cpp
)
libimg2simg = compile(expand('libsparse', img2simgfiles), '-Iinclude -Ilibsparse/include')
link('libsparse/img2simg', libsparse + libimg2simg, '-lz')
libimg2simg = compile(expand('core/libsparse', img2simgfiles), '-Iinclude -Icore/libsparse/include')
link('img2simg', libbase + libsparse + libimg2simg, '-lz')