-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #162 from cadivus/auto_setup_linux
Auto setup Linux target - make manual target modifications obsolete
- Loading branch information
Showing
9 changed files
with
230 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
|
||
# Will be something like /home/test/flutter_projects/example | ||
program_path="${PWD%%/build/linux/*}" | ||
|
||
# Will be the path of this script | ||
scriptdir=$(cd $(dirname $0); pwd -P) | ||
|
||
echo "Modifying target cc files..." | ||
|
||
bash $scriptdir/tools/import_webview_cef_header_my_application.sh "$program_path/linux/my_application.cc" | ||
bash $scriptdir/tools/add_key_release_event_to_my_application.sh "$program_path/linux/my_application.cc" | ||
bash $scriptdir/tools/add_key_press_event_to_my_application.sh "$program_path/linux/my_application.cc" | ||
|
||
bash $scriptdir/tools/import_webview_cef_header_main.sh "$program_path/linux/main.cc" | ||
bash $scriptdir/tools/add_webview_init_to_main.sh "$program_path/linux/main.cc" |
39 changes: 39 additions & 0 deletions
39
linux/target_modifier/tools/add_key_press_event_to_my_application.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
|
||
# Add | ||
# g_signal_connect(view, \"key_press_event\", G_CALLBACK(processKeyEventForCEF), nullptr); | ||
# after | ||
# FlView* view = fl_view_new(project); | ||
# if not already added | ||
|
||
# Check if the correct number of arguments is passed | ||
if [ $# -ne 1 ]; then | ||
echo "Usage: $0 <file-path>" | ||
exit 1 | ||
fi | ||
|
||
# Assign file path argument | ||
file="$1" | ||
|
||
# Check if the file exists | ||
if [ ! -f "$file" ]; then | ||
echo "File not found: $file" | ||
exit 1 | ||
fi | ||
|
||
# Check if the line g_signal_connect exists in the file | ||
if grep -q '^[[:space:]]*g_signal_connect(view, "key_press_event", G_CALLBACK(processKeyEventForCEF), nullptr);' "$file"; then | ||
echo "The line 'g_signal_connect(view, \"key_press_event\", G_CALLBACK(processKeyEventForCEF), nullptr);' already exists in the file." | ||
else | ||
# Insert g_signal_connect after the first occurrence of FlView* view = fl_view_new(project); | ||
awk ' | ||
/^[[:space:]]*FlView\* view = fl_view_new\(project\);/ { | ||
print $0; | ||
print " g_signal_connect(view, \"key_press_event\", G_CALLBACK(processKeyEventForCEF), nullptr);"; | ||
next; | ||
} | ||
{ print } | ||
' "$file" > "$file.tmp" && mv "$file.tmp" "$file" | ||
|
||
echo "Added 'g_signal_connect(view, \"key_press_event\", G_CALLBACK(processKeyEventForCEF), nullptr);' after 'FlView* view = fl_view_new(project);'." | ||
fi |
39 changes: 39 additions & 0 deletions
39
linux/target_modifier/tools/add_key_release_event_to_my_application.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
|
||
# Add | ||
# g_signal_connect(view, \"key_release_event\", G_CALLBACK(processKeyEventForCEF), nullptr); | ||
# after | ||
# FlView* view = fl_view_new(project); | ||
# if not already added | ||
|
||
# Check if the correct number of arguments is passed | ||
if [ $# -ne 1 ]; then | ||
echo "Usage: $0 <file-path>" | ||
exit 1 | ||
fi | ||
|
||
# Assign file path argument | ||
file="$1" | ||
|
||
# Check if the file exists | ||
if [ ! -f "$file" ]; then | ||
echo "File not found: $file" | ||
exit 1 | ||
fi | ||
|
||
# Check if the line g_signal_connect exists in the file | ||
if grep -q '^[[:space:]]*g_signal_connect(view, "key_release_event", G_CALLBACK(processKeyEventForCEF), nullptr);' "$file"; then | ||
echo "The line 'g_signal_connect(view, \"key_release_event\", G_CALLBACK(processKeyEventForCEF), nullptr);' already exists in the file." | ||
else | ||
# Insert g_signal_connect after the first occurrence of FlView* view = fl_view_new(project); | ||
awk ' | ||
/^[[:space:]]*FlView\* view = fl_view_new\(project\);/ { | ||
print $0; | ||
print " g_signal_connect(view, \"key_release_event\", G_CALLBACK(processKeyEventForCEF), nullptr);"; | ||
next; | ||
} | ||
{ print } | ||
' "$file" > "$file.tmp" && mv "$file.tmp" "$file" | ||
|
||
echo "Added 'g_signal_connect(view, \"key_release_event\", G_CALLBACK(processKeyEventForCEF), nullptr);' after 'FlView* view = fl_view_new(project);'." | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/bash | ||
|
||
# Adds | ||
# initCEFProcesses(argc, argv); | ||
# to main function of main.cc | ||
|
||
# Check if the correct number of arguments is passed | ||
if [ $# -ne 1 ]; then | ||
echo "Usage: $0 <file-path>" | ||
exit 1 | ||
fi | ||
|
||
# Assign file path argument | ||
file="$1" | ||
|
||
# Check if the file exists | ||
if [ ! -f "$file" ]; then | ||
echo "File not found: $file" | ||
exit 1 | ||
fi | ||
|
||
# Check if the line initCEFProcesses(argc, argv); already exists in the file | ||
if grep -q '^[[:space:]]*initCEFProcesses(argc, argv);' "$file"; then | ||
echo "The line 'initCEFProcesses(argc, argv);' already exists in the file." | ||
else | ||
# Insert initCEFProcesses(argc, argv); before the first line starting with g_autoptr( | ||
awk ' | ||
/^[[:space:]]*g_autoptr/ { | ||
print " initCEFProcesses(argc, argv);"; | ||
} | ||
{ print } | ||
' "$file" > "$file.tmp" && mv "$file.tmp" "$file" | ||
|
||
echo "Added 'initCEFProcesses(argc, argv);' before the first line starting with 'g_autoptr('." | ||
fi |
27 changes: 27 additions & 0 deletions
27
linux/target_modifier/tools/import_webview_cef_header_main.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
|
||
# Adds '#include <webview_cef/webview_cef_plugin.h>' at the top of the file | ||
|
||
# Check if the correct number of arguments is passed | ||
if [ $# -ne 1 ]; then | ||
echo "Usage: $0 <file-path>" | ||
exit 1 | ||
fi | ||
|
||
# Assign file path argument | ||
file="$1" | ||
|
||
# Check if the file exists | ||
if [ ! -f "$file" ]; then | ||
echo "File not found: $file" | ||
exit 1 | ||
fi | ||
|
||
# Check if the line already exists in the file | ||
if grep -q '#include <webview_cef/webview_cef_plugin.h>' "$file"; then | ||
echo "The line '#include <webview_cef/webview_cef_plugin.h>' already exists in the file." | ||
else | ||
# Add the line at the top of the file | ||
(echo "#include <webview_cef/webview_cef_plugin.h>"; cat "$file") > "$file.tmp" && mv "$file.tmp" "$file" | ||
echo "Added '#include <webview_cef/webview_cef_plugin.h>' at the top of the file." | ||
fi |
40 changes: 40 additions & 0 deletions
40
linux/target_modifier/tools/import_webview_cef_header_my_application.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/bash | ||
|
||
# Adds the line | ||
# '#include <webview_cef/webview_cef_plugin.h>' | ||
# after the line | ||
# '#include "flutter/generated_plugin_registrant.h"' | ||
# if '#include <webview_cef/webview_cef_plugin.h>' is missing | ||
|
||
# Check if the correct number of arguments is passed | ||
if [ $# -ne 1 ]; then | ||
echo "Usage: $0 <file-path>" | ||
exit 1 | ||
fi | ||
|
||
# Assign file path argument | ||
file="$1" | ||
|
||
# Check if the file exists | ||
if [ ! -f "$file" ]; then | ||
echo "File not found: $file" | ||
exit 1 | ||
fi | ||
|
||
# Check if the line already exists in the file | ||
if grep -q '#include <webview_cef/webview_cef_plugin.h>' "$file"; then | ||
echo "The line '#include <webview_cef/webview_cef_plugin.h>' already exists in the file." | ||
exit 0 | ||
fi | ||
|
||
# Iterate through the file and look for the line "#include \"flutter/generated_plugin_registrant.h\"" | ||
awk ' | ||
/#include "flutter\/generated_plugin_registrant.h"/ { | ||
print; | ||
print "#include <webview_cef/webview_cef_plugin.h>" | ||
next | ||
} | ||
{ print } | ||
' "$file" > "$file.tmp" && mv "$file.tmp" "$file" | ||
|
||
echo "Added '#include <webview_cef/webview_cef_plugin.h>' after '#include \"flutter/generated_plugin_registrant.h\"'" |