Initial Windows GN build
This change configures the Windows host target for GN. It should allow
building unit tests for the host.
Change-Id: Ib92c9a83b9b858a9b7ed55487199c63896580af1
diff --git a/pw_string/format_test.cc b/pw_string/format_test.cc
index 46c78eb..6344ad5 100644
--- a/pw_string/format_test.cc
+++ b/pw_string/format_test.cc
@@ -76,7 +76,7 @@
TEST(Format, ArgumentLargerThanBuffer_ReturnsResourceExhausted) {
char buffer[5];
- auto result = Format(buffer, "%s", "2big!");
+ auto result = Format(buffer, "%s%c", "2big", '!');
EXPECT_EQ(Status::RESOURCE_EXHAUSTED, result.status());
EXPECT_EQ(4u, result.size());
diff --git a/pw_toolchain/host_clang.gni b/pw_toolchain/host_clang.gni
index 2dd9577..491e3bc 100644
--- a/pw_toolchain/host_clang.gni
+++ b/pw_toolchain/host_clang.gni
@@ -151,15 +151,7 @@
_link_mapfile = "{{output_dir}}/{{target_output_name}}.map"
- if (host_os == "linux") {
- _link_flags += [
- # Output a map file that shows symbols and their location.
- "-Wl,-Map,$_link_mapfile",
-
- # Delete unreferenced sections. Helpful with -ffunction-sections.
- "-Wl,--gc-sections",
- ]
- } else if (host_os == "mac") {
+ if (host_os == "mac") {
_link_flags += [
# Output a map file that shows symbols and their location.
"-Wl,-map,$_link_mapfile",
@@ -167,6 +159,14 @@
# Delete unreferenced sections. Helpful with -ffunction-sections.
"-Wl,-dead_strip",
]
+ } else {
+ _link_flags += [
+ # Output a map file that shows symbols and their location.
+ "-Wl,-Map,$_link_mapfile",
+
+ # Delete unreferenced sections. Helpful with -ffunction-sections.
+ "-Wl,--gc-sections",
+ ]
}
_link_command = string_join(" ", _link_flags)
diff --git a/pw_toolchain/host_gcc.gni b/pw_toolchain/host_gcc.gni
index 211aa63..1d221ed 100644
--- a/pw_toolchain/host_gcc.gni
+++ b/pw_toolchain/host_gcc.gni
@@ -154,15 +154,7 @@
_link_mapfile = "{{output_dir}}/{{target_output_name}}.map"
- if (host_os == "linux") {
- _link_flags += [
- # Output a map file that shows symbols and their location.
- "-Wl,-Map,$_link_mapfile",
-
- # Delete unreferenced sections. Helpful with -ffunction-sections.
- "-Wl,--gc-sections",
- ]
- } else if (host_os == "mac") {
+ if (host_os == "mac") {
_link_flags += [
# Output a map file that shows symbols and their location.
"-Wl,-map,$_link_mapfile",
@@ -170,6 +162,14 @@
# Delete unreferenced sections. Helpful with -ffunction-sections.
"-Wl,-dead_strip",
]
+ } else {
+ _link_flags += [
+ # Output a map file that shows symbols and their location.
+ "-Wl,-Map,$_link_mapfile",
+
+ # Delete unreferenced sections. Helpful with -ffunction-sections.
+ "-Wl,--gc-sections",
+ ]
}
_link_command = string_join(" ", _link_flags)
diff --git a/targets/host/windows.gni b/targets/host/windows.gni
index 922cfb3..a35c9f4 100644
--- a/targets/host/windows.gni
+++ b/targets/host/windows.gni
@@ -15,3 +15,10 @@
import("host_common.gni")
pw_automatic_test_runner = get_path_info("run_test.bat", "abspath")
+
+pw_target_toolchain = "$dir_pw_toolchain:host_gcc_og"
+
+# This is here as bloaty_config_file cannot be an empty string or GN fails.
+# TODO(frolv): Add this file and enable size reports on Windows.
+pw_executable_config.bloaty_config_file =
+ get_path_info("windows.bloaty", "abspath")