diff options
Diffstat (limited to 'third_party/python/gyp/test/assembly')
9 files changed, 193 insertions, 0 deletions
diff --git a/third_party/python/gyp/test/assembly/gyptest-assembly.py b/third_party/python/gyp/test/assembly/gyptest-assembly.py new file mode 100755 index 0000000000..8a84310544 --- /dev/null +++ b/third_party/python/gyp/test/assembly/gyptest-assembly.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python + +# Copyright (c) 2012 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. + +""" +A basic test of compiling assembler files. +""" + +import sys +import TestGyp + +if sys.platform != 'win32': + # TODO(bradnelson): get this working for windows. + test = TestGyp.TestGyp(formats=['!msvs']) + + 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() diff --git a/third_party/python/gyp/test/assembly/gyptest-override.py b/third_party/python/gyp/test/assembly/gyptest-override.py new file mode 100644 index 0000000000..e84a23e855 --- /dev/null +++ b/third_party/python/gyp/test/assembly/gyptest-override.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python + +# Copyright (c) 2012 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. + +""" +Make sure that manual rules on Windows override the built in ones. +""" + +import sys +import TestGyp + +if sys.platform == 'win32': + test = TestGyp.TestGyp(formats=['msvs', 'ninja']) + CHDIR = 'src' + test.run_gyp('override.gyp', chdir=CHDIR) + test.build('override.gyp', test.ALL, chdir=CHDIR) + expect = """\ +Hello from program.c +Got 42. +""" + test.run_built_executable('program', chdir=CHDIR, stdout=expect) + test.pass_test() diff --git a/third_party/python/gyp/test/assembly/src/as.bat b/third_party/python/gyp/test/assembly/src/as.bat new file mode 100644 index 0000000000..b796db97ca --- /dev/null +++ b/third_party/python/gyp/test/assembly/src/as.bat @@ -0,0 +1,4 @@ +@echo off +:: Mock windows assembler. +cl /MD /c %1 /Fo"%2" + diff --git a/third_party/python/gyp/test/assembly/src/assembly.gyp b/third_party/python/gyp/test/assembly/src/assembly.gyp new file mode 100644 index 0000000000..565cb0fa0e --- /dev/null +++ b/third_party/python/gyp/test/assembly/src/assembly.gyp @@ -0,0 +1,62 @@ +# 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" or OS=="ios"', { + 'defines': ['PLATFORM_MAC'], + }], + ['OS=="linux"', { + 'defines': ['PLATFORM_LINUX'], + }], + ['OS=="android"', { + 'defines': ['PLATFORM_ANDROID'], + }], + ], + }, + '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, + }, + ], + }, + },], + ], +} diff --git a/third_party/python/gyp/test/assembly/src/lib1.S b/third_party/python/gyp/test/assembly/src/lib1.S new file mode 100644 index 0000000000..7de9f19cf9 --- /dev/null +++ b/third_party/python/gyp/test/assembly/src/lib1.S @@ -0,0 +1,15 @@ +#if PLATFORM_WINDOWS || PLATFORM_MAC +# define IDENTIFIER(n) _##n +#else /* Linux */ +# define IDENTIFIER(n) n +#endif + +.globl IDENTIFIER(lib1_function) +IDENTIFIER(lib1_function): +#if !defined(PLATFORM_ANDROID) + movl $42, %eax + ret +#else /* Android (assuming ARM) */ + mov r0, #42 + bx lr +#endif diff --git a/third_party/python/gyp/test/assembly/src/lib1.c b/third_party/python/gyp/test/assembly/src/lib1.c new file mode 100644 index 0000000000..be21ecd5f6 --- /dev/null +++ b/third_party/python/gyp/test/assembly/src/lib1.c @@ -0,0 +1,3 @@ +int lib1_function(void) { + return 42; +} diff --git a/third_party/python/gyp/test/assembly/src/override.gyp b/third_party/python/gyp/test/assembly/src/override.gyp new file mode 100644 index 0000000000..39a4072eff --- /dev/null +++ b/third_party/python/gyp/test/assembly/src/override.gyp @@ -0,0 +1,34 @@ +# Copyright (c) 2012 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', + 'sources': [ + 'program.c', + 'override_asm.asm', + ], + 'rules': [ + { + # Test that if there's a specific .asm rule, it overrides the + # built in one on Windows. + 'rule_name': 'assembler', + 'msvs_cygwin_shell': 0, + 'extension': 'asm', + 'inputs': [ + 'as.bat', + ], + 'outputs': [ + 'output.obj', + ], + 'action': ['as.bat', 'lib1.c', '<(_outputs)'], + 'message': 'Building assembly file <(RULE_INPUT_PATH)', + 'process_outputs_as_sources': 1, + }, + ], + }, + ], +} diff --git a/third_party/python/gyp/test/assembly/src/override_asm.asm b/third_party/python/gyp/test/assembly/src/override_asm.asm new file mode 100644 index 0000000000..be93b23baa --- /dev/null +++ b/third_party/python/gyp/test/assembly/src/override_asm.asm @@ -0,0 +1,8 @@ +; Copyright (c) 2012 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. + +; This is a placeholder. It should not be referenced if overrides work +; correctly. + +Bad stuff that shouldn't assemble. diff --git a/third_party/python/gyp/test/assembly/src/program.c b/third_party/python/gyp/test/assembly/src/program.c new file mode 100644 index 0000000000..eee862712e --- /dev/null +++ b/third_party/python/gyp/test/assembly/src/program.c @@ -0,0 +1,12 @@ +#include <stdio.h> + +extern int lib1_function(void); + +int main(void) +{ + fprintf(stdout, "Hello from program.c\n"); + fflush(stdout); + fprintf(stdout, "Got %d.\n", lib1_function()); + fflush(stdout); + return 0; +} |