diff --git a/toolchain/clang.gni b/toolchain/clang.gni index 532f26b118c3184bfc2f106c17b05aa17bbdb368..5aab3f3a800121037f69e813a0d3b9f6b5f11421 100755 --- a/toolchain/clang.gni +++ b/toolchain/clang.gni @@ -62,33 +62,54 @@ template("clang_toolchain") { } tool("solink") { outfile = "{{output_dir}}/{{target_output_name}}{{output_extension}}" + stripped_outfile = outfile + rspfile = "$outfile.rsp" rspfile_content = "{{inputs}}" - command = "$ld -shared {{ldflags}} {{inputs}} {{libs}} -o $outfile" + command = "" if (need_strip) { - unstripped_outfile = outfile - command += " && $strip" + " \"$unstripped_outfile\" \"$outfile\"" + stripped_outfile = "{{output_dir}}/usr/lib/stripped/{{target_output_name}}{{output_extension}}" + command += "mkdir -p {{output_dir}}/usr/lib/stripped && " } + + command += "$ld -shared {{ldflags}} {{inputs}} {{libs}} -o $outfile" + if (need_strip) { + command += " && $strip \"$outfile\" \"$stripped_outfile\"" + } + default_output_extension = ".so" description = "SOLINK $outfile" default_output_dir = "{{root_out_dir}}" output_prefix = "lib" outputs = [ outfile ] + if (stripped_outfile != outfile) { + outputs += [ stripped_outfile ] + } } tool("link") { outfile = "{{output_dir}}/bin/{{target_output_name}}{{output_extension}}" + stripped_outfile = outfile + rspfile = "$outfile.rsp" custom_ld_flags = " " - command = + command = "" + if (need_strip) { + stripped_outfile = "{{output_dir}}/bin/stripped/{{target_output_name}}{{output_extension}}" + command += "mkdir -p {{output_dir}}/bin/stripped && " + } + command += "$cc {{ldflags}} {{inputs}} {{libs}} $custom_ld_flags -o $outfile" if (need_strip) { - command += " && $strip $outfile" + command += " && $strip \"$outfile\" \"$stripped_outfile\"" } description = "LLVM LINK $outfile" default_output_dir = "{{root_out_dir}}" rspfile_content = "{{inputs}}" outputs = [ outfile ] + if (stripped_outfile != outfile) { + outputs += [ stripped_outfile ] + } } tool("stamp") { if (host_os == "win") { diff --git a/toolchain/gcc.gni b/toolchain/gcc.gni index 5764933674191ed66252d5321ae420f649b8c282..e03908417292a1e50e35bc29615f3c7cca8abfc0 100755 --- a/toolchain/gcc.gni +++ b/toolchain/gcc.gni @@ -73,35 +73,54 @@ template("gcc_toolchain") { } tool("solink") { outfile = "{{output_dir}}/{{target_output_name}}{{output_extension}}" - rspfile = "{{output}}.rsp" + stripped_outfile = outfile + + rspfile = "$outfile.rsp" rspfile_content = "{{inputs}}" - command = + command = "" + if (need_strip) { + stripped_outfile = "{{output_dir}}/usr/lib/stripped/{{target_output_name}}{{output_extension}}" + command += "mkdir -p {{output_dir}}/usr/lib/stripped && " + } + command += "$ld -shared {{ldflags}} $extra_ldflags " + "-Wl,--start-group {{inputs}} {{libs}} -Wl,--end-group -o $outfile" if (need_strip) { - command += "&& $strip $outfile" + command += " && $strip \"$outfile\" -o \"$stripped_outfile\"" } description = "SOLINK $outfile" outputs = [ outfile ] - + if (stripped_outfile != outfile) { + outputs += [ stripped_outfile ] + } default_output_dir = "{{root_out_dir}}" default_output_extension = ".so" output_prefix = "lib" } tool("link") { outfile = "{{output_dir}}/bin/{{target_output_name}}{{output_extension}}" + stripped_outfile = outfile + rspfile = "$outfile.rsp" - command = + command = "" + if (need_strip) { + stripped_outfile = "{{output_dir}}/bin/stripped/{{target_output_name}}{{output_extension}}" + command += "mkdir -p {{output_dir}}/bin/stripped && " + } + command += "$ld {{ldflags}} $extra_ldflags " + "-Wl,--start-group {{inputs}} {{libs}} -Wl,--end-group -o $outfile " if (need_strip) { - command += "&& $strip $outfile" + command += " && $strip \"$outfile\" -o \"$stripped_outfile\"" } description = "LINK $outfile" default_output_dir = "{{root_out_dir}}" rspfile_content = "{{inputs}}" outputs = [ outfile ] + if (stripped_outfile != outfile) { + outputs += [ stripped_outfile ] + } } tool("stamp") { if (host_os == "win") {