-
Notifications
You must be signed in to change notification settings - Fork 442
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove unnecessary external dependencies
- Loading branch information
1 parent
9cdb86c
commit 3175132
Showing
10 changed files
with
173 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 11 additions & 11 deletions
22
examples/crate_universe/complicated_dependencies/BUILD.bazel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
examples/crate_universe/complicated_dependencies/boringssl_utils.bzl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
"""BoringSSL Utils""" | ||
|
||
def _boringssl_build_script_dir_impl(ctx): | ||
output = ctx.actions.declare_directory(ctx.attr.out) | ||
|
||
ssl = ctx.file.ssl | ||
crypto = ctx.file.crypto | ||
|
||
inputs = depset([ssl, crypto]) | ||
|
||
ctx.actions.run( | ||
executable = ctx.executable._maker, | ||
oututs = [output], | ||
inputs = inputs, | ||
env = { | ||
"ARG_CRYPTO": crypto.path, | ||
"ARG_OUTPUT": output.path, | ||
"ARG_SSL": ssl.path, | ||
}, | ||
) | ||
|
||
return [DefaultInfo( | ||
files = depset([output]), | ||
runfiles = ctx.runfiles([output]), | ||
)] | ||
|
||
boringssl_build_script_dir = rule( | ||
doc = "A utility rule for building directories compatible with its `cargo_build_script` target.", | ||
implementation = _boringssl_build_script_dir_impl, | ||
attrs = { | ||
"crypto": attr.label( | ||
doc = "The `crypto`/`libcrypto` library.", | ||
allow_single_file = True, | ||
mandatory = True, | ||
), | ||
"out": attr.string( | ||
doc = "The name of the output directory.", | ||
mandatory = True, | ||
), | ||
"ssl": attr.label( | ||
doc = "The `ssl`/`libssl` library.", | ||
allow_single_file = True, | ||
mandatory = True, | ||
), | ||
"_maker": attr.label( | ||
cfg = "exec", | ||
executable = True, | ||
default = Label("//crate_universe/complicated_dependencies:build_script_dir_maker"), | ||
), | ||
}, | ||
) |
17 changes: 17 additions & 0 deletions
17
examples/crate_universe/complicated_dependencies/build_script_dir_maker.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//! A utility script for the "complicated dependencies" example. | ||
use std::{env, fs}; | ||
use std::path::PathBuf; | ||
|
||
fn main() { | ||
let ssl = PathBuf::from(env::var("ARG_SSL").unwrap()); | ||
let crypto = PathBuf::from(env::var("ARG_CRYPTO").unwrap()); | ||
let output = PathBuf::from(env::var("ARG_OUTPUT").unwrap()); | ||
|
||
let build_dir = output.join("build") | ||
|
||
fs::create_dir_all(&build_dir).unwrap(); | ||
|
||
fs::copy(ssl, build_dir.join(ssl.file_name().unwrap())).unwrap(); | ||
fs::copy(crypto, build_dir.join(crypto.file_name().unwrap())).unwrap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
"""Utility rules""" | ||
|
||
def _transition_platform_impl(_, attr): | ||
return {"//command_line_option:platforms": str(attr.platform)} | ||
|
||
_transition_platform = transition( | ||
implementation = _transition_platform_impl, | ||
inputs = [], | ||
outputs = ["//command_line_option:platforms"], | ||
) | ||
|
||
def _platform_transition_binary_impl(ctx): | ||
default_info = ctx.attr.binary[DefaultInfo] | ||
executable = ctx.executable.binary | ||
|
||
output = ctx.actions.declare_file("{}.{}".format(ctx.label.name, executable.extension).rstrip(".")) | ||
ctx.actions.symlink( | ||
output = output, | ||
target_file = executable, | ||
is_executable = True, | ||
) | ||
files = depset(direct = [executable], transitive = [default_info.files]) | ||
runfiles = ctx.runfiles([output, executable]).merge(default_info.default_runfiles) | ||
|
||
return [DefaultInfo( | ||
files = files, | ||
runfiles = runfiles, | ||
executable = output, | ||
)] | ||
|
||
platform_transition_binary = rule( | ||
doc = "Transitions a target to the provided platform.", | ||
implementation = _platform_transition_binary_impl, | ||
attrs = { | ||
"binary": attr.label( | ||
doc = "The target to transition", | ||
allow_single_file = True, | ||
cfg = _transition_platform, | ||
executable = True, | ||
), | ||
"platform": attr.label( | ||
doc = "The platform to transition to.", | ||
mandatory = True, | ||
), | ||
"_allowlist_function_transition": attr.label( | ||
default = "@bazel_tools//tools/allowlists/function_transition_allowlist", | ||
), | ||
}, | ||
executable = True, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
"""Utility rules""" | ||
|
||
def _transition_platform_impl(_, attr): | ||
return {"//command_line_option:platforms": str(attr.platform)} | ||
|
||
_transition_platform = transition( | ||
implementation = _transition_platform_impl, | ||
inputs = [], | ||
outputs = ["//command_line_option:platforms"], | ||
) | ||
|
||
def _platform_transition_filegroup_impl(ctx): | ||
files = [src[DefaultInfo].files for src in ctx.attr.srcs] | ||
runfiles = ctx.runfiles().merge_all([src[DefaultInfo].default_runfiles for src in ctx.attr.srcs]) | ||
|
||
return [DefaultInfo( | ||
files = files, | ||
runfiles = runfiles, | ||
)] | ||
|
||
platform_transition_filegroup = rule( | ||
doc = "Transitions a target to the provided platform.", | ||
implementation = _platform_transition_filegroup_impl, | ||
attrs = { | ||
"platform": attr.label( | ||
doc = "The platform to transition to.", | ||
mandatory = True, | ||
), | ||
"srcs": attr.label_list( | ||
doc = "The targets to transition", | ||
allow_files = True, | ||
cfg = _transition_platform, | ||
), | ||
"_allowlist_function_transition": attr.label( | ||
default = "@bazel_tools//tools/allowlists/function_transition_allowlist", | ||
), | ||
}, | ||
) |