Chromium Code Reviews| Index: fusl/BUILD.gn |
| diff --git a/fusl/BUILD.gn b/fusl/BUILD.gn |
| index a352bcbc19e88b8e6c358b7889dbe09ab84f0390..a8a867f4e7a3ee52f6ab56707531d7f59daf78d3 100644 |
| --- a/fusl/BUILD.gn |
| +++ b/fusl/BUILD.gn |
| @@ -2,6 +2,9 @@ |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| +# Define the sysroot directory. |
| +sysroot = "$root_out_dir/sysroot" |
| + |
| config("fusl_config") { |
| cflags = [ |
| # Flags from musl |
| @@ -1467,10 +1470,13 @@ static_library("libc") { |
| deps += [ ":libc_${current_cpu}" ] |
| } |
| -# Build a sysroot. |
| -sysroot = "${target_out_dir}/sysroot/" |
| -sysroot_lib_dir = "${sysroot}/usr/lib" |
| -sysroot_include_dir = "${sysroot}/usr/include" |
| +static_library("libgcc_s") { |
|
viettrungluu
2016/02/01 21:15:55
What's this for?
kulakowski
2016/02/01 21:29:29
Will add comment.
|
| + complete_static_lib = true |
| +} |
| + |
| +static_library("libm") { |
|
viettrungluu
2016/02/01 21:15:55
I assume this is so "-lm" works? Could you add a c
kulakowski
2016/02/01 21:29:29
Ditto.
|
| + complete_static_lib = true |
| +} |
| template("copy_objects") { |
| assert(defined(invoker.input_dir), "input_dir must be defined") |
| @@ -1504,6 +1510,9 @@ template("copy_objects") { |
| } |
| } |
| +sysroot_lib_dir = "${sysroot}/usr/lib" |
| +sysroot_include_dir = "${sysroot}/usr/include" |
| + |
| copy_objects("copy_crt_objects") { |
| sources = [ |
| "Scrt1.o", |
| @@ -1548,34 +1557,86 @@ copy("copy_include_bits") { |
| ] |
| } |
| -copy("copy_libc") { |
| +copy("copy_libs") { |
| deps = [ |
| ":libc", |
| + ":libgcc_s", |
| + ":libm", |
| ] |
| sources = [ |
| "${target_out_dir}/libc.a", |
| + "${target_out_dir}/libgcc_s.a", |
| + "${target_out_dir}/libm.a", |
| ] |
| outputs = [ |
| - "${sysroot_lib_dir}/libc.a", |
| + "${sysroot_lib_dir}/{{source_name_part}}.a", |
| ] |
| } |
| -group("sysroot") { |
| +group("copy_sysroot") { |
| deps = [ |
| ":copy_crt_objects", |
| ":copy_include", |
| ":copy_include_bits", |
| - ":copy_libc", |
| + ":copy_libs", |
| ] |
| if (current_cpu == "x64") { |
| deps += [ ":copy_crt_x64_objects" ] |
| } |
| } |
| +action("finish_sysroot") { |
| + script = "tools/populate_crt.py" |
| + |
| + clang = "//third_party/llvm-build/Release+Asserts/bin/clang" |
| + target = "$sysroot/usr/lib" |
| + |
| + args = [ |
| + rebase_path(clang), |
| + rebase_path(target), |
| + ] |
| + |
| + outputs = [ |
| + "$target/crtbegin.o", |
| + "$target/crtend.o", |
| + "$target/libgcc.a", |
| + ] |
| + |
| + deps = [ |
| + ":copy_sysroot", |
| + ] |
| +} |
| + |
| +config("sysroot_config") { |
| + rebased_sysroot = rebase_path(sysroot) |
| + |
| + cflags = [ |
| + "--sysroot=$rebased_sysroot", |
| + "-fPIC", |
| + "-static", |
| + ] |
| + |
| + ldflags = [ "--sysroot=$rebased_sysroot" ] |
| +} |
| + |
| +executable("empty_main") { |
| + configs = [] |
| + configs += [ ":sysroot_config" ] |
| + |
| + sources = [ |
| + "test/empty_main.c", |
| + ] |
| + |
| + deps = [ |
| + ":finish_sysroot", |
| + ] |
| +} |
| + |
| group("fusl") { |
| deps = [ |
| - ":crt", |
| - ":libc", |
| - ":sysroot", |
| + ":crt(//build/toolchain/fusl:fusl_$current_cpu)", |
| + ":empty_main(//build/toolchain/fusl:fusl_$current_cpu)", |
| + ":finish_sysroot(//build/toolchain/fusl:fusl_$current_cpu)", |
| + ":libc(//build/toolchain/fusl:fusl_$current_cpu)", |
| ] |
| } |