Skip to content

Commit

Permalink
Version 3.5.0-256.0.dev
Browse files Browse the repository at this point in the history
Merge 0b31d88 into dev
  • Loading branch information
Dart CI committed Jun 12, 2024
2 parents 32dfbfc + 0b31d88 commit 9e1e251
Show file tree
Hide file tree
Showing 33 changed files with 1,446 additions and 924 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/issue-triage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ jobs:
ISSUE_URL: ${{ github.event.issue.html_url }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GOOGLE_API_KEY: ${{ secrets.GEMINI_API_KEY }}
run: dart bin/triage.dart $ISSUE_URL --dry-run
run: dart bin/triage.dart $ISSUE_URL
1 change: 1 addition & 0 deletions .github/workflows/scorecards-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Scorecards supply-chain security

on:
# Only the default branch is supported.
branch_protection_rule:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/third-party-deps-scan.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Third party deps scan

on:
# Only the default branch is supported.
branch_protection_rule:
Expand Down Expand Up @@ -52,4 +53,4 @@ jobs:
permissions:
# Needed to upload the SARIF results to code-scanning dashboard.
security-events: write
contents: read
contents: read
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
- `Dart_NewListOf` and `Dart_IsLegacyType` functions are
removed from Dart C API.

- `Dart_DefaultCanonicalizeUrl` is removed from the Dart C API.

## 3.4.0

### Language
Expand Down
2 changes: 1 addition & 1 deletion pkg/dartdev/lib/src/dds_runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class DDSRunner {
);

try {
final result = json.decode(launchResult);
final result = json.decode(launchResult) as Map<String, dynamic>;
if (result
case {
'state': 'started',
Expand Down
41 changes: 32 additions & 9 deletions pkg/dartdev/test/native_assets/build_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,25 @@ void main(List<String> args) async {
final relativeExeUri = Uri.file('./bin/dart_app/dart_app.exe');
final absoluteExeUri = dartAppUri.resolveUri(relativeExeUri);
expect(await File.fromUri(absoluteExeUri).exists(), true);
for (final exeUri in [absoluteExeUri, relativeExeUri]) {
final result = await runProcess(
executable: exeUri,
arguments: [],
workingDirectory: dartAppUri,
logger: logger,
);
expectDartAppStdout(result.stdout);
}
await _withTempDir((tempUri) async {
// The link needs to have the same extension as the executable on
// Windows to be able to be executable.
final link = Link.fromUri(tempUri.resolve('my_link.exe'));
await link.create(absoluteExeUri.toFilePath());
for (final exeUri in [
absoluteExeUri,
relativeExeUri,
link.uri,
]) {
final result = await runProcess(
executable: exeUri,
arguments: [],
workingDirectory: dartAppUri,
logger: logger,
);
expectDartAppStdout(result.stdout);
}
});
});
});
}
Expand Down Expand Up @@ -177,3 +187,16 @@ void main(List<String> args) {
});
});
}

Future<void> _withTempDir(Future<void> Function(Uri tempUri) fun) async {
final tempDir = await Directory.systemTemp.createTemp('link_dir');
final tempDirResolved = Directory(await tempDir.resolveSymbolicLinks());
try {
await fun(tempDirResolved.uri);
} finally {
if (!Platform.environment.containsKey(keepTempKey) ||
Platform.environment[keepTempKey]!.isEmpty) {
await tempDirResolved.delete(recursive: true);
}
}
}
54 changes: 50 additions & 4 deletions runtime/bin/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import("../../build/config/gclient_args.gni")
import("../../build/dart/dart_action.gni")
import("../../sdk_args.gni")
import("../platform/platform_sources.gni")
import("../runtime_args.gni")
import("../vm/compiler/compiler_sources.gni")
import("../vm/ffi/ffi_sources.gni")
Expand All @@ -15,6 +16,7 @@ import("builtin_sources.gni")
import("cli_sources.gni")
import("io_impl_sources.gni")
import("io_sources.gni")
import("native_assets_impl_sources.gni")

