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/xcode_writer.h" | 5 #include "tools/gn/xcode_writer.h" |
6 | 6 |
7 #include <iomanip> | 7 #include <iomanip> |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <sstream> | 10 #include <sstream> |
(...skipping 24 matching lines...) Expand all Loading... |
35 const Value* target_os_value = args.GetArgOverride(variables::kTargetOs); | 35 const Value* target_os_value = args.GetArgOverride(variables::kTargetOs); |
36 if (target_os_value) { | 36 if (target_os_value) { |
37 if (target_os_value->type() == Value::STRING) { | 37 if (target_os_value->type() == Value::STRING) { |
38 if (target_os_value->string_value() == "ios") | 38 if (target_os_value->string_value() == "ios") |
39 return XcodeWriter::WRITER_TARGET_OS_IOS; | 39 return XcodeWriter::WRITER_TARGET_OS_IOS; |
40 } | 40 } |
41 } | 41 } |
42 return XcodeWriter::WRITER_TARGET_OS_MACOS; | 42 return XcodeWriter::WRITER_TARGET_OS_MACOS; |
43 } | 43 } |
44 | 44 |
45 std::string GetArchs(const Args& args) { | |
46 const Value* target_cpu_value = args.GetArgOverride(variables::kTargetCpu); | |
47 if (target_cpu_value) { | |
48 if (target_cpu_value->type() == Value::STRING) { | |
49 if (target_cpu_value->string_value() == "x86") | |
50 return "i386"; | |
51 if (target_cpu_value->string_value() == "x64") | |
52 return "x86_64"; | |
53 if (target_cpu_value->string_value() == "arm") | |
54 return "armv7"; | |
55 if (target_cpu_value->string_value() == "armv7") | |
56 return "armv7"; | |
57 if (target_cpu_value->string_value() == "arm64") | |
58 return "armv64"; | |
59 } | |
60 } | |
61 return "x86_64"; | |
62 } | |
63 | |
64 std::string GetBuildScript(const std::string& target_name, | 45 std::string GetBuildScript(const std::string& target_name, |
65 const std::string& build_path, | 46 const std::string& build_path, |
66 const std::string& ninja_extra_args) { | 47 const std::string& ninja_extra_args) { |
67 std::stringstream script; | 48 std::stringstream script; |
68 script << "echo note: \"Compile and copy " << target_name << " via ninja\"\n" | 49 script << "echo note: \"Compile and copy " << target_name << " via ninja\"\n" |
69 << "exec "; | 50 << "exec "; |
70 if (!build_path.empty()) | 51 if (!build_path.empty()) |
71 script << "env PATH=\"" << build_path << "\" "; | 52 script << "env PATH=\"" << build_path << "\" "; |
72 script << "ninja -C ."; | 53 script << "ninja -C ."; |
73 if (!ninja_extra_args.empty()) | 54 if (!ninja_extra_args.empty()) |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 const XcodeWriter::TargetOsType target_os = | 131 const XcodeWriter::TargetOsType target_os = |
151 GetTargetOs(build_settings->build_args()); | 132 GetTargetOs(build_settings->build_args()); |
152 | 133 |
153 PBXAttributes attributes; | 134 PBXAttributes attributes; |
154 switch (target_os) { | 135 switch (target_os) { |
155 case XcodeWriter::WRITER_TARGET_OS_IOS: | 136 case XcodeWriter::WRITER_TARGET_OS_IOS: |
156 attributes["SDKROOT"] = "iphoneos"; | 137 attributes["SDKROOT"] = "iphoneos"; |
157 attributes["TARGETED_DEVICE_FAMILY"] = "1,2"; | 138 attributes["TARGETED_DEVICE_FAMILY"] = "1,2"; |
158 break; | 139 break; |
159 case XcodeWriter::WRITER_TARGET_OS_MACOS: | 140 case XcodeWriter::WRITER_TARGET_OS_MACOS: |
160 attributes["ARCHS"] = GetArchs(build_settings->build_args()); | 141 attributes["SDKROOT"] = "macosx"; |
161 attributes["SDKROOT"] = "macosx10.11"; | |
162 break; | 142 break; |
163 } | 143 } |
164 | 144 |
165 const std::string source_path = | 145 const std::string source_path = |
166 base::FilePath::FromUTF8Unsafe( | 146 base::FilePath::FromUTF8Unsafe( |
167 RebasePath("//", build_settings->build_dir())) | 147 RebasePath("//", build_settings->build_dir())) |
168 .StripTrailingSeparators() | 148 .StripTrailingSeparators() |
169 .AsUTF8Unsafe(); | 149 .AsUTF8Unsafe(); |
170 | 150 |
171 std::string config_name = build_settings->build_dir() | 151 std::string config_name = build_settings->build_dir() |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 for (auto* object : pair.second) { | 401 for (auto* object : pair.second) { |
422 object->Print(out, 2); | 402 object->Print(out, 2); |
423 } | 403 } |
424 out << "/* End " << ToString(pair.first) << " section */\n"; | 404 out << "/* End " << ToString(pair.first) << " section */\n"; |
425 } | 405 } |
426 | 406 |
427 out << "\t};\n" | 407 out << "\t};\n" |
428 << "\trootObject = " << project->Reference() << ";\n" | 408 << "\trootObject = " << project->Reference() << ";\n" |
429 << "}\n"; | 409 << "}\n"; |
430 } | 410 } |
OLD | NEW |