Skip to content

Commit 56756ea

Browse files
committed
src: fix multi-output-actions bug in make
1 parent 949e8bb commit 56756ea

File tree

6 files changed

+150
-145
lines changed

6 files changed

+150
-145
lines changed

pylib/gyp/MakefileWriter.py

Lines changed: 119 additions & 116 deletions
Large diffs are not rendered by default.

test/actions-multiple-outputs-with-dependencies/gyptest-action.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# found in the LICENSE file.
66

77
"""
8-
Verifies actions with multiple outputs & dependncies will correctly rebuild.
8+
Verifies actions with multiple outputs & dependencies will correctly rebuild.
99
1010
This is a regression test for crrev.com/1177163002.
1111
"""
@@ -17,10 +17,6 @@
1717
import sys
1818
import time
1919

20-
if sys.platform in ('darwin', 'win32'):
21-
print("This test is currently disabled: https://crbug.com/483696.")
22-
sys.exit(0)
23-
2420
test = TestGyp.TestGyp()
2521

2622
TESTDIR='relocate/src'
@@ -30,6 +26,7 @@
3026
def build_and_check(content):
3127
test.write(TESTDIR + '/input.txt', content)
3228
test.build('action.gyp', 'upper', chdir=TESTDIR)
29+
test.up_to_date('action.gyp', 'upper', chdir=TESTDIR)
3330
test.built_file_must_match('result.txt', content, chdir=TESTDIR)
3431

3532
build_and_check('Content for first build.')

test/actions-multiple-outputs-with-dependencies/src/action.gyp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,20 @@
1717
{
1818
'target_name': 'lower',
1919
'type': 'none',
20-
'actions': [{
21-
'action_name': 'lower_action',
22-
'inputs': ['input.txt'],
23-
'outputs': ['<(PRODUCT_DIR)/out1.txt', '<(PRODUCT_DIR)/out2.txt'],
24-
'action': ['python', 'rcopy.py', '<@(_inputs)', '<@(_outputs)'],
25-
}],
20+
'actions': [
21+
{
22+
'action_name': 'lower_action',
23+
'external': 'true',
24+
'inputs': ['input.txt'],
25+
'outputs': ['<(PRODUCT_DIR)/out1.txt', '<(PRODUCT_DIR)/out2.txt'],
26+
'action': ['python', 'rcopy.py', '<@(_inputs)', '<@(_outputs)'],
27+
},
28+
{
29+
'action_name': 'lower_action2',
30+
'inputs': ['input.txt'],
31+
'outputs': ['<(PRODUCT_DIR)/out2.1.txt'],
32+
'action': ['python', 'rcopy.py', '<@(_inputs)', '<@(_outputs)'],
33+
}],
2634
},
2735
],
2836
}
Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,9 @@
1-
#!/usr/bin/env python
2-
3-
# Copyright (c) 2015 Google Inc. All rights reserved.
4-
# Use of this source code is governed by a BSD-style license that can be
5-
# found in the LICENSE file.
6-
71
"""
82
Verifies actions with multiple outputs will correctly rebuild.
93
"""
104

11-
from __future__ import print_function
12-
135
import TestGyp
146
import os
15-
import sys
16-
17-
if sys.platform == 'win32':
18-
print("This test is currently disabled: https://crbug.com/483696.")
19-
sys.exit(0)
207

218
test = TestGyp.TestGyp()
229

@@ -28,6 +15,7 @@
2815
def build_and_check():
2916
# Build + check that both outputs exist.
3017
test.build('multiple-outputs.gyp', chdir=chdir)
18+
test.up_to_date('action.gyp', chdir=chdir)
3119
test.built_file_must_exist('out1.txt', chdir=chdir)
3220
test.built_file_must_exist('out2.txt', chdir=chdir)
3321

@@ -36,10 +24,10 @@ def build_and_check():
3624

3725
# Remove either + rebuild. Both should exist (again).
3826
os.remove(test.built_file_path('out1.txt', chdir=chdir))
39-
build_and_check();
27+
build_and_check()
4028

4129
# Remove the other + rebuild. Both should exist (again).
4230
os.remove(test.built_file_path('out2.txt', chdir=chdir))
43-
build_and_check();
31+
build_and_check()
4432

4533
test.pass_test()

test/actions-multiple-outputs/src/multiple-outputs.gyp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
'actions': [
1111
{
1212
'action_name': 'action1',
13+
'external': 'true',
1314
'inputs': [],
1415
'outputs': [
1516
'<(PRODUCT_DIR)/out1.txt',

test/lib/TestGyp.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,22 @@ def match_modulo_line_numbers(contents_a, contents_b):
5454
return TestCommon.match_exact(contents_a, contents_b)
5555

5656

57-
def mk_temp_dir(workdir):
57+
def mk_temp_dir(workdir, hint=''):
5858
# Put test output in out/testworkarea by default.
5959
# Use temporary names so there are no collisions.
6060
workdir = workdir or 'testworkarea'
6161
workdir = os.path.join('out', workdir)
6262
# Create work area if it doesn't already exist.
6363
if not os.path.isdir(workdir):
6464
os.makedirs(workdir)
65-
return tempfile.mktemp(prefix='testgyp.', dir=workdir)
65+
if hint:
66+
slug = re.sub(r'[/.\\]', '_', hint)
67+
dir_name = os.path.join(workdir, slug)
68+
if os.path.exists(dir_name):
69+
shutil.rmtree(dir_name)
70+
return dir_name
71+
else:
72+
return tempfile.mktemp(prefix='testgyp.', dir=workdir)
6673

6774

6875
@contextmanager
@@ -131,7 +138,8 @@ def __init__(self, gyp=None, **kw):
131138
if 'description' not in kw:
132139
bt = [t[0] for t in traceback.extract_stack() if 'gyptest' in t[0]]
133140
kw['description'] = bt and bt.pop()
134-
kw['workdir'] = mk_temp_dir(kw.get('workdir'))
141+
kw_workdir = kw.get('workdir')
142+
kw['workdir'] = mk_temp_dir(kw_workdir, kw['description'])
135143
kw_formats = kw.pop('formats', [])
136144

137145
if not gyp:

0 commit comments

Comments
 (0)