OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "tools/gn/visual_studio_utils.h" | 5 #include "tools/gn/visual_studio_utils.h" |
6 | 6 |
| 7 #include <vector> |
| 8 |
7 #include "base/md5.h" | 9 #include "base/md5.h" |
| 10 #include "base/strings/string_split.h" |
8 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
9 | 12 |
10 CompilerOptions::CompilerOptions() = default; | 13 CompilerOptions::CompilerOptions() = default; |
11 | 14 |
12 CompilerOptions::~CompilerOptions() = default; | 15 CompilerOptions::~CompilerOptions() = default; |
13 | 16 |
| 17 LinkerOptions::LinkerOptions() = default; |
| 18 |
| 19 LinkerOptions::~LinkerOptions() = default; |
| 20 |
14 std::string MakeGuid(const std::string& entry_path, const std::string& seed) { | 21 std::string MakeGuid(const std::string& entry_path, const std::string& seed) { |
15 std::string str = base::ToUpperASCII(base::MD5String(seed + entry_path)); | 22 std::string str = base::ToUpperASCII(base::MD5String(seed + entry_path)); |
16 return '{' + str.substr(0, 8) + '-' + str.substr(8, 4) + '-' + | 23 return '{' + str.substr(0, 8) + '-' + str.substr(8, 4) + '-' + |
17 str.substr(12, 4) + '-' + str.substr(16, 4) + '-' + | 24 str.substr(12, 4) + '-' + str.substr(16, 4) + '-' + |
18 str.substr(20, 12) + '}'; | 25 str.substr(20, 12) + '}'; |
19 } | 26 } |
20 | 27 |
21 #define SetOption(condition, member, value) \ | 28 #define SetOption(condition, member, value) \ |
22 if (condition) { \ | 29 if (condition) { \ |
23 options->member = value; \ | 30 options->member = value; \ |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 case 'w': | 115 case 'w': |
109 AppendOption(cflag.size() > 3 && cflag[2] == 'd', | 116 AppendOption(cflag.size() > 3 && cflag[2] == 'd', |
110 disable_specific_warnings, cflag.substr(3), ';') | 117 disable_specific_warnings, cflag.substr(3), ';') |
111 break; | 118 break; |
112 } | 119 } |
113 } | 120 } |
114 | 121 |
115 // Put everything else into additional_options. | 122 // Put everything else into additional_options. |
116 options->additional_options += cflag + ' '; | 123 options->additional_options += cflag + ' '; |
117 } | 124 } |
| 125 |
| 126 // Parses |ldflags| value and stores it in |options|. |
| 127 void ParseLinkerOption(const std::string& ldflag, LinkerOptions* options) { |
| 128 const char kSubsytemPrefix[] ="/SUBSYSTEM:"; |
| 129 if (base::StartsWith(ldflag, kSubsytemPrefix, |
| 130 base::CompareCase::SENSITIVE)) { |
| 131 const std::string subsystem( |
| 132 ldflag.begin() + std::string(kSubsytemPrefix).length(), |
| 133 ldflag.end()); |
| 134 const std::vector<std::string> tokens = base::SplitString( |
| 135 subsystem, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
| 136 if (!tokens.empty()) |
| 137 options->subsystem = tokens[0]; |
| 138 } |
| 139 } |
OLD | NEW |