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")
# Directory where generated files were previously persisted.
# Defaults to third_party\win_build_output\midl\|out_dir|.
#
# dynamic_guid (optional)
# If the GUID is not constant across builds, the current GUID.
# dynamic_guids (optional)
# 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)
# Whether a .tlb file should be added to outputs. Defaults to false.
......@@ -58,10 +65,10 @@ template("midl") {
rebase_path(out_dir, root_gen_dir)
}
if (defined(invoker.dynamic_guid)) {
dynamic_guid = invoker.dynamic_guid
if (defined(invoker.dynamic_guids)) {
dynamic_guids = invoker.dynamic_guids
} else {
dynamic_guid = "none"
dynamic_guids = "none"
}
if (defined(invoker.header_file)) {
......@@ -117,7 +124,7 @@ template("midl") {
win_tool_arch,
generated_dir,
rebase_path(out_dir, root_build_dir),
dynamic_guid,
dynamic_guids,
type_library_file,
header_file,
dlldata_file,
......
......@@ -99,30 +99,6 @@ def ZapTimestamp(filename):
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):
# See ZapTimestamp() for a short overview of the .tlb format.
contents = open(tlb_file, 'rb').read()
......@@ -160,33 +136,6 @@ def recreate_guid_hashtable(contents, ntypes, guid_off, guid_len):
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):
contents = open(h_file, 'rb').read()
for key in dynamic_guids:
......@@ -339,8 +288,8 @@ def run_midl(args, env_dict):
return 0, midl_output_dir
def main(arch, gendir, outdir, dynamic_guid, tlb, h, dlldata, iid, proxy, clang,
idl, *flags):
def main(arch, gendir, outdir, dynamic_guids, tlb, h, dlldata, iid, proxy,
clang, idl, *flags):
# Copy checked-in outputs to final location.
source = gendir
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,
source = os.path.normpath(source)
distutils.dir_util.copy_tree(source, outdir, preserve_times=False)
dynamic_guids = None
if dynamic_guid != 'none':
if '=' not in dynamic_guid:
overwrite_cls_guid(os.path.join(outdir, h), os.path.join(outdir, iid),
os.path.join(outdir, tlb), uuid.UUID(dynamic_guid))
else:
dynamic_guids = re.sub('PLACEHOLDER-GUID-', '', dynamic_guid, flags=re.I)
dynamic_guids = dynamic_guids.split(',')
dynamic_guids = dict(s.split('=') for s in dynamic_guids)
overwrite_guids(os.path.join(outdir, h), os.path.join(outdir, iid),
os.path.join(outdir, proxy), os.path.join(outdir, tlb),
dynamic_guids)
if dynamic_guids != 'none':
assert '=' in dynamic_guids
dynamic_guids = re.sub('PLACEHOLDER-GUID-', '', dynamic_guids, flags=re.I)
dynamic_guids = dynamic_guids.split(',')
dynamic_guids = dict(s.split('=') for s in dynamic_guids)
overwrite_guids(os.path.join(outdir, h), os.path.join(outdir, iid),
os.path.join(outdir, proxy), os.path.join(outdir, tlb),
dynamic_guids)
else:
dynamic_guids = None
# On non-Windows, that's all we can do.
if sys.platform != 'win32':
......@@ -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
# 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
# by CreateProcess. Drop last 2 NULs, one for list terminator, one for
......
......@@ -237,31 +237,18 @@ process_version_rc_template("version") {
output = "$root_out_dir/gaia_credential_provider.rc"
}
GCP_PLACEHOLDER_CLSID = "PLACEHOLDER-GUID-89adae71-aee5-4ee2-bffb-e8424e06f519"
if (is_chrome_branded) {
gaia_credential_provider_clsid = "0b5bfdf0-4594-47ac-940a-cfc69abc561c"
} else {
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") {
dynamic_guid = gaia_credential_provider_clsid
deps = [ ":generate_credential_provider_idl_file" ]
dynamic_guids = "$GCP_PLACEHOLDER_CLSID=$gaia_credential_provider_clsid"
header_file = "gaia_credential_provider_i.h"
sources = get_target_outputs(":generate_credential_provider_idl_file")
sources = [ "gaia_credential_provider.templ" ]
}
grit("static_resources") {
......
......@@ -55,7 +55,7 @@ library GaiaCredentialProviderLib
{
importlib("stdole2.tlb");
[
uuid(@GAIA_CREDENTIAL_PROVIDER_CLSID@),
uuid(PLACEHOLDER-GUID-89adae71-aee5-4ee2-bffb-e8424e06f519),
]
coclass GaiaCredentialProvider
{
......
......@@ -16,8 +16,8 @@ updater_clsid = "3d852661-c795-4d20-9b95-5561e9a1d2d9"
IUPDATER_IID = "D0E1CACC-C63C-4192-94AB-BF8EAD0E3B83"
midl("updater_idl_idl") {
dynamic_guid = "$UpdaterClass_replaceable_uuid=$updater_clsid," +
"$IUpdater_replaceable_uuid=$IUPDATER_IID"
dynamic_guids = "$UpdaterClass_replaceable_uuid=$updater_clsid," +
"$IUpdater_replaceable_uuid=$IUPDATER_IID"
header_file = "updater_idl.h"
sources = [ "updater_idl.template" ]
......
......@@ -176,24 +176,13 @@ source_set("unit_tests") {
]
}
action("generate_idl") {
script = "//build/util/version.py"
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),
]
}
RDP_DESKTOP_SESSION_PLACEHOLDER_CLSID =
"PLACEHOLDER-GUID-6741fd0a-6a8a-5838-a35e-8088697e2088"
midl("remoting_lib_idl") {
sources = get_target_outputs(":generate_idl")
dynamic_guid = rdp_desktop_session_clsid
deps = [ ":generate_idl" ]
sources = [ "chromoting_lib.templ" ]
dynamic_guids =
"$RDP_DESKTOP_SESSION_PLACEHOLDER_CLSID=$rdp_desktop_session_clsid"
writes_tlb = true
}
......@@ -218,8 +207,8 @@ config("MIDL_config") {
static_library("remoting_lib_ps") {
sources = [
"$root_gen_dir/remoting/host/win/chromoting_lib.dlldata.c",
"$root_gen_dir/remoting/host/win/chromoting_lib_p.c",
"$target_gen_dir/chromoting_lib.dlldata.c",
"$target_gen_dir/chromoting_lib_p.c",
]
configs -= [ "//build/config/compiler:chromium_code" ]
......
......@@ -61,7 +61,7 @@ library ChromotingLib {
importlib("stdole2.tlb");
[
uuid(@RDP_DESKTOP_SESSION_CLSID@),
uuid(PLACEHOLDER-GUID-6741fd0a-6a8a-5838-a35e-8088697e2088),
helpstring("RdpDesktopSession Class")
]
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