Skip to content

Commit

Permalink
Update build configurations to latest
Browse files Browse the repository at this point in the history
  • Loading branch information
zcbenz committed Mar 9, 2024
1 parent 3071594 commit c98d654
Show file tree
Hide file tree
Showing 333 changed files with 12,642 additions and 12,191 deletions.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,23 @@
import os
import pathlib
import re
import sys
from typing import Dict, List
import urllib.request


def _fetch_json(url):
return json.load(urllib.request.urlopen(url))


def _latest(api_url, install_scripts=None):
def _find_valid_urls(release, artifact_regex):
urls = [x['browser_download_url'] for x in release['assets']]
if artifact_regex:
urls = [x for x in urls if re.search(artifact_regex, x)]
return urls


def _latest(api_url, install_scripts=None, artifact_regex=None):
# Make the version change every time this file changes.
md5 = hashlib.md5()
md5.update(pathlib.Path(__file__).read_bytes())
Expand All @@ -27,8 +36,15 @@ def _latest(api_url, install_scripts=None):
md5.update(pathlib.Path(path).read_bytes())
file_hash = md5.hexdigest()[:10]

release = _fetch_json(f'{api_url}/releases/latest')['tag_name']
print('{}.{}'.format(release, file_hash))
releases: List[Dict] = _fetch_json(f'{api_url}/releases')
for release in releases:
tag_name = release['tag_name']
urls = _find_valid_urls(release, artifact_regex)
if len(urls) == 1:
print('{}.{}'.format(tag_name, file_hash))
return
print(f'Bad urls={urls} for tag_name={tag_name}, skipping.',
file=sys.stderr)


