Skip to content

Commit

Permalink
[GN] Fix TargetPath in Visual Studio projects
Browse files Browse the repository at this point in the history
GN assumes that output_dir is root_build_dir for executables.
If that not so, Visual Studio can't find an executable to run and debug.
To fix it we are changing TargetPath field from $(ProjectName)$(TargetExt).
to exact path to ninja target output. Not sure about chromium, but it makes
sense for some standalone configurations

R=avakulenko@chromium.org, dpranke@chromium.org

Change-Id: Id9ccb7be96cc11f9504f4ea5a6e6117e1c55247b
Reviewed-on: https://chromium-review.googlesource.com/852459
Commit-Queue: agrieve <agrieve@chromium.org>
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
Reviewed-by: Bruce Dawson <brucedawson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#528626}
  • Loading branch information
samogot authored and Commit Bot committed Jan 11, 2018
1 parent 1f13273 commit e3ec639
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ Ion Rosca <rosca@adobe.com>
Irmak Kavasoglu <irmakkavasoglu@gmail.com>
Isaac Murchie <murchieisaac@gmail.com>
Isaac Reilly <reillyi@amazon.com>
Ivan Naydonov <samogot@gmail.com>
Ivan Sham <ivansham@amazon.com>
J. Ryan Stinnett <jryans@chromium.org>
Jack Bates <jack@nottheoilrig.com>
Expand Down
7 changes: 3 additions & 4 deletions tools/gn/visual_studio_writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,8 @@ bool VisualStudioWriter::WriteProjectFileContents(

project.SubElement("PropertyGroup", XmlAttributes("Label", "UserMacros"));

std::string ninja_target = GetNinjaTarget(target);

{
std::unique_ptr<XmlElementWriter> properties =
project.SubElement("PropertyGroup");
Expand All @@ -524,8 +526,7 @@ bool VisualStudioWriter::WriteProjectFileContents(
}
properties->SubElement("TargetName")->Text("$(ProjectName)");
if (target->output_type() != Target::GROUP) {
properties->SubElement("TargetPath")
->Text("$(OutDir)\\$(ProjectName)$(TargetExt)");
properties->SubElement("TargetPath")->Text("$(OutDir)\\" + ninja_target);
}
}

Expand Down Expand Up @@ -636,8 +637,6 @@ bool VisualStudioWriter::WriteProjectFileContents(
"$(VCTargetsPath)\\BuildCustomizations\\masm.targets"));
project.SubElement("ImportGroup", XmlAttributes("Label", "ExtensionTargets"));

std::string ninja_target = GetNinjaTarget(target);

{
std::unique_ptr<XmlElementWriter> build =
project.SubElement("Target", XmlAttributes("Name", "Build"));
Expand Down

0 comments on commit e3ec639

Please sign in to comment.