config("libdart_builtin_config") {
if (is_win) {
Expand Down Expand Up @@ -107,6 +109,35 @@ build_libdart_builtin("libdart_builtin_product_host_targeting_host") {
extra_configs = [ "..:dart_product_config" ]
}

template("build_native_assets_api") {
extra_configs = []
if (defined(invoker.extra_configs)) {
extra_configs += invoker.extra_configs
}
source_set(target_name) {
configs += [ "..:dart_config" ] + extra_configs
deps = []
include_dirs = [ ".." ]
sources = native_assets_impl_sources
}
}

build_native_assets_api("native_assets_api") {
extra_configs = [
"..:dart_maybe_product_config",
"..:dart_os_config",
"..:dart_arch_config",
]
}

build_native_assets_api("native_assets_api_product") {
extra_configs = [
"..:dart_product_config",
"..:dart_os_config",
"..:dart_arch_config",
]
}

static_library("crashpad") {
configs += [
"..:dart_arch_config",
Expand Down Expand Up @@ -844,6 +875,11 @@ dart_executable("dart") {
if (!exclude_kernel_service) {
extra_deps += [ ":dart_kernel_platform_cc" ]
}
if (dart_runtime_mode == "release") {
extra_deps += [ ":native_assets_api_product" ]
} else {
extra_deps += [ ":native_assets_api" ]
}
}

dart_executable("dart_precompiled_runtime") {
Expand All @@ -870,9 +906,15 @@ dart_executable("dart_precompiled_runtime") {
]

if (dart_runtime_mode == "release") {
extra_deps += [ ":elf_loader_product" ]
extra_deps += [
":elf_loader_product",
":native_assets_api_product",
]
} else {
extra_deps += [ ":elf_loader" ]
extra_deps += [
":elf_loader",
":native_assets_api",
]
}

if (dart_runtime_mode == "release") {
Expand Down Expand Up @@ -902,7 +944,10 @@ dart_executable("dart_precompiled_runtime_product") {
"snapshot_empty.cc",
]

extra_deps += [ ":elf_loader_product" ]
extra_deps += [
":elf_loader_product",
":native_assets_api_product",
]
}

# This flag is set in runtime/runtime_args.gni
Expand Down Expand Up @@ -986,6 +1031,7 @@ source_set("run_vm_tests_set") {

# The VM sources are already included in libdart, so we just want to add in
# the tests here.
platform_tests = rebase_path(platform_sources_tests, ".", "../platform")
vm_tests = rebase_path(vm_sources_tests, ".", "../vm")
compiler_tests = rebase_path(compiler_sources_tests, ".", "../vm/compiler")
heap_tests = rebase_path(heap_sources_tests, ".", "../vm/heap")
Expand All @@ -1006,7 +1052,7 @@ source_set("run_vm_tests_set") {
"vmservice_impl.cc",
"vmservice_impl.h",
] + builtin_impl_tests + vm_tests + compiler_tests + heap_tests +
io_impl_tests
io_impl_tests + platform_tests
}

executable("run_vm_tests") {
Expand Down
4 changes: 0 additions & 4 deletions runtime/bin/dartutils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,12 @@
#include "bin/directory.h"
#include "bin/file.h"
#include "bin/io_buffer.h"
#include "bin/namespace.h"
#include "bin/platform.h"
#include "bin/typed_data_utils.h"
#include "bin/utils.h"
#include "include/dart_api.h"
#include "include/dart_native_api.h"
#include "include/dart_tools_api.h"
#include "platform/assert.h"
#include "platform/globals.h"
#include "platform/memory_sanitizer.h"
#include "platform/utils.h"

// Return the error from the containing function if handle is in error handle.
Expand Down
15 changes: 14 additions & 1 deletion runtime/bin/loader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include "bin/utils.h"
#include "include/dart_tools_api.h"
#include "platform/growable_array.h"
#include "platform/uri.h"
#include "platform/utils.h"

namespace dart {
namespace bin {
Expand Down Expand Up @@ -87,7 +89,18 @@ Dart_Handle Loader::LibraryTagHandler(Dart_LibraryTag tag,
if (is_dart_scheme_url || is_dart_library) {
return url;
}
return Dart_DefaultCanonicalizeUrl(library_url, url);
const char* url_cstr;
result = Dart_StringToCString(url, &url_cstr);
if (Dart_IsError(result)) {
return result;
}
CStringUniquePtr resolved_uri = ResolveUri(url_cstr, library_url_string);
if (!resolved_uri) {
return DartUtils::NewError("%s: Unable to canonicalize uri '%s'.",
__FUNCTION__, url_cstr);
}
result = Dart_NewStringFromCString(resolved_uri.get());
return result;
}
#if !defined(DART_PRECOMPILED_RUNTIME)
if (tag == Dart_kKernelTag) {
Expand Down
25 changes: 20 additions & 5 deletions runtime/bin/main_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include "bin/dartutils.h"
#include "bin/dfe.h"
#include "bin/error_exit.h"
#include "bin/eventhandler.h"
#include "bin/exe_utils.h"
#include "bin/file.h"
#include "bin/gzip.h"
Expand All @@ -28,18 +27,15 @@
#include "bin/platform.h"
#include "bin/process.h"
#include "bin/snapshot_utils.h"
#include "bin/thread.h"
#include "bin/utils.h"
#include "bin/vmservice_impl.h"
#include "include/bin/dart_io_api.h"
#include "include/bin/native_assets_api.h"
#include "include/dart_api.h"
#include "include/dart_embedder_api.h"
#include "include/dart_tools_api.h"
#include "platform/globals.h"
#include "platform/growable_array.h"
#include "platform/hashmap.h"
#include "platform/syslog.h"
#include "platform/text_buffer.h"
#include "platform/utils.h"

extern "C" {
Expand Down Expand Up @@ -251,6 +247,13 @@ static bool OnIsolateInitialize(void** child_callback_data, char** error) {
return false;
}

static void* NativeAssetsDlopenRelative(const char* path, char** error) {
auto isolate_group_data =
reinterpret_cast<IsolateGroupData*>(Dart_CurrentIsolateGroupData());
const char* script_uri = isolate_group_data->script_url;
return NativeAssets::DlopenRelative(path, script_uri, error);
}

static Dart_Isolate IsolateSetupHelper(Dart_Isolate isolate,
bool is_main_isolate,
const char* script_uri,
Expand Down Expand Up @@ -385,6 +388,18 @@ static Dart_Isolate IsolateSetupHelper(Dart_Isolate isolate,
}
#endif // !defined(DART_PRECOMPILED_RUNTIME)

#if !defined(DART_PRECOMPILER)
NativeAssetsApi native_assets;
memset(&native_assets, 0, sizeof(native_assets));
native_assets.dlopen_absolute = &NativeAssets::DlopenAbsolute;
native_assets.dlopen_relative = &NativeAssetsDlopenRelative;
native_assets.dlopen_system = &NativeAssets::DlopenSystem;
native_assets.dlopen_executable = &NativeAssets::DlopenExecutable;
native_assets.dlopen_process = &NativeAssets::DlopenProcess;
native_assets.dlsym = &NativeAssets::Dlsym;
Dart_InitializeNativeAssetsResolver(&native_assets);
#endif // !defined(DART_PRECOMPILER)

// Make the isolate runnable so that it is ready to handle messages.
Dart_ExitScope();
Dart_ExitIsolate();
Expand Down
Loading

0 comments on commit 9e1e251

Please sign in to comment.