def _get_url(api_url,
Expand All @@ -38,13 +54,10 @@ def _get_url(api_url,
# Split off our md5 hash.
version = os.environ['_3PP_VERSION'].rsplit('.', 1)[0]
json_dict = _fetch_json(f'{api_url}/releases/tags/{version}')
urls = [x['browser_download_url'] for x in json_dict['assets']]

if artifact_regex:
urls = [x for x in urls if re.search(artifact_regex, x)]
urls = _find_valid_urls(json_dict, artifact_regex)

if len(urls) != 1:
raise Exception('len(urls) != 1: \n' + '\n'.join(urls))
raise Exception('len(urls) != 1, urls: \n' + '\n'.join(urls))

partial_manifest = {
'url': urls,
Expand All @@ -61,8 +74,7 @@ def main(*,
artifact_filename=None,
artifact_extension=None,
artifact_regex=None,
install_scripts=None,
extract_extension=None):
install_scripts=None):
"""The fetch.py script for a 3pp module.
Args:
Expand All @@ -82,13 +94,11 @@ def main(*,

api_url = f'https://api.github.com/repos/{project}'
if args.action == 'latest':
_latest(api_url, install_scripts=install_scripts)
_latest(api_url,
install_scripts=install_scripts,
artifact_regex=artifact_regex)
else:
_get_url(api_url,
artifact_filename=artifact_filename,
artifact_extension=artifact_extension,
artifact_regex=artifact_regex)


if __name__ == '__main__':
main()
File renamed without changes.
37 changes: 36 additions & 1 deletion build/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@
# found in the LICENSE file.

import("//build/buildflag_header.gni")
import("//build/config/cast.gni")
import("//build/config/chrome_build.gni")
import("//build/config/chromecast_build.gni")
import("//build/config/chromeos/args.gni")
import("//build/config/chromeos/ui_mode.gni")
import("//build/config/features.gni")
import("//build/util/process_version.gni")
import("//build_overrides/build.gni")

if (is_ios) {
import("//build/config/ios/ios_sdk.gni")
}

source_set("buildflag_header_h") {
sources = [ "buildflag.h" ]
}
Expand All @@ -29,6 +33,26 @@ buildflag_header("branding_buildflags") {
"GOOGLE_CHROME_BRANDING=0",
]
}

if (is_chrome_for_testing) {
assert(!is_chrome_branded,
"`is_chrome_for_testing` is incompatible with `is_chrome_branded`")

flags += [ "CHROME_FOR_TESTING=1" ]
} else {
flags += [ "CHROME_FOR_TESTING=0" ]
}

# Note: `GOOGLE_CHROME_FOR_TESTING_BRANDING` and `CHROMIUM_BRANDING` are not
# mutually exclusive.
if (is_chrome_for_testing_branded) {
assert(is_chrome_for_testing,
"`is_chrome_for_testing_branded` requires `is_chrome_for_testing`")

flags += [ "GOOGLE_CHROME_FOR_TESTING_BRANDING=1" ]
} else {
flags += [ "GOOGLE_CHROME_FOR_TESTING_BRANDING=0" ]
}
}

buildflag_header("blink_buildflags") {
Expand Down Expand Up @@ -59,6 +83,17 @@ buildflag_header("chromeos_buildflags") {
]
}

buildflag_header("robolectric_buildflags") {
header = "robolectric_buildflags.h"
flags = [ "IS_ROBOLECTRIC=$is_robolectric" ]
}

buildflag_header("ios_buildflags") {
header = "ios_buildflags.h"
_is_ios_app_extension = is_ios && ios_is_app_extension
flags = [ "IS_IOS_APP_EXTENSION=$_is_ios_app_extension" ]
}

if (build_with_chromium) {
group("gold_common_pytype") {
testonly = true
Expand Down
6 changes: 4 additions & 2 deletions build/DIR_METADATA
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
monorail {
monorail: {
component: "Build"
}

team_email: "build@chromium.org"
buganizer_public: {
component_id: 1456832
}
8 changes: 6 additions & 2 deletions build/OWNERS
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
set noparent
# NOTE: keep this in sync with lsc-owners-override@chromium.org owners
# NOTE: keep this in sync with global-owners-override@chromium.org owners
# by emailing lsc-policy@chromium.org when this list changes.
agrieve@chromium.org
brucedawson@chromium.org
dpranke@google.com
jochen@chromium.org
jwata@google.com
philwo@chromium.org
richardwa@google.com
sdefresne@chromium.org
thakis@chromium.org
thomasanderson@chromium.org
tikuta@chromium.org
ukai@google.com

# Clang build config changes:
file://tools/clang/scripts/OWNERS
Expand All @@ -17,7 +21,7 @@ file://tools/clang/scripts/OWNERS
smaier@chromium.org
wnwen@chromium.org

# NOTE: keep this in sync with lsc-owners-override@chromium.org owners
# NOTE: keep this in sync with global-owners-override@chromium.org owners
# by emailing lsc-policy@chromium.org when this list changes.

# Mac build changes:
Expand Down
5 changes: 0 additions & 5 deletions build/OWNERS.setnoparent
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ file://ui/android/java/res/LAYOUT_OWNERS
# The rules are documented at:
# https://sites.google.com/a/chromium.org/dev/developers/how-tos/enterprise/adding-new-policies
file://components/policy/ENTERPRISE_POLICY_OWNERS
file://components/policy/resources/templates/OWNERS

# This restriction is in place due to the complicated compliance regulations
# around this code.
Expand All @@ -58,10 +57,6 @@ file://chrome/android/java/src/org/chromium/chrome/browser/searchwidget/COMPLIAN
# deprecation and versioning steps must be taken when doing so.
file://chrome/browser/notifications/android/java/src/org/chromium/chrome/browser/notifications/channels/NOTIFICATION_CHANNEL_OWNERS

# The Weblayer API is supposed to be stable and will be used outside of the
# chromium repository.
file://weblayer/API_OWNERS

# New features for lock/login UI on Chrome OS need to work stably in all corner
# cases.
file://ash/login/LOGIN_LOCK_OWNERS
Expand Down
7 changes: 6 additions & 1 deletion build/action_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

import gn_helpers

from typing import Optional
from typing import Sequence


@contextlib.contextmanager
def atomic_output(path, mode='w+b', only_if_changed=True):
Expand Down Expand Up @@ -60,7 +63,9 @@ def add_depfile_arg(parser):
func('--depfile', help='Path to depfile (refer to "gn help depfile")')


def write_depfile(depfile_path, first_gn_output, inputs=None):
def write_depfile(depfile_path: str,
first_gn_output: str,
inputs: Optional[Sequence[str]] = None) -> None:
"""Writes a ninja depfile.
See notes about how to use depfiles in //build/docs/writing_gn_templates.md.
Expand Down
1 change: 0 additions & 1 deletion build/apple/OWNERS
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
mark@chromium.org
rohitrao@chromium.org
rsesek@chromium.org
sdefresne@chromium.org
50 changes: 27 additions & 23 deletions build/apple/tweak_info_plist.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,30 @@

TOP = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))

assert sys.version_info.major >= 3, "Requires python 3.0 or higher."

def _ConvertPlist(source_plist, output_plist, fmt):
"""Convert |source_plist| to |fmt| and save as |output_plist|."""
assert sys.version_info.major == 2, "Use plistlib directly in Python 3"
return subprocess.call(
['plutil', '-convert', fmt, '-o', output_plist, source_plist])

def _WritePlistIfChanged(plist, output_path, fmt):
"""Write a plist file.
Write `plist` to `output_path` in `fmt`. If `output_path` already exist,
the file is only overwritten if its content would be different. This allows
ninja to consider all dependent step to be considered as unnecessary (see
"restat" in ninja documentation).
"""
if os.path.isfile(output_path):
with open(output_path, 'rb') as f:
try:
exising_plist = plistlib.load(f)
if exising_plist == plist:
return
except plistlib.InvalidFileException:
# If the file cannot be parsed by plistlib, then overwrite it.
pass

