Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
11d756a6
E
engine
项目概览
sxychenjing
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
11d756a6
编写于
10月 09, 2020
作者:
G
George Wright
提交者:
GitHub
10月 09, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add dart_entrypoint_argc/argv to the FlutterProjectArgs (#21737)
上级
ec1d1111
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
89 addition
and
0 deletion
+89
-0
shell/platform/embedder/embedder.cc
shell/platform/embedder/embedder.cc
+14
-0
shell/platform/embedder/embedder.h
shell/platform/embedder/embedder.h
+13
-0
shell/platform/embedder/fixtures/main.dart
shell/platform/embedder/fixtures/main.dart
+7
-0
shell/platform/embedder/tests/embedder_config_builder.cc
shell/platform/embedder/tests/embedder_config_builder.cc
+25
-0
shell/platform/embedder/tests/embedder_config_builder.h
shell/platform/embedder/tests/embedder_config_builder.h
+3
-0
shell/platform/embedder/tests/embedder_unittests.cc
shell/platform/embedder/tests/embedder_unittests.cc
+27
-0
未找到文件。
shell/platform/embedder/embedder.cc
浏览文件 @
11d756a6
...
...
@@ -1126,6 +1126,20 @@ FlutterEngineResult FlutterEngineInitialize(size_t version,
}
}
if
(
SAFE_ACCESS
(
args
,
dart_entrypoint_argc
,
0
)
>
0
)
{
if
(
SAFE_ACCESS
(
args
,
dart_entrypoint_argv
,
nullptr
)
==
nullptr
)
{
return
LOG_EMBEDDER_ERROR
(
kInvalidArguments
,
"Could not determine Dart entrypoint arguments "
"as dart_entrypoint_argc "
"was set, but dart_entrypoint_argv was null."
);
}
std
::
vector
<
std
::
string
>
arguments
(
args
->
dart_entrypoint_argc
);
for
(
int
i
=
0
;
i
<
args
->
dart_entrypoint_argc
;
++
i
)
{
arguments
[
i
]
=
std
::
string
{
args
->
dart_entrypoint_argv
[
i
]};
}
settings
.
dart_entrypoint_args
=
std
::
move
(
arguments
);
}
if
(
!
run_configuration
.
IsValid
())
{
return
LOG_EMBEDDER_ERROR
(
kInvalidArguments
,
...
...
shell/platform/embedder/embedder.h
浏览文件 @
11d756a6
...
...
@@ -1368,6 +1368,19 @@ typedef struct {
/// matches what the platform would natively resolve to as possible.
FlutterComputePlatformResolvedLocaleCallback
compute_platform_resolved_locale_callback
;
/// The command line argument count for arguments passed through to the Dart
/// entrypoint.
int
dart_entrypoint_argc
;
/// The command line arguments passed through to the Dart entrypoint. The
/// strings must be `NULL` terminated.
///
/// The strings will be copied out and so any strings passed in here can
/// be safely collected after initializing the engine with
/// `FlutterProjectArgs`.
const
char
*
const
*
dart_entrypoint_argv
;
}
FlutterProjectArgs
;
//------------------------------------------------------------------------------
...
...
shell/platform/embedder/fixtures/main.dart
浏览文件 @
11d756a6
...
...
@@ -733,3 +733,10 @@ void render_targets_are_recycled() {
};
window
.
scheduleFrame
();
}
void
nativeArgumentsCallback
(
List
<
String
>
args
)
native
'NativeArgumentsCallback'
;
@pragma
(
'vm:entry-point'
)
void
dart_entrypoint_args
(
List
<
String
>
args
)
{
nativeArgumentsCallback
(
args
);
}
shell/platform/embedder/tests/embedder_config_builder.cc
浏览文件 @
11d756a6
...
...
@@ -217,6 +217,14 @@ void EmbedderConfigBuilder::AddCommandLineArgument(std::string arg) {
command_line_arguments_
.
emplace_back
(
std
::
move
(
arg
));
}
void
EmbedderConfigBuilder
::
AddDartEntrypointArgument
(
std
::
string
arg
)
{
if
(
arg
.
size
()
==
0
)
{
return
;
}
dart_entrypoint_arguments_
.
emplace_back
(
std
::
move
(
arg
));
}
void
EmbedderConfigBuilder
::
SetPlatformTaskRunner
(
const
FlutterTaskRunnerDescription
*
runner
)
{
if
(
runner
==
nullptr
)
{
...
...
@@ -317,6 +325,23 @@ UniqueEngine EmbedderConfigBuilder::SetupEngine(bool run) const {
project_args
.
command_line_argc
=
0
;
}
std
::
vector
<
const
char
*>
dart_args
;
dart_args
.
reserve
(
dart_entrypoint_arguments_
.
size
());
for
(
const
auto
&
arg
:
dart_entrypoint_arguments_
)
{
dart_args
.
push_back
(
arg
.
c_str
());
}
if
(
dart_args
.
size
()
>
0
)
{
project_args
.
dart_entrypoint_argv
=
dart_args
.
data
();
project_args
.
dart_entrypoint_argc
=
dart_args
.
size
();
}
else
{
// Clear it out in case this is not the first engine launch from the
// embedder config builder.
project_args
.
dart_entrypoint_argv
=
nullptr
;
project_args
.
dart_entrypoint_argc
=
0
;
}
auto
result
=
run
?
FlutterEngineRun
(
FLUTTER_ENGINE_VERSION
,
&
renderer_config_
,
&
project_args
,
&
context_
,
&
engine
)
...
...
shell/platform/embedder/tests/embedder_config_builder.h
浏览文件 @
11d756a6
...
...
@@ -76,6 +76,8 @@ class EmbedderConfigBuilder {
void
AddCommandLineArgument
(
std
::
string
arg
);
void
AddDartEntrypointArgument
(
std
::
string
arg
);
void
SetPlatformTaskRunner
(
const
FlutterTaskRunnerDescription
*
runner
);
void
SetRenderTaskRunner
(
const
FlutterTaskRunnerDescription
*
runner
);
...
...
@@ -106,6 +108,7 @@ class EmbedderConfigBuilder {
FlutterCustomTaskRunners
custom_task_runners_
=
{};
FlutterCompositor
compositor_
=
{};
std
::
vector
<
std
::
string
>
command_line_arguments_
;
std
::
vector
<
std
::
string
>
dart_entrypoint_arguments_
;
UniqueEngine
SetupEngine
(
bool
run
)
const
;
...
...
shell/platform/embedder/tests/embedder_unittests.cc
浏览文件 @
11d756a6
...
...
@@ -473,6 +473,33 @@ TEST_F(EmbedderTest, VMShutsDownWhenNoEnginesInProcess) {
}
}
//------------------------------------------------------------------------------
///
TEST_F
(
EmbedderTest
,
DartEntrypointArgs
)
{
auto
&
context
=
GetEmbedderContext
(
ContextType
::
kSoftwareContext
);
EmbedderConfigBuilder
builder
(
context
);
builder
.
SetSoftwareRendererConfig
();
builder
.
AddDartEntrypointArgument
(
"foo"
);
builder
.
AddDartEntrypointArgument
(
"bar"
);
builder
.
SetDartEntrypoint
(
"dart_entrypoint_args"
);
fml
::
AutoResetWaitableEvent
callback_latch
;
std
::
vector
<
std
::
string
>
callback_args
;
auto
nativeArgumentsCallback
=
[
&
callback_args
,
&
callback_latch
](
Dart_NativeArguments
args
)
{
Dart_Handle
exception
=
nullptr
;
callback_args
=
tonic
::
DartConverter
<
std
::
vector
<
std
::
string
>>::
FromArguments
(
args
,
0
,
exception
);
callback_latch
.
Signal
();
};
context
.
AddNativeCallback
(
"NativeArgumentsCallback"
,
CREATE_NATIVE_ENTRY
(
nativeArgumentsCallback
));
auto
engine
=
builder
.
LaunchEngine
();
callback_latch
.
Wait
();
ASSERT_EQ
(
callback_args
[
0
],
"foo"
);
ASSERT_EQ
(
callback_args
[
1
],
"bar"
);
}
//------------------------------------------------------------------------------
/// These snapshots may be materialized from symbols and the size field may not
/// be relevant. Since this information is redundant, engine launch should not
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录