Skip to content

Commit

Permalink
Mojo: use OS whitelists to specify OS-specific typemaps.
Browse files Browse the repository at this point in the history
Per-OS typemaps are specified by listing them separately, requiring
non-trivial busywork to add an OS-specific typemap, especially for the
first typemap restricted to a particular OS.

Add a new typemap field os_whitelist. If specified in a typemap,
only apply that typemap when targeting an OS included in the whitelist.
For example,

os_whitelist = [ "android", "win" ]

would enable the typemap only if is_android or is_win is true.

Change-Id: I54c32cb131e67b083a4245d171c6d927f6d9df24
Tbr: jam@chromium.org, dcheng@chromium.org
Reviewed-on: https://chromium-review.googlesource.com/784371
Commit-Queue: Sam McNally <sammc@chromium.org>
Reviewed-by: Ken Rockot <rockot@chromium.org>
Cr-Commit-Position: refs/heads/master@{#518859}
  • Loading branch information
sammc authored and Commit Bot committed Nov 23, 2017
1 parent 27bcca7 commit f3a1182
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 74 deletions.
1 change: 1 addition & 0 deletions content/common/native_types_mac.typemap
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# found in the LICENSE file.

mojom = "//content/common/native_types.mojom"
os_whitelist = [ "mac" ]
public_headers = [
"//third_party/WebKit/public/platform/WebScrollbarButtonsPlacement.h",
"//third_party/WebKit/public/platform/mac/WebScrollbarTheme.h",
Expand Down
1 change: 1 addition & 0 deletions content/common/typemaps.gni
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ typemaps = [
"//content/common/background_fetch/background_fetch_types.typemap",
"//content/common/frame_messages.typemap",
"//content/common/native_types.typemap",
"//content/common/native_types_mac.typemap",
"//content/common/navigation_params.typemap",
"//content/common/media/media_devices.typemap",
"//content/common/media/media_stream.typemap",
Expand Down
5 changes: 0 additions & 5 deletions content/common/typemaps_mac.gni

This file was deleted.

36 changes: 0 additions & 36 deletions mojo/public/tools/bindings/chromium_bindings_configuration.gni
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ _typemap_imports = [
"//url/mojo/typemaps.gni",
]

_typemap_imports_mac = [ "//content/common/typemaps_mac.gni" ]

_typemap_imports_chromeos = []

_typemaps = []
foreach(typemap_import, _typemap_imports) {
# Avoid reassignment error by assigning to empty scope first.
Expand All @@ -74,36 +70,4 @@ foreach(typemap, _typemaps) {
} ]
}

_typemaps_mac = []
foreach(typemap_import, _typemap_imports_mac) {
_imported = {
}
_imported = read_file(typemap_import, "scope")
_typemaps_mac += _imported.typemaps
}

typemaps_mac = []
foreach(typemap, _typemaps_mac) {
typemaps_mac += [ {
filename = typemap
config = read_file(typemap, "scope")
} ]
}

_typemaps_chromeos = []
foreach(typemap_import, _typemap_imports_chromeos) {
_imported = {
}
_imported = read_file(typemap_import, "scope")
_typemaps_chromeos += _imported.typemaps
}

typemaps_chromeos = []
foreach(typemap, _typemaps_chromeos) {
typemaps_chromeos += [ {
filename = typemap
config = read_file(typemap, "scope")
} ]
}

component_macro_suffix = ""
57 changes: 24 additions & 33 deletions mojo/public/tools/bindings/mojom.gni
Original file line number Diff line number Diff line change
Expand Up @@ -113,21 +113,6 @@ if (enable_mojom_typemapping) {
_typemap_config = typemap.config
read_file(_typemap_config.mojom, "")
}
if (is_mac && defined(configuration.typemaps_mac)) {
foreach(typemap, configuration.typemaps_mac) {
_typemap_config = {
}
_typemap_config = typemap.config
read_file(_typemap_config.mojom, "")
}
} else if (is_chromeos && defined(configuration.typemaps_chromeos)) {
foreach(typemap, configuration.typemaps_chromeos) {
_typemap_config = {
}
_typemap_config = typemap.config
read_file(_typemap_config.mojom, "")
}
}
}
} else {
_bindings_configuration_files = []
Expand Down Expand Up @@ -622,25 +607,31 @@ template("mojom") {
}
_typemap_config = typemap.config
if (get_path_info(source, "abspath") == _typemap_config.mojom) {
active_typemaps += [ typemap ]
}
}
if (is_mac && defined(bindings_configuration.typemaps_mac)) {
foreach(typemap, bindings_configuration.typemaps_mac) {
_typemap_config = {
}
_typemap_config = typemap.config
if (get_path_info(source, "abspath") == _typemap_config.mojom) {
active_typemaps += [ typemap ]
}
}
} else if (is_chromeos &&
defined(bindings_configuration.typemaps_chromeos)) {
foreach(typemap, bindings_configuration.typemaps_chromeos) {
_typemap_config = {
enabled = false
if (!defined(_typemap_config.os_whitelist)) {
enabled = true
} else {
foreach(os, _typemap_config.os_whitelist) {
if (os == "android" && is_android) {
enabled = true
} else if (os == "chromeos" && is_chromeos) {
enabled = true
} else if (os == "fuchsia" && is_fuchsia) {
enabled = true
} else if (os == "ios" && is_ios) {
enabled = true
} else if (os == "linux" && is_linux) {
enabled = true
} else if (os == "mac" && is_mac) {
enabled = true
} else if (os == "posix" && is_posix) {
enabled = true
} else if (os == "win" && is_win) {
enabled = true
}
}
}
_typemap_config = typemap.config
if (get_path_info(source, "abspath") == _typemap_config.mojom) {
if (enabled) {
active_typemaps += [ typemap ]
}
}
Expand Down

0 comments on commit f3a1182

Please sign in to comment.