diff --git a/addons/gdcef/README.md b/addons/gdcef/README.md index 191977b..2fc9ade 100644 --- a/addons/gdcef/README.md +++ b/addons/gdcef/README.md @@ -95,12 +95,6 @@ describing the given demos. var browser = $CEF.create_browser("https://github.com/Lecrapouille/gdcef", $TextureRect, {}) browser.get_name("hello") ``` -- In Linux, you will have to write something like: -``` -export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/your/path/gdcef/examples/build -``` - -to make your system finds shared libraries such as `libcef.so`. - You should obtain a minimal CEF browser not reacting to your mouse and key binding. See the 2D and 3D demos to make your browser tab reacts to your input events. diff --git a/addons/gdcef/build.py b/addons/gdcef/build.py index 048c15c..0665644 100755 --- a/addons/gdcef/build.py +++ b/addons/gdcef/build.py @@ -54,9 +54,7 @@ CEF_BUILD_FOLDER_NAME = "build" # When we are compiling demos we are creating a folder holding CEF build artifacts. # But, in the aim to save space on your hard disk the folder is a pointer to folder -# CEF_ARTIFACTS_BUILD_PATH. If you modify this variable, do not forget to also change -# Godot .gdns and .gdnlib files inside the libs folders in GDCEF_EXAMPLES_PATH the -# demos folder. +# CEF_ARTIFACTS_BUILD_PATH. CEF_ARTIFACTS_FOLDER_NAME = "cef_artifacts" # Use OpenMP for using CPU parallelim (i.e. for copying textures) CEF_USE_CPU_PARALLELISM = "yes" # or "no" @@ -427,6 +425,15 @@ def compile_gdnative_cef(path): else: fatal("Unknown archi " + OSTYPE + ": I dunno how to compile CEF module primary process") +############################################################################### +### Compile Godot CEF module named GDCef and its subprocess +def create_gdextension_file(): + info("Create Godot .gdextension file") + with open(os.path.join(GDCEF_PATH, "gdcef.gdextension.in"), "r") as f: + extension = f.read().replace("CEF_ARTIFACTS_FOLDER_NAME", CEF_ARTIFACTS_FOLDER_NAME) + with open(os.path.join(CEF_ARTIFACTS_BUILD_PATH, "gdcef.gdextension"), "w") as f: + f.write(extension) + ############################################################################### ### Check if compilers are present (Windows) def check_compiler(): @@ -484,7 +491,9 @@ def prepare_godot_examples(): path = os.path.join(GDCEF_EXAMPLES_PATH, filename) if os.path.isdir(path) and os.path.isfile(os.path.join(path, "project.godot")): info(" - Demo " + path) - symlink(CEF_ARTIFACTS_BUILD_PATH, os.path.join(path, CEF_ARTIFACTS_FOLDER_NAME)) + artifacts_path = os.path.join(path, CEF_ARTIFACTS_FOLDER_NAME) + mkdir(os.path.dirname(artifacts_path)) + symlink(CEF_ARTIFACTS_BUILD_PATH, artifacts_path) ############################################################################### ### Run Godot example @@ -493,12 +502,12 @@ def run_godot_example(): " into '" + CEF_ARTIFACTS_BUILD_PATH + "' and can be used for your Godot" " project. Do not forget to add .gdns and .gdnlib files refering to libgdcef.so/dll.\n") if OSTYPE == "Linux": - info("For Unix systems you have to make your system know where to find shared" - " libraries needed for CEF. Save the following command in your environment" - " (~/.bashrc i.e.):\n\n" - " export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:" + CEF_ARTIFACTS_BUILD_PATH + "\n" - " export LD_PRELOAD=" + CEF_ARTIFACTS_BUILD_PATH + "/libcef.so\n") - info("Once done, you can run your Godot editor " + GODOT_VERSION + " and try" + info("`" + CEF_ARTIFACTS_FOLDER_NAME + "` path is used to find shared libraries" + " needed for CEF. Put `" + CEF_ARTIFACTS_BUILD_PATH + "` as `" + + CEF_ARTIFACTS_FOLDER_NAME + "` into your project to avoid having to set" + " LD_LIBRARY_PATH environment variable. If you want use other folder name," + " edit value of CEF_ARTIFACTS_FOLDER_NAME in build.py and rebuild project.\n") + info("You can run your Godot editor " + GODOT_VERSION + " and try" " one of the demos located in '" + GDCEF_EXAMPLES_PATH + "'.\n\nHave fun!") ############################################################################### @@ -514,5 +523,6 @@ def run_godot_example(): install_cef_assets() compile_gdnative_cef(GDCEF_PATH) compile_gdnative_cef(GDCEF_PROCESSES_PATH) + create_gdextension_file() prepare_godot_examples() run_godot_example() diff --git a/addons/gdcef/demos/2D/CEF.gd b/addons/gdcef/demos/2D/CEF.gd index 80b89c4..d3cdff6 100644 --- a/addons/gdcef/demos/2D/CEF.gd +++ b/addons/gdcef/demos/2D/CEF.gd @@ -331,9 +331,7 @@ func _ready(): # artifacts: allows path such as "build" or "res://cef_artifacts/". Note that "res://" # will use ProjectSettings.globalize_path but exported projects don't support globalize_path: # https://docs.godotengine.org/en/3.5/classes/class_projectsettings.html#class-projectsettings-method-globalize-path - var resource_path = "res://cef_artifacts/" if !$CEF.initialize({ - "artifacts":resource_path, "incognito":true, "locale":"en-US", "enable_media_stream": true diff --git a/addons/gdcef/demos/2D/libs/gdcef.gdextension b/addons/gdcef/demos/2D/libs/gdcef.gdextension deleted file mode 100644 index 1aee141..0000000 --- a/addons/gdcef/demos/2D/libs/gdcef.gdextension +++ /dev/null @@ -1,17 +0,0 @@ -[configuration] -entry_symbol = "gdcef_library_init" -compatibility_minimum = 4.1 - -[libraries] -linux.x86_64.debug = "res://cef_artifacts/libgdcef.so" -linux.x86_64.release = "res://cef_artifacts/libgdcef.so" -linux.x86_32.debug = "res://cef_artifacts/libgdcef.so" -linux.x86_32.release = "res://cef_artifacts/libgdcef.so" - -windows.x86_64.debug = "res://cef_artifacts/libgdcef.dll" -windows.x86_64.release = "res://cef_artifacts/libgdcef.dll" -windows.x86_32.debug = "res://cef_artifacts/libgdcef.dll" -windows.x86_32.release = "res://cef_artifacts/libgdcef.dll" - -macos.debug = "res://cef_artifacts/Frameworks/Chromium\ Embedded\ Framework.framework/Libraries/libgdcef.dylib" -macos.release = "res://cef_artifacts/Frameworks/Chromium\ Embedded\ Framework.framework/Libraries/libgdcef.dylib" diff --git a/addons/gdcef/demos/3D/GUI.gd b/addons/gdcef/demos/3D/GUI.gd index 7eeb2ba..3062135 100644 --- a/addons/gdcef/demos/3D/GUI.gd +++ b/addons/gdcef/demos/3D/GUI.gd @@ -148,8 +148,7 @@ func _ready(): # artifacts: allows path such as "build" or "res://cef_artifacts/". Note that "res://" # will use ProjectSettings.globalize_path but exported projects don't support globalize_path: # https://docs.godotengine.org/en/3.5/classes/class_projectsettings.html#class-projectsettings-method-globalize-path - var resource_path = "res://cef_artifacts/" - if !$CEF.initialize({"artifacts":resource_path, "incognito":true, "locale":"en-US"}): + if !$CEF.initialize({"incognito":true, "locale":"en-US"}): push_error($CEF.get_error()) get_tree().quit() return diff --git a/addons/gdcef/demos/3D/libs/gdcef.gdextension b/addons/gdcef/demos/3D/libs/gdcef.gdextension deleted file mode 100644 index 1aee141..0000000 --- a/addons/gdcef/demos/3D/libs/gdcef.gdextension +++ /dev/null @@ -1,17 +0,0 @@ -[configuration] -entry_symbol = "gdcef_library_init" -compatibility_minimum = 4.1 - -[libraries] -linux.x86_64.debug = "res://cef_artifacts/libgdcef.so" -linux.x86_64.release = "res://cef_artifacts/libgdcef.so" -linux.x86_32.debug = "res://cef_artifacts/libgdcef.so" -linux.x86_32.release = "res://cef_artifacts/libgdcef.so" - -windows.x86_64.debug = "res://cef_artifacts/libgdcef.dll" -windows.x86_64.release = "res://cef_artifacts/libgdcef.dll" -windows.x86_32.debug = "res://cef_artifacts/libgdcef.dll" -windows.x86_32.release = "res://cef_artifacts/libgdcef.dll" - -macos.debug = "res://cef_artifacts/Frameworks/Chromium\ Embedded\ Framework.framework/Libraries/libgdcef.dylib" -macos.release = "res://cef_artifacts/Frameworks/Chromium\ Embedded\ Framework.framework/Libraries/libgdcef.dylib" diff --git a/addons/gdcef/demos/HelloCEF/Control.gd b/addons/gdcef/demos/HelloCEF/Control.gd index 185025d..3db9081 100644 --- a/addons/gdcef/demos/HelloCEF/Control.gd +++ b/addons/gdcef/demos/HelloCEF/Control.gd @@ -161,8 +161,7 @@ func _ready(): # artifacts: allows path such as "build" or "res://cef_artifacts/". Note that "res://" # will use ProjectSettings.globalize_path but exported projects don't support globalize_path: # https://docs.godotengine.org/en/3.5/classes/class_projectsettings.html#class-projectsettings-method-globalize-path - var resource_path = "res://cef_artifacts/" - if !$CEF.initialize({"artifacts":resource_path, "incognito":true, "locale":"en-US"}): + if !$CEF.initialize({"incognito":true, "locale":"en-US"}): push_error("Failed initializing CEF") get_tree().quit() else: diff --git a/addons/gdcef/demos/HelloCEF/libs/gdcef.gdextension b/addons/gdcef/demos/HelloCEF/libs/gdcef.gdextension deleted file mode 100644 index 1aee141..0000000 --- a/addons/gdcef/demos/HelloCEF/libs/gdcef.gdextension +++ /dev/null @@ -1,17 +0,0 @@ -[configuration] -entry_symbol = "gdcef_library_init" -compatibility_minimum = 4.1 - -[libraries] -linux.x86_64.debug = "res://cef_artifacts/libgdcef.so" -linux.x86_64.release = "res://cef_artifacts/libgdcef.so" -linux.x86_32.debug = "res://cef_artifacts/libgdcef.so" -linux.x86_32.release = "res://cef_artifacts/libgdcef.so" - -windows.x86_64.debug = "res://cef_artifacts/libgdcef.dll" -windows.x86_64.release = "res://cef_artifacts/libgdcef.dll" -windows.x86_32.debug = "res://cef_artifacts/libgdcef.dll" -windows.x86_32.release = "res://cef_artifacts/libgdcef.dll" - -macos.debug = "res://cef_artifacts/Frameworks/Chromium\ Embedded\ Framework.framework/Libraries/libgdcef.dylib" -macos.release = "res://cef_artifacts/Frameworks/Chromium\ Embedded\ Framework.framework/Libraries/libgdcef.dylib" diff --git a/addons/gdcef/demos/README.md b/addons/gdcef/demos/README.md index 69b4d3a..cf59a34 100644 --- a/addons/gdcef/demos/README.md +++ b/addons/gdcef/demos/README.md @@ -18,15 +18,6 @@ No command line is needed. This script will: **Workaround For Windows:** You need **x64 Native Tools Command Prompt for VS 2022**, with **Administrator** privilege! -**Workaround For Linux:** for the moment, the `libcef.so` and other shared libraries, -as artifcats, are not found by the systeme (even if indicated in the `.gdnlib` file. -So for the moment, you have to store the path of the `build` in your `LD_LIBRARY_PATH` -(for example in your `~/.bashrc` file). - -``` -export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/your/path/gdcef/examples/build -``` - **Note concerning the build folder**: CEF artifcats are searched inside the `build` folder at the root of your Godot project. diff --git a/addons/gdcef/gdcef/SConstruct b/addons/gdcef/gdcef/SConstruct index be9a5d3..9442832 100644 --- a/addons/gdcef/gdcef/SConstruct +++ b/addons/gdcef/gdcef/SConstruct @@ -214,6 +214,10 @@ env.Append(LIBS = [libcef, 'libcef_dll_wrapper'], # Pathes header files of our module env.Append(CPPPATH=['src/']) +# Add artifacts folder to (embedded into output binary file) list of paths to search for shared libraries +# [2:-2] because we need value of cef_artifacts_folder without protected quotation marks +env.Append(RPATH=[env['cef_artifacts_folder'][2:-2]]) + # Compile the library sources = ['src/helper_files.cpp', 'src/browser_io.cpp', 'src/gdcef.cpp', 'src/gdbrowser.cpp', 'src/register_types.cpp'] # sources = Glob('src/*.cpp') diff --git a/addons/gdcef/gdcef/gdcef.gdextension.in b/addons/gdcef/gdcef/gdcef.gdextension.in new file mode 100644 index 0000000..3b8b171 --- /dev/null +++ b/addons/gdcef/gdcef/gdcef.gdextension.in @@ -0,0 +1,17 @@ +[configuration] +entry_symbol = "gdcef_library_init" +compatibility_minimum = 4.1 + +[libraries] +linux.x86_64.debug = "res://CEF_ARTIFACTS_FOLDER_NAME/libgdcef.so" +linux.x86_64.release = "res://CEF_ARTIFACTS_FOLDER_NAME/libgdcef.so" +linux.x86_32.debug = "res://CEF_ARTIFACTS_FOLDER_NAME/libgdcef.so" +linux.x86_32.release = "res://CEF_ARTIFACTS_FOLDER_NAME/libgdcef.so" + +windows.x86_64.debug = "res://CEF_ARTIFACTS_FOLDER_NAME/libgdcef.dll" +windows.x86_64.release = "res://CEF_ARTIFACTS_FOLDER_NAME/libgdcef.dll" +windows.x86_32.debug = "res://CEF_ARTIFACTS_FOLDER_NAME/libgdcef.dll" +windows.x86_32.release = "res://CEF_ARTIFACTS_FOLDER_NAME/libgdcef.dll" + +macos.debug = "res://CEF_ARTIFACTS_FOLDER_NAME/Frameworks/Chromium\ Embedded\ Framework.framework/Libraries/libgdcef.dylib" +macos.release = "res://CEF_ARTIFACTS_FOLDER_NAME/Frameworks/Chromium\ Embedded\ Framework.framework/Libraries/libgdcef.dylib" diff --git a/addons/gdcef/subprocess/SConstruct b/addons/gdcef/subprocess/SConstruct index a55f086..cc3a5e2 100644 --- a/addons/gdcef/subprocess/SConstruct +++ b/addons/gdcef/subprocess/SConstruct @@ -48,6 +48,7 @@ opts.Add(EnumVariable('arch', 'Platform architecture', 'x86_64', ['x86_64', 'arm opts.Add(BoolVariable('use_llvm', 'Use the LLVM / Clang compiler', 'no')) opts.Add(PathVariable('api_path', 'Godot C++ API', '')) opts.Add(PathVariable('build_path', 'Build path', '')) +opts.Add(PathVariable('cef_artifacts_folder', 'CEF artifacts folder', '', PathVariable.PathAccept)) # Updates the environment with the option variables. opts.Update(env) @@ -204,6 +205,10 @@ env.Append(LIBS = [libcef, 'libcef_dll_wrapper'], # Pathes header files of our module env.Append(CPPPATH=['src/']) +# Add artifacts folder to (embedded into output binary file) list of paths to search for shared libraries +# [2:-2] because we need value of cef_artifacts_folder without protected quotation marks +env.Append(RPATH=[env['cef_artifacts_folder'][2:-2]]) + # Compile the application sources = Glob('src/*.cpp') application = env.Program(target=target_path + '/' + target_binary, source=sources)