diff options
author | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-24 02:08:39 +0000 |
---|---|---|
committer | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-24 02:08:39 +0000 |
commit | dbd8e4664da046faa5532eb69583158b3b2c191c (patch) | |
tree | 7c90340524cefd5c310cb926118559388bcb2c99 /net/tools | |
parent | 4dd01903cb5c1bb60bfb3682e80389f220ef1c90 (diff) | |
download | chromium_src-dbd8e4664da046faa5532eb69583158b3b2c191c.zip chromium_src-dbd8e4664da046faa5532eb69583158b3b2c191c.tar.gz chromium_src-dbd8e4664da046faa5532eb69583158b3b2c191c.tar.bz2 |
Have tld_cleanup generate a .cc file that contains the effective
tld data. This makes the build dependencies easier (helpful for
grit and gyp) and brings in the effective tld data on mac.
BUG=6076
Review URL: http://codereview.chromium.org/31004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10245 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/tools')
-rw-r--r-- | net/tools/tld_cleanup/README | 3 | ||||
-rw-r--r-- | net/tools/tld_cleanup/tld_cleanup.cc | 42 |
2 files changed, 35 insertions, 10 deletions
diff --git a/net/tools/tld_cleanup/README b/net/tools/tld_cleanup/README new file mode 100644 index 0000000..8eab5ee --- /dev/null +++ b/net/tools/tld_cleanup/README @@ -0,0 +1,3 @@ +When updating src/net/base/effective_tld_names.dat, re-run tld_cleanup which +will re-generate src/net/base/effective_tld_names.cc. Check in the updated +effective_tld_names.dat and effective_tld_names.cc together.
\ No newline at end of file diff --git a/net/tools/tld_cleanup/tld_cleanup.cc b/net/tools/tld_cleanup/tld_cleanup.cc index a33bce6..6595842 100644 --- a/net/tools/tld_cleanup/tld_cleanup.cc +++ b/net/tools/tld_cleanup/tld_cleanup.cc @@ -38,13 +38,26 @@ typedef std::set<std::string> StringSet; // been created with write access. bool WriteRules(const StringSet& rules, FilePath outfile) { std::string data; + data.append( + "// Copyright (c) 2009 The Chromium Authors. All rights reserved.\n" + "// Use of this source code is governed by a BSD-style license that\n" + "// can be found in the LICENSE file.\n\n" + "// This file is generated by net/tools/tld_cleanup/.\n" + "// DO NOT MANUALLY EDIT!\n" + "#include \"net/base/registry_controlled_domain.h\"\n\n" + "const char net::RegistryControlledDomainService::kDomainData[] =\n" + ); + for (StringSet::const_iterator iter = rules.begin(); iter != rules.end(); ++iter) { + data.append(" \""); data.append(*iter); - data.append("\n"); + data.append("\\n\"\n"); } + data.append(";\n"); + int written = file_util::WriteFile(outfile.ToWStringHack(), data.data(), data.size()); @@ -130,11 +143,11 @@ NormalizeResult NormalizeRule(std::string* rule) { // Loads the file described by 'in_filename', converts it to the desired format // (see the file comments above), and saves it into 'out_filename'. Returns // the most severe of the result codes encountered when normalizing the rules. -NormalizeResult NormalizeFile(const std::wstring& in_filename, - const std::wstring& out_filename) { +NormalizeResult NormalizeFile(const FilePath& in_filename, + const FilePath& out_filename) { std::string data; if (!file_util::ReadFileToString(in_filename, &data)) { - fwprintf(stderr, L"Unable to read file %ls\n", in_filename.c_str()); + LOG(ERROR) << "Unable to read file"; // We return success since we've already reported the error. return kSuccess; } @@ -181,8 +194,8 @@ NormalizeResult NormalizeFile(const std::wstring& in_filename, line_start = data.size(); } - if (!WriteRules(rules, FilePath::FromWStringHack(out_filename))) { - LOG(ERROR) << "Error(s) writing " << out_filename; + if (!WriteRules(rules, out_filename)) { + LOG(ERROR) << "Error(s) writing output file"; result = kError; } @@ -191,9 +204,9 @@ NormalizeResult NormalizeFile(const std::wstring& in_filename, int main(int argc, const char* argv[]) { base::EnableTerminationOnHeapCorruption(); - if (argc != 3) { + if (argc != 1) { fprintf(stderr, "Normalizes and verifies UTF-8 TLD data files\n"); - fprintf(stderr, "Usage: %s <input> <output>\n", argv[0]); + fprintf(stderr, "Usage: %s\n", argv[0]); return 1; } @@ -220,8 +233,17 @@ int main(int argc, const char* argv[]) { icu_util::Initialize(); - NormalizeResult result = NormalizeFile(UTF8ToWide(argv[1]), - UTF8ToWide(argv[2])); + FilePath input_file; + PathService::Get(base::DIR_SOURCE_ROOT, &input_file); + input_file = input_file.Append(FILE_PATH_LITERAL("net")) + .Append(FILE_PATH_LITERAL("base")) + .Append(FILE_PATH_LITERAL("effective_tld_names.dat")); + FilePath output_file; + PathService::Get(base::DIR_SOURCE_ROOT, &output_file); + output_file = output_file.Append(FILE_PATH_LITERAL("net")) + .Append(FILE_PATH_LITERAL("base")) + .Append(FILE_PATH_LITERAL("effective_tld_names.cc")); + NormalizeResult result = NormalizeFile(input_file, output_file); if (result != kSuccess) { fprintf(stderr, "Errors or warnings processing file. See log in tld_cleanup.log."); |