From b1dd59d667223b8f9265d1158a18b863e06143ca Mon Sep 17 00:00:00 2001 From: Refael Ackermann Date: Sun, 5 Feb 2017 17:07:31 -0500 Subject: [PATCH] ninja: handle `CONFIGURATION_NAME` edge case icu-generic.gyp has the phrase `'../../<(CONFIGURATION_NAME)'` that doesn't resolve correctly in the generated ninja --- lib/gyp/generator/ninja/index.js | 2 ++ .../gyppies/configuration_name_hack/dep/dep.c | 3 +++ .../configuration_name_hack/dep/dep.gyp | 19 ++++++++++++++++++ test/gyppies/configuration_name_hack/dep2.c | 3 +++ test/gyppies/configuration_name_hack/main.c | 6 ++++++ test/gyppies/configuration_name_hack/test.gyp | 20 +++++++++++++++++++ 6 files changed, 53 insertions(+) create mode 100644 test/gyppies/configuration_name_hack/dep/dep.c create mode 100644 test/gyppies/configuration_name_hack/dep/dep.gyp create mode 100644 test/gyppies/configuration_name_hack/dep2.c create mode 100644 test/gyppies/configuration_name_hack/main.c create mode 100644 test/gyppies/configuration_name_hack/test.gyp diff --git a/lib/gyp/generator/ninja/index.js b/lib/gyp/generator/ninja/index.js index d02d360..124ead0 100644 --- a/lib/gyp/generator/ninja/index.js +++ b/lib/gyp/generator/ninja/index.js @@ -140,6 +140,8 @@ Ninja.prototype.expand = function expand(p, productDir) { p = p.replace(/\$!INTERMEDIATE_DIR/g, intDir); } + // First one is in order to outsmart silly GYP file writers + p = p.replace(/(\.\.[\\\/])+\$\|CONFIGURATION_NAME/g, productDir); p = p.replace(/\$\|CONFIGURATION_NAME/g, this.config); // TODO(indutny): do this at input diff --git a/test/gyppies/configuration_name_hack/dep/dep.c b/test/gyppies/configuration_name_hack/dep/dep.c new file mode 100644 index 0000000..4f26abf --- /dev/null +++ b/test/gyppies/configuration_name_hack/dep/dep.c @@ -0,0 +1,3 @@ +int x() { + return 42; +} diff --git a/test/gyppies/configuration_name_hack/dep/dep.gyp b/test/gyppies/configuration_name_hack/dep/dep.gyp new file mode 100644 index 0000000..1afd6f7 --- /dev/null +++ b/test/gyppies/configuration_name_hack/dep/dep.gyp @@ -0,0 +1,19 @@ +{ + "targets": [{ + "target_name": "copy_dep", + "type": "none", + "copies": [{ + "destination": "<(PRODUCT_DIR)", + "files": [ + "dep.c", + ], + }], + }, { + "target_name": "dep", + "type": "static_library", + "dependencies": [ "copy_dep" ], + "sources": [ + "../<(CONFIGURATION_NAME)/dep.c", + ], + }], +} diff --git a/test/gyppies/configuration_name_hack/dep2.c b/test/gyppies/configuration_name_hack/dep2.c new file mode 100644 index 0000000..5cae03a --- /dev/null +++ b/test/gyppies/configuration_name_hack/dep2.c @@ -0,0 +1,3 @@ +int y() { + return 42; +} diff --git a/test/gyppies/configuration_name_hack/main.c b/test/gyppies/configuration_name_hack/main.c new file mode 100644 index 0000000..52fd844 --- /dev/null +++ b/test/gyppies/configuration_name_hack/main.c @@ -0,0 +1,6 @@ +int x(); +int y(); + +int main() { + return (x() == 42 && y() == 42) ? 0 : 1; +} diff --git a/test/gyppies/configuration_name_hack/test.gyp b/test/gyppies/configuration_name_hack/test.gyp new file mode 100644 index 0000000..e485eea --- /dev/null +++ b/test/gyppies/configuration_name_hack/test.gyp @@ -0,0 +1,20 @@ +{ + "targets": [{ + "target_name": "copy_dep2", + "type": "none", + "copies": [{ + "destination": "<(PRODUCT_DIR)", + "files": [ + "dep2.c", + ], + }], + }, { + "target_name": "test", + "type": "executable", + "dependencies": [ "dep/dep.gyp:dep", "copy_dep2" ], + "sources": [ + "out/<(CONFIGURATION_NAME)/dep2.c", + "main.c", + ], + }], +}