Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add "standalone_static_library" target flag
This flag is only valid for targets of type "static_library" Adding 'standalone_static_library': 1, ensures: 1) "thin" archive optimisation is disabled for this target (it will contain symbols) 2) The static_library will be "installed" to PRODUCT_DIR This change re-lands r1510-1512. Review URL: https://codereview.chromium.org/11031005/ Patch from Eric Boren <borenet@google.com>! git-svn-id: http://gyp.googlecode.com/svn/trunk@1516 78cadc50-ecff-11dd-a971-7dbc132099af
- Loading branch information
thakis@chromium.org
committed
Oct 5, 2012
1 parent
58f9b2f
commit 012857d
Showing
11 changed files
with
207 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
'libraries', | ||
'link_settings', | ||
'sources', | ||
'standalone_static_library', | ||
'target_name', | ||
'type', | ||
] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# 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': 'configurations', | ||
'type': 'none', | ||
'configurations': { | ||
'Debug': { | ||
'standalone_static_library': 1, | ||
}, | ||
} | ||
}, | ||
], | ||
} | ||
# 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': 'configurations', | ||
'type': 'none', | ||
'configurations': { | ||
'Debug': { | ||
'standalone_static_library': 1, | ||
}, | ||
} | ||
}, | ||
], | ||
} | ||
# 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': 'configurations', | ||
'type': 'none', | ||
'configurations': { | ||
'Debug': { | ||
'standalone_static_library': 1, | ||
}, | ||
} | ||
}, | ||
], | ||
} |
53 changes: 53 additions & 0 deletions
53
test/standalone-static-library/gyptest-standalone-static-library.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/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. | ||
|
||
""" | ||
Verifies build of a static_library with the standalone_static_library flag set. | ||
""" | ||
|
||
import os | ||
import subprocess | ||
import sys | ||
import TestGyp | ||
|
||
test = TestGyp.TestGyp() | ||
|
||
# Verify that types other than static_library cause a failure. | ||
test.run_gyp('invalid.gyp', status=1, stderr=None) | ||
target_str = 'invalid.gyp:bad#target' | ||
if test.format == 'scons': | ||
target_str = os.path.join(os.path.realpath(os.curdir), target_str) | ||
err = ['gyp: Target %s has type executable but standalone_static_library flag ' | ||
'is only valid for static_library type.' % target_str] | ||
test.must_contain_all_lines(test.stderr(), err) | ||
|
||
# Build a valid standalone_static_library. | ||
test.run_gyp('mylib.gyp') | ||
test.build('mylib.gyp', target='prog') | ||
|
||
# Verify that the static library is copied to the correct location. | ||
if test.format == 'scons': | ||
# For scons, we expect the library to be copied to the shared lib dir. | ||
standalone_static_library_dir = test.SHARED_LIB | ||
else: | ||
# Otherwise, we expect the library to be copied to $PRODUCT_DIR. | ||
standalone_static_library_dir = test.EXECUTABLE | ||
path_to_lib = os.path.split( | ||
test.built_file_path('mylib', type=standalone_static_library_dir))[0] | ||
lib_name = test.built_file_basename('mylib', type=test.STATIC_LIB) | ||
path = os.path.join(path_to_lib, lib_name) | ||
test.must_exist(path) | ||
|
||
# Verify that the program runs properly. | ||
expect = 'hello from mylib.c\n' | ||
test.run_built_executable('prog', stdout=expect) | ||
|
||
# Verify that libmylib.a contains symbols. "ar -x" fails on a 'thin' archive. | ||
if test.format in ('make', 'ninja') and sys.platform.startswith('linux'): | ||
retcode = subprocess.call(['ar', '-x', path]) | ||
assert retcode == 0 | ||
|
||
test.pass_test() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# 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': 'bad', | ||
'type': 'executable', | ||
'standalone_static_library': 1, | ||
'sources': [ | ||
'prog.c', | ||
], | ||
}, | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#include <stdio.h> | ||
|
||
void print(void) | ||
{ | ||
printf("hello from mylib.c\n"); | ||
return; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# 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': 'mylib', | ||
'type': 'static_library', | ||
'standalone_static_library': 1, | ||
'sources': [ | ||
'mylib.c', | ||
], | ||
}, | ||
{ | ||
'target_name': 'prog', | ||
'type': 'executable', | ||
'sources': [ | ||
'prog.c', | ||
], | ||
'dependencies': [ | ||
'mylib', | ||
], | ||
}, | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
extern void print(void); | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
print(); | ||
return 0; | ||
} |