Skip to content

Commit

Permalink
Moved base test support stuff to //base/test/
Browse files Browse the repository at this point in the history
Moved gtest from //testing to //testing/gtest

By default, gn desc prints out all build flags (before it only printed them if you asked). Also, I added the objective C ones.

Added support for non-Windows assembly files.

Static libraries on Linux now start with "lib".

I added a new relative_source_root_dir which I needed for some grit work.

All dependencies of net now build, although net itself isn't done yet. This includes crypto, SSH, and the SSL library.

I worked a bunch on the libssl build. I added some build flags for configuring it to crypto/ssl. This is a nice demo of build modularization since this doesn't have to be in //build anymore.

I started working on a grit template to define the net resources. I found a bunch of things I need to implement so I'm checking the current state in with that stuff commented out and going to work on those features in a separate pass.

BUG=
R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/23112010

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@218838 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
brettw@chromium.org committed Aug 21, 2013
1 parent 04e50c7 commit c6f27f2
Show file tree
Hide file tree
Showing 30 changed files with 1,454 additions and 198 deletions.
6 changes: 3 additions & 3 deletions tools/gn/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ test("gn_unittests") {
]
deps = [
":gn_lib",
"//base:run_all_unittests",
"//base:test_support_base",
"//testing:gtest",
"//base/test:run_all_unittests",
"//base/test:test_support_base",
"//testing/gtest",
]
}

Expand Down
22 changes: 16 additions & 6 deletions tools/gn/command_desc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ template<typename T> void OutputRecursiveTargetConfig(

std::string out_str = out.str();
if (!out_str.empty()) {
OutputString(std::string(header_name) + "\n");
OutputString("\n" + std::string(header_name) + "\n");
OutputString(out_str);
}
}
Expand Down Expand Up @@ -273,6 +273,9 @@ const char kDesc_Help[] =
" Shows defines set for the //base:base target, annotated by where\n"
" each one was set from.\n";

