Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
godot
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
community
godot
Commits
14e6696c
Commit
14e6696c
authored
Apr 24, 2020
by
Fredia Huya-Kouadio
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implementation of the Godot Android Plugin configuration file
parent
163687d1
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
531 additions
and
51 deletions
+531
-51
editor_export.cpp
editor/editor_export.cpp
+53
-1
editor_export.h
editor/editor_export.h
+4
-1
project_export.cpp
editor/project_export.cpp
+7
-0
project_export.h
editor/project_export.h
+1
-0
export.cpp
platform/android/export/export.cpp
+131
-13
AndroidManifest.xml
platform/android/java/app/AndroidManifest.xml
+2
-2
build.gradle
platform/android/java/app/build.gradle
+21
-8
config.gradle
platform/android/java/app/config.gradle
+51
-22
build.gradle
platform/android/java/build.gradle
+2
-1
GodotPluginRegistry.java
...src/org/godotengine/godot/plugin/GodotPluginRegistry.java
+8
-3
godot_plugin_config.h
platform/android/plugin/godot_plugin_config.h
+251
-0
No files found.
editor/editor_export.cpp
View file @
14e6696c
...
@@ -1162,6 +1162,7 @@ void EditorExport::save_presets() {
...
@@ -1162,6 +1162,7 @@ void EditorExport::save_presets() {
}
}
void
EditorExport
::
_bind_methods
()
{
void
EditorExport
::
_bind_methods
()
{
ADD_SIGNAL
(
MethodInfo
(
"export_presets_updated"
));
}
}
void
EditorExport
::
add_export_platform
(
const
Ref
<
EditorExportPlatform
>
&
p_platform
)
{
void
EditorExport
::
add_export_platform
(
const
Ref
<
EditorExportPlatform
>
&
p_platform
)
{
...
@@ -1229,8 +1230,13 @@ Vector<Ref<EditorExportPlugin>> EditorExport::get_export_plugins() {
...
@@ -1229,8 +1230,13 @@ Vector<Ref<EditorExportPlugin>> EditorExport::get_export_plugins() {
}
}
void
EditorExport
::
_notification
(
int
p_what
)
{
void
EditorExport
::
_notification
(
int
p_what
)
{
if
(
p_what
==
NOTIFICATION_ENTER_TREE
)
{
switch
(
p_what
)
{
case
NOTIFICATION_ENTER_TREE
:
{
load_config
();
load_config
();
}
break
;
case
NOTIFICATION_PROCESS
:
{
update_export_presets
();
}
break
;
}
}
}
}
...
@@ -1332,6 +1338,49 @@ void EditorExport::load_config() {
...
@@ -1332,6 +1338,49 @@ void EditorExport::load_config() {
block_save
=
false
;
block_save
=
false
;
}
}
void
EditorExport
::
update_export_presets
()
{
Map
<
StringName
,
List
<
EditorExportPlatform
::
ExportOption
>>
platform_options
;
for
(
int
i
=
0
;
i
<
export_platforms
.
size
();
i
++
)
{
Ref
<
EditorExportPlatform
>
platform
=
export_platforms
[
i
];
if
(
platform
->
should_update_export_options
())
{
List
<
EditorExportPlatform
::
ExportOption
>
options
;
platform
->
get_export_options
(
&
options
);
platform_options
[
platform
->
get_name
()]
=
options
;
}
}
bool
export_presets_updated
=
false
;
for
(
int
i
=
0
;
i
<
export_presets
.
size
();
i
++
)
{
Ref
<
EditorExportPreset
>
preset
=
export_presets
[
i
];
if
(
platform_options
.
has
(
preset
->
get_platform
()
->
get_name
()))
{
export_presets_updated
=
true
;
List
<
EditorExportPlatform
::
ExportOption
>
options
=
platform_options
[
preset
->
get_platform
()
->
get_name
()];
// Copy the previous preset values
Map
<
StringName
,
Variant
>
previous_values
=
preset
->
values
;
// Clear the preset properties and values prior to reloading
preset
->
properties
.
clear
();
preset
->
values
.
clear
();
for
(
List
<
EditorExportPlatform
::
ExportOption
>::
Element
*
E
=
options
.
front
();
E
;
E
=
E
->
next
())
{
preset
->
properties
.
push_back
(
E
->
get
().
option
);
StringName
option_name
=
E
->
get
().
option
.
name
;
preset
->
values
[
option_name
]
=
previous_values
.
has
(
option_name
)
?
previous_values
[
option_name
]
:
E
->
get
().
default_value
;
}
}
}
if
(
export_presets_updated
)
{
emit_signal
(
_export_presets_updated
);
}
}
bool
EditorExport
::
poll_export_platforms
()
{
bool
EditorExport
::
poll_export_platforms
()
{
bool
changed
=
false
;
bool
changed
=
false
;
for
(
int
i
=
0
;
i
<
export_platforms
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
export_platforms
.
size
();
i
++
)
{
...
@@ -1351,7 +1400,10 @@ EditorExport::EditorExport() {
...
@@ -1351,7 +1400,10 @@ EditorExport::EditorExport() {
save_timer
->
connect
(
"timeout"
,
callable_mp
(
this
,
&
EditorExport
::
_save
));
save_timer
->
connect
(
"timeout"
,
callable_mp
(
this
,
&
EditorExport
::
_save
));
block_save
=
false
;
block_save
=
false
;
_export_presets_updated
=
"export_presets_updated"
;
singleton
=
this
;
singleton
=
this
;
set_process
(
true
);
}
}
EditorExport
::~
EditorExport
()
{
EditorExport
::~
EditorExport
()
{
...
...
editor/editor_export.h
View file @
14e6696c
...
@@ -227,6 +227,7 @@ public:
...
@@ -227,6 +227,7 @@ public:
virtual
Ref
<
EditorExportPreset
>
create_preset
();
virtual
Ref
<
EditorExportPreset
>
create_preset
();
virtual
void
get_export_options
(
List
<
ExportOption
>
*
r_options
)
=
0
;
virtual
void
get_export_options
(
List
<
ExportOption
>
*
r_options
)
=
0
;
virtual
bool
should_update_export_options
()
{
return
false
;
}
virtual
bool
get_option_visibility
(
const
String
&
p_option
,
const
Map
<
StringName
,
Variant
>
&
p_options
)
const
{
return
true
;
}
virtual
bool
get_option_visibility
(
const
String
&
p_option
,
const
Map
<
StringName
,
Variant
>
&
p_options
)
const
{
return
true
;
}
virtual
String
get_os_name
()
const
=
0
;
virtual
String
get_os_name
()
const
=
0
;
...
@@ -350,6 +351,8 @@ class EditorExport : public Node {
...
@@ -350,6 +351,8 @@ class EditorExport : public Node {
Vector
<
Ref
<
EditorExportPreset
>>
export_presets
;
Vector
<
Ref
<
EditorExportPreset
>>
export_presets
;
Vector
<
Ref
<
EditorExportPlugin
>>
export_plugins
;
Vector
<
Ref
<
EditorExportPlugin
>>
export_plugins
;
StringName
_export_presets_updated
;
Timer
*
save_timer
;
Timer
*
save_timer
;
bool
block_save
;
bool
block_save
;
...
@@ -381,7 +384,7 @@ public:
...
@@ -381,7 +384,7 @@ public:
Vector
<
Ref
<
EditorExportPlugin
>>
get_export_plugins
();
Vector
<
Ref
<
EditorExportPlugin
>>
get_export_plugins
();
void
load_config
();
void
load_config
();
void
update_export_presets
();
bool
poll_export_platforms
();
bool
poll_export_platforms
();
EditorExport
();
EditorExport
();
...
...
editor/project_export.cpp
View file @
14e6696c
...
@@ -133,6 +133,12 @@ void ProjectExportDialog::_add_preset(int p_platform) {
...
@@ -133,6 +133,12 @@ void ProjectExportDialog::_add_preset(int p_platform) {
_edit_preset
(
EditorExport
::
get_singleton
()
->
get_export_preset_count
()
-
1
);
_edit_preset
(
EditorExport
::
get_singleton
()
->
get_export_preset_count
()
-
1
);
}
}
void
ProjectExportDialog
::
_force_update_current_preset_parameters
()
{
// Force the parameters section to refresh its UI.
parameters
->
edit
(
nullptr
);
_update_current_preset
();
}
void
ProjectExportDialog
::
_update_current_preset
()
{
void
ProjectExportDialog
::
_update_current_preset
()
{
_edit_preset
(
presets
->
get_current
());
_edit_preset
(
presets
->
get_current
());
}
}
...
@@ -1101,6 +1107,7 @@ ProjectExportDialog::ProjectExportDialog() {
...
@@ -1101,6 +1107,7 @@ ProjectExportDialog::ProjectExportDialog() {
parameters
->
set_name
(
TTR
(
"Options"
));
parameters
->
set_name
(
TTR
(
"Options"
));
parameters
->
set_v_size_flags
(
Control
::
SIZE_EXPAND_FILL
);
parameters
->
set_v_size_flags
(
Control
::
SIZE_EXPAND_FILL
);
parameters
->
connect
(
"property_edited"
,
callable_mp
(
this
,
&
ProjectExportDialog
::
_update_parameters
));
parameters
->
connect
(
"property_edited"
,
callable_mp
(
this
,
&
ProjectExportDialog
::
_update_parameters
));
EditorExport
::
get_singleton
()
->
connect
(
"export_presets_updated"
,
callable_mp
(
this
,
&
ProjectExportDialog
::
_force_update_current_preset_parameters
));
// Resources export parameters.
// Resources export parameters.
...
...
editor/project_export.h
View file @
14e6696c
...
@@ -123,6 +123,7 @@ private:
...
@@ -123,6 +123,7 @@ private:
void
_delete_preset_confirm
();
void
_delete_preset_confirm
();
void
_update_export_all
();
void
_update_export_all
();
void
_force_update_current_preset_parameters
();
void
_update_current_preset
();
void
_update_current_preset
();
void
_update_presets
();
void
_update_presets
();
...
...
platform/android/export/export.cpp
View file @
14e6696c
...
@@ -44,6 +44,7 @@
...
@@ -44,6 +44,7 @@
#include "editor/editor_node.h"
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
#include "editor/editor_settings.h"
#include "platform/android/logo.gen.h"
#include "platform/android/logo.gen.h"
#include "platform/android/plugin/godot_plugin_config.h"
#include "platform/android/run_icon.gen.h"
#include "platform/android/run_icon.gen.h"
#include <string.h>
#include <string.h>
...
@@ -252,16 +253,45 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
...
@@ -252,16 +253,45 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
EditorProgress
*
ep
;
EditorProgress
*
ep
;
};
};
Vector
<
PluginConfig
>
plugins
;
volatile
bool
plugins_changed
;
Mutex
plugins_lock
;
Vector
<
Device
>
devices
;
Vector
<
Device
>
devices
;
volatile
bool
devices_changed
;
volatile
bool
devices_changed
;
Mutex
device_lock
;
Mutex
device_lock
;
Thread
*
device
_thread
;
Thread
*
check_for_changes
_thread
;
volatile
bool
quit_request
;
volatile
bool
quit_request
;
static
void
_
device
_poll_thread
(
void
*
ud
)
{
static
void
_
check_for_changes
_poll_thread
(
void
*
ud
)
{
EditorExportPlatformAndroid
*
ea
=
(
EditorExportPlatformAndroid
*
)
ud
;
EditorExportPlatformAndroid
*
ea
=
(
EditorExportPlatformAndroid
*
)
ud
;
while
(
!
ea
->
quit_request
)
{
while
(
!
ea
->
quit_request
)
{
// Check for plugins updates
{
// Nothing to do if we already know the plugins have changed.
if
(
!
ea
->
plugins_changed
)
{
Vector
<
PluginConfig
>
loaded_plugins
=
get_plugins
();
MutexLock
lock
(
ea
->
plugins_lock
);
if
(
ea
->
plugins
.
size
()
!=
loaded_plugins
.
size
())
{
ea
->
plugins_changed
=
true
;
}
else
{
for
(
int
i
=
0
;
i
<
ea
->
plugins
.
size
();
i
++
)
{
if
(
ea
->
plugins
[
i
].
name
!=
loaded_plugins
[
i
].
name
)
{
ea
->
plugins_changed
=
true
;
break
;
}
}
}
if
(
ea
->
plugins_changed
)
{
ea
->
plugins
=
loaded_plugins
;
}
}
}
// Check for devices updates
String
adb
=
EditorSettings
::
get_singleton
()
->
get
(
"export/android/adb"
);
String
adb
=
EditorSettings
::
get_singleton
()
->
get
(
"export/android/adb"
);
if
(
FileAccess
::
exists
(
adb
))
{
if
(
FileAccess
::
exists
(
adb
))
{
String
devices
;
String
devices
;
...
@@ -573,6 +603,73 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
...
@@ -573,6 +603,73 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
return
abis
;
return
abis
;
}
}
/// List the gdap files in the directory specified by the p_path parameter.
static
Vector
<
String
>
list_gdap_files
(
const
String
&
p_path
)
{
Vector
<
String
>
dir_files
;
DirAccessRef
da
=
DirAccess
::
open
(
p_path
);
if
(
da
)
{
da
->
list_dir_begin
();
while
(
true
)
{
String
file
=
da
->
get_next
();
if
(
file
==
""
)
{
break
;
}
if
(
da
->
current_is_dir
()
||
da
->
current_is_hidden
())
{
continue
;
}
if
(
file
.
ends_with
(
PLUGIN_CONFIG_EXT
))
{
dir_files
.
push_back
(
file
);
}
}
da
->
list_dir_end
();
}
return
dir_files
;
}
static
Vector
<
PluginConfig
>
get_plugins
()
{
Vector
<
PluginConfig
>
loaded_plugins
;
String
plugins_dir
=
ProjectSettings
::
get_singleton
()
->
get_resource_path
().
plus_file
(
"android/plugins"
);
// Add the prebuilt plugins
loaded_plugins
.
append_array
(
get_prebuilt_plugins
(
plugins_dir
));
if
(
DirAccess
::
exists
(
plugins_dir
))
{
Vector
<
String
>
plugins_filenames
=
list_gdap_files
(
plugins_dir
);
if
(
!
plugins_filenames
.
empty
())
{
Ref
<
ConfigFile
>
config_file
=
memnew
(
ConfigFile
);
for
(
int
i
=
0
;
i
<
plugins_filenames
.
size
();
i
++
)
{
PluginConfig
config
=
load_plugin_config
(
config_file
,
plugins_dir
.
plus_file
(
plugins_filenames
[
i
]));
if
(
config
.
valid_config
)
{
loaded_plugins
.
push_back
(
config
);
}
else
{
print_error
(
"Invalid plugin config file "
+
plugins_filenames
[
i
]);
}
}
}
}
return
loaded_plugins
;
}
static
Vector
<
PluginConfig
>
get_enabled_plugins
(
const
Ref
<
EditorExportPreset
>
&
p_presets
)
{
Vector
<
PluginConfig
>
enabled_plugins
;
Vector
<
PluginConfig
>
all_plugins
=
get_plugins
();
for
(
int
i
=
0
;
i
<
all_plugins
.
size
();
i
++
)
{
PluginConfig
plugin
=
all_plugins
[
i
];
bool
enabled
=
p_presets
->
get
(
"plugins/"
+
plugin
.
name
);
if
(
enabled
)
{
enabled_plugins
.
push_back
(
plugin
);
}
}
return
enabled_plugins
;
}
static
Error
store_in_apk
(
APKExportData
*
ed
,
const
String
&
p_path
,
const
Vector
<
uint8_t
>
&
p_data
,
int
compression_method
=
Z_DEFLATED
)
{
static
Error
store_in_apk
(
APKExportData
*
ed
,
const
String
&
p_path
,
const
Vector
<
uint8_t
>
&
p_data
,
int
compression_method
=
Z_DEFLATED
)
{
zip_fileinfo
zipfi
=
get_zip_fileinfo
();
zip_fileinfo
zipfi
=
get_zip_fileinfo
();
zipOpenNewFileInZip
(
ed
->
apk
,
zipOpenNewFileInZip
(
ed
->
apk
,
...
@@ -674,7 +771,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
...
@@ -674,7 +771,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
int
xr_mode_index
=
p_preset
->
get
(
"xr_features/xr_mode"
);
int
xr_mode_index
=
p_preset
->
get
(
"xr_features/xr_mode"
);
String
plugins
=
p_preset
->
get
(
"custom_template/plugins"
);
String
plugins
_names
=
get_plugins_names
(
get_enabled_plugins
(
p_preset
)
);
Vector
<
String
>
perms
;
Vector
<
String
>
perms
;
...
@@ -829,9 +926,9 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
...
@@ -829,9 +926,9 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
}
}
}
}
if
(
tname
==
"meta-data"
&&
attrname
==
"value"
&&
value
==
"
custom_template_plugins_value"
)
{
if
(
tname
==
"meta-data"
&&
attrname
==
"value"
&&
value
==
"
plugins_value"
&&
!
plugins_names
.
empty
()
)
{
// Update the meta-data 'android:value' attribute with the list of enabled plugins.
// Update the meta-data 'android:value' attribute with the list of enabled plugins.
string_table
.
write
[
attr_value
]
=
plugins
;
string_table
.
write
[
attr_value
]
=
plugins
_names
;
}
}
iofs
+=
20
;
iofs
+=
20
;
...
@@ -1354,7 +1451,14 @@ public:
...
@@ -1354,7 +1451,14 @@ public:
r_options
->
push_back
(
ExportOption
(
PropertyInfo
(
Variant
::
STRING
,
"custom_template/debug"
,
PROPERTY_HINT_GLOBAL_FILE
,
"*.apk"
),
""
));
r_options
->
push_back
(
ExportOption
(
PropertyInfo
(
Variant
::
STRING
,
"custom_template/debug"
,
PROPERTY_HINT_GLOBAL_FILE
,
"*.apk"
),
""
));
r_options
->
push_back
(
ExportOption
(
PropertyInfo
(
Variant
::
STRING
,
"custom_template/release"
,
PROPERTY_HINT_GLOBAL_FILE
,
"*.apk"
),
""
));
r_options
->
push_back
(
ExportOption
(
PropertyInfo
(
Variant
::
STRING
,
"custom_template/release"
,
PROPERTY_HINT_GLOBAL_FILE
,
"*.apk"
),
""
));
r_options
->
push_back
(
ExportOption
(
PropertyInfo
(
Variant
::
BOOL
,
"custom_template/use_custom_build"
),
false
));
r_options
->
push_back
(
ExportOption
(
PropertyInfo
(
Variant
::
BOOL
,
"custom_template/use_custom_build"
),
false
));
r_options
->
push_back
(
ExportOption
(
PropertyInfo
(
Variant
::
STRING
,
"custom_template/plugins"
,
PROPERTY_HINT_PLACEHOLDER_TEXT
,
"Plugin1,Plugin2,..."
),
""
));
Vector
<
PluginConfig
>
plugins_configs
=
get_plugins
();
for
(
int
i
=
0
;
i
<
plugins_configs
.
size
();
i
++
)
{
print_verbose
(
"Found Android plugin "
+
plugins_configs
[
i
].
name
);
r_options
->
push_back
(
ExportOption
(
PropertyInfo
(
Variant
::
BOOL
,
"plugins/"
+
plugins_configs
[
i
].
name
),
false
));
}
plugins_changed
=
false
;
r_options
->
push_back
(
ExportOption
(
PropertyInfo
(
Variant
::
STRING
,
"command_line/extra_args"
),
""
));
r_options
->
push_back
(
ExportOption
(
PropertyInfo
(
Variant
::
STRING
,
"command_line/extra_args"
),
""
));
r_options
->
push_back
(
ExportOption
(
PropertyInfo
(
Variant
::
INT
,
"version/code"
,
PROPERTY_HINT_RANGE
,
"1,4096,1,or_greater"
),
1
));
r_options
->
push_back
(
ExportOption
(
PropertyInfo
(
Variant
::
INT
,
"version/code"
,
PROPERTY_HINT_RANGE
,
"1,4096,1,or_greater"
),
1
));
r_options
->
push_back
(
ExportOption
(
PropertyInfo
(
Variant
::
STRING
,
"version/name"
),
"1.0"
));
r_options
->
push_back
(
ExportOption
(
PropertyInfo
(
Variant
::
STRING
,
"version/name"
),
"1.0"
));
...
@@ -1409,6 +1513,15 @@ public:
...
@@ -1409,6 +1513,15 @@ public:
return
logo
;
return
logo
;
}
}
virtual
bool
should_update_export_options
()
{
bool
export_options_changed
=
plugins_changed
;
if
(
export_options_changed
)
{
// don't clear unless we're reporting true, to avoid race
plugins_changed
=
false
;
}
return
export_options_changed
;
}
virtual
bool
poll_export
()
{
virtual
bool
poll_export
()
{
bool
dc
=
devices_changed
;
bool
dc
=
devices_changed
;
if
(
dc
)
{
if
(
dc
)
{
...
@@ -1755,18 +1868,22 @@ public:
...
@@ -1755,18 +1868,22 @@ public:
#endif
#endif
String
build_path
=
ProjectSettings
::
get_singleton
()
->
get_resource_path
().
plus_file
(
"android/build"
);
String
build_path
=
ProjectSettings
::
get_singleton
()
->
get_resource_path
().
plus_file
(
"android/build"
);
String
plugins_dir
=
ProjectSettings
::
get_singleton
()
->
get_resource_path
().
plus_file
(
"android/plugins"
);
build_command
=
build_path
.
plus_file
(
build_command
);
build_command
=
build_path
.
plus_file
(
build_command
);
String
package_name
=
get_package_name
(
p_preset
->
get
(
"package/unique_name"
));
String
package_name
=
get_package_name
(
p_preset
->
get
(
"package/unique_name"
));
String
plugins
=
p_preset
->
get
(
"custom_template/plugins"
);
Vector
<
PluginConfig
>
enabled_plugins
=
get_enabled_plugins
(
p_preset
);
String
local_plugins_binaries
=
get_plugins_binaries
(
BINARY_TYPE_LOCAL
,
enabled_plugins
);
String
remote_plugins_binaries
=
get_plugins_binaries
(
BINARY_TYPE_REMOTE
,
enabled_plugins
);
String
custom_maven_repos
=
get_plugins_custom_maven_repos
(
enabled_plugins
);
List
<
String
>
cmdline
;
List
<
String
>
cmdline
;
cmdline
.
push_back
(
"build"
);
cmdline
.
push_back
(
"build"
);
cmdline
.
push_back
(
"-Pexport_package_name="
+
package_name
);
// argument to specify the package name.
cmdline
.
push_back
(
"-Pexport_package_name="
+
package_name
);
// argument to specify the package name.
cmdline
.
push_back
(
"-Pcustom_template_plugins_dir="
+
plugins_dir
);
// argument to specify the plugins directory.
cmdline
.
push_back
(
"-Pplugins_local_binaries="
+
local_plugins_binaries
);
// argument to specify the list of plugins local dependencies.
cmdline
.
push_back
(
"-Pcustom_template_plugins="
+
plugins
);
// argument to specify the list of plugins to enable.
cmdline
.
push_back
(
"-Pplugins_remote_binaries="
+
remote_plugins_binaries
);
// argument to specify the list of plugins remote dependencies.
cmdline
.
push_back
(
"-Pplugins_maven_repos="
+
custom_maven_repos
);
// argument to specify the list of custom maven repos for the plugins dependencies.
cmdline
.
push_back
(
"-p"
);
// argument to specify the start directory.
cmdline
.
push_back
(
"-p"
);
// argument to specify the start directory.
cmdline
.
push_back
(
build_path
);
// start directory.
cmdline
.
push_back
(
build_path
);
// start directory.
/*{ used for debug
/*{ used for debug
...
@@ -2283,14 +2400,15 @@ public:
...
@@ -2283,14 +2400,15 @@ public:
run_icon
->
create_from_image
(
img
);
run_icon
->
create_from_image
(
img
);
devices_changed
=
true
;
devices_changed
=
true
;
plugins_changed
=
true
;
quit_request
=
false
;
quit_request
=
false
;
device_thread
=
Thread
::
create
(
_device
_poll_thread
,
this
);
check_for_changes_thread
=
Thread
::
create
(
_check_for_changes
_poll_thread
,
this
);
}
}
~
EditorExportPlatformAndroid
()
{
~
EditorExportPlatformAndroid
()
{
quit_request
=
true
;
quit_request
=
true
;
Thread
::
wait_to_finish
(
device
_thread
);
Thread
::
wait_to_finish
(
check_for_changes
_thread
);
memdelete
(
device
_thread
);
memdelete
(
check_for_changes
_thread
);
}
}
};
};
...
...
platform/android/java/app/AndroidManifest.xml
View file @
14e6696c
...
@@ -32,8 +32,8 @@
...
@@ -32,8 +32,8 @@
<!-- Metadata populated at export time and used by Godot to figure out which plugins must be enabled. -->
<!-- Metadata populated at export time and used by Godot to figure out which plugins must be enabled. -->
<meta-data
<meta-data
android:name=
"
custom_template_
plugins"
android:name=
"plugins"
android:value=
"
custom_template_
plugins_value"
/>
android:value=
"plugins_value"
/>
<activity
<activity
android:name=
".GodotApp"
android:name=
".GodotApp"
...
...
platform/android/java/app/build.gradle
View file @
14e6696c
...
@@ -21,6 +21,16 @@ allprojects {
...
@@ -21,6 +21,16 @@ allprojects {
mavenCentral
()
mavenCentral
()
google
()
google
()
jcenter
()
jcenter
()
// Godot user plugins custom maven repos
String
[]
mavenRepos
=
getGodotPluginsMavenRepos
()
if
(
mavenRepos
!=
null
&&
mavenRepos
.
size
()
>
0
)
{
for
(
String
repoUrl
:
mavenRepos
)
{
maven
{
url
repoUrl
}
}
}
}
}
}
}
...
@@ -40,15 +50,18 @@ dependencies {
...
@@ -40,15 +50,18 @@ dependencies {
releaseImplementation
fileTree
(
dir:
'libs/release'
,
include:
[
'*.jar'
,
'*.aar'
])
releaseImplementation
fileTree
(
dir:
'libs/release'
,
include:
[
'*.jar'
,
'*.aar'
])
}
}
// Godot prebuilt plugins
// Godot user plugins remote dependencies
implementation
fileTree
(
dir:
'libs/plugins'
,
include:
[
"GodotPayment*.aar"
])
String
[]
remoteDeps
=
getGodotPluginsRemoteBinaries
()
if
(
remoteDeps
!=
null
&&
remoteDeps
.
size
()
>
0
)
{
for
(
String
dep
:
remoteDeps
)
{
implementation
dep
}
}
// Godot user plugins dependencies
// Godot user plugins local dependencies
String
pluginsDir
=
getGodotPluginsDirectory
()
String
[]
pluginsBinaries
=
getGodotPluginsLocalBinaries
()
String
[]
pluginsBinaries
=
getGodotPluginsBinaries
()
if
(
pluginsBinaries
!=
null
&&
pluginsBinaries
.
size
()
>
0
)
{
if
(
pluginsDir
!=
null
&&
!
pluginsDir
.
isEmpty
()
&&
implementation
files
(
pluginsBinaries
)
pluginsBinaries
!=
null
&&
pluginsBinaries
.
size
()
>
0
)
{
implementation
fileTree
(
dir:
pluginsDir
,
include:
pluginsBinaries
)
}
}
}
}
...
...
platform/android/java/app/config.gradle
View file @
14e6696c
...
@@ -28,39 +28,68 @@ ext.getExportPackageName = { ->
...
@@ -28,39 +28,68 @@ ext.getExportPackageName = { ->
return
appId
return
appId
}
}
final
String
PLUGIN_VALUE_SEPARATOR_REGEX
=
"\\|"
/**
/**
* Parse the project properties for the 'custom_template_plugins' property and return
* Parse the project properties for the 'plugins_maven_repos' property and return the list
* their binaries for inclusion in the build dependencies.
* of maven repos.
*
* The listed plugins must have their binaries in the project plugins directory.
*/
*/
ext
.
getGodotPlugins
Binarie
s
=
{
->
ext
.
getGodotPlugins
MavenRepo
s
=
{
->
S
tring
[]
binDep
s
=
[]
S
et
<
String
>
mavenRepo
s
=
[]
// Retrieve the list of
enabled plugin
s.
// Retrieve the list of
maven repo
s.
if
(
project
.
hasProperty
(
"
custom_template_plugin
s"
))
{
if
(
project
.
hasProperty
(
"
plugins_maven_repo
s"
))
{
String
pluginsList
=
project
.
property
(
"custom_template_plugin
s"
)
String
mavenReposProperty
=
project
.
property
(
"plugins_maven_repo
s"
)
if
(
pluginsList
!=
null
&&
!
pluginsList
.
trim
().
isEmpty
())
{
if
(
mavenReposProperty
!=
null
&&
!
mavenReposProperty
.
trim
().
isEmpty
())
{
for
(
String
plugin
:
pluginsList
.
split
(
","
))
{
for
(
String
mavenRepoUrl
:
mavenReposProperty
.
split
(
PLUGIN_VALUE_SEPARATOR_REGEX
))
{
binDeps
+=
plugin
.
trim
()
+
"*.aar"
mavenRepos
+=
mavenRepoUrl
.
trim
()
}
}
}
}
}
}
return
binDeps
return
mavenRepos
}
/**
* Parse the project properties for the 'plugins_remote_binaries' property and return
* it for inclusion in the build dependencies.
*/
ext
.
getGodotPluginsRemoteBinaries
=
{
->
Set
<
String
>
remoteDeps
=
[]
// Retrieve the list of remote plugins binaries.
if
(
project
.
hasProperty
(
"plugins_remote_binaries"
))
{
String
remoteDepsList
=
project
.
property
(
"plugins_remote_binaries"
)
if
(
remoteDepsList
!=
null
&&
!
remoteDepsList
.
trim
().
isEmpty
())
{
for
(
String
dep:
remoteDepsList
.
split
(
PLUGIN_VALUE_SEPARATOR_REGEX
))
{
remoteDeps
+=
dep
.
trim
()
}
}
}
return
remoteDeps
}
}
/**
/**
* Parse the project properties for the '
custom_template_plugins_dir
' property and return
* Parse the project properties for the '
plugins_local_binaries
' property and return
*
its value
.
*
their binaries for inclusion in the build dependencies
.
*
*
*
The returned value is the directory containing user plugins
.
*
Returns the prebuilt plugins if the 'plugins_local_binaries' property is unavailable
.
*/
*/
ext
.
getGodotPluginsDirectory
=
{
->
ext
.
getGodotPluginsLocalBinaries
=
{
->
// The plugins directory is provided by the 'custom_template_plugins_dir' property.
// Set the prebuilt plugins as default. If custom build is enabled,
String
pluginsDir
=
project
.
hasProperty
(
"custom_template_plugins_dir"
)
// the 'plugins_local_binaries' will be defined so we can use it instead.
?
project
.
property
(
"custom_template_plugins_dir"
)
Set
<
String
>
binDeps
=
[
"libs/plugins/GodotPayment.release.aar"
]
:
""
// Retrieve the list of local plugins binaries.
if
(
project
.
hasProperty
(
"plugins_local_binaries"
))
{
binDeps
.
clear
()
String
pluginsList
=
project
.
property
(
"plugins_local_binaries"
)
if
(
pluginsList
!=
null
&&
!
pluginsList
.
trim
().
isEmpty
())
{
for
(
String
plugin
:
pluginsList
.
split
(
PLUGIN_VALUE_SEPARATOR_REGEX
))
{
binDeps
+=
plugin
.
trim
()
}
}
}
return
pluginsDir
return
binDeps
}
}
platform/android/java/build.gradle
View file @
14e6696c
...
@@ -140,7 +140,7 @@ task generateGodotTemplates(type: GradleBuild) {
...
@@ -140,7 +140,7 @@ task generateGodotTemplates(type: GradleBuild) {
startParameter
.
excludedTaskNames
+=
":lib:"
+
getSconsTaskName
(
buildType
)
startParameter
.
excludedTaskNames
+=
":lib:"
+
getSconsTaskName
(
buildType
)
}
}
tasks
=
[
"copyGodotPaymentPluginToAppModule"
]
tasks
=
[]
// Only build the apks and aar files for which we have native shared libraries.
// Only build the apks and aar files for which we have native shared libraries.
for
(
String
target
:
supportedTargets
)
{
for
(
String
target
:
supportedTargets
)
{
...
@@ -161,6 +161,7 @@ task generateGodotTemplates(type: GradleBuild) {
...
@@ -161,6 +161,7 @@ task generateGodotTemplates(type: GradleBuild) {
}
}
}
}
dependsOn
'copyGodotPaymentPluginToAppModule'
finalizedBy
'zipCustomBuild'
finalizedBy
'zipCustomBuild'
}
}
...
...
platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPluginRegistry.java
View file @
14e6696c
...
@@ -58,7 +58,9 @@ public final class GodotPluginRegistry {
...
@@ -58,7 +58,9 @@ public final class GodotPluginRegistry {
/**
/**
* Name for the metadata containing the list of Godot plugins to enable.
* Name for the metadata containing the list of Godot plugins to enable.
*/
*/
private
static
final
String
GODOT_ENABLED_PLUGINS_LABEL
=
"custom_template_plugins"
;
private
static
final
String
GODOT_ENABLED_PLUGINS_LABEL
=
"plugins"
;
private
static
final
String
PLUGIN_VALUE_SEPARATOR_REGEX
=
"\\|"
;
private
static
GodotPluginRegistry
instance
;
private
static
GodotPluginRegistry
instance
;
private
final
ConcurrentHashMap
<
String
,
GodotPlugin
>
registry
;
private
final
ConcurrentHashMap
<
String
,
GodotPlugin
>
registry
;
...
@@ -128,13 +130,13 @@ public final class GodotPluginRegistry {
...
@@ -128,13 +130,13 @@ public final class GodotPluginRegistry {
}
}
// When using the Godot editor for building and exporting the apk, this is used to check
// When using the Godot editor for building and exporting the apk, this is used to check
// which plugins to enable
since the custom build template may contain prebuilt plugins
.
// which plugins to enable.
// When using a custom process to generate the apk, the metadata is not needed since
// When using a custom process to generate the apk, the metadata is not needed since
// it's assumed that the developer is aware of the dependencies included in the apk.
// it's assumed that the developer is aware of the dependencies included in the apk.
final
Set
<
String
>
enabledPluginsSet
;
final
Set
<
String
>
enabledPluginsSet
;
if
(
metaData
.
containsKey
(
GODOT_ENABLED_PLUGINS_LABEL
))
{
if
(
metaData
.
containsKey
(
GODOT_ENABLED_PLUGINS_LABEL
))
{
String
enabledPlugins
=
metaData
.
getString
(
GODOT_ENABLED_PLUGINS_LABEL
,
""
);
String
enabledPlugins
=
metaData
.
getString
(
GODOT_ENABLED_PLUGINS_LABEL
,
""
);
String
[]
enabledPluginsList
=
enabledPlugins
.
split
(
","
);
String
[]
enabledPluginsList
=
enabledPlugins
.
split
(
PLUGIN_VALUE_SEPARATOR_REGEX
);
if
(
enabledPluginsList
.
length
==
0
)
{
if
(
enabledPluginsList
.
length
==
0
)
{
// No plugins to enable. Aborting early.
// No plugins to enable. Aborting early.
return
;
return
;
...
@@ -158,6 +160,8 @@ public final class GodotPluginRegistry {
...
@@ -158,6 +160,8 @@ public final class GodotPluginRegistry {
continue
;
continue
;
}
}
Log
.
i
(
TAG
,
"Initializing Godot plugin "
+
pluginName
);
// Retrieve the plugin class full name.
// Retrieve the plugin class full name.
String
pluginHandleClassFullName
=
metaData
.
getString
(
metaDataName
);
String
pluginHandleClassFullName
=
metaData
.
getString
(
metaDataName
);
if
(!
TextUtils
.
isEmpty
(
pluginHandleClassFullName
))
{
if
(!
TextUtils
.
isEmpty
(
pluginHandleClassFullName
))
{
...
@@ -177,6 +181,7 @@ public final class GodotPluginRegistry {
...
@@ -177,6 +181,7 @@ public final class GodotPluginRegistry {
"Meta-data plugin name does not match the value returned by the plugin handle: "
+
pluginName
+
" =/= "
+
pluginHandle
.
getPluginName
());
"Meta-data plugin name does not match the value returned by the plugin handle: "
+
pluginName
+
" =/= "
+
pluginHandle
.
getPluginName
());
}
}
registry
.
put
(
pluginName
,
pluginHandle
);
registry
.
put
(
pluginName
,
pluginHandle
);
Log
.
i
(
TAG
,
"Completed initialization for Godot plugin "
+
pluginHandle
.
getPluginName
());
}
catch
(
ClassNotFoundException
e
)
{
}
catch
(
ClassNotFoundException
e
)
{
Log
.
w
(
TAG
,
"Unable to load Godot plugin "
+
pluginName
,
e
);
Log
.
w
(
TAG
,
"Unable to load Godot plugin "
+
pluginName
,
e
);
}
catch
(
IllegalAccessException
e
)
{
}
catch
(
IllegalAccessException
e
)
{
...
...
platform/android/plugin/godot_plugin_config.h
0 → 100644
View file @
14e6696c
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment