mirror of
				https://bitbucket.org/chromiumembedded/cef
				synced 2025-06-05 21:39:12 +02:00 
			
		
		
		
	- Headers that are included by .rc files need to be supplied to `declare_exe` via the `resources_deps` attribute (passed as the `deps attribute to `compile_rc`). The headers must be part of a cc_library target via either the `hdrs` or `srcs` attribute. - File paths for CEF resources are prefixed with "external/<repo>" when CEF is loaded as an external repo. Update `copy_filegroups` to work with these paths.
		
			
				
	
	
		
			66 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			66 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
# Copyright (c) 2024 The Chromium Embedded Framework Authors. All rights
 | 
						|
# reserved. Use of this source code is governed by a BSD-style license that
 | 
						|
# can be found in the LICENSE file.
 | 
						|
 | 
						|
def _copy_filegroups_impl(ctx):
 | 
						|
    inputs = ctx.files.filegroups
 | 
						|
    remove_prefixes = ctx.attr.remove_prefixes
 | 
						|
    add_prefix = ctx.attr.add_prefix
 | 
						|
 | 
						|
    outputs = []
 | 
						|
    for f in inputs:
 | 
						|
        relative_path = f.path
 | 
						|
        if relative_path.startswith("external/"):
 | 
						|
          # Remove the "external/<repo>" component, if any.
 | 
						|
          relative_path = "/".join(relative_path.split("/")[2:])
 | 
						|
 | 
						|
        for prefix in remove_prefixes:
 | 
						|
            # Add trailing forward slash if necessary.
 | 
						|
            if prefix[-1] != "/":
 | 
						|
                prefix += "/"
 | 
						|
            if len(prefix) > 0 and relative_path.startswith(prefix):
 | 
						|
                relative_path = relative_path[len(prefix):]
 | 
						|
                break
 | 
						|
 | 
						|
        if len(add_prefix) > 0:
 | 
						|
            # Add trailing forward slash if necessary.
 | 
						|
            if add_prefix[-1] != "/":
 | 
						|
                add_prefix += "/"
 | 
						|
            relative_path = add_prefix + relative_path
 | 
						|
 | 
						|
        out = ctx.actions.declare_file(relative_path)
 | 
						|
        outputs.append(out)
 | 
						|
 | 
						|
        if relative_path.find("/") > 0:
 | 
						|
            command="mkdir -p $(dirname {}) && cp {} {}".format(out.path, f.path, out.path)
 | 
						|
        else:
 | 
						|
            command="cp {} {}".format(f.path, out.path)
 | 
						|
 | 
						|
        ctx.actions.run_shell(
 | 
						|
            outputs=[out],
 | 
						|
            inputs=depset([f]),
 | 
						|
            command=command
 | 
						|
        )
 | 
						|
 | 
						|
    # Small sanity check
 | 
						|
    if len(inputs) != len(outputs):
 | 
						|
        fail("Output count should be 1-to-1 with input count.")
 | 
						|
 | 
						|
    return DefaultInfo(
 | 
						|
        files=depset(outputs),
 | 
						|
        runfiles=ctx.runfiles(files=outputs)
 | 
						|
    )
 | 
						|
 | 
						|
# Allows the file contents of |filegroups| to be copied next to a cc_binary
 | 
						|
# target via the |data| attribute.
 | 
						|
# Implementation based on https://stackoverflow.com/a/57983629
 | 
						|
copy_filegroups = rule(
 | 
						|
    implementation=_copy_filegroups_impl,
 | 
						|
    attrs={
 | 
						|
        "filegroups": attr.label_list(),
 | 
						|
        "remove_prefixes": attr.string_list(default = []),
 | 
						|
        "add_prefix": attr.string(default = ""),
 | 
						|
    },
 | 
						|
)
 | 
						|
 |