#define OUTPUT_CONFIG_VALUE(name) \
OutputRecursiveTargetConfig(target, #name, &ConfigValues::name);

int RunDesc(const std::vector<std::string>& args) {
if (args.size() != 1 && args.size() != 2) {
Err(Location(), "You're holding it wrong.",
Expand All @@ -285,8 +288,7 @@ int RunDesc(const std::vector<std::string>& args) {
return 1;

#define CONFIG_VALUE_HANDLER(name) \
} else if (what == #name) { \
OutputRecursiveTargetConfig(target, #name, &ConfigValues::name);
} else if (what == #name) { OUTPUT_CONFIG_VALUE(name)

if (args.size() == 2) {
// User specified one thing to display.
Expand All @@ -303,6 +305,8 @@ int RunDesc(const std::vector<std::string>& args) {
CONFIG_VALUE_HANDLER(cflags)
CONFIG_VALUE_HANDLER(cflags_c)
CONFIG_VALUE_HANDLER(cflags_cc)
CONFIG_VALUE_HANDLER(cflags_objc)
CONFIG_VALUE_HANDLER(cflags_objcc)
CONFIG_VALUE_HANDLER(ldflags)

} else {
Expand Down Expand Up @@ -333,9 +337,15 @@ int RunDesc(const std::vector<std::string>& args) {

PrintSources(target, true);
PrintConfigs(target, true);
OutputString("\n (Use \"gn desc <label> <thing you want to see>\" to show "
"the actual values\n applied by the different configs. "
"See \"gn help desc\" for more.)\n");

OUTPUT_CONFIG_VALUE(defines)
OUTPUT_CONFIG_VALUE(includes)
OUTPUT_CONFIG_VALUE(cflags)
OUTPUT_CONFIG_VALUE(cflags_c)
OUTPUT_CONFIG_VALUE(cflags_cc)
OUTPUT_CONFIG_VALUE(cflags_objc)
OUTPUT_CONFIG_VALUE(cflags_objcc)

PrintDeps(target, true);

return 0;
Expand Down
3 changes: 2 additions & 1 deletion tools/gn/commands.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ const Target* GetTargetForDesc(const std::vector<std::string>& args) {
.GetDefaultToolchainUnlocked();
Value arg_value(NULL, args[0]);
Err err;
Label label = Label::Resolve(SourceDir(), default_toolchain, arg_value, &err);
Label label =
Label::Resolve(SourceDir("//"), default_toolchain, arg_value, &err);
if (err.has_error()) {
err.PrintToStdout();
return NULL;
Expand Down
8 changes: 6 additions & 2 deletions tools/gn/filesystem_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,18 @@ SourceFileType GetSourceFileType(const SourceFile& file,
case Settings::WIN:
if (extension == "rc")
return SOURCE_RC;
// TODO(brettw) asm files.
break;

default:
break;
}

// TODO(brettw) asm files.
// TODO(brettw) weird thing with .S on non-Windows platforms.
if (os != Settings::WIN) {
if (extension == "S")
return SOURCE_S;
}

return SOURCE_UNKNOWN;
}

Expand Down
2 changes: 1 addition & 1 deletion tools/gn/filesystem_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ enum SourceFileType {
SOURCE_H,
SOURCE_M,
SOURCE_MM,
//SOURCE_S, // TODO(brettw) what is this?
SOURCE_S,
SOURCE_RC,
};

Expand Down
20 changes: 19 additions & 1 deletion tools/gn/function_exec_script.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "base/process/kill.h"
#include "base/process/launch.h"
#include "base/strings/string_number_conversions.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "tools/gn/err.h"
#include "tools/gn/filesystem_utils.h"
Expand Down Expand Up @@ -190,7 +191,7 @@ bool ExecProcess(const CommandLine& cmdline,
if (!ShuffleFileDescriptors(&fd_shuffle1))
_exit(127);

chdir(startup_dir.value().c_str());
file_util::SetCurrentDirectory(startup_dir);

// TODO(brettw) the base version GetAppOutput does a
// CloseSuperfluousFds call here. Do we need this?
Expand Down Expand Up @@ -323,6 +324,17 @@ Value RunExecScript(Scope* scope,
cmdline.AppendArg(script_args.list_value()[i].string_value());
}

// Log command line for debugging help.
base::TimeTicks begin_exec;
if (g_scheduler->verbose_logging()) {
#if defined(OS_WIN)
g_scheduler->Log("Pythoning", UTF16ToUTF8(cmdline.GetCommandLineString()));
#else
g_scheduler->Log("Pythoning", cmdline.GetCommandLineString());
#endif
begin_exec = base::TimeTicks::Now();
}

// Execute the process.
// TODO(brettw) set the environment block.
std::string output;
Expand All @@ -334,6 +346,12 @@ Value RunExecScript(Scope* scope,
"I was trying to execute \"" + FilePathToUTF8(python_path) + "\".");
return Value();
}
if (g_scheduler->verbose_logging()) {
g_scheduler->Log("Pythoning", script_source.value() + " took " +
base::Int64ToString(
(base::TimeTicks::Now() - begin_exec).InMilliseconds()) +
"ms");
}

// TODO(brettw) maybe we need stderr also for reasonable stack dumps.
if (exit_code != 0) {
Expand Down
6 changes: 5 additions & 1 deletion tools/gn/ninja_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ OutputFile NinjaHelper::GetOutputFileForSource(
case SOURCE_CC:
case SOURCE_M:
case SOURCE_MM:
case SOURCE_S:
name.append(target->settings()->IsWin() ? "obj" : "o");
break;

Expand Down Expand Up @@ -171,6 +172,7 @@ OutputFile NinjaHelper::GetTargetOutputFile(const Target* target) const {
ret.value().append(kObjectDirNoSlash);
AppendStringPiece(&ret.value(),
target->label().dir().SourceAbsoluteWithOneSlash());
ret.value().append(prefix);
ret.value().append(target->label().name());
if (extension[0]) {
ret.value().push_back('.');
Expand Down Expand Up @@ -210,9 +212,11 @@ std::string NinjaHelper::GetRuleForSourceType(const Settings* settings,
if (settings->IsWin()) {
if (type == SOURCE_RC)
return prefix + "rc";
} else {
if (type == SOURCE_S)
return prefix + "cc"; // Assembly files just get compiled by CC.
}

// TODO(brettw) stuff about "S" files on non-Windows.
return std::string();
}

Expand Down
10 changes: 10 additions & 0 deletions tools/gn/scope_per_file_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ const Value* ScopePerFileProvider::GetProgrammaticValue(
return GetRelativeRootOutputDir();
if (ident == variables::kRelativeRootGenDir)
return GetRelativeRootGenDir();
if (ident == variables::kRelativeSourceRootDir)
return GetRelativeSourceRootDir();
if (ident == variables::kRelativeTargetOutputDir)
return GetRelativeTargetOutputDir();
if (ident == variables::kRelativeTargetGenDir)
Expand Down Expand Up @@ -97,6 +99,14 @@ const Value* ScopePerFileProvider::GetRelativeRootGenDir() {
return relative_root_gen_dir_.get();
}

const Value* ScopePerFileProvider::GetRelativeSourceRootDir() {
if (!relative_source_root_dir_) {
relative_source_root_dir_.reset(new Value(NULL,
GetRelativeRootWithNoLastSlash()));
}
return relative_source_root_dir_.get();
}

const Value* ScopePerFileProvider::GetRelativeTargetOutputDir() {
if (!relative_target_output_dir_) {
relative_target_output_dir_.reset(new Value(NULL,
Expand Down
2 changes: 2 additions & 0 deletions tools/gn/scope_per_file_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class ScopePerFileProvider : public Scope::ProgrammaticProvider {
const Value* GetRelativeBuildToSourceRootDir();
const Value* GetRelativeRootOutputDir();
const Value* GetRelativeRootGenDir();
const Value* GetRelativeSourceRootDir();
const Value* GetRelativeTargetOutputDir();
const Value* GetRelativeTargetGenDir();

Expand All @@ -50,6 +51,7 @@ class ScopePerFileProvider : public Scope::ProgrammaticProvider {
scoped_ptr<Value> relative_build_to_source_root_dir_;
scoped_ptr<Value> relative_root_output_dir_;
scoped_ptr<Value> relative_root_gen_dir_;
scoped_ptr<Value> relative_source_root_dir_;
scoped_ptr<Value> relative_target_output_dir_;
scoped_ptr<Value> relative_target_gen_dir_;

Expand Down
11 changes: 9 additions & 2 deletions tools/gn/secondary/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@

group("root") {
deps = [
"//tools/gn",
"//ipc",
"//base(//build/toolchain/nacl:x86_newlib)",
"//crypto",
"//ipc",
"//net",
"//net/third_party/nss/ssl:crssl",
"//sdch",
"//third_party/icu:icudata",
"//third_party/zlib",
"//tools/gn",
"//url:url_lib",
]
}
130 changes: 0 additions & 130 deletions tools/gn/secondary/base/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -876,133 +876,3 @@ component("base_i18n") {
#},
}

static_library("test_support_base") {
sources = [
"perftimer.cc",
"test/expectations/expectation.cc",
"test/expectations/expectation.h",
"test/expectations/parser.cc",
"test/expectations/parser.h",
"test/mock_chrome_application_mac.h",
"test/mock_chrome_application_mac.mm",
"test/mock_devices_changed_observer.cc",
"test/mock_devices_changed_observer.h",
"test/mock_time_provider.cc",
"test/mock_time_provider.h",
"test/multiprocess_test.cc",
"test/multiprocess_test.h",
"test/multiprocess_test_android.cc",
"test/null_task_runner.cc",
"test/null_task_runner.h",
"test/perf_test_suite.cc",
"test/perf_test_suite.h",
"test/scoped_locale.cc",
"test/scoped_locale.h",
"test/scoped_path_override.cc",
"test/scoped_path_override.h",
"test/sequenced_task_runner_test_template.cc",
"test/sequenced_task_runner_test_template.h",
"test/sequenced_worker_pool_owner.cc",
"test/sequenced_worker_pool_owner.h",
"test/simple_test_clock.cc",
"test/simple_test_clock.h",
"test/simple_test_tick_clock.cc",
"test/simple_test_tick_clock.h",
"test/task_runner_test_template.cc",
"test/task_runner_test_template.h",
"test/test_file_util.h",
"test/test_file_util_linux.cc",
"test/test_file_util_mac.cc",
"test/test_file_util_posix.cc",
"test/test_file_util_win.cc",
"test/test_listener_ios.h",
"test/test_listener_ios.mm",
"test/test_pending_task.cc",
"test/test_pending_task.h",
"test/test_process_killer_win.cc",
"test/test_process_killer_win.h",
"test/test_reg_util_win.cc",
"test/test_reg_util_win.h",
"test/test_shortcut_win.cc",
"test/test_shortcut_win.h",
"test/test_simple_task_runner.cc",
"test/test_simple_task_runner.h",
"test/test_suite.cc",
"test/test_suite.h",
"test/test_support_android.cc",
"test/test_support_android.h",
"test/test_support_ios.h",
"test/test_support_ios.mm",
"test/test_switches.cc",
"test/test_switches.h",
"test/test_timeouts.cc",
"test/test_timeouts.h",
"test/thread_test_helper.cc",
"test/thread_test_helper.h",
"test/trace_event_analyzer.cc",
"test/trace_event_analyzer.h",
"test/values_test_util.cc",
"test/values_test_util.h",
]
deps = [
":base",
":base_static",
":base_i18n",
"//testing:gmock",
"//testing:gtest",
]

if (!is_posix) {
sources -= [
"test/scoped_locale.cc",
"test/scoped_locale.h",
]
}
if (is_ios) {
# Pull in specific Mac files for iOS (which have been filtered out
# by file name rules).
{ # Temporarily override the assignment filter in a new scope.
set_sources_assignment_filter([])
sources += "test/test_file_util_mac.cc"
}
}
#if (!is_bsd) {
# sources -= "test/test_file_util_linux.cc"
#}
#if (use_gtk) {
# deps += "/build/linux/system:gtk"
#}
#export_dependent_settings [
# 'base',
#]
}

config("perf_test_config") {
defines = [ "PERF_TEST" ]
}

static_library("test_support_perf") {
sources = [
"perftimer.cc",
"test/run_all_perftests.cc",
]
deps = [
":base",
"//testing:gtest",
]

direct_dependent_configs = [ ":perf_test_config" ]

#if (toolkit_uses_gtk) {
# deps += "/build/linux/system:gtk",
#}
}

static_library("run_all_unittests") {
sources = [
"test/run_all_unittests.cc",
]
deps = [
":test_support_base",
]
}
Loading

0 comments on commit c6f27f2

Please sign in to comment.