Commit 86842970 authored by S. Ganesh's avatar S. Ganesh Committed by Commit Bot

midl.py remove legacy |dynamic_guid|, replace with new |dynamic_guids|.

* Changed all Chromium projects using |dynamic_guid| to use the new
|dynamic_guids| multiple guid substitution enhancements.
* Removed the legacy |dynamic_guid| code.

Bug: 1109612
Change-Id: I2fb012884db39ad5489e988aef75113dd8c0258f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2500952Reviewed-by: default avatarJamie Walch <jamiewalch@chromium.org>
Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Reviewed-by: default avatarJoe Downing <joedow@google.com>
Commit-Queue: S. Ganesh <ganesh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821517}
parent 25ebb7a4
...@@ -25,8 +25,15 @@ import("//build/config/win/visual_studio_version.gni") ...@@ -25,8 +25,15 @@ import("//build/config/win/visual_studio_version.gni")
# Directory where generated files were previously persisted. # Directory where generated files were previously persisted.
# Defaults to third_party\win_build_output\midl\|out_dir|. # Defaults to third_party\win_build_output\midl\|out_dir|.
# #
# dynamic_guid (optional) # dynamic_guids (optional)
# If the GUID is not constant across builds, the current GUID. # If the GUIDs are not constant across builds, the current GUID
# substitutions.
# |dynamic_guids| is of the form:
# "PLACEHOLDER-GUID-158428a4-6014-4978-83ba-9fad0dabe791="
# "3d852661-c795-4d20-9b95-5561e9a1d2d9,"
# "PLACEHOLDER-GUID-63B8FFB1-5314-48C9-9C57-93EC8BC6184B="
# "D0E1CACC-C63C-4192-94AB-BF8EAD0E3B83".
# See midl.py for more details.
# #
# writes_tlb (optional) # writes_tlb (optional)
# Whether a .tlb file should be added to outputs. Defaults to false. # Whether a .tlb file should be added to outputs. Defaults to false.
...@@ -58,10 +65,10 @@ template("midl") { ...@@ -58,10 +65,10 @@ template("midl") {
rebase_path(out_dir, root_gen_dir) rebase_path(out_dir, root_gen_dir)
} }
if (defined(invoker.dynamic_guid)) { if (defined(invoker.dynamic_guids)) {
dynamic_guid = invoker.dynamic_guid dynamic_guids = invoker.dynamic_guids
} else { } else {
dynamic_guid = "none" dynamic_guids = "none"
} }
if (defined(invoker.header_file)) { if (defined(invoker.header_file)) {
...@@ -117,7 +124,7 @@ template("midl") { ...@@ -117,7 +124,7 @@ template("midl") {
win_tool_arch, win_tool_arch,
generated_dir, generated_dir,
rebase_path(out_dir, root_build_dir), rebase_path(out_dir, root_build_dir),
dynamic_guid, dynamic_guids,
type_library_file, type_library_file,
header_file, header_file,
dlldata_file, dlldata_file,
......
...@@ -99,30 +99,6 @@ def ZapTimestamp(filename): ...@@ -99,30 +99,6 @@ def ZapTimestamp(filename):
open(filename, 'wb').write(contents) open(filename, 'wb').write(contents)
def overwrite_cls_guid_h(h_file, dynamic_guid):
contents = open(h_file, 'rb').read()
contents = re.sub(br'class DECLSPEC_UUID\("[^"]*"\)',
br'class DECLSPEC_UUID("%s")' % str(dynamic_guid).encode(),
contents)
open(h_file, 'wb').write(contents)
def overwrite_cls_guid_iid(iid_file, dynamic_guid):
contents = open(iid_file, 'rb').read()
hexuuid = '0x%08x,0x%04x,0x%04x,' % dynamic_guid.fields[0:3]
# dynamic_guid.bytes is a bytestring in Py3, but a normal string in Py2.
if sys.version_info.major == 2:
hexuuid += ','.join('0x%02x' % ord(b) for b in dynamic_guid.bytes[8:])
else:
hexuuid += ','.join('0x%02x' % b for b in dynamic_guid.bytes[8:])
contents = re.sub(br'MIDL_DEFINE_GUID\(CLSID, ([^,]*),[^)]*\)',
br'MIDL_DEFINE_GUID(CLSID, \1,%s)' % hexuuid.encode(),
contents)
open(iid_file, 'wb').write(contents)
def get_tlb_contents(tlb_file): def get_tlb_contents(tlb_file):
# See ZapTimestamp() for a short overview of the .tlb format. # See ZapTimestamp() for a short overview of the .tlb format.
contents = open(tlb_file, 'rb').read() contents = open(tlb_file, 'rb').read()
...@@ -160,33 +136,6 @@ def recreate_guid_hashtable(contents, ntypes, guid_off, guid_len): ...@@ -160,33 +136,6 @@ def recreate_guid_hashtable(contents, ntypes, guid_off, guid_len):
struct.pack_into('<I', contents, hash_off + 4*i, hashval) struct.pack_into('<I', contents, hash_off + 4*i, hashval)
def overwrite_cls_guid_tlb(tlb_file, dynamic_guid):
contents, ntypes, type_off, guid_off, guid_len = get_tlb_contents(tlb_file)
# The first type should be a coclass. It points to the type's GUID in
# section 6, the GUID section.
coclass, = struct.unpack_from('<B', contents, type_off)
assert coclass == 0x25, "expected coclass"
guidind = struct.unpack_from('<I', contents, type_off + 0x2c)[0]
assert guidind + 14 <= guid_len
struct.pack_into('<IHH8s', contents, guid_off + guidind,
*(dynamic_guid.fields[0:3] + (dynamic_guid.bytes[8:], )))
recreate_guid_hashtable(contents, ntypes, guid_off, guid_len)
open(tlb_file, 'wb').write(contents)
# Handle a single clsid substitution where |dynamic_guid| is of the form
# "D0E1CACC-C63C-4192-94AB-BF8EAD0E3B83".
def overwrite_cls_guid(h_file, iid_file, tlb_file, dynamic_guid):
# Fix up GUID in .h, _i.c, and .tlb. This function assumes that there is only
# one coclass in the idl file, and that that's the type with the dynamic type.
overwrite_cls_guid_h(h_file, dynamic_guid)
overwrite_cls_guid_iid(iid_file, dynamic_guid)
overwrite_cls_guid_tlb(tlb_file, dynamic_guid)
def overwrite_guids_h(h_file, dynamic_guids): def overwrite_guids_h(h_file, dynamic_guids):
contents = open(h_file, 'rb').read() contents = open(h_file, 'rb').read()
for key in dynamic_guids: for key in dynamic_guids:
...@@ -339,8 +288,8 @@ def run_midl(args, env_dict): ...@@ -339,8 +288,8 @@ def run_midl(args, env_dict):
return 0, midl_output_dir return 0, midl_output_dir
def main(arch, gendir, outdir, dynamic_guid, tlb, h, dlldata, iid, proxy, clang, def main(arch, gendir, outdir, dynamic_guids, tlb, h, dlldata, iid, proxy,
idl, *flags): clang, idl, *flags):
# Copy checked-in outputs to final location. # Copy checked-in outputs to final location.
source = gendir source = gendir
if os.path.isdir(os.path.join(source, os.path.basename(idl))): if os.path.isdir(os.path.join(source, os.path.basename(idl))):
...@@ -349,18 +298,16 @@ def main(arch, gendir, outdir, dynamic_guid, tlb, h, dlldata, iid, proxy, clang, ...@@ -349,18 +298,16 @@ def main(arch, gendir, outdir, dynamic_guid, tlb, h, dlldata, iid, proxy, clang,
source = os.path.normpath(source) source = os.path.normpath(source)
distutils.dir_util.copy_tree(source, outdir, preserve_times=False) distutils.dir_util.copy_tree(source, outdir, preserve_times=False)
dynamic_guids = None if dynamic_guids != 'none':
if dynamic_guid != 'none': assert '=' in dynamic_guids
if '=' not in dynamic_guid: dynamic_guids = re.sub('PLACEHOLDER-GUID-', '', dynamic_guids, flags=re.I)
overwrite_cls_guid(os.path.join(outdir, h), os.path.join(outdir, iid), dynamic_guids = dynamic_guids.split(',')
os.path.join(outdir, tlb), uuid.UUID(dynamic_guid)) dynamic_guids = dict(s.split('=') for s in dynamic_guids)
else: overwrite_guids(os.path.join(outdir, h), os.path.join(outdir, iid),
dynamic_guids = re.sub('PLACEHOLDER-GUID-', '', dynamic_guid, flags=re.I) os.path.join(outdir, proxy), os.path.join(outdir, tlb),
dynamic_guids = dynamic_guids.split(',') dynamic_guids)
dynamic_guids = dict(s.split('=') for s in dynamic_guids) else:
overwrite_guids(os.path.join(outdir, h), os.path.join(outdir, iid), dynamic_guids = None
os.path.join(outdir, proxy), os.path.join(outdir, tlb),
dynamic_guids)
# On non-Windows, that's all we can do. # On non-Windows, that's all we can do.
if sys.platform != 'win32': if sys.platform != 'win32':
...@@ -383,7 +330,7 @@ def main(arch, gendir, outdir, dynamic_guid, tlb, h, dlldata, iid, proxy, clang, ...@@ -383,7 +330,7 @@ def main(arch, gendir, outdir, dynamic_guid, tlb, h, dlldata, iid, proxy, clang,
# On Windows, run midl.exe on the input and check that its outputs are # On Windows, run midl.exe on the input and check that its outputs are
# identical to the checked-in outputs (after replacing guids if # identical to the checked-in outputs (after replacing guids if
# |dynamic_guid(s)| is specified). # |dynamic_guids| is specified).
# Read the environment block from the file. This is stored in the format used # Read the environment block from the file. This is stored in the format used
# by CreateProcess. Drop last 2 NULs, one for list terminator, one for # by CreateProcess. Drop last 2 NULs, one for list terminator, one for
......
...@@ -237,31 +237,18 @@ process_version_rc_template("version") { ...@@ -237,31 +237,18 @@ process_version_rc_template("version") {
output = "$root_out_dir/gaia_credential_provider.rc" output = "$root_out_dir/gaia_credential_provider.rc"
} }
GCP_PLACEHOLDER_CLSID = "PLACEHOLDER-GUID-89adae71-aee5-4ee2-bffb-e8424e06f519"
if (is_chrome_branded) { if (is_chrome_branded) {
gaia_credential_provider_clsid = "0b5bfdf0-4594-47ac-940a-cfc69abc561c" gaia_credential_provider_clsid = "0b5bfdf0-4594-47ac-940a-cfc69abc561c"
} else { } else {
gaia_credential_provider_clsid = "89adae71-aee5-4ee2-bffb-e8424e06f519" gaia_credential_provider_clsid = "89adae71-aee5-4ee2-bffb-e8424e06f519"
} }
action("generate_credential_provider_idl_file") {
script = "//build/util/version.py"
inputs = [ "gaia_credential_provider_idl.templ" ]
outputs = [ "$target_gen_dir/gaia_credential_provider.idl" ]
args = [
"-e",
"GAIA_CREDENTIAL_PROVIDER_CLSID='$gaia_credential_provider_clsid'",
rebase_path(inputs[0], root_build_dir),
rebase_path(outputs[0], root_build_dir),
]
}
midl("gaia_credential_provider_idl") { midl("gaia_credential_provider_idl") {
dynamic_guid = gaia_credential_provider_clsid dynamic_guids = "$GCP_PLACEHOLDER_CLSID=$gaia_credential_provider_clsid"
deps = [ ":generate_credential_provider_idl_file" ]
header_file = "gaia_credential_provider_i.h" header_file = "gaia_credential_provider_i.h"
sources = get_target_outputs(":generate_credential_provider_idl_file") sources = [ "gaia_credential_provider.templ" ]
} }
grit("static_resources") { grit("static_resources") {
......
...@@ -55,7 +55,7 @@ library GaiaCredentialProviderLib ...@@ -55,7 +55,7 @@ library GaiaCredentialProviderLib
{ {
importlib("stdole2.tlb"); importlib("stdole2.tlb");
[ [
uuid(@GAIA_CREDENTIAL_PROVIDER_CLSID@), uuid(PLACEHOLDER-GUID-89adae71-aee5-4ee2-bffb-e8424e06f519),
] ]
coclass GaiaCredentialProvider coclass GaiaCredentialProvider
{ {
......
...@@ -16,8 +16,8 @@ updater_clsid = "3d852661-c795-4d20-9b95-5561e9a1d2d9" ...@@ -16,8 +16,8 @@ updater_clsid = "3d852661-c795-4d20-9b95-5561e9a1d2d9"
IUPDATER_IID = "D0E1CACC-C63C-4192-94AB-BF8EAD0E3B83" IUPDATER_IID = "D0E1CACC-C63C-4192-94AB-BF8EAD0E3B83"
midl("updater_idl_idl") { midl("updater_idl_idl") {
dynamic_guid = "$UpdaterClass_replaceable_uuid=$updater_clsid," + dynamic_guids = "$UpdaterClass_replaceable_uuid=$updater_clsid," +
"$IUpdater_replaceable_uuid=$IUPDATER_IID" "$IUpdater_replaceable_uuid=$IUPDATER_IID"
header_file = "updater_idl.h" header_file = "updater_idl.h"
sources = [ "updater_idl.template" ] sources = [ "updater_idl.template" ]
......
...@@ -176,24 +176,13 @@ source_set("unit_tests") { ...@@ -176,24 +176,13 @@ source_set("unit_tests") {
] ]
} }
action("generate_idl") { RDP_DESKTOP_SESSION_PLACEHOLDER_CLSID =
script = "//build/util/version.py" "PLACEHOLDER-GUID-6741fd0a-6a8a-5838-a35e-8088697e2088"
inputs = [ "chromoting_lib_idl.templ" ]
outputs = [ "$target_gen_dir/chromoting_lib.idl" ]
args = [
"-e",
"RDP_DESKTOP_SESSION_CLSID='$rdp_desktop_session_clsid'",
rebase_path(inputs[0], root_build_dir),
rebase_path(outputs[0], root_build_dir),
]
}
midl("remoting_lib_idl") { midl("remoting_lib_idl") {
sources = get_target_outputs(":generate_idl") sources = [ "chromoting_lib.templ" ]
dynamic_guid = rdp_desktop_session_clsid dynamic_guids =
deps = [ ":generate_idl" ] "$RDP_DESKTOP_SESSION_PLACEHOLDER_CLSID=$rdp_desktop_session_clsid"
writes_tlb = true writes_tlb = true
} }
...@@ -218,8 +207,8 @@ config("MIDL_config") { ...@@ -218,8 +207,8 @@ config("MIDL_config") {
static_library("remoting_lib_ps") { static_library("remoting_lib_ps") {
sources = [ sources = [
"$root_gen_dir/remoting/host/win/chromoting_lib.dlldata.c", "$target_gen_dir/chromoting_lib.dlldata.c",
"$root_gen_dir/remoting/host/win/chromoting_lib_p.c", "$target_gen_dir/chromoting_lib_p.c",
] ]
configs -= [ "//build/config/compiler:chromium_code" ] configs -= [ "//build/config/compiler:chromium_code" ]
......
...@@ -61,7 +61,7 @@ library ChromotingLib { ...@@ -61,7 +61,7 @@ library ChromotingLib {
importlib("stdole2.tlb"); importlib("stdole2.tlb");
[ [
uuid(@RDP_DESKTOP_SESSION_CLSID@), uuid(PLACEHOLDER-GUID-6741fd0a-6a8a-5838-a35e-8088697e2088),
helpstring("RdpDesktopSession Class") helpstring("RdpDesktopSession Class")
] ]
coclass RdpDesktopSession { coclass RdpDesktopSession {
......
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