Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions fml/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ source_set("fml") {
"paths.cc",
"paths.h",
"posix_wrappers.h",
"process.h",
"raster_thread_merger.cc",
"raster_thread_merger.h",
"shared_thread_merger.cc",
Expand Down Expand Up @@ -251,6 +252,7 @@ source_set("fml") {
"platform/win/native_library_win.cc",
"platform/win/paths_win.cc",
"platform/win/posix_wrappers_win.cc",
"platform/win/process_win.cc",
]
} else {
sources += [
Expand All @@ -260,6 +262,7 @@ source_set("fml") {
"platform/posix/native_library_posix.cc",
"platform/posix/paths_posix.cc",
"platform/posix/posix_wrappers_posix.cc",
"platform/posix/process_posix.cc",
]
}
}
Expand Down
13 changes: 13 additions & 0 deletions fml/platform/posix/process_posix.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <unistd.h>

namespace fml {

int GetCurrentProcId() {
return static_cast<int>(getpid());
}

} // namespace fml
13 changes: 13 additions & 0 deletions fml/platform/win/process_win.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <windows.h>

namespace fml {

int GetCurrentProcId() {
return static_cast<int>(::GetCurrentProcessId());
}

} // namespace fml
14 changes: 14 additions & 0 deletions fml/process.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef FLUTTER_FML_PROCESS_H_
#define FLUTTER_FML_PROCESS_H_

namespace fml {

int GetCurrentProcId();

} // namespace fml

#endif // FLUTTER_FML_PROCESS_H_
26 changes: 18 additions & 8 deletions impeller/compiler/compiler_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,39 @@
// found in the LICENSE file.

#include "impeller/compiler/compiler_test.h"
#include "flutter/fml/paths.h"
#include "flutter/fml/process.h"

#include <algorithm>
#include <filesystem>

namespace impeller {
namespace compiler {
namespace testing {

static fml::UniqueFD CreateIntermediatesDirectory() {
static std::string GetIntermediatesPath() {
auto test_name = flutter::testing::GetCurrentTestName();
std::replace(test_name.begin(), test_name.end(), '/', '_');
std::replace(test_name.begin(), test_name.end(), '.', '_');
return fml::OpenDirectory(flutter::testing::OpenFixturesDirectory(),
test_name.c_str(),
true, // create if necessary
fml::FilePermission::kReadWrite);
std::stringstream dir_name;
dir_name << test_name << "_" << std::to_string(fml::GetCurrentProcId());
return fml::paths::JoinPaths(
{flutter::testing::GetFixturesPath(), dir_name.str()});
}

CompilerTest::CompilerTest()
: intermediates_directory_(CreateIntermediatesDirectory()) {
CompilerTest::CompilerTest() : intermediates_path_(GetIntermediatesPath()) {
intermediates_directory_ =
fml::OpenDirectory(intermediates_path_.c_str(),
true, // create if necessary
fml::FilePermission::kReadWrite);
FML_CHECK(intermediates_directory_.is_valid());
}

CompilerTest::~CompilerTest() = default;
CompilerTest::~CompilerTest() {
intermediates_directory_.reset();

std::filesystem::remove_all(std::filesystem::path(intermediates_path_));
}

static std::string ReflectionHeaderName(const char* fixture_name) {
std::stringstream stream;
Expand Down
1 change: 1 addition & 0 deletions impeller/compiler/compiler_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class CompilerTest : public ::testing::TestWithParam<TargetPlatform> {
const char* entry_point_name = "main") const;

private:
std::string intermediates_path_;
fml::UniqueFD intermediates_directory_;

CompilerTest(const CompilerTest&) = delete;
Expand Down