with open(output_path, 'wb') as f:
plist_format = {'binary1': plistlib.FMT_BINARY, 'xml1': plistlib.FMT_XML}
plistlib.dump(plist, f, fmt=plist_format[fmt])


def _GetOutput(args):
Expand Down Expand Up @@ -331,17 +349,9 @@ def Main(argv):
print('No --plist specified.', file=sys.stderr)
return 1

# Read the plist into its parsed format. Convert the file to 'xml1' as
# plistlib only supports that format in Python 2.7.
with tempfile.NamedTemporaryFile() as temp_info_plist:
if sys.version_info.major == 2:
retcode = _ConvertPlist(options.plist_path, temp_info_plist.name, 'xml1')
if retcode != 0:
return retcode
plist = plistlib.readPlist(temp_info_plist.name)
else:
with open(options.plist_path, 'rb') as f:
plist = plistlib.load(f)
# Read the plist into its parsed format.
with open(options.plist_path, 'rb') as f:
plist = plistlib.load(f)

# Convert overrides.
overrides = {}
Expand Down Expand Up @@ -433,13 +443,7 @@ def Main(argv):
# Now that all keys have been mutated, rewrite the file.
# Convert Info.plist to the format requested by the --format flag. Any
# format would work on Mac but iOS requires specific format.
if sys.version_info.major == 2:
with tempfile.NamedTemporaryFile() as temp_info_plist:
plistlib.writePlist(plist, temp_info_plist.name)
return _ConvertPlist(temp_info_plist.name, output_path, options.format)
with open(output_path, 'wb') as f:
plist_format = {'binary1': plistlib.FMT_BINARY, 'xml1': plistlib.FMT_XML}
plistlib.dump(plist, f, fmt=plist_format[options.format])
_WritePlistIfChanged(plist, output_path, options.format)


if __name__ == '__main__':
Expand Down
8 changes: 4 additions & 4 deletions build/build_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -358,19 +358,19 @@

// Type detection for wchar_t.
#if defined(OS_WIN)
#define WCHAR_T_IS_UTF16
#define WCHAR_T_IS_16_BIT
#elif defined(OS_FUCHSIA)
#define WCHAR_T_IS_UTF32
#define WCHAR_T_IS_32_BIT
#elif defined(OS_POSIX) && defined(COMPILER_GCC) && defined(__WCHAR_MAX__) && \
(__WCHAR_MAX__ == 0x7fffffff || __WCHAR_MAX__ == 0xffffffff)
#define WCHAR_T_IS_UTF32
#define WCHAR_T_IS_32_BIT
#elif defined(OS_POSIX) && defined(COMPILER_GCC) && defined(__WCHAR_MAX__) && \
(__WCHAR_MAX__ == 0x7fff || __WCHAR_MAX__ == 0xffff)
// On Posix, we'll detect short wchar_t, but projects aren't guaranteed to
// compile in this mode (in particular, Chrome doesn't). This is intended for
// other projects using base who manage their own dependencies and make sure
// short wchar works for them.
#define WCHAR_T_IS_UTF16
#define WCHAR_T_IS_16_BIT
#else
#error Please add support for your compiler in build/build_config.h
#endif
Expand Down
1 change: 0 additions & 1 deletion build/check_gn_headers_whitelist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ chrome/install_static/install_modes.h
chrome/install_static/install_util.h
chrome/install_static/test/scoped_install_details.h
chrome/installer/util/google_update_settings.h
components/cdm/browser/cdm_message_filter_android.h
components/device_event_log/device_event_log_export.h
components/login/login_export.h
components/media_router/common/providers/cast/certificate/cast_crl_root_ca_cert_der-inc.h
Expand Down
4 changes: 2 additions & 2 deletions build/config/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# found in the LICENSE file.

import("//build/config/c++/c++.gni")
import("//build/config/cast.gni")
import("//build/config/chrome_build.gni")
import("//build/config/chromecast_build.gni")
import("//build/config/dcheck_always_on.gni")
import("//build/config/features.gni")

Expand Down Expand Up @@ -252,7 +252,7 @@ group("common_deps") {

if (is_fuchsia) {
public_deps +=
[ "//third_party/fuchsia-sdk/sdk/build/config:runtime_library_group" ]
[ "//third_party/fuchsia-gn-sdk/src/config:runtime_library_group" ]
if (is_asan) {
public_deps += [ "//build/config/fuchsia:asan_runtime_library" ]
}
Expand Down
Loading

0 comments on commit c98d654

Please sign in to comment.