[GN] Use basename for PRODUCT_NAME in Xcode project.
Per Xcode's build settings documentation:
Product Name (PRODUCT_NAME)
This is the basename of the product generated by the target.
The original code uses full path as the PRODUCT_NAME, so this CL
changes it to use only the basename.
Bug:
Change-Id: Idee0603a7d032866057f9a73c15f153a13ea97bd
Reviewed-on: https://chromium-review.googlesource.com/746945
Reviewed-by: Sylvain Defresne <sdefresne@chromium.org>
Commit-Queue: Yuke Liao <liaoyuke@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#513514}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 8d849d4ce22ab76ade95c8215d71857e789d0150
diff --git a/tools/gn/xcode_object.cc b/tools/gn/xcode_object.cc
index 8a31470..17d82e5 100644
--- a/tools/gn/xcode_object.cc
+++ b/tools/gn/xcode_object.cc
@@ -742,10 +742,18 @@
std::string(), output_name,
type.empty() ? GetSourceType(ext) : type)));
- size_t ext_offset = FindExtensionOffset(output_name);
+ // Per Xcode build settings documentation: Product Name (PRODUCT_NAME) should
+ // the basename of the product generated by the target.
+ // Therefore, take the basename of output name without file extension as the
+ // "PRODUCT_NAME".
+ size_t basename_offset = FindFilenameOffset(output_name);
+ std::string output_basename = basename_offset != std::string::npos
+ ? output_name.substr(basename_offset)
+ : output_name;
+ size_t ext_offset = FindExtensionOffset(output_basename);
std::string product_name = ext_offset != std::string::npos
- ? output_name.substr(0, ext_offset - 1)
- : output_name;
+ ? output_basename.substr(0, ext_offset - 1)
+ : output_basename;
PBXAttributes attributes = extra_attributes;
attributes["CODE_SIGNING_REQUIRED"] = "NO";