mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Strip Linux binaries
We distribute some Linux binaries. It's useful for them to be small.
This commit is contained in:
parent
fc0c50b804
commit
ffd6a26ce9
@ -36,6 +36,10 @@ concurrent_links = exec_script("get_concurrent_links.py", [], "value")
|
||||
# - deps
|
||||
# Just forwarded to the toolchain definition.
|
||||
# - is_clang
|
||||
# - strip
|
||||
# Location of the strip executable. When specified, strip will be run on
|
||||
# all shared libraries and executables as they are built. The pre-stripped
|
||||
# artifacts will be put in lib.stripped/ and exe.stripped/.
|
||||
template("gcc_toolchain") {
|
||||
toolchain(target_name) {
|
||||
assert(defined(invoker.cc), "gcc_toolchain() must specify a \"cc\" value")
|
||||
@ -185,9 +189,21 @@ template("gcc_toolchain") {
|
||||
}
|
||||
|
||||
tool("link") {
|
||||
outfile = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}"
|
||||
exename = "{{target_output_name}}{{output_extension}}"
|
||||
outfile = "{{root_out_dir}}/$exename"
|
||||
rspfile = "$outfile.rsp"
|
||||
command = "$ld {{ldflags}} -o $outfile -Wl,--start-group @$rspfile {{solibs}} -Wl,--end-group $libs_section_prefix {{libs}} $libs_section_postfix"
|
||||
unstripped_outfile = outfile
|
||||
|
||||
if (defined(invoker.strip)) {
|
||||
unstripped_outfile = "{{root_out_dir}}/exe.unstripped/$exename"
|
||||
}
|
||||
|
||||
command = "$ld {{ldflags}} -o $unstripped_outfile -Wl,--start-group @$rspfile {{solibs}} -Wl,--end-group $libs_section_prefix {{libs}} $libs_section_postfix"
|
||||
if (defined(invoker.strip)) {
|
||||
strip = invoker.strip
|
||||
strip_command = "${strip} --strip-unneeded -o $outfile $unstripped_outfile"
|
||||
command += " && " + strip_command
|
||||
}
|
||||
if (defined(invoker.postlink)) {
|
||||
command += " && " + invoker.postlink
|
||||
}
|
||||
@ -196,6 +212,9 @@ template("gcc_toolchain") {
|
||||
outputs = [
|
||||
outfile,
|
||||
]
|
||||
if (outfile != unstripped_outfile) {
|
||||
outputs += [ unstripped_outfile ]
|
||||
}
|
||||
if (defined(invoker.link_outputs)) {
|
||||
outputs += invoker.link_outputs
|
||||
}
|
||||
|
||||
@ -80,6 +80,7 @@ gcc_toolchain("clang_x64") {
|
||||
nm = "nm"
|
||||
ar = "ar"
|
||||
ld = cxx
|
||||
strip = "strip"
|
||||
|
||||
toolchain_cpu = "x64"
|
||||
toolchain_os = "linux"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user