| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Helper tool that is built and run during a build to pull strings from | 5 // Helper tool that is built and run during a build to pull strings from |
| 6 // the GRD files and generate the InfoPlist.strings files needed for | 6 // the GRD files and generate the InfoPlist.strings files needed for |
| 7 // Mac OS X app bundles. | 7 // Mac OS X app bundles. |
| 8 | 8 |
| 9 #import <Foundation/Foundation.h> | 9 #import <Foundation/Foundation.h> |
| 10 #include <stdint.h> | 10 #include <stdint.h> |
| 11 #include <stdio.h> | 11 #include <stdio.h> |
| 12 #include <unistd.h> | 12 #include <unistd.h> |
| 13 | 13 |
| 14 #include <memory> | 14 #include <memory> |
| 15 | 15 |
| 16 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
| 17 #include "base/files/file_util.h" | 17 #include "base/files/file_util.h" |
| 18 #include "base/i18n/icu_util.h" |
| 18 #include "base/i18n/message_formatter.h" | 19 #include "base/i18n/message_formatter.h" |
| 19 #include "base/mac/scoped_nsautorelease_pool.h" | 20 #include "base/mac/scoped_nsautorelease_pool.h" |
| 20 #include "base/strings/string_piece.h" | 21 #include "base/strings/string_piece.h" |
| 21 #include "base/strings/string_util.h" | 22 #include "base/strings/string_util.h" |
| 22 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
| 23 #include "base/strings/sys_string_conversions.h" | 24 #include "base/strings/sys_string_conversions.h" |
| 24 #include "base/time/time.h" | 25 #include "base/time/time.h" |
| 25 #include "chrome/grit/chromium_strings.h" | 26 #include "chrome/grit/chromium_strings.h" |
| 26 #include "ui/base/resource/data_pack.h" | 27 #include "ui/base/resource/data_pack.h" |
| 27 | 28 |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 CHECK_ARG(!output_dir, "Missing path to write InfoPlist.strings files"); | 204 CHECK_ARG(!output_dir, "Missing path to write InfoPlist.strings files"); |
| 204 CHECK_ARG(!branding_strings_name, "Missing branding strings file name"); | 205 CHECK_ARG(!branding_strings_name, "Missing branding strings file name"); |
| 205 CHECK_ARG(argc == 0, "Missing language list"); | 206 CHECK_ARG(argc == 0, "Missing language list"); |
| 206 CHECK_ARG((strcmp(app_type, kAppType_Main) != 0 && | 207 CHECK_ARG((strcmp(app_type, kAppType_Main) != 0 && |
| 207 strcmp(app_type, kAppType_Helper) != 0), | 208 strcmp(app_type, kAppType_Helper) != 0), |
| 208 "Unknown app type"); | 209 "Unknown app type"); |
| 209 | 210 |
| 210 char* const* lang_list = argv; | 211 char* const* lang_list = argv; |
| 211 int lang_list_count = argc; | 212 int lang_list_count = argc; |
| 212 | 213 |
| 214 base::i18n::InitializeICU(); |
| 215 |
| 213 // Parse the version file and build our string | 216 // Parse the version file and build our string |
| 214 NSString* version_string = ApplicationVersionString(version_file_path); | 217 NSString* version_string = ApplicationVersionString(version_file_path); |
| 215 if (!version_string) { | 218 if (!version_string) { |
| 216 fprintf(stderr, "ERROR: failed to get a version string"); | 219 fprintf(stderr, "ERROR: failed to get a version string"); |
| 217 exit(1); | 220 exit(1); |
| 218 } | 221 } |
| 219 | 222 |
| 220 NSFileManager* fm = [NSFileManager defaultManager]; | 223 NSFileManager* fm = [NSFileManager defaultManager]; |
| 221 | 224 |
| 222 for (int loop = 0; loop < lang_list_count; ++loop) { | 225 for (int loop = 0; loop < lang_list_count; ++loop) { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 [output_path stringByAppendingPathComponent:@"InfoPlist.strings"]; | 326 [output_path stringByAppendingPathComponent:@"InfoPlist.strings"]; |
| 324 if (![strings_file_contents_utf8 writeToFile:output_path | 327 if (![strings_file_contents_utf8 writeToFile:output_path |
| 325 atomically:YES]) { | 328 atomically:YES]) { |
| 326 fprintf(stderr, "ERROR: Failed to write out '%s'\n", | 329 fprintf(stderr, "ERROR: Failed to write out '%s'\n", |
| 327 [output_path UTF8String]); | 330 [output_path UTF8String]); |
| 328 exit(1); | 331 exit(1); |
| 329 } | 332 } |
| 330 } | 333 } |
| 331 return 0; | 334 return 0; |
| 332 } | 335 } |
| OLD | NEW |