Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: tools/gn/filesystem_utils.cc

Issue 2265833002: Implement `gn analyze`. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sample tests Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/filesystem_utils.h" 5 #include "tools/gn/filesystem_utils.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 747
748 return file_data == data; 748 return file_data == data;
749 } 749 }
750 750
751 bool WriteFileIfChanged(const base::FilePath& file_path, 751 bool WriteFileIfChanged(const base::FilePath& file_path,
752 const std::string& data, 752 const std::string& data,
753 Err* err) { 753 Err* err) {
754 if (ContentsEqual(file_path, data)) 754 if (ContentsEqual(file_path, data))
755 return true; 755 return true;
756 756
757 return WriteFile(file_path, data, err);
758 }
759
760 bool WriteFile(const base::FilePath& file_path, const std::string& data,
761 Err* err) {
757 // Create the directory if necessary. 762 // Create the directory if necessary.
758 if (!base::CreateDirectory(file_path.DirName())) { 763 if (!base::CreateDirectory(file_path.DirName())) {
759 if (err) { 764 if (err) {
760 *err = 765 *err =
761 Err(Location(), "Unable to create directory.", 766 Err(Location(), "Unable to create directory.",
762 "I was using \"" + FilePathToUTF8(file_path.DirName()) + "\"."); 767 "I was using \"" + FilePathToUTF8(file_path.DirName()) + "\".");
763 } 768 }
764 return false; 769 return false;
765 } 770 }
766 771
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 BuildDirContext(target), target->label().dir(), type); 902 BuildDirContext(target), target->label().dir(), type);
898 } 903 }
899 904
900 SourceDir GetScopeCurrentBuildDirAsSourceDir(const Scope* scope, 905 SourceDir GetScopeCurrentBuildDirAsSourceDir(const Scope* scope,
901 BuildDirType type) { 906 BuildDirType type) {
902 if (type == BuildDirType::TOOLCHAIN_ROOT) 907 if (type == BuildDirType::TOOLCHAIN_ROOT)
903 return GetBuildDirAsSourceDir(BuildDirContext(scope), type); 908 return GetBuildDirAsSourceDir(BuildDirContext(scope), type);
904 return GetSubBuildDirAsSourceDir( 909 return GetSubBuildDirAsSourceDir(
905 BuildDirContext(scope), scope->GetSourceDir(), type); 910 BuildDirContext(scope), scope->GetSourceDir(), type);
906 } 911 }
OLDNEW
« no previous file with comments | « tools/gn/filesystem_utils.h ('k') | tools/gn/gn.gyp » ('j') | tools/gn/gn.gyp » ('J')

Powered by Google App Engine
This is Rietveld 408576698