diff --git a/pw_libc/BUILD.gn b/pw_libc/BUILD.gn index 2ff58b11a7..9374463c87 100644 --- a/pw_libc/BUILD.gn +++ b/pw_libc/BUILD.gn @@ -53,7 +53,15 @@ config("no-shadow") { # pw_libc.a from llvm-libc. Otherwise, we create an empty pw_libc.a. if (dir_pw_third_party_llvm_libc != "") { pw_libc_source_set("stdlib") { - functions = [ "abs" ] + functions = [ + "abs", + "rand", + "srand", + ] + additional_srcs = [ "rand_util.cpp" ] + + # srand and rand are both tested in rand_test.cpp. + no_test_functions = [ "srand" ] } pw_libc_source_set("string") { diff --git a/third_party/llvm_libc/llvm_libc.gni b/third_party/llvm_libc/llvm_libc.gni index 05f80b052c..e9414408b9 100644 --- a/third_party/llvm_libc/llvm_libc.gni +++ b/third_party/llvm_libc/llvm_libc.gni @@ -31,6 +31,11 @@ template("pw_libc_source_set") { pw_source_set(target_name) { dir = target_dir + additional_srcs = [] + if (defined(invoker.additional_srcs)) { + additional_srcs = invoker.additional_srcs + } + include_dirs = [ dir_pw_third_party_llvm_libc ] defines = [ @@ -48,6 +53,7 @@ template("pw_libc_source_set") { "defines", "functions", "no_test_functions", + "additional_srcs", ]) public = [] @@ -57,6 +63,10 @@ template("pw_libc_source_set") { public += [ "$dir/$function.h" ] sources += [ "$dir/$function.cpp" ] } + + foreach(src, additional_srcs) { + sources += [ "$dir/$src" ] + } } pw_test("${source_set_target_name}_tests") { @@ -75,6 +85,7 @@ template("pw_libc_source_set") { "defines", "functions", "no_test_functions", + "additional_srcs", ]) sources = []