Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
googletest
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
googletest
Commits
95279071
Commit
95279071
authored
Sep 30, 2009
by
zhanyong.wan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactors the scons script (by Vlad Losev).
Fixes a typo in __GNUC__ (by Zhanyong Wan).
parent
bd851333
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
114 additions
and
115 deletions
+114
-115
SConscript
scons/SConscript
+3
-113
SConstruct.common
scons/SConstruct.common
+109
-0
gtest-internal-inl.h
src/gtest-internal-inl.h
+2
-2
No files found.
scons/SConscript
View file @
95279071
#!/usr/bin/python2.4
# -*- Python -*-
#
# Copyright 2008 Google Inc. All Rights Reserved.
# Copyright 2008 Google Inc. All Rights Reserved.
#
#
# Redistribution and use in source and binary forms, with or without
# Redistribution and use in source and binary forms, with or without
...
@@ -96,118 +95,9 @@ import os
...
@@ -96,118 +95,9 @@ import os
############################################################
############################################################
# Environments for building the targets, sorted by name.
# Environments for building the targets, sorted by name.
class
EnvCreator
:
"""Creates new customized environments from a base one."""
@staticmethod
def
_Remove
(
env
,
attribute
,
value
):
"""Removes the given attribute value from the environment."""
attribute_values
=
env
[
attribute
]
if
value
in
attribute_values
:
attribute_values
.
remove
(
value
)
@staticmethod
def
Create
(
base_env
,
modifier
=
None
):
# User should NOT create more than one environment with the same
# modifier (including None).
new_env
=
env
.
Clone
()
if
modifier
:
modifier
(
new_env
)
else
:
new_env
[
'OBJ_SUFFIX'
]
=
''
# Default suffix for unchanged environment.
return
new_env
;
# Each of the following methods modifies the environment for a particular
# purpose and can be used by clients for creating new environments. Each
# one needs to set the OBJ_SUFFIX variable to a unique suffix to
# differentiate targets built with that environment. Otherwise, SCons may
# complain about same target built with different settings.
@staticmethod
def
UseOwnTuple
(
env
):
"""Instructs Google Test to use its internal implementation of tuple."""
env
[
'OBJ_SUFFIX'
]
=
'_use_own_tuple'
env
.
Append
(
CPPDEFINES
=
'GTEST_USE_OWN_TR1_TUPLE=1'
)
@staticmethod
def
WarningOk
(
env
):
"""Does not treat warnings as errors.
Necessary for compiling gtest_unittest.cc, which triggers a gcc
warning when testing EXPECT_EQ(NULL, ptr)."""
env
[
'OBJ_SUFFIX'
]
=
'_warning_ok'
if
env
[
'PLATFORM'
]
==
'win32'
:
EnvCreator
.
_Remove
(
env
,
'CCFLAGS'
,
'-WX'
)
else
:
EnvCreator
.
_Remove
(
env
,
'CCFLAGS'
,
'-Werror'
)
@staticmethod
def
WithExceptions
(
env
):
"""Re-enables exceptions."""
# We compile gtest_unittest in this environment which means we need to
# allow warnings here as well.
EnvCreator
.
WarningOk
(
env
)
env
[
'OBJ_SUFFIX'
]
=
'_ex'
# Overrides the suffix supplied by WarningOK.
if
env
[
'PLATFORM'
]
==
'win32'
:
env
.
Append
(
CCFLAGS
=
[
'/EHsc'
])
env
.
Append
(
CPPDEFINES
=
'_HAS_EXCEPTIONS=1'
)
# Undoes the _TYPEINFO_ hack, which is unnecessary and only creates
# trouble when exceptions are enabled.
EnvCreator
.
_Remove
(
env
,
'CPPDEFINES'
,
'_TYPEINFO_'
)
EnvCreator
.
_Remove
(
env
,
'CPPDEFINES'
,
'_HAS_EXCEPTIONS=0'
)
else
:
env
.
Append
(
CCFLAGS
=
'-fexceptions'
)
EnvCreator
.
_Remove
(
env
,
'CCFLAGS'
,
'-fno-exceptions'
)
@staticmethod
def
LessOptimized
(
env
):
"""Disables certain optimizations on Windows.
We need to disable some optimization flags for some tests on
Windows; otherwise the redirection of stdout does not work
(apparently because of a compiler bug)."""
env
[
'OBJ_SUFFIX'
]
=
'_less_optimized'
if
env
[
'PLATFORM'
]
==
'win32'
:
for
flag
in
[
'/O1'
,
'/Os'
,
'/Og'
,
'/Oy'
]:
EnvCreator
.
_Remove
(
env
,
'LINKFLAGS'
,
flag
)
@staticmethod
def
WithThreads
(
env
):
"""Allows use of threads.
Currently only enables pthreads under GCC."""
env
[
'OBJ_SUFFIX'
]
=
'_with_threads'
if
env
[
'PLATFORM'
]
!=
'win32'
:
# Assuming POSIX-like environment with GCC.
# TODO(vladl@google.com): sniff presence of pthread_atfork instead of
# selecting on a platform.
env
.
Append
(
CCFLAGS
=
[
'-pthread'
])
env
.
Append
(
LINKFLAGS
=
[
'-pthread'
])
@staticmethod
def
NoRtti
(
env
):
"""Disables RTTI support."""
# We compile gtest_unittest in this environment which means we need to
# allow warnings here as well.
EnvCreator
.
WarningOk
(
env
)
env
[
'OBJ_SUFFIX'
]
=
'_no_rtti'
# Overrides suffix supplied by WarningOK.
if
env
[
'PLATFORM'
]
==
'win32'
:
env
.
Append
(
CCFLAGS
=
[
'/GR-'
])
else
:
env
.
Append
(
CCFLAGS
=
[
'-fno-rtti'
])
env
.
Append
(
CPPDEFINES
=
'GTEST_HAS_RTTI=0'
)
Import
(
'env'
)
Import
(
'env'
)
EnvCreator
=
SConscript
(
'SConstruct.common'
)
.
EnvCreator
env
=
EnvCreator
.
Create
(
env
)
env
=
EnvCreator
.
Create
(
env
)
# Note: The relative paths in SConscript files are relative to the location
# Note: The relative paths in SConscript files are relative to the location
...
...
scons/SConstruct.common
View file @
95279071
...
@@ -247,5 +247,114 @@ class SConstructHelper:
...
@@ -247,5 +247,114 @@ class SConstructHelper:
variant_dir=env['BUILD_DIR'],
variant_dir=env['BUILD_DIR'],
duplicate=0)
duplicate=0)
class EnvCreator:
"""Creates new customized environments from a base one."""
def _Remove(cls, env, attribute, value):
"""Removes the given attribute value from the environment."""
attribute_values = env[attribute]
if value in attribute_values:
attribute_values.remove(value)
_Remove = classmethod(_Remove)
def Create(cls, base_env, modifier=None):
# User should NOT create more than one environment with the same
# modifier (including None).
env = base_env.Clone()
if modifier:
modifier(env)
else:
env['OBJ_SUFFIX'] = '' # Default suffix for unchanged environment.
return env;
Create = classmethod(Create)
# Each of the following methods modifies the environment for a particular
# purpose and can be used by clients for creating new environments. Each
# one needs to set the OBJ_SUFFIX variable to a unique suffix to
# differentiate targets built with that environment. Otherwise, SCons may
# complain about same target built with different settings.
def UseOwnTuple(cls, env):
"""Instructs Google Test to use its internal implementation of tuple."""
env['OBJ_SUFFIX'] = '_use_own_tuple'
env.Append(CPPDEFINES = 'GTEST_USE_OWN_TR1_TUPLE=1')
UseOwnTuple = classmethod(UseOwnTuple)
def WarningOk(cls, env):
"""Does not treat warnings as errors.
Necessary for compiling gtest_unittest.cc, which triggers a gcc
warning when testing EXPECT_EQ(NULL, ptr)."""
env['OBJ_SUFFIX'] = '_warning_ok'
if env['PLATFORM'] == 'win32':
cls._Remove(env, 'CCFLAGS', '-WX')
else:
cls._Remove(env, 'CCFLAGS', '-Werror')
WarningOk = classmethod(WarningOk)
def WithExceptions(cls, env):
"""Re-enables exceptions."""
# We compile gtest_unittest in this environment which means we need to
# allow warnings here as well.
cls.WarningOk(env)
env['OBJ_SUFFIX'] = '_ex' # Overrides the suffix supplied by WarningOK.
if env['PLATFORM'] == 'win32':
env.Append(CCFLAGS=['/EHsc'])
env.Append(CPPDEFINES='_HAS_EXCEPTIONS=1')
# Undoes the _TYPEINFO_ hack, which is unnecessary and only creates
# trouble when exceptions are enabled.
cls._Remove(env, 'CPPDEFINES', '_TYPEINFO_')
cls._Remove(env, 'CPPDEFINES', '_HAS_EXCEPTIONS=0')
else:
env.Append(CCFLAGS='-fexceptions')
cls._Remove(env, 'CCFLAGS', '-fno-exceptions')
WithExceptions = classmethod(WithExceptions)
def LessOptimized(cls, env):
"""Disables certain optimizations on Windows.
We need to disable some optimization flags for some tests on
Windows; otherwise the redirection of stdout does not work
(apparently because of a compiler bug)."""
env['OBJ_SUFFIX'] = '_less_optimized'
if env['PLATFORM'] == 'win32':
for flag in ['/O1', '/Os', '/Og', '/Oy']:
cls._Remove(env, 'LINKFLAGS', flag)
LessOptimized = classmethod(LessOptimized)
def WithThreads(cls, env):
"""Allows use of threads.
Currently only enables pthreads under GCC."""
env['OBJ_SUFFIX'] = '_with_threads'
if env['PLATFORM'] != 'win32':
# Assuming POSIX-like environment with GCC.
# TODO(vladl@google.com): sniff presence of pthread_atfork instead of
# selecting on a platform.
env.Append(CCFLAGS=['-pthread'])
env.Append(LINKFLAGS=['-pthread'])
WithThreads = classmethod(WithThreads)
def NoRtti(cls, env):
"""Disables RTTI support."""
# We compile gtest_unittest in this environment which means we need to
# allow warnings here as well.
cls.WarningOk(env)
env['OBJ_SUFFIX'] = '_no_rtti' # Overrides suffix supplied by WarningOK.
if env['PLATFORM'] == 'win32':
env.Append(CCFLAGS=['/GR-'])
else:
env.Append(CCFLAGS=['-fno-rtti'])
env.Append(CPPDEFINES='GTEST_HAS_RTTI=0')
NoRtti = classmethod(NoRtti)
sconstruct_helper = SConstructHelper()
sconstruct_helper = SConstructHelper()
Return('sconstruct_helper')
Return('sconstruct_helper')
src/gtest-internal-inl.h
View file @
95279071
...
@@ -1198,14 +1198,14 @@ bool ParseNaturalNumber(const ::std::string& str, Integer* number) {
...
@@ -1198,14 +1198,14 @@ bool ParseNaturalNumber(const ::std::string& str, Integer* number) {
char
*
end
;
char
*
end
;
// BiggestConvertible is the largest integer type that system-provided
// BiggestConvertible is the largest integer type that system-provided
// string-to-number conversion routines can return.
// string-to-number conversion routines can return.
#if GTEST_OS_WINDOWS && !defined(__GNU
_
C__)
#if GTEST_OS_WINDOWS && !defined(__GNUC__)
// MSVC and C++ Builder define __int64 instead of the standard long long.
// MSVC and C++ Builder define __int64 instead of the standard long long.
typedef
unsigned
__int64
BiggestConvertible
;
typedef
unsigned
__int64
BiggestConvertible
;
const
BiggestConvertible
parsed
=
_strtoui64
(
str
.
c_str
(),
&
end
,
10
);
const
BiggestConvertible
parsed
=
_strtoui64
(
str
.
c_str
(),
&
end
,
10
);
#else
#else
typedef
unsigned
long
long
BiggestConvertible
;
// NOLINT
typedef
unsigned
long
long
BiggestConvertible
;
// NOLINT
const
BiggestConvertible
parsed
=
strtoull
(
str
.
c_str
(),
&
end
,
10
);
const
BiggestConvertible
parsed
=
strtoull
(
str
.
c_str
(),
&
end
,
10
);
#endif // GTEST_OS_WINDOWS && !defined(__GNU
_
C__)
#endif // GTEST_OS_WINDOWS && !defined(__GNUC__)
const
bool
parse_success
=
*
end
==
'\0'
&&
errno
==
0
;
const
bool
parse_success
=
*
end
==
'\0'
&&
errno
==
0
;
// TODO(vladl@google.com): Convert this to compile time assertion when it is
// TODO(vladl@google.com): Convert this to compile time assertion when it is
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment