mirror of https://github.com/lukechilds/node.git
Ben Noordhuis
13 years ago
527 changed files with 20547 additions and 334 deletions
@ -0,0 +1,307 @@ |
|||
[MASTER] |
|||
|
|||
# Specify a configuration file. |
|||
#rcfile= |
|||
|
|||
# Python code to execute, usually for sys.path manipulation such as |
|||
# pygtk.require(). |
|||
#init-hook= |
|||
|
|||
# Profiled execution. |
|||
profile=no |
|||
|
|||
# Add files or directories to the blacklist. They should be base names, not |
|||
# paths. |
|||
ignore=CVS |
|||
|
|||
# Pickle collected data for later comparisons. |
|||
persistent=yes |
|||
|
|||
# List of plugins (as comma separated values of python modules names) to load, |
|||
# usually to register additional checkers. |
|||
load-plugins= |
|||
|
|||
|
|||
[MESSAGES CONTROL] |
|||
|
|||
# Enable the message, report, category or checker with the given id(s). You can |
|||
# either give multiple identifier separated by comma (,) or put this option |
|||
# multiple time. |
|||
#enable= |
|||
|
|||
# Disable the message, report, category or checker with the given id(s). You |
|||
# can either give multiple identifier separated by comma (,) or put this option |
|||
# multiple time (only on the command line, not in the configuration file where |
|||
# it should appear only once). |
|||
# C0103: Invalid name "NN" (should match [a-z_][a-z0-9_]{2,30}$) |
|||
# C0111: Missing docstring |
|||
# C0302: Too many lines in module (NN) |
|||
# R0902: Too many instance attributes (N/7) |
|||
# R0903: Too few public methods (N/2) |
|||
# R0904: Too many public methods (NN/20) |
|||
# R0912: Too many branches (NN/12) |
|||
# R0913: Too many arguments (N/5) |
|||
# R0914: Too many local variables (NN/15) |
|||
# R0915: Too many statements (NN/50) |
|||
# W0141: Used builtin function 'map' |
|||
# W0142: Used * or ** magic |
|||
# W0232: Class has no __init__ method |
|||
# W0511: TODO |
|||
# W0603: Using the global statement |
|||
# |
|||
# These should be enabled eventually: |
|||
# C0112: Empty docstring |
|||
# C0301: Line too long (NN/80) |
|||
# C0321: More than one statement on single line |
|||
# C0322: Operator not preceded by a space |
|||
# C0323: Operator not followed by a space |
|||
# C0324: Comma not followed by a space |
|||
# E0101: Explicit return in __init__ |
|||
# E0102: function already defined line NN |
|||
# E1002: Use of super on an old style class |
|||
# E1101: Instance of 'XX' has no 'YY' member |
|||
# E1103: Instance of 'XX' has no 'XX' member (but some types could not be inferred) |
|||
# E0602: Undefined variable 'XX' |
|||
# F0401: Unable to import 'XX' |
|||
# R0201: Method could be a function |
|||
# R0801: Similar lines in N files |
|||
# W0102: Dangerous default value {} as argument |
|||
# W0104: Statement seems to have no effect |
|||
# W0105: String statement has no effect |
|||
# W0108: Lambda may not be necessary |
|||
# W0201: Attribute 'XX' defined outside __init__ |
|||
# W0212: Access to a protected member XX of a client class |
|||
# W0221: Arguments number differs from overridden method |
|||
# W0223: Method 'XX' is abstract in class 'YY' but is not overridden |
|||
# W0231: __init__ method from base class 'XX' is not called |
|||
# W0301: Unnecessary semicolon |
|||
# W0311: Bad indentation. Found NN spaces, expected NN |
|||
# W0401: Wildcard import XX |
|||
# W0402: Uses of a deprecated module 'string' |
|||
# W0403: Relative import 'XX', should be 'YY.XX' |
|||
# W0404: Reimport 'XX' (imported line NN) |
|||
# W0601: Global variable 'XX' undefined at the module level |
|||
# W0602: Using global for 'XX' but no assignment is done |
|||
# W0611: Unused import pprint |
|||
# W0612: Unused variable 'XX' |
|||
# W0613: Unused argument 'XX' |
|||
# W0614: Unused import XX from wildcard import |
|||
# W0621: Redefining name 'XX' from outer scope (line NN) |
|||
# W0622: Redefining built-in 'NN' |
|||
# W0631: Using possibly undefined loop variable 'XX' |
|||
# W0701: Raising a string exception |
|||
# W0702: No exception type(s) specified |
|||
disable=C0103,C0111,C0302,R0902,R0903,R0904,R0912,R0913,R0914,R0915,W0141,W0142,W0232,W0511,W0603,C0112,C0301,C0321,C0322,C0323,C0324,E0101,E0102,E1002,E1101,E1103,E0602,F0401,R0201,R0801,W0102,W0104,W0105,W0108,W0201,W0212,W0221,W0223,W0231,W0301,W0311,W0401,W0402,W0403,W0404,W0601,W0602,W0611,W0612,W0613,W0614,W0621,W0622,W0631,W0701,W0702 |
|||
|
|||
|
|||
[REPORTS] |
|||
|
|||
# Set the output format. Available formats are text, parseable, colorized, msvs |
|||
# (visual studio) and html |
|||
output-format=text |
|||
|
|||
# Include message's id in output |
|||
include-ids=yes |
|||
|
|||
# Put messages in a separate file for each module / package specified on the |
|||
# command line instead of printing them on stdout. Reports (if any) will be |
|||
# written in a file name "pylint_global.[txt|html]". |
|||
files-output=no |
|||
|
|||
# Tells whether to display a full report or only the messages |
|||
reports=no |
|||
|
|||
# Python expression which should return a note less than 10 (10 is the highest |
|||
# note). You have access to the variables errors warning, statement which |
|||
# respectively contain the number of errors / warnings messages and the total |
|||
# number of statements analyzed. This is used by the global evaluation report |
|||
# (RP0004). |
|||
evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) |
|||
|
|||
# Add a comment according to your evaluation note. This is used by the global |
|||
# evaluation report (RP0004). |
|||
comment=no |
|||
|
|||
|
|||
[VARIABLES] |
|||
|
|||
# Tells whether we should check for unused import in __init__ files. |
|||
init-import=no |
|||
|
|||
# A regular expression matching the beginning of the name of dummy variables |
|||
# (i.e. not used). |
|||
dummy-variables-rgx=_|dummy |
|||
|
|||
# List of additional names supposed to be defined in builtins. Remember that |
|||
# you should avoid to define new builtins when possible. |
|||
additional-builtins= |
|||
|
|||
|
|||
[TYPECHECK] |
|||
|
|||
# Tells whether missing members accessed in mixin class should be ignored. A |
|||
# mixin class is detected if its name ends with "mixin" (case insensitive). |
|||
ignore-mixin-members=yes |
|||
|
|||
# List of classes names for which member attributes should not be checked |
|||
# (useful for classes with attributes dynamically set). |
|||
ignored-classes=SQLObject |
|||
|
|||
# When zope mode is activated, add a predefined set of Zope acquired attributes |
|||
# to generated-members. |
|||
zope=no |
|||
|
|||
# List of members which are set dynamically and missed by pylint inference |
|||
# system, and so shouldn't trigger E0201 when accessed. Python regular |
|||
# expressions are accepted. |
|||
generated-members=REQUEST,acl_users,aq_parent |
|||
|
|||
|
|||
[MISCELLANEOUS] |
|||
|
|||
# List of note tags to take in consideration, separated by a comma. |
|||
notes=FIXME,XXX,TODO |
|||
|
|||
|
|||
[SIMILARITIES] |
|||
|
|||
# Minimum lines number of a similarity. |
|||
min-similarity-lines=4 |
|||
|
|||
# Ignore comments when computing similarities. |
|||
ignore-comments=yes |
|||
|
|||
# Ignore docstrings when computing similarities. |
|||
ignore-docstrings=yes |
|||
|
|||
|
|||
[FORMAT] |
|||
|
|||
# Maximum number of characters on a single line. |
|||
max-line-length=80 |
|||
|
|||
# Maximum number of lines in a module |
|||
max-module-lines=1000 |
|||
|
|||
# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 |
|||
# tab). |
|||
indent-string=' ' |
|||
|
|||
|
|||
[BASIC] |
|||
|
|||
# Required attributes for module, separated by a comma |
|||
required-attributes= |
|||
|
|||
# List of builtins function names that should not be used, separated by a comma |
|||
bad-functions=map,filter,apply,input |
|||
|
|||
# Regular expression which should only match correct module names |
|||
module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ |
|||
|
|||
# Regular expression which should only match correct module level names |
|||
const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$ |
|||
|
|||
# Regular expression which should only match correct class names |
|||
class-rgx=[A-Z_][a-zA-Z0-9]+$ |
|||
|
|||
# Regular expression which should only match correct function names |
|||
function-rgx=[a-z_][a-z0-9_]{2,30}$ |
|||
|
|||
# Regular expression which should only match correct method names |
|||
method-rgx=[a-z_][a-z0-9_]{2,30}$ |
|||
|
|||
# Regular expression which should only match correct instance attribute names |
|||
attr-rgx=[a-z_][a-z0-9_]{2,30}$ |
|||
|
|||
# Regular expression which should only match correct argument names |
|||
argument-rgx=[a-z_][a-z0-9_]{2,30}$ |
|||
|
|||
# Regular expression which should only match correct variable names |
|||
variable-rgx=[a-z_][a-z0-9_]{2,30}$ |
|||
|
|||
# Regular expression which should only match correct list comprehension / |
|||
# generator expression variable names |
|||
inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ |
|||
|
|||
# Good variable names which should always be accepted, separated by a comma |
|||
good-names=i,j,k,ex,Run,_ |
|||
|
|||
# Bad variable names which should always be refused, separated by a comma |
|||
bad-names=foo,bar,baz,toto,tutu,tata |
|||
|
|||
# Regular expression which should only match functions or classes name which do |
|||
# not require a docstring |
|||
no-docstring-rgx=__.*__ |
|||
|
|||
|
|||
[DESIGN] |
|||
|
|||
# Maximum number of arguments for function / method |
|||
max-args=5 |
|||
|
|||
# Argument names that match this expression will be ignored. Default to name |
|||
# with leading underscore |
|||
ignored-argument-names=_.* |
|||
|
|||
# Maximum number of locals for function / method body |
|||
max-locals=15 |
|||
|
|||
# Maximum number of return / yield for function / method body |
|||
max-returns=6 |
|||
|
|||
# Maximum number of branch for function / method body |
|||
max-branchs=12 |
|||
|
|||
# Maximum number of statements in function / method body |
|||
max-statements=50 |
|||
|
|||
# Maximum number of parents for a class (see R0901). |
|||
max-parents=7 |
|||
|
|||
# Maximum number of attributes for a class (see R0902). |
|||
max-attributes=7 |
|||
|
|||
# Minimum number of public methods for a class (see R0903). |
|||
min-public-methods=2 |
|||
|
|||
# Maximum number of public methods for a class (see R0904). |
|||
max-public-methods=20 |
|||
|
|||
|
|||
[CLASSES] |
|||
|
|||
# List of interface methods to ignore, separated by a comma. This is used for |
|||
# instance to not check methods defines in Zope's Interface base class. |
|||
ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by |
|||
|
|||
# List of method names used to declare (i.e. assign) instance attributes. |
|||
defining-attr-methods=__init__,__new__,setUp |
|||
|
|||
# List of valid names for the first argument in a class method. |
|||
valid-classmethod-first-arg=cls |
|||
|
|||
|
|||
[IMPORTS] |
|||
|
|||
# Deprecated modules which should not be used, separated by a comma |
|||
deprecated-modules=regsub,string,TERMIOS,Bastion,rexec |
|||
|
|||
# Create a graph of every (i.e. internal and external) dependencies in the |
|||
# given file (report RP0402 must not be disabled) |
|||
import-graph= |
|||
|
|||
# Create a graph of external dependencies in the given file (report RP0402 must |
|||
# not be disabled) |
|||
ext-import-graph= |
|||
|
|||
# Create a graph of internal dependencies in the given file (report RP0402 must |
|||
# not be disabled) |
|||
int-import-graph= |
|||
|
|||
|
|||
[EXCEPTIONS] |
|||
|
|||
# Exceptions that will emit a warning when being caught. Defaults to |
|||
# "Exception" |
|||
overgeneral-exceptions=Exception |
@ -0,0 +1,23 @@ |
|||
#!/usr/bin/env python |
|||
|
|||
# Copyright (c) 2009 Google Inc. All rights reserved. |
|||
# Use of this source code is governed by a BSD-style license that can be |
|||
# found in the LICENSE file. |
|||
|
|||
""" |
|||
Verifies actions which are not depended on by other targets get executed. |
|||
""" |
|||
|
|||
import TestGyp |
|||
|
|||
test = TestGyp.TestGyp() |
|||
|
|||
test.run_gyp('bare.gyp', chdir='src') |
|||
test.relocate('src', 'relocate/src') |
|||
test.build('bare.gyp', chdir='relocate/src') |
|||
|
|||
file_content = 'Hello from bare.py\n' |
|||
|
|||
test.built_file_must_match('out.txt', file_content, chdir='relocate/src') |
|||
|
|||
test.pass_test() |
@ -0,0 +1,25 @@ |
|||
# Copyright (c) 2009 Google Inc. All rights reserved. |
|||
# Use of this source code is governed by a BSD-style license that can be |
|||
# found in the LICENSE file. |
|||
|
|||
{ |
|||
'targets': [ |
|||
{ |
|||
'target_name': 'bare', |
|||
'type': 'none', |
|||
'actions': [ |
|||
{ |
|||
'action_name': 'action1', |
|||
'inputs': [ |
|||
'bare.py', |
|||
], |
|||
'outputs': [ |
|||
'<(PRODUCT_DIR)/out.txt', |
|||
], |
|||
'action': ['python', 'bare.py', '<(PRODUCT_DIR)/out.txt'], |
|||
'msvs_cygwin_shell': 0, |
|||
}, |
|||
], |
|||
}, |
|||
], |
|||
} |
@ -0,0 +1,11 @@ |
|||
#!/usr/bin/env python |
|||
|
|||
# Copyright (c) 2009 Google Inc. All rights reserved. |
|||
# Use of this source code is governed by a BSD-style license that can be |
|||
# found in the LICENSE file. |
|||
|
|||
import sys |
|||
|
|||
f = open(sys.argv[1], 'wb') |
|||
f.write('Hello from bare.py\n') |
|||
f.close() |
@ -0,0 +1,42 @@ |
|||
#!/usr/bin/env python |
|||
|
|||
# Copyright (c) 2011 Google Inc. All rights reserved. |
|||
# Use of this source code is governed by a BSD-style license that can be |
|||
# found in the LICENSE file. |
|||
|
|||
""" |
|||
Verifies two actions can be attached to the same input files. |
|||
""" |
|||
|
|||
import TestGyp |
|||
|
|||
test = TestGyp.TestGyp() |
|||
|
|||
test.run_gyp('actions.gyp', chdir='src') |
|||
|
|||
test.relocate('src', 'relocate/src') |
|||
|
|||
# Test that two actions can be attached to the same inputs. |
|||
test.build('actions.gyp', test.ALL, chdir='relocate/src') |
|||
test.must_contain('relocate/src/output1.txt', 'hello there') |
|||
test.must_contain('relocate/src/output2.txt', 'hello there') |
|||
test.must_contain('relocate/src/output3.txt', 'hello there') |
|||
test.must_contain('relocate/src/output4.txt', 'hello there') |
|||
|
|||
# Test that process_outputs_as_sources works in conjuction with merged |
|||
# actions. |
|||
test.run_built_executable( |
|||
'multiple_action_source_filter', |
|||
chdir='relocate/src', |
|||
stdout=( |
|||
'{\n' |
|||
'bar\n' |
|||
'car\n' |
|||
'dar\n' |
|||
'ear\n' |
|||
'}\n' |
|||
), |
|||
) |
|||
|
|||
|
|||
test.pass_test() |
@ -0,0 +1,165 @@ |
|||
# Copyright (c) 2011 Google Inc. All rights reserved. |
|||
# Use of this source code is governed by a BSD-style license that can be |
|||
# found in the LICENSE file. |
|||
|
|||
{ |
|||
'variables': { |
|||
# Have a long string so that actions will exceed xp 512 character |
|||
# command limit on xp. |
|||
'long_string': |
|||
'abcdefghijklmnopqrstuvwxyz0123456789' |
|||
'abcdefghijklmnopqrstuvwxyz0123456789' |
|||
'abcdefghijklmnopqrstuvwxyz0123456789' |
|||
'abcdefghijklmnopqrstuvwxyz0123456789' |
|||
'abcdefghijklmnopqrstuvwxyz0123456789' |
|||
'abcdefghijklmnopqrstuvwxyz0123456789' |
|||
'abcdefghijklmnopqrstuvwxyz0123456789' |
|||
'abcdefghijklmnopqrstuvwxyz0123456789' |
|||
'abcdefghijklmnopqrstuvwxyz0123456789' |
|||
'abcdefghijklmnopqrstuvwxyz0123456789' |
|||
'abcdefghijklmnopqrstuvwxyz0123456789' |
|||
}, |
|||
'targets': [ |
|||
{ |
|||
'target_name': 'multiple_action_target', |
|||
'type': 'none', |
|||
'actions': [ |
|||
{ |
|||
'action_name': 'action1', |
|||
'inputs': [ |
|||
'copy.py', |
|||
'input.txt', |
|||
], |
|||
'outputs': [ |
|||
'output1.txt', |
|||
], |
|||
'action': [ |
|||
'python', '<@(_inputs)', '<(_outputs)', '<(long_string)', |
|||
], |
|||
# Allows the test to run without hermetic cygwin on windows. |
|||
'msvs_cygwin_shell': 0, |
|||
}, |
|||
{ |
|||
'action_name': 'action2', |
|||
'inputs': [ |
|||
'copy.py', |
|||
'input.txt', |
|||
], |
|||
'outputs': [ |
|||
'output2.txt', |
|||
], |
|||
'action': [ |
|||
'python', '<@(_inputs)', '<(_outputs)', '<(long_string)', |
|||
], |
|||
# Allows the test to run without hermetic cygwin on windows. |
|||
'msvs_cygwin_shell': 0, |
|||
}, |
|||
{ |
|||
'action_name': 'action3', |
|||
'inputs': [ |
|||
'copy.py', |
|||
'input.txt', |
|||
], |
|||
'outputs': [ |
|||
'output3.txt', |
|||
], |
|||
'action': [ |
|||
'python', '<@(_inputs)', '<(_outputs)', '<(long_string)', |
|||
], |
|||
# Allows the test to run without hermetic cygwin on windows. |
|||
'msvs_cygwin_shell': 0, |
|||
}, |
|||
{ |
|||
'action_name': 'action4', |
|||
'inputs': [ |
|||
'copy.py', |
|||
'input.txt', |
|||
], |
|||
'outputs': [ |
|||
'output4.txt', |
|||
], |
|||
'action': [ |
|||
'python', '<@(_inputs)', '<(_outputs)', '<(long_string)', |
|||
], |
|||
# Allows the test to run without hermetic cygwin on windows. |
|||
'msvs_cygwin_shell': 0, |
|||
}, |
|||
], |
|||
}, |
|||
{ |
|||
'target_name': 'multiple_action_source_filter', |
|||
'type': 'executable', |
|||
'sources': [ |
|||
'main.c', |
|||
# TODO(bradnelson): add foo.c here once this issue is fixed: |
|||
# http://code.google.com/p/gyp/issues/detail?id=175 |
|||
], |
|||
'actions': [ |
|||
{ |
|||
'action_name': 'action1', |
|||
'inputs': [ |
|||
'foo.c', |
|||
'filter.py', |
|||
], |
|||
'outputs': [ |
|||
'<(INTERMEDIATE_DIR)/output1.c', |
|||
], |
|||
'process_outputs_as_sources': 1, |
|||
'action': [ |
|||
'python', 'filter.py', 'foo', 'bar', 'foo.c', '<@(_outputs)', |
|||
], |
|||
# Allows the test to run without hermetic cygwin on windows. |
|||
'msvs_cygwin_shell': 0, |
|||
}, |
|||
{ |
|||
'action_name': 'action2', |
|||
'inputs': [ |
|||
'foo.c', |
|||
'filter.py', |
|||
], |
|||
'outputs': [ |
|||
'<(INTERMEDIATE_DIR)/output2.c', |
|||
], |
|||
'process_outputs_as_sources': 1, |
|||
'action': [ |
|||
'python', 'filter.py', 'foo', 'car', 'foo.c', '<@(_outputs)', |
|||
], |
|||
# Allows the test to run without hermetic cygwin on windows. |
|||
'msvs_cygwin_shell': 0, |
|||
}, |
|||
{ |
|||
'action_name': 'action3', |
|||
'inputs': [ |
|||
'foo.c', |
|||
'filter.py', |
|||
], |
|||
'outputs': [ |
|||
'<(INTERMEDIATE_DIR)/output3.c', |
|||
], |
|||
'process_outputs_as_sources': 1, |
|||
'action': [ |
|||
'python', 'filter.py', 'foo', 'dar', 'foo.c', '<@(_outputs)', |
|||
], |
|||
# Allows the test to run without hermetic cygwin on windows. |
|||
'msvs_cygwin_shell': 0, |
|||
}, |
|||
{ |
|||
'action_name': 'action4', |
|||
'inputs': [ |
|||
'foo.c', |
|||
'filter.py', |
|||
], |
|||
'outputs': [ |
|||
'<(INTERMEDIATE_DIR)/output4.c', |
|||
], |
|||
'process_outputs_as_sources': 1, |
|||
'action': [ |
|||
'python', 'filter.py', 'foo', 'ear', 'foo.c', '<@(_outputs)', |
|||
], |
|||
# Allows the test to run without hermetic cygwin on windows. |
|||
'msvs_cygwin_shell': 0, |
|||
}, |
|||
], |
|||
}, |
|||
], |
|||
} |
@ -0,0 +1,9 @@ |
|||
#!/usr/bin/env python |
|||
# Copyright (c) 2011 Google Inc. All rights reserved. |
|||
# Use of this source code is governed by a BSD-style license that can be |
|||
# found in the LICENSE file. |
|||
|
|||
import shutil |
|||
import sys |
|||
|
|||
shutil.copyfile(sys.argv[1], sys.argv[2]) |
@ -0,0 +1,12 @@ |
|||
#!/usr/bin/env python |
|||
# Copyright (c) 2011 Google Inc. All rights reserved. |
|||
# Use of this source code is governed by a BSD-style license that can be |
|||
# found in the LICENSE file. |
|||
|
|||
|
|||
import sys |
|||
|
|||
data = open(sys.argv[3], 'r').read() |
|||
fh = open(sys.argv[4], 'w') |
|||
fh.write(data.replace(sys.argv[1], sys.argv[2])) |
|||
fh.close() |
@ -0,0 +1,11 @@ |
|||
/*
|
|||
* Copyright (c) 2011 Google Inc. All rights reserved. |
|||
* Use of this source code is governed by a BSD-style license that can be |
|||
* found in the LICENSE file. |
|||
*/ |
|||
|
|||
#include <stdio.h> |
|||
|
|||
void foo(void) { |
|||
printf("foo\n"); |
|||
} |
@ -0,0 +1 @@ |
|||
hello there |
@ -0,0 +1,22 @@ |
|||
/*
|
|||
* Copyright (c) 2011 Google Inc. All rights reserved. |
|||
* Use of this source code is governed by a BSD-style license that can be |
|||
* found in the LICENSE file. |
|||
*/ |
|||
|
|||
#include <stdio.h> |
|||
|
|||
void bar(void); |
|||
void car(void); |
|||
void dar(void); |
|||
void ear(void); |
|||
|
|||
int main() { |
|||
printf("{\n"); |
|||
bar(); |
|||
car(); |
|||
dar(); |
|||
ear(); |
|||
printf("}\n"); |
|||
return 0; |
|||
} |
@ -0,0 +1,26 @@ |
|||
#!/usr/bin/env python |
|||
|
|||
# Copyright (c) 2009 Google Inc. All rights reserved. |
|||
# Use of this source code is governed by a BSD-style license that can be |
|||
# found in the LICENSE file. |
|||
|
|||
""" |
|||
Test actions that output to PRODUCT_DIR. |
|||
""" |
|||
|
|||
import TestGyp |
|||
|
|||
# TODO fix this for xcode: http://code.google.com/p/gyp/issues/detail?id=88 |
|||
test = TestGyp.TestGyp(formats=['!xcode']) |
|||
|
|||
test.run_gyp('none.gyp', chdir='src') |
|||
|
|||
test.build('none.gyp', test.ALL, chdir='src') |
|||
|
|||
file_content = 'Hello from make-file.py\n' |
|||
subdir_file_content = 'Hello from make-subdir-file.py\n' |
|||
|
|||
test.built_file_must_match('file.out', file_content, chdir='src') |
|||
test.built_file_must_match('subdir_file.out', subdir_file_content, chdir='src') |
|||
|
|||
test.pass_test() |
@ -0,0 +1,11 @@ |
|||
#!/usr/bin/env python |
|||
|
|||
# Copyright (c) 2009 Google Inc. All rights reserved. |
|||
# Use of this source code is governed by a BSD-style license that can be |
|||
# found in the LICENSE file. |
|||
|
|||
import sys |
|||
|
|||
contents = 'Hello from make-file.py\n' |
|||
|
|||
open(sys.argv[1], 'wb').write(contents) |
@ -0,0 +1,31 @@ |
|||
# Copyright (c) 2009 Google Inc. All rights reserved. |
|||
# Use of this source code is governed by a BSD-style license that can be |
|||
# found in the LICENSE file. |
|||
|
|||
{ |
|||
'targets': [ |
|||
{ |
|||
'target_name': 'file', |
|||
'type': 'none', |
|||
'msvs_cygwin_shell': 0, |
|||
'actions': [ |
|||
{ |
|||
'action_name': 'make-file', |
|||
'inputs': [ |
|||
'make-file.py', |
|||
], |
|||
'outputs': [ |
|||
'<(PRODUCT_DIR)/file.out', |
|||
], |
|||
'action': [ |
|||
'python', '<(_inputs)', '<@(_outputs)', |
|||
], |
|||
'process_outputs_as_sources': 1, |
|||
} |
|||
], |
|||
'dependencies': [ |
|||
'subdir/subdir.gyp:subdir_file', |
|||
], |
|||
}, |
|||
], |
|||
} |
@ -0,0 +1,11 @@ |
|||
#!/usr/bin/env python |
|||
|
|||
# Copyright (c) 2009 Google Inc. All rights reserved. |
|||
# Use of this source code is governed by a BSD-style license that can be |
|||
# found in the LICENSE file. |
|||
|
|||
import sys |
|||
|
|||
contents = 'Hello from make-subdir-file.py\n' |
|||
|
|||
open(sys.argv[1], 'wb').write(contents) |
@ -0,0 +1,28 @@ |
|||
# Copyright (c) 2009 Google Inc. All rights reserved. |
|||
# Use of this source code is governed by a BSD-style license that can be |
|||
# found in the LICENSE file. |
|||
|
|||
{ |
|||
'targets': [ |
|||
{ |
|||
'target_name': 'subdir_file', |
|||
'type': 'none', |
|||
'msvs_cygwin_shell': 0, |
|||
'actions': [ |
|||
{ |
|||
'action_name': 'make-subdir-file', |
|||
'inputs': [ |
|||
'make-subdir-file.py', |
|||
], |
|||
'outputs': [ |
|||
'<(PRODUCT_DIR)/subdir_file.out', |
|||
], |
|||
'action': [ |
|||
'python', '<(_inputs)', '<@(_outputs)', |
|||
], |
|||
'process_outputs_as_sources': 1, |
|||
} |
|||
], |
|||
}, |
|||
], |
|||
} |
@ -0,0 +1,101 @@ |
|||
#!/usr/bin/env python |
|||
|
|||
# Copyright (c) 2009 Google Inc. All rights reserved. |
|||
# Use of this source code is governed by a BSD-style license that can be |
|||
# found in the LICENSE file. |
|||
|
|||
""" |
|||
Verifies simple actions when using an explicit build target of 'all'. |
|||
""" |
|||
|
|||
import glob |
|||
import os |
|||
import TestGyp |
|||
|
|||
test = TestGyp.TestGyp(workdir='workarea_all') |
|||
|
|||
test.run_gyp('actions.gyp', chdir='src') |
|||
|
|||
test.relocate('src', 'relocate/src') |
|||
|
|||
# Some gyp files use an action that mentions an output but never |
|||
# writes it as a means to making the action run on every build. That |
|||
# doesn't mesh well with ninja's semantics. TODO(evan): figure out |
|||
# how to work always-run actions in to ninja. |
|||
if test.format == 'ninja': |
|||
test.build('actions.gyp', test.ALL, chdir='relocate/src') |
|||
else: |
|||
# Test that an "always run" action increases a counter on multiple |
|||
# invocations, and that a dependent action updates in step. |
|||
test.build('actions.gyp', test.ALL, chdir='relocate/src') |
|||
test.must_match('relocate/src/subdir1/actions-out/action-counter.txt', '1') |
|||
test.must_match('relocate/src/subdir1/actions-out/action-counter_2.txt', '1') |
|||
test.build('actions.gyp', test.ALL, chdir='relocate/src') |
|||
test.must_match('relocate/src/subdir1/actions-out/action-counter.txt', '2') |
|||
test.must_match('relocate/src/subdir1/actions-out/action-counter_2.txt', '2') |
|||
|
|||
# The "always run" action only counts to 2, but the dependent target |
|||
# will count forever if it's allowed to run. This verifies that the |
|||
# dependent target only runs when the "always run" action generates |
|||
# new output, not just because the "always run" ran. |
|||
test.build('actions.gyp', test.ALL, chdir='relocate/src') |
|||
test.must_match('relocate/src/subdir1/actions-out/action-counter.txt', '2') |
|||
test.must_match('relocate/src/subdir1/actions-out/action-counter_2.txt', '2') |
|||
|
|||
expect = """\ |
|||
Hello from program.c |
|||
Hello from make-prog1.py |
|||
Hello from make-prog2.py |
|||
""" |
|||
|
|||
if test.format == 'xcode': |
|||
chdir = 'relocate/src/subdir1' |
|||
else: |
|||
chdir = 'relocate/src' |
|||
test.run_built_executable('program', chdir=chdir, stdout=expect) |
|||
|
|||
|
|||
test.must_match('relocate/src/subdir2/file.out', "Hello from make-file.py\n") |
|||
|
|||
|
|||
expect = "Hello from generate_main.py\n" |
|||
|
|||
if test.format == 'xcode': |
|||
chdir = 'relocate/src/subdir3' |
|||
else: |
|||
chdir = 'relocate/src' |
|||
test.run_built_executable('null_input', chdir=chdir, stdout=expect) |
|||
|
|||
|
|||
# Clean out files which may have been created if test.ALL was run. |
|||
def clean_dep_files(): |
|||
for file in (glob.glob('relocate/src/dep_*.txt') + |
|||
glob.glob('relocate/src/deps_all_done_*.txt')): |
|||
if os.path.exists(file): |
|||
os.remove(file) |
|||
|
|||
# Confirm our clean. |
|||
clean_dep_files() |
|||
test.must_not_exist('relocate/src/dep_1.txt') |
|||
test.must_not_exist('relocate/src/deps_all_done_first_123.txt') |
|||
|
|||
# Make sure all deps finish before an action is run on a 'None' target. |
|||
# If using the Make builder, add -j to make things more difficult. |
|||
arguments = [] |
|||
if test.format == 'make': |
|||
arguments = ['-j'] |
|||
test.build('actions.gyp', 'action_with_dependencies_123', chdir='relocate/src', |
|||
arguments=arguments) |
|||
test.must_exist('relocate/src/deps_all_done_first_123.txt') |
|||
|
|||
# Try again with a target that has deps in reverse. Output files from |
|||
# previous tests deleted. Confirm this execution did NOT run the ALL |
|||
# target which would mess up our dep tests. |
|||
clean_dep_files() |
|||
test.build('actions.gyp', 'action_with_dependencies_321', chdir='relocate/src', |
|||
arguments=arguments) |
|||
test.must_exist('relocate/src/deps_all_done_first_321.txt') |
|||
test.must_not_exist('relocate/src/deps_all_done_first_123.txt') |
|||
|
|||
|
|||
test.pass_test() |
@ -0,0 +1,68 @@ |
|||
#!/usr/bin/env python |
|||
|
|||
# Copyright (c) 2009 Google Inc. All rights reserved. |
|||
# Use of this source code is governed by a BSD-style license that can be |
|||
# found in the LICENSE file. |
|||
|
|||
""" |
|||
Verifies simple actions when using the default build target. |
|||
""" |
|||
|
|||
import TestGyp |
|||
|
|||
test = TestGyp.TestGyp(workdir='workarea_default') |
|||
|
|||
test.run_gyp('actions.gyp', chdir='src') |
|||
|
|||
test.relocate('src', 'relocate/src') |
|||
|
|||
# Some gyp files use an action that mentions an output but never |
|||
# writes it as a means to making the action run on every build. That |
|||
# doesn't mesh well with ninja's semantics. TODO(evan): figure out |
|||
# how to work always-run actions in to ninja. |
|||
if test.format == 'ninja': |
|||
test.build('actions.gyp', test.ALL, chdir='relocate/src') |
|||
else: |
|||
# Test that an "always run" action increases a counter on multiple |
|||
# invocations, and that a dependent action updates in step. |
|||
test.build('actions.gyp', chdir='relocate/src') |
|||
test.must_match('relocate/src/subdir1/actions-out/action-counter.txt', '1') |
|||
test.must_match('relocate/src/subdir1/actions-out/action-counter_2.txt', '1') |
|||
test.build('actions.gyp', chdir='relocate/src') |
|||
test.must_match('relocate/src/subdir1/actions-out/action-counter.txt', '2') |
|||
test.must_match('relocate/src/subdir1/actions-out/action-counter_2.txt', '2') |
|||
|
|||
# The "always run" action only counts to 2, but the dependent target |
|||
# will count forever if it's allowed to run. This verifies that the |
|||
# dependent target only runs when the "always run" action generates |
|||
# new output, not just because the "always run" ran. |
|||
test.build('actions.gyp', test.ALL, chdir='relocate/src') |
|||
test.must_match('relocate/src/subdir1/actions-out/action-counter.txt', '2') |
|||
test.must_match('relocate/src/subdir1/actions-out/action-counter_2.txt', '2') |
|||
|
|||
expect = """\ |
|||
Hello from program.c |
|||
Hello from make-prog1.py |
|||
Hello from make-prog2.py |
|||
""" |
|||
|
|||
if test.format == 'xcode': |
|||
chdir = 'relocate/src/subdir1' |
|||
else: |
|||
chdir = 'relocate/src' |
|||
test.run_built_executable('program', chdir=chdir, stdout=expect) |
|||
|
|||
|
|||
test.must_match('relocate/src/subdir2/file.out', "Hello from make-file.py\n") |
|||
|
|||
|
|||
expect = "Hello from generate_main.py\n" |
|||
|
|||
if test.format == 'xcode': |
|||
chdir = 'relocate/src/subdir3' |
|||
else: |
|||
chdir = 'relocate/src' |
|||
test.run_built_executable('null_input', chdir=chdir, stdout=expect) |
|||
|
|||
|
|||
test.pass_test() |
@ -0,0 +1,24 @@ |
|||
#!/usr/bin/env python |
|||
|
|||
# Copyright (c) 2009 Google Inc. All rights reserved. |
|||
# Use of this source code is governed by a BSD-style license that can be |
|||
# found in the LICENSE file. |
|||
|
|||
""" |
|||
Verifies behavior for different action configuration errors: |
|||
exit status of 1, and the expected error message must be in stderr. |
|||
""" |
|||
|
|||
import TestGyp |
|||
|
|||
test = TestGyp.TestGyp(workdir='workarea_errors') |
|||
|
|||
|
|||
test.run_gyp('action_missing_name.gyp', chdir='src', status=1, stderr=None) |
|||
expect = [ |
|||
"Anonymous action in target broken_actions2. An action must have an 'action_name' field.", |
|||
] |
|||
test.must_contain_all_lines(test.stderr(), expect) |
|||
|
|||
|
|||
test.pass_test() |
@ -0,0 +1,24 @@ |
|||
# Copyright (c) 2009 Google Inc. All rights reserved. |
|||
# Use of this source code is governed by a BSD-style license that can be |
|||
# found in the LICENSE file. |
|||
|
|||
{ |
|||
'targets': [ |
|||
{ |
|||
'target_name': 'broken_actions2', |
|||
'type': 'none', |
|||
'actions': [ |
|||
{ |
|||
'inputs': [ |
|||
'no_name.input', |
|||
], |
|||
'action': [ |
|||
'python', |
|||
'-c', |
|||
'print \'missing name\'', |
|||
], |
|||
}, |
|||
], |
|||
}, |
|||
], |
|||
} |
@ -0,0 +1,114 @@ |
|||
# Copyright (c) 2009 Google Inc. All rights reserved. |
|||
# Use of this source code is governed by a BSD-style license that can be |
|||
# found in the LICENSE file. |
|||
|
|||
{ |
|||
'targets': [ |
|||
{ |
|||
'target_name': 'pull_in_all_actions', |
|||
'type': 'none', |
|||
'dependencies': [ |
|||
'subdir1/executable.gyp:*', |
|||
'subdir2/none.gyp:*', |
|||
'subdir3/null_input.gyp:*', |
|||
], |
|||
}, |
|||
{ |
|||
'target_name': 'depend_on_always_run_action', |
|||
'type': 'none', |
|||
'dependencies': [ 'subdir1/executable.gyp:counter' ], |
|||
'actions': [ |
|||
{ |
|||
'action_name': 'use_always_run_output', |
|||
'inputs': [ |
|||
'subdir1/actions-out/action-counter.txt', |
|||
'subdir1/counter.py', |
|||
], |
|||
'outputs': [ |
|||
'subdir1/actions-out/action-counter_2.txt', |
|||
], |
|||
'action': [ |
|||
'python', 'subdir1/counter.py', '<(_outputs)', |
|||
], |
|||
# Allows the test to run without hermetic cygwin on windows. |
|||
'msvs_cygwin_shell': 0, |
|||
}, |
|||
], |
|||
}, |
|||
|
|||
# Three deps which don't finish immediately. |
|||
# Each one has a small delay then creates a file. |
|||
# Delays are 1.0, 1.1, and 2.0 seconds. |
|||
{ |
|||
'target_name': 'dep_1', |
|||
'type': 'none', |
|||
'actions': [{ |
|||
'inputs': [ 'actions.gyp' ], |
|||
'outputs': [ 'dep_1.txt' ], |
|||
'action_name': 'dep_1', |
|||
'action': [ 'python', '-c', |
|||
'import time; time.sleep(1); open(\'dep_1.txt\', \'w\')' ], |
|||
# Allows the test to run without hermetic cygwin on windows. |
|||
'msvs_cygwin_shell': 0, |
|||
}], |
|||
}, |
|||
{ |
|||
'target_name': 'dep_2', |
|||
'type': 'none', |
|||
'actions': [{ |
|||
'inputs': [ 'actions.gyp' ], |
|||
'outputs': [ 'dep_2.txt' ], |
|||
'action_name': 'dep_2', |
|||
'action': [ 'python', '-c', |
|||
'import time; time.sleep(1.1); open(\'dep_2.txt\', \'w\')' ], |
|||
# Allows the test to run without hermetic cygwin on windows. |
|||
'msvs_cygwin_shell': 0, |
|||
}], |
|||
}, |
|||
{ |
|||
'target_name': 'dep_3', |
|||
'type': 'none', |
|||
'actions': [{ |
|||
'inputs': [ 'actions.gyp' ], |
|||
'outputs': [ 'dep_3.txt' ], |
|||
'action_name': 'dep_3', |
|||
'action': [ 'python', '-c', |
|||
'import time; time.sleep(2.0); open(\'dep_3.txt\', \'w\')' ], |
|||
# Allows the test to run without hermetic cygwin on windows. |
|||
'msvs_cygwin_shell': 0, |
|||
}], |
|||
}, |
|||
|
|||
# An action which assumes the deps have completed. |
|||
# Does NOT list the output files of it's deps as inputs. |
|||
# On success create the file deps_all_done_first.txt. |
|||
{ |
|||
'target_name': 'action_with_dependencies_123', |
|||
'type': 'none', |
|||
'dependencies': [ 'dep_1', 'dep_2', 'dep_3' ], |
|||
'actions': [{ |
|||
'inputs': [ 'actions.gyp' ], |
|||
'outputs': [ 'deps_all_done_first_123.txt' ], |
|||
'action_name': 'action_with_dependencies_123', |
|||
'action': [ 'python', 'confirm-dep-files.py', '<(_outputs)' ], |
|||
# Allows the test to run without hermetic cygwin on windows. |
|||
'msvs_cygwin_shell': 0, |
|||
}], |
|||
}, |
|||
# Same as above but with deps in reverse. |
|||
{ |
|||
'target_name': 'action_with_dependencies_321', |
|||
'type': 'none', |
|||
'dependencies': [ 'dep_3', 'dep_2', 'dep_1' ], |
|||
'actions': [{ |
|||
'inputs': [ 'actions.gyp' ], |
|||
'outputs': [ 'deps_all_done_first_321.txt' ], |
|||
'action_name': 'action_with_dependencies_321', |
|||
'action': [ 'python', 'confirm-dep-files.py', '<(_outputs)' ], |
|||
# Allows the test to run without hermetic cygwin on windows. |
|||
'msvs_cygwin_shell': 0, |
|||
}], |
|||
}, |
|||
|
|||
], |
|||
} |
@ -0,0 +1,21 @@ |
|||
#!/usr/bin/env python |
|||
|
|||
# Copyright (c) 2011 Google Inc. All rights reserved. |
|||
# Use of this source code is governed by a BSD-style license that can be |
|||
# found in the LICENSE file. |
|||
|
|||
"""Confirms presence of files generated by our targets we depend on. |
|||
If they exist, create a new file. |
|||
|
|||
Note target's input files are explicitly NOT defined in the gyp file |
|||
so they can't easily be passed to this script as args. |
|||
""" |
|||
|
|||
import os |
|||
import sys |
|||
|
|||
outfile = sys.argv[1] # Example value we expect: deps_all_done_first_123.txt |
|||
if (os.path.exists("dep_1.txt") and |
|||
os.path.exists("dep_2.txt") and |
|||
os.path.exists("dep_3.txt")): |
|||
open(outfile, "w") |
@ -0,0 +1,46 @@ |
|||
#!/usr/bin/env python |
|||
|
|||
# Copyright (c) 2010 Google Inc. All rights reserved. |
|||
# Use of this source code is governed by a BSD-style license that can be |
|||
# found in the LICENSE file. |
|||
|
|||
import sys |
|||
import time |
|||
|
|||
output = sys.argv[1] |
|||
persistoutput = "%s.persist" % sys.argv[1] |
|||
|
|||
count = 0 |
|||
try: |
|||
count = open(persistoutput, 'r').read() |
|||
except: |
|||
pass |
|||
count = int(count) + 1 |
|||
|
|||
if len(sys.argv) > 2: |
|||
max_count = int(sys.argv[2]) |
|||
if count > max_count: |
|||
count = max_count |
|||
|
|||
oldcount = 0 |
|||
try: |
|||
oldcount = open(output, 'r').read() |
|||
except: |
|||
pass |
|||
|
|||
# Save the count in a file that is undeclared, and thus hidden, to gyp. We need |
|||
# to do this because, prior to running commands, scons deletes any declared |
|||
# outputs, so we would lose our count if we just wrote to the given output file. |
|||
# (The other option is to use Precious() in the scons generator, but that seems |
|||
# too heavy-handed just to support this somewhat unrealistic test case, and |
|||
# might lead to unintended side-effects). |
|||
open(persistoutput, 'w').write('%d' % (count)) |
|||
|
|||
# Only write the given output file if the count has changed. |
|||
if int(oldcount) != count: |
|||
open(output, 'w').write('%d' % (count)) |
|||
# Sleep so the next run changes the file time sufficiently to make the build |
|||
# detect the file as changed. |
|||
time.sleep(1) |
|||
|
|||
sys.exit(0) |
@ -0,0 +1,74 @@ |
|||
# Copyright (c) 2009 Google Inc. All rights reserved. |
|||
# Use of this source code is governed by a BSD-style license that can be |
|||
# found in the LICENSE file. |
|||
|
|||
{ |
|||
'targets': [ |
|||
{ |
|||
'target_name': 'program', |
|||
'type': 'executable', |
|||
'msvs_cygwin_shell': 0, |
|||
'sources': [ |
|||
'program.c', |
|||
], |
|||
'actions': [ |
|||
{ |
|||
'action_name': 'make-prog1', |
|||
'inputs': [ |
|||
'make-prog1.py', |
|||
], |
|||
'outputs': [ |
|||
'<(INTERMEDIATE_DIR)/prog1.c', |
|||
], |
|||
'action': [ |
|||
'python', '<(_inputs)', '<@(_outputs)', |
|||
], |
|||
'process_outputs_as_sources': 1, |
|||
}, |
|||
{ |
|||
'action_name': 'make-prog2', |
|||
'inputs': [ |
|||
'make-prog2.py', |
|||
], |
|||
'outputs': [ |
|||
'actions-out/prog2.c', |
|||
], |
|||
'action': [ |
|||
'python', '<(_inputs)', '<@(_outputs)', |
|||
], |
|||
'process_outputs_as_sources': 1, |
|||
# Allows the test to run without hermetic cygwin on windows. |
|||
'msvs_cygwin_shell': 0, |
|||
}, |
|||
], |
|||
}, |
|||
{ |
|||
'target_name': 'counter', |
|||
'type': 'none', |
|||
'actions': [ |
|||
{ |
|||
# This action should always run, regardless of whether or not it's |
|||
# inputs or the command-line change. We do this by creating a dummy |
|||
# first output, which is always missing, thus causing the build to |
|||
# always try to recreate it. Actual output files should be listed |
|||
# after the dummy one, and dependent targets should list the real |
|||
# output(s) in their inputs |
|||
# (see '../actions.gyp:depend_on_always_run_action'). |
|||
'action_name': 'action_counter', |
|||
'inputs': [ |
|||
'counter.py', |
|||
], |
|||
'outputs': [ |
|||
'actions-out/action-counter.txt.always', |
|||
'actions-out/action-counter.txt', |
|||
], |
|||
'action': [ |
|||
'python', '<(_inputs)', 'actions-out/action-counter.txt', '2', |
|||
], |
|||
# Allows the test to run without hermetic cygwin on windows. |
|||
'msvs_cygwin_shell': 0, |
|||
}, |
|||
], |
|||
}, |
|||
], |
|||
} |
@ -0,0 +1,20 @@ |
|||
#!/usr/bin/env python |
|||
|
|||
# Copyright (c) 2009 Google Inc. All rights reserved. |
|||
# Use of this source code is governed by a BSD-style license that can be |
|||
# found in the LICENSE file. |
|||
|
|||
import sys |
|||
|
|||
contents = r""" |
|||
#include <stdio.h> |
|||
|
|||
void prog1(void) |
|||
{ |
|||
printf("Hello from make-prog1.py\n"); |
|||
} |
|||
""" |
|||
|
|||
open(sys.argv[1], 'w').write(contents) |
|||
|
|||
sys.exit(0) |
@ -0,0 +1,20 @@ |
|||
#!/usr/bin/env python |
|||
|
|||
# Copyright (c) 2009 Google Inc. All rights reserved. |
|||
# Use of this source code is governed by a BSD-style license that can be |
|||
# found in the LICENSE file. |
|||
|
|||
import sys |
|||
|
|||
contents = r""" |
|||
#include <stdio.h> |
|||
|
|||
void prog2(void) |
|||
{ |
|||
printf("Hello from make-prog2.py\n"); |
|||
} |
|||
""" |
|||
|
|||
open(sys.argv[1], 'w').write(contents) |
|||
|
|||
sys.exit(0) |
@ -0,0 +1,12 @@ |
|||
#include <stdio.h> |
|||
|
|||
extern void prog1(void); |
|||
extern void prog2(void); |
|||
|
|||
int main(int argc, char *argv[]) |
|||
{ |
|||
printf("Hello from program.c\n"); |
|||
prog1(); |
|||
prog2(); |
|||
return 0; |
|||
} |
@ -0,0 +1,11 @@ |
|||
#!/usr/bin/env python |
|||
|
|||
# Copyright (c) 2009 Google Inc. All rights reserved. |
|||
# Use of this source code is governed by a BSD-style license that can be |
|||
# found in the LICENSE file. |
|||
|
|||
import sys |
|||
|
|||
contents = "Hello from make-file.py\n" |
|||
|
|||
open(sys.argv[1], 'wb').write(contents) |
@ -0,0 +1,33 @@ |
|||
# Copyright (c) 2009 Google Inc. All rights reserved. |
|||
# Use of this source code is governed by a BSD-style license that can be |
|||
# found in the LICENSE file. |
|||
|
|||
{ |
|||
'targets': [ |
|||
{ |
|||
'target_name': 'file', |
|||
'type': 'none', |
|||
'msvs_cygwin_shell': 0, |
|||
'actions': [ |
|||
{ |
|||
'action_name': 'make-file', |
|||
'inputs': [ |
|||
'make-file.py', |
|||
], |
|||
'outputs': [ |
|||
'file.out', |
|||
# TODO: enhance testing infrastructure to test this |
|||
# without having to hard-code the intermediate dir paths. |
|||
#'<(INTERMEDIATE_DIR)/file.out', |
|||
], |
|||
'action': [ |
|||
'python', '<(_inputs)', '<@(_outputs)', |
|||
], |
|||
'process_outputs_as_sources': 1, |
|||
# Allows the test to run without hermetic cygwin on windows. |
|||
'msvs_cygwin_shell': 0, |
|||
} |
|||
], |
|||
}, |
|||
], |
|||
} |
@ -0,0 +1,21 @@ |
|||
#!/usr/bin/env python |
|||
|
|||
# Copyright (c) 2009 Google Inc. All rights reserved. |
|||
# Use of this source code is governed by a BSD-style license that can be |
|||
# found in the LICENSE file. |
|||
|
|||
import sys |
|||
|
|||
contents = """ |
|||
#include <stdio.h> |
|||
|
|||
int main(int argc, char *argv[]) |
|||
{ |
|||
printf("Hello from generate_main.py\\n"); |
|||
return 0; |
|||
} |
|||
""" |
|||
|
|||
open(sys.argv[1], 'w').write(contents) |
|||
|
|||
sys.exit(0) |
@ -0,0 +1,29 @@ |
|||
# Copyright (c) 2009 Google Inc. All rights reserved. |
|||
# Use of this source code is governed by a BSD-style license that can be |
|||
# found in the LICENSE file. |
|||
|
|||
{ |
|||
'targets': [ |
|||
{ |
|||
'target_name': 'null_input', |
|||
'type': 'executable', |
|||
'msvs_cygwin_shell': 0, |
|||
'actions': [ |
|||
{ |
|||
'action_name': 'generate_main', |
|||
'process_outputs_as_sources': 1, |
|||
'inputs': [], |
|||
'outputs': [ |
|||
'<(INTERMEDIATE_DIR)/main.c', |
|||
], |
|||
'action': [ |
|||
# TODO: we can't just use <(_outputs) here?! |
|||
'python', 'generate_main.py', '<(INTERMEDIATE_DIR)/main.c', |
|||
], |
|||
# Allows the test to run without hermetic cygwin on windows. |
|||
'msvs_cygwin_shell': 0, |
|||
}, |
|||
], |
|||
}, |
|||
], |
|||
} |
@ -0,0 +1,55 @@ |
|||
#!/usr/bin/env python |
|||
|
|||
# Copyright (c) 2009 Google Inc. All rights reserved. |
|||
# Use of this source code is governed by a BSD-style license that can be |
|||
# found in the LICENSE file. |
|||
|
|||
""" |
|||
Verifies simple actions when using an explicit build target of 'all'. |
|||
""" |
|||
|
|||
import TestGyp |
|||
|
|||
test = TestGyp.TestGyp() |
|||
|
|||
test.run_gyp('all.gyp', chdir='src') |
|||
test.relocate('src', 'relocate/src') |
|||
|
|||
# Build all. |
|||
test.build('all.gyp', chdir='relocate/src') |
|||
|
|||
if test.format=='xcode': |
|||
chdir = 'relocate/src/dir1' |
|||
else: |
|||
chdir = 'relocate/src' |
|||
|
|||
# Output is as expected. |
|||
file_content = 'Hello from emit.py\n' |
|||
test.built_file_must_match('out2.txt', file_content, chdir=chdir) |
|||
|
|||
test.built_file_must_not_exist('out.txt', chdir='relocate/src') |
|||
test.built_file_must_not_exist('foolib1', |
|||
type=test.SHARED_LIB, |
|||
chdir=chdir) |
|||
|
|||
# TODO(mmoss) Make consistent with scons, with 'dir1' before 'out/Default'? |
|||
if test.format in ('make', 'ninja'): |
|||
chdir='relocate/src' |
|||
else: |
|||
chdir='relocate/src/dir1' |
|||
|
|||
# Build the action explicitly. |
|||
test.build('actions.gyp', 'action1_target', chdir=chdir) |
|||
|
|||
# Check that things got run. |
|||
file_content = 'Hello from emit.py\n' |
|||
test.built_file_must_exist('out.txt', chdir=chdir) |
|||
|
|||
# Build the shared library explicitly. |
|||
test.build('actions.gyp', 'foolib1', chdir=chdir) |
|||
|
|||
test.built_file_must_exist('foolib1', |
|||
type=test.SHARED_LIB, |
|||
chdir=chdir) |
|||
|
|||
test.pass_test() |
@ -0,0 +1,13 @@ |
|||
# Copyright (c) 2009 Google Inc. All rights reserved. |
|||
# Use of this source code is governed by a BSD-style license that can be |
|||
# found in the LICENSE file. |
|||
|
|||
{ |
|||
'targets': [ |
|||
{ |
|||
'target_name': 'all_targets', |
|||
'type': 'none', |
|||
'dependencies': ['dir1/actions.gyp:*'], |
|||
}, |
|||
], |
|||
} |
@ -0,0 +1,56 @@ |
|||
# Copyright (c) 2009 Google Inc. All rights reserved. |
|||
# Use of this source code is governed by a BSD-style license that can be |
|||
# found in the LICENSE file. |
|||
|
|||
{ |
|||
'targets': [ |
|||
{ |
|||
'target_name': 'action1_target', |
|||
'type': 'none', |
|||
'suppress_wildcard': 1, |
|||
'actions': [ |
|||
{ |
|||
'action_name': 'action1', |
|||
'inputs': [ |
|||
'emit.py', |
|||
], |
|||
'outputs': [ |
|||
'<(PRODUCT_DIR)/out.txt', |
|||
], |
|||
'action': ['python', 'emit.py', '<(PRODUCT_DIR)/out.txt'], |
|||
'msvs_cygwin_shell': 0, |
|||
}, |
|||
], |
|||
}, |
|||
{ |
|||
'target_name': 'action2_target', |
|||
'type': 'none', |
|||
'actions': [ |
|||
{ |
|||
'action_name': 'action2', |
|||
'inputs': [ |
|||
'emit.py', |
|||
], |
|||
'outputs': [ |
|||
'<(PRODUCT_DIR)/out2.txt', |
|||
], |
|||
'action': ['python', 'emit.py', '<(PRODUCT_DIR)/out2.txt'], |
|||
'msvs_cygwin_shell': 0, |
|||
}, |
|||
], |
|||
}, |
|||
{ |
|||
'target_name': 'foolib1', |
|||
'type': 'shared_library', |
|||
'suppress_wildcard': 1, |
|||
'sources': ['lib1.c'], |
|||
}, |
|||
], |
|||
'conditions': [ |
|||
['OS=="linux"', { |
|||
'target_defaults': { |
|||
'cflags': ['-fPIC'], |
|||
}, |
|||
}], |
|||
], |
|||
} |
@ -0,0 +1,11 @@ |
|||
#!/usr/bin/env python |
|||
|
|||
# Copyright (c) 2009 Google Inc. All rights reserved. |
|||
# Use of this source code is governed by a BSD-style license that can be |
|||
# found in the LICENSE file. |
|||
|
|||
import sys |
|||
|
|||
f = open(sys.argv[1], 'wb') |
|||
f.write('Hello from emit.py\n') |
|||
f.close() |
@ -0,0 +1,6 @@ |
|||
#ifdef _WIN32 |
|||
__declspec(dllexport) |
|||
#endif |
|||
int func1(void) { |
|||
return 42; |
|||
} |
@ -0,0 +1,31 @@ |
|||
#!/usr/bin/env python |
|||
|
|||
# Copyright (c) 2009 Google Inc. All rights reserved. |
|||
# Use of this source code is governed by a BSD-style license that can be |
|||
# found in the LICENSE file. |
|||
|
|||
""" |
|||
Verifies that .hpp files are ignored when included in the source list on all |
|||
platforms. |
|||
""" |
|||
|
|||
import sys |
|||
import TestGyp |
|||
|
|||
# TODO(bradnelson): get this working for windows. |
|||
test = TestGyp.TestGyp(formats=['make', 'ninja', 'scons', 'xcode']) |
|||
|
|||
test.run_gyp('assembly.gyp', chdir='src') |
|||
|
|||
test.relocate('src', 'relocate/src') |
|||
|
|||
test.build('assembly.gyp', test.ALL, chdir='relocate/src') |
|||
|
|||
expect = """\ |
|||
Hello from program.c |
|||
Got 42. |
|||
""" |
|||
test.run_built_executable('program', chdir='relocate/src', stdout=expect) |
|||
|
|||
|
|||
test.pass_test() |
@ -0,0 +1,4 @@ |
|||
@echo off |
|||
:: Mock windows assembler. |
|||
cl /c %1 /Fo"%2" |
|||
|
@ -0,0 +1,59 @@ |
|||
# Copyright (c) 2009 Google Inc. All rights reserved. |
|||
# Use of this source code is governed by a BSD-style license that can be |
|||
# found in the LICENSE file. |
|||
|
|||
{ |
|||
'target_defaults': { |
|||
'conditions': [ |
|||
['OS=="win"', { |
|||
'defines': ['PLATFORM_WIN'], |
|||
}], |
|||
['OS=="mac"', { |
|||
'defines': ['PLATFORM_MAC'], |
|||
}], |
|||
['OS=="linux"', { |
|||
'defines': ['PLATFORM_LINUX'], |
|||
}], |
|||
], |
|||
}, |
|||
'targets': [ |
|||
{ |
|||
'target_name': 'program', |
|||
'type': 'executable', |
|||
'dependencies': ['lib1'], |
|||
'sources': [ |
|||
'program.c', |
|||
], |
|||
}, |
|||
{ |
|||
'target_name': 'lib1', |
|||
'type': 'static_library', |
|||
'sources': [ |
|||
'lib1.S', |
|||
], |
|||
}, |
|||
], |
|||
'conditions': [ |
|||
['OS=="win"', { |
|||
'target_defaults': { |
|||
'rules': [ |
|||
{ |
|||
'rule_name': 'assembler', |
|||
'msvs_cygwin_shell': 0, |
|||
'extension': 'S', |
|||
'inputs': [ |
|||
'as.bat', |
|||
], |
|||
'outputs': [ |
|||
'<(INTERMEDIATE_DIR)/<(RULE_INPUT_ROOT).obj', |
|||
], |
|||
'action': |
|||
['as.bat', 'lib1.c', '<(_outputs)'], |
|||
'message': 'Building assembly file <(RULE_INPUT_PATH)', |
|||
'process_outputs_as_sources': 1, |
|||
}, |
|||
], |
|||
}, |
|||
},], |
|||
], |
|||
} |
@ -0,0 +1,10 @@ |
|||
#if PLATFORM_WINDOWS || PLATFORM_MAC |
|||
# define IDENTIFIER(n) _##n |
|||
#else /* Linux */ |
|||
# define IDENTIFIER(n) n |
|||
#endif |
|||
|
|||
.globl IDENTIFIER(lib1_function) |
|||
IDENTIFIER(lib1_function): |
|||
movl $42, %eax |
|||
ret |
@ -0,0 +1,3 @@ |
|||
int lib1_function(void) { |
|||
return 42; |
|||
} |
@ -0,0 +1,12 @@ |
|||
#include <stdio.h> |
|||
|
|||
extern int lib1_function(void); |
|||
|
|||
int main(int argc, char *argv[]) |
|||
{ |
|||
fprintf(stdout, "Hello from program.c\n"); |
|||
fflush(stdout); |
|||
fprintf(stdout, "Got %d.\n", lib1_function()); |
|||
fflush(stdout); |
|||
return 0; |
|||
} |
@ -0,0 +1,77 @@ |
|||
#!/usr/bin/env python |
|||
|
|||
# Copyright (c) 2009 Google Inc. All rights reserved. |
|||
# Use of this source code is governed by a BSD-style license that can be |
|||
# found in the LICENSE file. |
|||
|
|||
""" |
|||
Verify the settings that cause a set of programs to be created in |
|||
a specific build directory, and that no intermediate built files |
|||
get created outside of that build directory hierarchy even when |
|||
referred to with deeply-nested ../../.. paths. |
|||
""" |
|||
|
|||
import TestGyp |
|||
|
|||
# TODO(mmoss): Make only supports (theoretically) a single, global build |
|||
# directory (through GYP_GENERATOR_FLAGS 'output_dir'), rather than |
|||
# gyp-file-specific settings (e.g. the stuff in builddir.gypi) that the other |
|||
# generators support, so this doesn't work yet for make. |
|||
# TODO(mmoss) Make also has the issue that the top-level Makefile is written to |
|||
# the "--depth" location, which is one level above 'src', but then this test |
|||
# moves 'src' somewhere else, leaving the Makefile behind, so make can't find |
|||
# its sources. I'm not sure if make is wrong for writing outside the current |
|||
# directory, or if the test is wrong for assuming everything generated is under |
|||
# the current directory. |
|||
test = TestGyp.TestGyp(formats=['!make', '!ninja']) |
|||
|
|||
test.run_gyp('prog1.gyp', '--depth=..', chdir='src') |
|||
|
|||
test.relocate('src', 'relocate/src') |
|||
|
|||
test.subdir('relocate/builddir') |
|||
|
|||
# Make sure that all the built ../../etc. files only get put under builddir, |
|||
# by making all of relocate read-only and then making only builddir writable. |
|||
test.writable('relocate', False) |
|||
test.writable('relocate/builddir', True) |
|||
|
|||
# Suppress the test infrastructure's setting SYMROOT on the command line. |
|||
test.build('prog1.gyp', test.ALL, SYMROOT=None, chdir='relocate/src') |
|||
|
|||
expect1 = """\ |
|||
Hello from prog1.c |
|||
Hello from func1.c |
|||
""" |
|||
|
|||
expect2 = """\ |
|||
Hello from subdir2/prog2.c |
|||
Hello from func2.c |
|||
""" |
|||
|
|||
expect3 = """\ |
|||
Hello from subdir2/subdir3/prog3.c |
|||
Hello from func3.c |
|||
""" |
|||
|
|||
expect4 = """\ |
|||
Hello from subdir2/subdir3/subdir4/prog4.c |
|||
Hello from func4.c |
|||
""" |
|||
|
|||
expect5 = """\ |
|||
Hello from subdir2/subdir3/subdir4/subdir5/prog5.c |
|||
Hello from func5.c |
|||
""" |
|||
|
|||
def run_builddir(prog, expect): |
|||
dir = 'relocate/builddir/Default/' |
|||
test.run(program=test.workpath(dir + prog), stdout=expect) |
|||
|
|||
run_builddir('prog1', expect1) |
|||
run_builddir('prog2', expect2) |
|||
run_builddir('prog3', expect3) |
|||
run_builddir('prog4', expect4) |
|||
run_builddir('prog5', expect5) |
|||
|
|||
test.pass_test() |
@ -0,0 +1,77 @@ |
|||
#!/usr/bin/env python |
|||
|
|||
# Copyright (c) 2009 Google Inc. All rights reserved. |
|||
# Use of this source code is governed by a BSD-style license that can be |
|||
# found in the LICENSE file. |
|||
|
|||
""" |
|||
Verify the settings that cause a set of programs to be created in |
|||
a specific build directory, and that no intermediate built files |
|||
get created outside of that build directory hierarchy even when |
|||
referred to with deeply-nested ../../.. paths. |
|||
""" |
|||
|
|||
import TestGyp |
|||
|
|||
# TODO(mmoss): Make only supports (theoretically) a single, global build |
|||
# directory (through GYP_GENERATOR_FLAGS 'output_dir'), rather than |
|||
# gyp-file-specific settings (e.g. the stuff in builddir.gypi) that the other |
|||
# generators support, so this doesn't work yet for make. |
|||
# TODO(mmoss) Make also has the issue that the top-level Makefile is written to |
|||
# the "--depth" location, which is one level above 'src', but then this test |
|||
# moves 'src' somewhere else, leaving the Makefile behind, so make can't find |
|||
# its sources. I'm not sure if make is wrong for writing outside the current |
|||
# directory, or if the test is wrong for assuming everything generated is under |
|||
# the current directory. |
|||
test = TestGyp.TestGyp(formats=['!make', '!ninja']) |
|||
|
|||
test.run_gyp('prog1.gyp', '--depth=..', chdir='src') |
|||
|
|||
test.relocate('src', 'relocate/src') |
|||
|
|||
test.subdir('relocate/builddir') |
|||
|
|||
# Make sure that all the built ../../etc. files only get put under builddir, |
|||
# by making all of relocate read-only and then making only builddir writable. |
|||
test.writable('relocate', False) |
|||
test.writable('relocate/builddir', True) |
|||
|
|||
# Suppress the test infrastructure's setting SYMROOT on the command line. |
|||
test.build('prog1.gyp', SYMROOT=None, chdir='relocate/src') |
|||
|
|||
expect1 = """\ |
|||
Hello from prog1.c |
|||
Hello from func1.c |
|||
""" |
|||
|
|||
expect2 = """\ |
|||
Hello from subdir2/prog2.c |
|||
Hello from func2.c |
|||
""" |
|||
|
|||
expect3 = """\ |
|||
Hello from subdir2/subdir3/prog3.c |
|||
Hello from func3.c |
|||
""" |
|||
|
|||
expect4 = """\ |
|||
Hello from subdir2/subdir3/subdir4/prog4.c |
|||
Hello from func4.c |
|||
""" |
|||
|
|||
expect5 = """\ |
|||
Hello from subdir2/subdir3/subdir4/subdir5/prog5.c |
|||
Hello from func5.c |
|||
""" |
|||
|
|||
def run_builddir(prog, expect): |
|||
dir = 'relocate/builddir/Default/' |
|||
test.run(program=test.workpath(dir + prog), stdout=expect) |
|||
|
|||
run_builddir('prog1', expect1) |
|||
run_builddir('prog2', expect2) |
|||
run_builddir('prog3', expect3) |
|||
run_builddir('prog4', expect4) |
|||
run_builddir('prog5', expect5) |
|||
|
|||
test.pass_test() |
@ -0,0 +1,21 @@ |
|||
# Copyright (c) 2009 Google Inc. All rights reserved. |
|||
# Use of this source code is governed by a BSD-style license that can be |
|||
# found in the LICENSE file. |
|||
|
|||
{ |
|||
'target_defaults': { |
|||
'configurations': { |
|||
'Default': { |
|||
'msvs_configuration_attributes': { |
|||
'OutputDirectory': '<(DEPTH)\\builddir\Default', |
|||
}, |
|||
}, |
|||
}, |
|||
}, |
|||
'scons_settings': { |
|||
'sconsbuild_dir': '<(DEPTH)/builddir', |
|||
}, |
|||
'xcode_settings': { |
|||
'SYMROOT': '<(DEPTH)/builddir', |
|||
}, |
|||
} |
@ -0,0 +1,6 @@ |
|||
#include <stdio.h> |
|||
|
|||
void func1(void) |
|||
{ |
|||
printf("Hello from func1.c\n"); |
|||
} |
@ -0,0 +1,6 @@ |
|||
#include <stdio.h> |
|||
|
|||
void func2(void) |
|||
{ |
|||
printf("Hello from func2.c\n"); |
|||
} |
@ -0,0 +1,6 @@ |
|||
#include <stdio.h> |
|||
|
|||
void func3(void) |
|||
{ |
|||
printf("Hello from func3.c\n"); |
|||
} |
@ -0,0 +1,6 @@ |
|||
#include <stdio.h> |
|||
|
|||
void func4(void) |
|||
{ |
|||
printf("Hello from func4.c\n"); |
|||
} |
@ -0,0 +1,6 @@ |
|||
#include <stdio.h> |
|||
|
|||
void func5(void) |
|||
{ |
|||
printf("Hello from func5.c\n"); |
|||
} |
@ -0,0 +1,10 @@ |
|||
#include <stdio.h> |
|||
|
|||
extern void func1(void); |
|||
|
|||
int main(int argc, char *argv[]) |
|||
{ |
|||
printf("Hello from prog1.c\n"); |
|||
func1(); |
|||
return 0; |
|||
} |
@ -0,0 +1,30 @@ |
|||
# Copyright (c) 2009 Google Inc. All rights reserved. |
|||
# Use of this source code is governed by a BSD-style license that can be |
|||
# found in the LICENSE file. |
|||
|
|||
{ |
|||
'includes': [ |
|||
'builddir.gypi', |
|||
], |
|||
'targets': [ |
|||
{ |
|||
'target_name': 'pull_in_all', |
|||
'type': 'none', |
|||
'dependencies': [ |
|||
'prog1', |
|||
'subdir2/prog2.gyp:prog2', |
|||
'subdir2/subdir3/prog3.gyp:prog3', |
|||
'subdir2/subdir3/subdir4/prog4.gyp:prog4', |
|||
'subdir2/subdir3/subdir4/subdir5/prog5.gyp:prog5', |
|||
], |
|||
}, |
|||
{ |
|||
'target_name': 'prog1', |
|||
'type': 'executable', |
|||
'sources': [ |
|||
'prog1.c', |
|||
'func1.c', |
|||
], |
|||
}, |
|||
], |
|||
} |
@ -0,0 +1,10 @@ |
|||
#include <stdio.h> |
|||
|
|||
extern void func2(void); |
|||
|
|||
int main(int argc, char *argv[]) |
|||
{ |
|||
printf("Hello from subdir2/prog2.c\n"); |
|||
func2(); |
|||
return 0; |
|||
} |
@ -0,0 +1,19 @@ |
|||
# Copyright (c) 2009 Google Inc. All rights reserved. |
|||
# Use of this source code is governed by a BSD-style license that can be |
|||
# found in the LICENSE file. |
|||
|
|||
{ |
|||
'includes': [ |
|||
'../builddir.gypi', |
|||
], |
|||
'targets': [ |
|||
{ |
|||
'target_name': 'prog2', |
|||
'type': 'executable', |
|||
'sources': [ |
|||
'prog2.c', |
|||
'../func2.c', |
|||
], |
|||
}, |
|||
], |
|||
} |
@ -0,0 +1,10 @@ |
|||
#include <stdio.h> |
|||
|
|||
extern void func3(void); |
|||
|
|||
int main(int argc, char *argv[]) |
|||
{ |
|||
printf("Hello from subdir2/subdir3/prog3.c\n"); |
|||
func3(); |
|||
return 0; |
|||
} |
@ -0,0 +1,19 @@ |
|||
# Copyright (c) 2009 Google Inc. All rights reserved. |
|||
# Use of this source code is governed by a BSD-style license that can be |
|||
# found in the LICENSE file. |
|||
|
|||
{ |
|||
'includes': [ |
|||
'../../builddir.gypi', |
|||
], |
|||
'targets': [ |
|||
{ |
|||
'target_name': 'prog3', |
|||
'type': 'executable', |
|||
'sources': [ |
|||
'prog3.c', |
|||
'../../func3.c', |
|||
], |
|||
}, |
|||
], |
|||
} |
@ -0,0 +1,10 @@ |
|||
#include <stdio.h> |
|||
|
|||
extern void func4(void); |
|||
|
|||
int main(int argc, char *argv[]) |
|||
{ |
|||
printf("Hello from subdir2/subdir3/subdir4/prog4.c\n"); |
|||
func4(); |
|||
return 0; |
|||
} |
@ -0,0 +1,19 @@ |
|||
# Copyright (c) 2009 Google Inc. All rights reserved. |
|||
# Use of this source code is governed by a BSD-style license that can be |
|||
# found in the LICENSE file. |
|||
|
|||
{ |
|||
'includes': [ |
|||
'../../../builddir.gypi', |
|||
], |
|||
'targets': [ |
|||
{ |
|||
'target_name': 'prog4', |
|||
'type': 'executable', |
|||
'sources': [ |
|||
'prog4.c', |
|||
'../../../func4.c', |
|||
], |
|||
}, |
|||
], |
|||
} |
@ -0,0 +1,10 @@ |
|||
#include <stdio.h> |
|||
|
|||
extern void func5(void); |
|||
|
|||
int main(int argc, char *argv[]) |
|||
{ |
|||
printf("Hello from subdir2/subdir3/subdir4/subdir5/prog5.c\n"); |
|||
func5(); |
|||
return 0; |
|||
} |
@ -0,0 +1,19 @@ |
|||
# Copyright (c) 2009 Google Inc. All rights reserved. |
|||
# Use of this source code is governed by a BSD-style license that can be |
|||
# found in the LICENSE file. |
|||
|
|||
{ |
|||
'includes': [ |
|||
'../../../../builddir.gypi', |
|||
], |
|||
'targets': [ |
|||
{ |
|||
'target_name': 'prog5', |
|||
'type': 'executable', |
|||
'sources': [ |
|||
'prog5.c', |
|||
'../../../../func5.c', |
|||
], |
|||
}, |
|||
], |
|||
} |
@ -0,0 +1,15 @@ |
|||
/* Copyright (c) 2010 Google Inc. All rights reserved.
|
|||
* Use of this source code is governed by a BSD-style license that can be |
|||
* found in the LICENSE file. */ |
|||
|
|||
#include <stdio.h> |
|||
|
|||
int main(int argc, char *argv[]) |
|||
{ |
|||
#ifdef __OPTIMIZE__ |
|||
printf("Using an optimization flag\n"); |
|||
#else |
|||
printf("Using no optimization flag\n"); |
|||
#endif |
|||
return 0; |
|||
} |
@ -0,0 +1,16 @@ |
|||
# Copyright (c) 2010 Google Inc. All rights reserved. |
|||
# Use of this source code is governed by a BSD-style license that can be |
|||
# found in the LICENSE file. |
|||
|
|||
{ |
|||
'targets': [ |
|||
{ |
|||
'target_name': 'cflags', |
|||
'type': 'executable', |
|||
'opt': '-Os', |
|||
'sources': [ |
|||
'cflags.c', |
|||
], |
|||
}, |
|||
], |
|||
} |
@ -0,0 +1,65 @@ |
|||
#!/usr/bin/env python |
|||
|
|||
# Copyright (c) 2010 Google Inc. All rights reserved. |
|||
# Use of this source code is governed by a BSD-style license that can be |
|||
# found in the LICENSE file. |
|||
|
|||
""" |
|||
Verifies build of an executable with C++ define specified by a gyp define, and |
|||
the use of the environment during regeneration when the gyp file changes. |
|||
""" |
|||
|
|||
import os |
|||
import TestGyp |
|||
|
|||
env_stack = [] |
|||
|
|||
|
|||
def PushEnv(): |
|||
env_copy = os.environ.copy() |
|||
env_stack.append(env_copy) |
|||
|
|||
def PopEnv(): |
|||
os.eniron=env_stack.pop() |
|||
|
|||
# Regenerating build files when a gyp file changes is currently only supported |
|||
# by the make generator. |
|||
test = TestGyp.TestGyp(formats=['make']) |
|||
|
|||
try: |
|||
PushEnv() |
|||
os.environ['CFLAGS'] = '-O0' |
|||
test.run_gyp('cflags.gyp') |
|||
finally: |
|||
# We clear the environ after calling gyp. When the auto-regeneration happens, |
|||
# the same define should be reused anyway. Reset to empty string first in |
|||
# case the platform doesn't support unsetenv. |
|||
PopEnv() |
|||
|
|||
test.build('cflags.gyp') |
|||
|
|||
expect = """\ |
|||
Using no optimization flag |
|||
""" |
|||
test.run_built_executable('cflags', stdout=expect) |
|||
|
|||
test.sleep() |
|||
|
|||
try: |
|||
PushEnv() |
|||
os.environ['CFLAGS'] = '-O2' |
|||
test.run_gyp('cflags.gyp') |
|||
finally: |
|||
# We clear the environ after calling gyp. When the auto-regeneration happens, |
|||
# the same define should be reused anyway. Reset to empty string first in |
|||
# case the platform doesn't support unsetenv. |
|||
PopEnv() |
|||
|
|||
test.build('cflags.gyp') |
|||
|
|||
expect = """\ |
|||
Using an optimization flag |
|||
""" |
|||
test.run_built_executable('cflags', stdout=expect) |
|||
|
|||
test.pass_test() |
@ -0,0 +1,29 @@ |
|||
#!/usr/bin/env python |
|||
|
|||
# Copyright (c) 2009 Google Inc. All rights reserved. |
|||
# Use of this source code is governed by a BSD-style license that can be |
|||
# found in the LICENSE file. |
|||
|
|||
""" |
|||
Verifies that .hpp files are ignored when included in the source list on all |
|||
platforms. |
|||
""" |
|||
|
|||
import TestGyp |
|||
|
|||
test = TestGyp.TestGyp() |
|||
|
|||
test.run_gyp('headers.gyp', chdir='src') |
|||
|
|||
test.relocate('src', 'relocate/src') |
|||
|
|||
test.build('headers.gyp', test.ALL, chdir='relocate/src') |
|||
|
|||
expect = """\ |
|||
Hello from program.c |
|||
Hello from lib1.c |
|||
""" |
|||
test.run_built_executable('program', chdir='relocate/src', stdout=expect) |
|||
|
|||
|
|||
test.pass_test() |
@ -0,0 +1,26 @@ |
|||
# Copyright (c) 2009 Google Inc. All rights reserved. |
|||
# Use of this source code is governed by a BSD-style license that can be |
|||
# found in the LICENSE file. |
|||
|
|||
{ |
|||
'targets': [ |
|||
{ |
|||
'target_name': 'program', |
|||
'type': 'executable', |
|||
'dependencies': [ |
|||
'lib1' |
|||
], |
|||
'sources': [ |
|||
'program.cpp', |
|||
], |
|||
}, |
|||
{ |
|||
'target_name': 'lib1', |
|||
'type': 'static_library', |
|||
'sources': [ |
|||
'lib1.hpp', |
|||
'lib1.cpp', |
|||
], |
|||
}, |
|||
], |
|||
} |
@ -0,0 +1,7 @@ |
|||
#include <stdio.h> |
|||
#include "lib1.hpp" |
|||
|
|||
void lib1_function(void) { |
|||
fprintf(stdout, "Hello from lib1.c\n"); |
|||
fflush(stdout); |
|||
} |
@ -0,0 +1,6 @@ |
|||
#ifndef _lib1_hpp |
|||
#define _lib1_hpp |
|||
|
|||
extern void lib1_function(void); |
|||
|
|||
#endif |
@ -0,0 +1,9 @@ |
|||
#include <stdio.h> |
|||
#include "lib1.hpp" |
|||
|
|||
int main(int argc, char *argv[]) { |
|||
fprintf(stdout, "Hello from program.c\n"); |
|||
fflush(stdout); |
|||
lib1_function(); |
|||
return 0; |
|||
} |
@ -0,0 +1,15 @@ |
|||
#include <stdio.h> |
|||
|
|||
int main(int argc, char *argv[]) |
|||
{ |
|||
#ifdef FOO |
|||
printf("Foo configuration\n"); |
|||
#endif |
|||
#ifdef DEBUG |
|||
printf("Debug configuration\n"); |
|||
#endif |
|||
#ifdef RELEASE |
|||
printf("Release configuration\n"); |
|||
#endif |
|||
return 0; |
|||
} |
@ -0,0 +1,32 @@ |
|||
# Copyright (c) 2009 Google Inc. All rights reserved. |
|||
# Use of this source code is governed by a BSD-style license that can be |
|||
# found in the LICENSE file. |
|||
|
|||
{ |
|||
'targets': [ |
|||
{ |
|||
'target_name': 'configurations', |
|||
'type': 'executable', |
|||
'sources': [ |
|||
'configurations.c', |
|||
], |
|||
'configurations': { |
|||
'Debug': { |
|||
'defines': [ |
|||
'DEBUG', |
|||
], |
|||
}, |
|||
'Release': { |
|||
'defines': [ |
|||
'RELEASE', |
|||
], |
|||
}, |
|||
'Foo': { |
|||
'defines': [ |
|||
'FOO', |
|||
], |
|||
}, |
|||
} |
|||
}, |
|||
], |
|||
} |
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue