OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "tools/gn/create_bundle_target_generator.h" | |
6 | |
7 #include "tools/gn/filesystem_utils.h" | |
8 #include "tools/gn/parse_tree.h" | |
9 #include "tools/gn/scope.h" | |
10 #include "tools/gn/substitution_type.h" | |
11 #include "tools/gn/target.h" | |
12 #include "tools/gn/value.h" | |
13 #include "tools/gn/variables.h" | |
14 | |
15 CreateBundleTargetGenerator::CreateBundleTargetGenerator( | |
16 Target* target, | |
17 Scope* scope, | |
18 const FunctionCallNode* function_call, | |
19 Err* err) : TargetGenerator(target, scope, function_call, err) {} | |
20 | |
21 CreateBundleTargetGenerator::~CreateBundleTargetGenerator() {} | |
22 | |
23 void CreateBundleTargetGenerator::DoRun() { | |
24 target_->set_output_type(Target::CREATE_BUNDLE); | |
25 | |
26 BundleData& bundle_data = target_->bundle_data(); | |
27 if (!GetBundleDir(std::string(), | |
28 variables::kBundleRootDir, | |
29 &bundle_data.root_dir())) | |
30 return; | |
31 if (!GetBundleDir(bundle_data.root_dir(), | |
32 variables::kBundleResourcesDir, | |
33 &bundle_data.resources_dir())) | |
34 return; | |
35 if (!GetBundleDir(bundle_data.root_dir(), | |
36 variables::kBundleExecutableDir, | |
37 &bundle_data.executable_dir())) | |
38 return; | |
39 if (!GetBundleDir(bundle_data.root_dir(), | |
40 variables::kBundlePlugInsDir, | |
41 &bundle_data.plugins_dir())) | |
42 return; | |
43 } | |
44 | |
45 bool CreateBundleTargetGenerator::GetBundleDir( | |
46 const std::string& bundle_root_dir, | |
47 const base::StringPiece& name, | |
48 std::string* bundle_dir) { | |
49 const Value* value = scope_->GetValue(name, true); | |
50 if (!value) | |
51 return true; | |
52 if (!value->VerifyTypeIs(Value::STRING, err_)) | |
53 return false; | |
54 const std::string& str = value->string_value(); | |
55 if (!EnsureStringIsInOutputDir(GetBuildSettings()->build_dir(), | |
56 str, value->origin(), err_)) | |
brettw
2016/03/07 21:57:30
Did clang indent this? I'd expect this to be moved
sdefresne
2016/03/08 14:33:30
No, I forgot to run "git cl format", fixed.
| |
57 return false; | |
58 if (str != bundle_root_dir && | |
59 !IsStringInOutputDir(SourceDir(bundle_root_dir), str)) { | |
60 *err_ = Err(value->origin(), "Path is not in bundle root dir.", | |
61 "The given file should be in the bundle root directory or below.\n" | |
62 "Normally you would do \"$bundle_root_dir/foo\". I interpreted this\n" | |
63 "as \"" + str + "\"."); | |
64 return false; | |
65 } | |
66 bundle_dir->assign(value->string_value()); | |
67 return true; | |
68 } | |
OLD | NEW |