diff options
| author | Shinichiro Hamaji <shinichiro.hamaji@gmail.com> | 2017-08-11 17:26:42 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-08-11 17:26:42 +0900 |
| commit | a62b43673f4b937b5258b492399e4e8e3625ef61 (patch) | |
| tree | 6534e4a074bcfd50e188879247988bf5d3f4ea86 | |
| parent | 18ff00f914e7058cd51b4de8480b4a1c5263a39d (diff) | |
| parent | 7420d583c9e781aec066f3f6453c16e4c5ba35aa (diff) | |
| download | platform_build_kati-a62b43673f4b937b5258b492399e4e8e3625ef61.tar.gz platform_build_kati-a62b43673f4b937b5258b492399e4e8e3625ef61.tar.bz2 platform_build_kati-a62b43673f4b937b5258b492399e4e8e3625ef61.zip | |
Merge pull request #120 from danw/implicit_outputs
Support Ninja implicit outputs
| -rw-r--r-- | .travis.yml | 8 | ||||
| -rw-r--r-- | dep.cc | 5 | ||||
| -rw-r--r-- | dep.h | 1 | ||||
| -rw-r--r-- | ninja.cc | 16 | ||||
| -rw-r--r-- | testcase/ninja_implicit_outputs.sh | 39 |
5 files changed, 66 insertions, 3 deletions
diff --git a/.travis.yml b/.travis.yml index 3bbe280..9c14f63 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,18 @@ language: cpp +dist: trusty +sudo: required + compiler: - clang cache: apt before_script: - - sudo add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu/ trusty main universe" - sudo apt-get update -qq - - sudo apt-get install -y libstdc++-4.8-dev clang-3.5 ninja-build realpath + - sudo apt-get install -y realpath + - wget https://github.com/ninja-build/ninja/releases/download/v1.7.2/ninja-linux.zip + - unzip ninja-linux.zip -d ~/bin script: - make -j4 ckati ckati_tests @@ -239,6 +239,7 @@ DepNode::DepNode(Symbol o, bool p, bool r) is_restat(r), rule_vars(NULL), depfile_var(NULL), + implicit_outputs_var(NULL), ninja_pool_var(NULL), output_pattern(Symbol::IsUninitialized()) { g_dep_node_pool->push_back(this); @@ -254,6 +255,7 @@ class DepBuilder { implicit_rules_(new RuleTrie()), first_rule_(Symbol::IsUninitialized{}), depfile_var_name_(Intern(".KATI_DEPFILE")), + implicit_outputs_var_name_(Intern(".KATI_IMPLICIT_OUTPUTS")), ninja_pool_var_name_(Intern(".KATI_NINJA_POOL")) { ScopedTimeReporter tr("make dep (populate)"); PopulateRules(rules); @@ -616,6 +618,8 @@ class DepBuilder { if (name == depfile_var_name_) { n->depfile_var = new_var; + } else if (name == implicit_outputs_var_name_) { + n->implicit_outputs_var = new_var; } else if (name == ninja_pool_var_name_) { n->ninja_pool_var = new_var; } else { @@ -662,6 +666,7 @@ class DepBuilder { unordered_set<Symbol> phony_; unordered_set<Symbol> restat_; Symbol depfile_var_name_; + Symbol implicit_outputs_var_name_; Symbol ninja_pool_var_name_; }; @@ -45,6 +45,7 @@ struct DepNode { vector<Symbol> actual_order_only_inputs; Vars* rule_vars; Var* depfile_var; + Var* implicit_outputs_var; Var* ninja_pool_var; Symbol output_pattern; Loc loc; @@ -546,7 +546,21 @@ class NinjaGenerator { bool use_local_pool, ostringstream* o) { const DepNode* node = nn->node; string target = EscapeBuildTarget(node->output); - *o << "build " << target << ": " << rule_name; + *o << "build " << target; + if (node->implicit_outputs_var) { + string implicit_outputs; + node->implicit_outputs_var->Eval(ev_, &implicit_outputs); + + bool first = true; + for (StringPiece output : WordScanner(implicit_outputs)) { + if (first) { + *o << " |"; + first = false; + } + *o << " " << EscapeNinja(output.as_string()).c_str(); + } + } + *o << ": " << rule_name; vector<Symbol> order_onlys; if (node->is_phony) { *o << " _kati_always_build_"; diff --git a/testcase/ninja_implicit_outputs.sh b/testcase/ninja_implicit_outputs.sh new file mode 100644 index 0000000..eb9ef13 --- /dev/null +++ b/testcase/ninja_implicit_outputs.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# +# Copyright 2015 Google Inc. All rights reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -e + +mk="$@" + +cat <<EOF >Makefile +all: a b + +a b: + touch A + echo 1 >>A +c: .KATI_IMPLICIT_OUTPUTS := d +c: + touch C + echo 1 >>C +EOF + +$@ -j1 all c +if [ -e ninja.sh ]; then ./ninja.sh -j1 all d; fi + +echo "A:" +cat A +echo "C": +cat C |
