Commit aeb6fda3 authored by Michael Moss's avatar Michael Moss Committed by Commit Bot

Support building diff tools for multiple archs at the same time.

Some tools need to be used both when creating diffs and when installing
diffs, so need to support the archs of both the target system and the
system generating the diffs. These are generally the same thing, but
when cross-compiling for arm64 on x86, it requires universal binaries.

BUG=1119472

Cq-Include-Trybots: luci.chromium.try:mac-rel,mac-arm64-rel
Change-Id: Ic329561b8f034477d491121e507ba34821419516
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2462242
Commit-Queue: Michael Moss <mmoss@chromium.org>
Reviewed-by: default avatarMark Mentovai <mark@chromium.org>
Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Auto-Submit: Michael Moss <mmoss@chromium.org>
Cr-Commit-Position: refs/heads/master@{#818949}
parent 923603e2
...@@ -60,22 +60,19 @@ copy("copies") { ...@@ -60,22 +60,19 @@ copy("copies") {
deps = [ deps = [
":copy_signing", ":copy_signing",
"//chrome:entitlements", "//chrome:entitlements",
"//chrome/installer/mac/third_party/bsdiff:goobsdiff($host_toolchain)", "//chrome/installer/mac/third_party/bsdiff:goobsdiff",
"//chrome/installer/mac/third_party/bsdiff:goobspatch", "//chrome/installer/mac/third_party/bsdiff:goobspatch",
"//chrome/installer/mac/third_party/xz:lzma_decompress", "//chrome/installer/mac/third_party/xz:lzma_decompress",
"//chrome/installer/mac/third_party/xz:xz($host_toolchain)", "//chrome/installer/mac/third_party/xz:xz",
"//chrome/installer/mac/third_party/xz:xzdec", "//chrome/installer/mac/third_party/xz:xzdec",
] ]
sources = [ sources = [
"$root_gen_dir/chrome/app-entitlements.plist", "$root_gen_dir/chrome/app-entitlements.plist",
get_label_info( "$root_out_dir/goobsdiff",
"//chrome/installer/mac/third_party/bsdiff:goobsdiff($host_toolchain)",
"root_out_dir") + "/goobsdiff",
"$root_out_dir/goobspatch", "$root_out_dir/goobspatch",
"$root_out_dir/liblzma_decompress.dylib", "$root_out_dir/liblzma_decompress.dylib",
get_label_info("//chrome/installer/mac/third_party/xz:xz($host_toolchain)", "$root_out_dir/xz",
"root_out_dir") + "/xz",
"$root_out_dir/xzdec", "$root_out_dir/xzdec",
"//chrome/app/helper-gpu-entitlements.plist", "//chrome/app/helper-gpu-entitlements.plist",
"//chrome/app/helper-plugin-entitlements.plist", "//chrome/app/helper-plugin-entitlements.plist",
...@@ -141,3 +138,25 @@ group("mac_signing_tests") { ...@@ -141,3 +138,25 @@ group("mac_signing_tests") {
"//third_party/catapult/third_party/typ/", "//third_party/catapult/third_party/typ/",
] ]
} }
config("fat_binary_config") {
visibility = [ "./*" ]
# Always build arm64 targets as universal (fat) binaries, since these need to
# run on both the install machine and the machine where the diff installers
# are created, and the latter is probably not arm64.
if (current_cpu == "arm64") {
fat_binary_flags = [
# Help the compiler find lipo for creating fat binaries.
"-B",
mac_bin_path,
"-arch",
"x86_64",
"-arch",
"arm64",
]
cflags = fat_binary_flags
ldflags = fat_binary_flags
}
}
...@@ -2,31 +2,21 @@ ...@@ -2,31 +2,21 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
# Because size is a concern, don't link against all of base. Instead,
# just bring in a copy of the one component that's needed, along with
# the adapter that allows it to be called from C (not C++) code.
static_library("goobsdiff_sha1_adapter") {
visibility = [ ":*" ]
check_includes = false
sources = [
"../../../../../base/hash/sha1.cc",
"sha1_adapter.cc",
"sha1_adapter.h",
]
deps = [ "//base:logging_buildflags" ] # Needed by sha1.cc
}
executable("goobsdiff") { executable("goobsdiff") {
# Avoid default deps, which pull in the hermetic libc++, which is not needed
# for this pure C executable, and which doesn't play well with creating
# one-off universal binaries, since libc++ is not built as universal.
no_default_deps = true
sources = [ "goobsdiff.c" ] sources = [ "goobsdiff.c" ]
configs -= [ "//build/config/compiler:chromium_code" ] configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ] configs += [
"//build/config/compiler:no_chromium_code",
"//chrome/installer/mac:fat_binary_config"
]
deps = [ deps = [
":goobsdiff_sha1_adapter",
"//chrome/installer/mac/third_party/xz:lzma", "//chrome/installer/mac/third_party/xz:lzma",
] ]
...@@ -39,13 +29,20 @@ executable("goobsdiff") { ...@@ -39,13 +29,20 @@ executable("goobsdiff") {
} }
executable("goobspatch") { executable("goobspatch") {
# Avoid default deps, which pull in the hermetic libc++, which is not needed
# for this pure C executable, and which doesn't play well with creating
# one-off universal binaries, since libc++ is not built as universal.
no_default_deps = true
sources = [ "goobspatch.c" ] sources = [ "goobspatch.c" ]
configs -= [ "//build/config/compiler:chromium_code" ] configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ] configs += [
"//build/config/compiler:no_chromium_code",
"//chrome/installer/mac:fat_binary_config"
]
deps = [ deps = [
":goobsdiff_sha1_adapter",
"//chrome/installer/mac/third_party/xz:lzma_decompress", "//chrome/installer/mac/third_party/xz:lzma_decompress",
] ]
......
...@@ -33,7 +33,6 @@ Local Modifications: ...@@ -33,7 +33,6 @@ Local Modifications:
checked in to the Chromium repository at r49280. checked in to the Chromium repository at r49280.
- Created goobsdiff.gyp for GYP build system integration. - Created goobsdiff.gyp for GYP build system integration.
- Renamed bsdiff.c to goobsdiff.c and bspatch.c to goobspatch.c. - Renamed bsdiff.c to goobsdiff.c and bspatch.c to goobspatch.c.
- Added sha1_adapter.cc, sha1_adapter.h, and empty.cc to facilitate hashing.
- Added #include <sys/types.h> to goobspatch.c so that it compiles. (Oops!) - Added #include <sys/types.h> to goobspatch.c so that it compiles. (Oops!)
- Changed the magic number in the header from BSDIFF40 to BSDIFF4G. - Changed the magic number in the header from BSDIFF40 to BSDIFF4G.
- Expanded the header to include SHA1 hashes of the original and new files, - Expanded the header to include SHA1 hashes of the original and new files,
......
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This is an empty file with a .cc extension, to convince the toolchain
// (I'm looking at YOU, Xcode) that it needs to link any target this file
// belongs to as C++.
...@@ -41,6 +41,7 @@ __FBSDID("$FreeBSD: src/usr.bin/bsdiff/bsdiff/bsdiff.c,v 1.1 2005/08/06 01:59:05 ...@@ -41,6 +41,7 @@ __FBSDID("$FreeBSD: src/usr.bin/bsdiff/bsdiff/bsdiff.c,v 1.1 2005/08/06 01:59:05
#include <zlib.h> #include <zlib.h>
#if defined(__APPLE__) #if defined(__APPLE__)
#include <CommonCrypto/CommonDigest.h>
#include <libkern/OSByteOrder.h> #include <libkern/OSByteOrder.h>
#define htole64(x) OSSwapHostToLittleInt64(x) #define htole64(x) OSSwapHostToLittleInt64(x)
#elif defined(__linux__) #elif defined(__linux__)
...@@ -51,8 +52,6 @@ __FBSDID("$FreeBSD: src/usr.bin/bsdiff/bsdiff/bsdiff.c,v 1.1 2005/08/06 01:59:05 ...@@ -51,8 +52,6 @@ __FBSDID("$FreeBSD: src/usr.bin/bsdiff/bsdiff/bsdiff.c,v 1.1 2005/08/06 01:59:05
#error Provide htole64 for this platform #error Provide htole64 for this platform
#endif #endif
#include "chrome/installer/mac/third_party/bsdiff/sha1_adapter.h"
#define MIN(x,y) (((x)<(y)) ? (x) : (y)) #define MIN(x,y) (((x)<(y)) ? (x) : (y))
static void split(off_t *I,off_t *V,off_t start,off_t len,off_t h) static void split(off_t *I,off_t *V,off_t start,off_t len,off_t h)
...@@ -409,8 +408,8 @@ int main(int argc,char *argv[]) ...@@ -409,8 +408,8 @@ int main(int argc,char *argv[])
memcpy(header, "BSDIFF4G", 8); memcpy(header, "BSDIFF4G", 8);
offtout(oldsize, header + 32); offtout(oldsize, header + 32);
offtout(newsize, header + 40); offtout(newsize, header + 40);
SHA1(old, oldsize, header + 48); CC_SHA1(old, oldsize, header + 48);
SHA1(new, newsize, header + 68); CC_SHA1(new, newsize, header + 68);
/* Compute the differences */ /* Compute the differences */
scan=0;len=0; scan=0;len=0;
......
...@@ -41,6 +41,7 @@ __FBSDID("$FreeBSD: src/usr.bin/bsdiff/bspatch/bspatch.c,v 1.1 2005/08/06 01:59: ...@@ -41,6 +41,7 @@ __FBSDID("$FreeBSD: src/usr.bin/bsdiff/bspatch/bspatch.c,v 1.1 2005/08/06 01:59:
#include <zlib.h> #include <zlib.h>
#if defined(__APPLE__) #if defined(__APPLE__)
#include <CommonCrypto/CommonDigest.h>
#include <libkern/OSByteOrder.h> #include <libkern/OSByteOrder.h>
#define le64toh(x) OSSwapLittleToHostInt64(x) #define le64toh(x) OSSwapLittleToHostInt64(x)
#elif defined(__linux__) #elif defined(__linux__)
...@@ -51,8 +52,6 @@ __FBSDID("$FreeBSD: src/usr.bin/bsdiff/bspatch/bspatch.c,v 1.1 2005/08/06 01:59: ...@@ -51,8 +52,6 @@ __FBSDID("$FreeBSD: src/usr.bin/bsdiff/bspatch/bspatch.c,v 1.1 2005/08/06 01:59:
#error Provide le64toh for this platform #error Provide le64toh for this platform
#endif #endif
#include "chrome/installer/mac/third_party/bsdiff/sha1_adapter.h"
static inline off_t offtin(u_char *buf) static inline off_t offtin(u_char *buf)
{ {
return le64toh(*((off_t*)buf)); return le64toh(*((off_t*)buf));
...@@ -61,7 +60,7 @@ static inline off_t offtin(u_char *buf) ...@@ -61,7 +60,7 @@ static inline off_t offtin(u_char *buf)
static void sha1tostr(const u_char *sha1, char *sha1str) static void sha1tostr(const u_char *sha1, char *sha1str)
{ {
int i; int i;
for (i = 0; i < SHA1_DIGEST_LENGTH; ++i) for (i = 0; i < CC_SHA1_DIGEST_LENGTH; ++i)
sprintf(&sha1str[i * 2], "%02x", sha1[i]); sprintf(&sha1str[i * 2], "%02x", sha1[i]);
} }
...@@ -375,9 +374,9 @@ int main(int argc,char * argv[]) ...@@ -375,9 +374,9 @@ int main(int argc,char * argv[])
off_t oldpos,newpos; off_t oldpos,newpos;
off_t ctrl[3]; off_t ctrl[3];
off_t i; off_t i;
u_char sha1[SHA1_DIGEST_LENGTH]; u_char sha1[CC_SHA1_DIGEST_LENGTH];
char sha1str[SHA1_DIGEST_LENGTH * 2 + 1]; char sha1str[CC_SHA1_DIGEST_LENGTH * 2 + 1];
char expected_sha1str[SHA1_DIGEST_LENGTH * 2 + 1]; char expected_sha1str[CC_SHA1_DIGEST_LENGTH * 2 + 1];
if(argc!=4) errx(1,"usage: %s oldfile newfile patchfile",argv[0]); if(argc!=4) errx(1,"usage: %s oldfile newfile patchfile",argv[0]);
...@@ -452,7 +451,7 @@ int main(int argc,char * argv[]) ...@@ -452,7 +451,7 @@ int main(int argc,char * argv[])
if (expect_oldsize != oldsize) if (expect_oldsize != oldsize)
errx(1, "old size mismatch: %lld != %lld", errx(1, "old size mismatch: %lld != %lld",
oldsize, expect_oldsize); oldsize, expect_oldsize);
SHA1(old, oldsize, sha1); CC_SHA1(old, oldsize, sha1);
if (memcmp(sha1, header + 48, sizeof(sha1)) != 0) { if (memcmp(sha1, header + 48, sizeof(sha1)) != 0) {
sha1tostr(sha1, sha1str); sha1tostr(sha1, sha1str);
sha1tostr(header + 48, expected_sha1str); sha1tostr(header + 48, expected_sha1str);
...@@ -506,7 +505,7 @@ int main(int argc,char * argv[]) ...@@ -506,7 +505,7 @@ int main(int argc,char * argv[])
cfclose(&df); cfclose(&df);
cfclose(&ef); cfclose(&ef);
SHA1(new, newsize, sha1); CC_SHA1(new, newsize, sha1);
if (memcmp(sha1, header + 68, sizeof(sha1)) != 0) { if (memcmp(sha1, header + 68, sizeof(sha1)) != 0) {
sha1tostr(sha1, sha1str); sha1tostr(sha1, sha1str);
sha1tostr(header + 68, expected_sha1str); sha1tostr(header + 68, expected_sha1str);
......
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/installer/mac/third_party/bsdiff/sha1_adapter.h"
#include "base/hash/sha1.h"
void SHA1(const unsigned char* data, size_t len, unsigned char* hash) {
base::SHA1HashBytes(data, len, hash);
}
/* Copyright (c) 2011 The Chromium Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file. */
#ifndef CHROME_INSTALLER_MAC_THIRD_PARTY_BSDIFF_SHA1_ADAPTER_H_
#define CHROME_INSTALLER_MAC_THIRD_PARTY_BSDIFF_SHA1_ADAPTER_H_
/* This file defines a wrapper around Chromium's C++ base::SHA1HashBytes
* function allowing it to be called from C code. */
#include <sys/types.h>
#define SHA1_DIGEST_LENGTH 20
#if defined(__cplusplus)
extern "C" {
#endif
void SHA1(const unsigned char* data, size_t len, unsigned char* hash);
#if defined(__cplusplus)
} // extern "C"
#endif
#endif /* CHROME_INSTALLER_MAC_THIRD_PARTY_BSDIFF_SHA1_ADAPTER_H_ */
...@@ -127,6 +127,7 @@ source_set("common") { ...@@ -127,6 +127,7 @@ source_set("common") {
":common_config", ":common_config",
":compress_config", ":compress_config",
":decompress_config", ":decompress_config",
"//chrome/installer/mac:fat_binary_config",
] ]
sources = [ sources = [
...@@ -213,6 +214,7 @@ source_set("decompress") { ...@@ -213,6 +214,7 @@ source_set("decompress") {
configs += [ configs += [
":common_config", ":common_config",
":decompress_config", ":decompress_config",
"//chrome/installer/mac:fat_binary_config",
] ]
sources = [ sources = [
...@@ -256,6 +258,7 @@ source_set("compress") { ...@@ -256,6 +258,7 @@ source_set("compress") {
configs += [ configs += [
":common_config", ":common_config",
":compress_config", ":compress_config",
"//chrome/installer/mac:fat_binary_config",
] ]
sources = [ sources = [
...@@ -317,9 +320,15 @@ source_set("lzma") { ...@@ -317,9 +320,15 @@ source_set("lzma") {
# is distributed in Google Chrome update disk images and is used by more # is distributed in Google Chrome update disk images and is used by more
# than one tool. # than one tool.
shared_library("lzma_decompress") { shared_library("lzma_decompress") {
# Avoid default deps, which pull in the hermetic libc++, which is not needed
# for this pure C executable, and which doesn't play well with creating
# one-off universal binaries, since libc++ is not built as universal.
no_default_deps = true
configs += [ configs += [
":common_config", ":common_config",
":decompress_config", ":decompress_config",
"//chrome/installer/mac:fat_binary_config",
] ]
public_configs = [ ":lzma_decompress_config" ] public_configs = [ ":lzma_decompress_config" ]
...@@ -343,10 +352,16 @@ shared_library("lzma_decompress") { ...@@ -343,10 +352,16 @@ shared_library("lzma_decompress") {
} }
executable("xz") { executable("xz") {
# Avoid default deps, which pull in the hermetic libc++, which is not needed
# for this pure C executable, and which doesn't play well with creating
# one-off universal binaries, since libc++ is not built as universal.
no_default_deps = true
configs += [ configs += [
":common_config", ":common_config",
":decompress_config", ":decompress_config",
":compress_config", ":compress_config",
"//chrome/installer/mac:fat_binary_config",
] ]
sources = [ sources = [
...@@ -378,9 +393,15 @@ executable("xz") { ...@@ -378,9 +393,15 @@ executable("xz") {
} }
executable("xzdec") { executable("xzdec") {
# Avoid default deps, which pull in the hermetic libc++, which is not needed
# for this pure C executable, and which doesn't play well with creating
# one-off universal binaries, since libc++ is not built as universal.
no_default_deps = true
configs += [ configs += [
":common_config", ":common_config",
":decompress_config", ":decompress_config",
"//chrome/installer/mac:fat_binary_config",
] ]
sources = [ sources = [
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment