diff options
| author | colincross <ccross@android.com> | 2019-11-11 18:28:51 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-11-11 18:28:51 -0800 |
| commit | 89f56d726ab4d019b827079aeada95d80525301f (patch) | |
| tree | 135be6138af201aa14c8626e6e1d1eecee9dee2d | |
| parent | 9da3296746a0cd55b38ebebf91e7f57105a4c36f (diff) | |
| parent | c49ae30495420880d4bdf92c41b93bcbdca4536c (diff) | |
| download | platform_build_kati-89f56d726ab4d019b827079aeada95d80525301f.tar.gz platform_build_kati-89f56d726ab4d019b827079aeada95d80525301f.tar.bz2 platform_build_kati-89f56d726ab4d019b827079aeada95d80525301f.zip | |
Merge pull request #172 from colincross/default_pool
Add support for --default_pool in ninja mode
| -rw-r--r-- | flags.cc | 2 | ||||
| -rw-r--r-- | flags.h | 1 | ||||
| -rw-r--r-- | ninja.cc | 12 | ||||
| -rw-r--r-- | testcase/ninja_pool.sh | 65 |
4 files changed, 74 insertions, 6 deletions
@@ -161,6 +161,8 @@ void Flags::Parse(int argc, char** argv) { } else if (ParseCommandLineOptionWithArg("--writable", argv, &i, &writable_str)) { writable.push_back(writable_str); + } else if (ParseCommandLineOptionWithArg("--default_pool", argv, &i, + &default_pool)) { } else if (arg[0] == '-') { ERROR("Unknown flag: %s", arg); } else { @@ -55,6 +55,7 @@ struct Flags { bool warn_phony_looks_real; bool werror_phony_looks_real; bool werror_writable; + const char* default_pool; const char* goma_dir; const char* ignore_dirty_pattern; const char* no_ignore_dirty_pattern; @@ -570,10 +570,18 @@ class NinjaGenerator { } } *o << "\n"; + + string pool; if (node->ninja_pool_var) { - string pool; node->ninja_pool_var->Eval(ev_, &pool); - *o << " pool = " << pool << "\n"; + } + + if (pool != "") { + if (pool != "none") { + *o << " pool = " << pool << "\n"; + } + } else if (g_flags.default_pool) { + *o << " pool = " << g_flags.default_pool << "\n"; } else if (use_local_pool) { *o << " pool = local_pool\n"; } diff --git a/testcase/ninja_pool.sh b/testcase/ninja_pool.sh index 5fed8e4..4d3d15c 100644 --- a/testcase/ninja_pool.sh +++ b/testcase/ninja_pool.sh @@ -21,9 +21,23 @@ mk="$@" cat <<EOF > Makefile -test: .KATI_NINJA_POOL := test_pool -test: +test: test_pool test_none test_default test_blank + +test_pool: .KATI_NINJA_POOL := test_pool +test_pool: + echo "PASS" + +test_none: .KATI_NINJA_POOL := none +test_none: + echo "PASS" + +test_default: + echo "PASS" + +test_blank: .KATI_NINJA_POOL := +test_blank: echo "PASS" + EOF ${mk} 2>${log} @@ -32,12 +46,55 @@ if [ -e ninja.sh ]; then cat <<EOF > build.ninja pool test_pool depth = 1 +pool default_pool + depth = 1 include kati.ninja EOF ./ninja.sh fi if [ -e ninja.sh ]; then - if ! grep -q "pool = test_pool" kati.ninja; then - echo "Pool not present in build.ninja" + if ! grep -A1 "build test_pool:" kati.ninja | grep -q "pool = test_pool"; then + echo "test_pool not present for test_pool rule in build.ninja" + fi + if grep -A1 "build test_none:" kati.ninja | grep -q "pool ="; then + echo "unexpected pool present for test_none rule in build.ninja" + fi + if grep -A1 "build test_default:" kati.ninja | grep -q "pool ="; then + echo "unexpected pool present for test_default rule in build.ninja" + fi + if grep -A1 "build test_blank:" kati.ninja | grep -q "pool ="; then + echo "unexpected pool present for test_blank rule in build.ninja" + fi +fi + +args= +if ! echo "${mk}" | grep -qv "kati"; then + args=--default_pool=default_pool +fi + +${mk} ${args} 2>${log} +if [ -e ninja.sh ]; then + mv build.ninja kati.ninja + cat <<EOF > build.ninja +pool test_pool + depth = 1 +pool default_pool + depth = 1 +include kati.ninja +EOF + ./ninja.sh +fi +if [ -e ninja.sh ]; then + if ! grep -A1 "build test_pool:" kati.ninja | grep -q "pool = test_pool"; then + echo "test_pool not present for test_pool rule in build.ninja" + fi + if grep -A1 "build test_none:" kati.ninja | grep -q "pool = "; then + echo "unexpected pool present for test_none rule in build.ninja" + fi + if ! grep -A1 "build test_default:" kati.ninja | grep -q "pool = default_pool"; then + echo "default_pool not present for test_default rule in build.ninja" + fi + if ! grep -A1 "build test_blank:" kati.ninja | grep -q "pool = default_pool"; then + echo "default_pool not present for test_blank rule in build.ninja" fi fi |
