Revert 4298 "Makes it possible to find files used by some unit t..."

> Makes it possible to find files used by some unit tests when running them as Chrome native tests.
> 
> BUG=N/A
> R=andrew@webrtc.org
> 
> Review URL: https://webrtc-codereview.appspot.com/1749004

Broke Android NDK/Android.mk builds.

TBR=henrike@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/1752006

git-svn-id: http://webrtc.googlecode.com/svn/trunk@4299 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
pbos@webrtc.org 2013-07-05 08:49:09 +00:00
parent caf2fcca6a
commit db7d82f26f
4 changed files with 34 additions and 78 deletions

2
DEPS
View File

@ -158,7 +158,7 @@ hooks = [
# If a newer version or no current download exists, it will download # If a newer version or no current download exists, it will download
# the resources and extract them. # the resources and extract them.
"pattern": ".", "pattern": ".",
"action": ["python", Var("root_dir") + "/webrtc/tools/update_resources.py"], "action": ["python", Var("root_dir") + "/webrtc/tools/update.py"],
}, },
{ {
# A change to a .gyp, .gypi, or to GYP itself should run the generator. # A change to a .gyp, .gypi, or to GYP itself should run the generator.

View File

@ -62,8 +62,6 @@
'sources': [ 'sources': [
'test_suite.cc', 'test_suite.cc',
'test_suite.h', 'test_suite.h',
'testsupport/android/root_path_android.cc',
'testsupport/android/root_path_android_chromium.cc',
'testsupport/fileutils.cc', 'testsupport/fileutils.cc',
'testsupport/fileutils.h', 'testsupport/fileutils.h',
'testsupport/frame_reader.cc', 'testsupport/frame_reader.cc',
@ -81,36 +79,6 @@
'testsupport/trace_to_stderr.cc', 'testsupport/trace_to_stderr.cc',
'testsupport/trace_to_stderr.h', 'testsupport/trace_to_stderr.h',
], ],
'conditions': [
# TODO(henrike): remove build_with_chromium==1 when the bots are using
# Chromium's buildbots.
['build_with_chromium==1 and OS=="android" and gtest_target_type=="shared_library"', {
'dependencies': [
'<(DEPTH)/base/base.gyp:base',
],
'sources!': [
'testsupport/android/root_path_android.cc',
],
# WebRTC tests use resource files for testing. These files are not
# hosted in WebRTC. The script ensures that the needed resources
# are downloaded. In stand alone WebRTC the script is called by
# the DEPS file. In Chromium, i.e. here, the files are pulled down
# only if tests requiring the resources are being built.
'actions': [
{
'action_name': 'get_resources',
'inputs': ['<(webrtc_root)/tools/update_resources.py'],
'outputs': ['../../resources'],
'action': ['python',
'<(webrtc_root)/tools/update_resources.py',
'-p ../../../'],
}],
}, {
'sources!': [
'testsupport/android/root_path_android_chromium.cc',
],
}],
],
}, },
{ {
# Depend on this target when you want to have test_support but also the # Depend on this target when you want to have test_support but also the

View File

@ -31,33 +31,28 @@
namespace webrtc { namespace webrtc {
namespace test { namespace test {
namespace {
#ifdef WIN32 #ifdef WIN32
const char* kPathDelimiter = "\\"; static const char* kPathDelimiter = "\\";
#else #else
const char* kPathDelimiter = "/"; static const char* kPathDelimiter = "/";
#endif #endif
#ifdef WEBRTC_ANDROID #ifdef WEBRTC_ANDROID
const char* kResourcesDirName = "resources"; static const char* kRootDirName = "/sdcard/";
static const char* kResourcesDirName = "resources";
#else #else
// The file we're looking for to identify the project root dir. // The file we're looking for to identify the project root dir.
const char* kProjectRootFileName = "DEPS"; static const char* kProjectRootFileName = "DEPS";
const char* kResourcesDirName = "resources"; static const char* kOutputDirName = "out";
static const char* kFallbackPath = "./";
static const char* kResourcesDirName = "resources";
#endif #endif
const char* kFallbackPath = "./";
const char* kOutputDirName = "out";
char relative_dir_path[FILENAME_MAX];
bool relative_dir_path_set = false;
} // namespace
const char* kCannotFindProjectRootDir = "ERROR_CANNOT_FIND_PROJECT_ROOT_DIR"; const char* kCannotFindProjectRootDir = "ERROR_CANNOT_FIND_PROJECT_ROOT_DIR";
std::string OutputPathAndroid(); namespace {
std::string ProjectRoothPathAndroid(); char relative_dir_path[FILENAME_MAX];
bool relative_dir_path_set = false;
}
void SetExecutablePath(const std::string& path) { void SetExecutablePath(const std::string& path) {
std::string working_dir = WorkingDir(); std::string working_dir = WorkingDir();
@ -78,30 +73,18 @@ bool FileExists(std::string& file_name) {
return stat(file_name.c_str(), &file_info) == 0; return stat(file_name.c_str(), &file_info) == 0;
} }
std::string OutputPathImpl() {
std::string path = ProjectRootPath();
if (path == kCannotFindProjectRootDir) {
return kFallbackPath;
}
path += kOutputDirName;
if (!CreateDirectory(path)) {
return kFallbackPath;
}
return path + kPathDelimiter;
}
#ifdef WEBRTC_ANDROID #ifdef WEBRTC_ANDROID
std::string ProjectRootPath() { std::string ProjectRootPath() {
return ProjectRoothPathAndroid(); return kRootDirName;
} }
std::string OutputPath() { std::string OutputPath() {
return OutputPathAndroid(); return kRootDirName;
} }
std::string WorkingDir() { std::string WorkingDir() {
return ProjectRootPath(); return kRootDirName;
} }
#else // WEBRTC_ANDROID #else // WEBRTC_ANDROID
@ -131,7 +114,15 @@ std::string ProjectRootPath() {
} }
std::string OutputPath() { std::string OutputPath() {
return OutputPathImpl(); std::string path = ProjectRootPath();
if (path == kCannotFindProjectRootDir) {
return kFallbackPath;
}
path += kOutputDirName;
if (!CreateDirectory(path)) {
return kFallbackPath;
}
return path + kPathDelimiter;
} }
std::string WorkingDir() { std::string WorkingDir() {

View File

@ -23,7 +23,6 @@ REMOTE_URL_BASE = 'http://commondatastorage.googleapis.com/webrtc-resources'
VERSION_FILENAME = 'webrtc-resources-version' VERSION_FILENAME = 'webrtc-resources-version'
FILENAME_PREFIX = 'webrtc-resources-' FILENAME_PREFIX = 'webrtc-resources-'
EXTENSION = '.tgz' EXTENSION = '.tgz'
RELATIVE_OUTPUT_PATH = '../../'
def main(): def main():
@ -42,6 +41,14 @@ def main():
print 'Skipping resources download since WEBRTC_SKIP_RESOURCES_DOWNLOAD set' print 'Skipping resources download since WEBRTC_SKIP_RESOURCES_DOWNLOAD set'
return return
project_root_dir = os.path.normpath(sys.path[0] + '/../../')
downloads_dir = os.path.join(project_root_dir, 'resources')
current_version_file = os.path.join(downloads_dir, VERSION_FILENAME)
# Ensure the downloads dir is created.
if not os.path.isdir(downloads_dir):
os.mkdir(downloads_dir)
# Define and parse arguments. # Define and parse arguments.
parser = OptionParser() parser = OptionParser()
parser.add_option('-f', '--force', action='store_true', dest='force', parser.add_option('-f', '--force', action='store_true', dest='force',
@ -49,17 +56,7 @@ def main():
parser.add_option('-b', '--base_url', dest='base_url', parser.add_option('-b', '--base_url', dest='base_url',
help= 'Overrides the default Base URL (%s) and uses the ' help= 'Overrides the default Base URL (%s) and uses the '
'supplied URL instead.' % REMOTE_URL_BASE) 'supplied URL instead.' % REMOTE_URL_BASE)
parser.add_option('-p', dest='path', help= 'path of resources directory' (options, unused_args) = parser.parse_args()
'relative to this script', default=RELATIVE_OUTPUT_PATH)
options = parser.parse_args()[0]
project_root_dir = os.path.normpath(sys.path[0] + '/' + options.path)
downloads_dir = os.path.join(project_root_dir, 'resources')
current_version_file = os.path.join(downloads_dir, VERSION_FILENAME)
# Ensure the downloads dir is created.
if not os.path.isdir(downloads_dir):
os.mkdir(downloads_dir)
# Download archive if forced or DEPS version is different than our current. # Download archive if forced or DEPS version is different than our current.
current_version = _get_current_version(current_version_file) current_version = _get_current_version(current_version_file)