目次
Chromium Embedded Framework
Chromium Embedded Framework(CEF) は、Chromiumベースのブラウザを他のアプリケーションに埋め込むための単純なフレームワークである。
フレームワークのダウンロード
chromiumembedded / cef — Bitbucket の Binary Distributions - CEF Automated Builds より cef_binary_74.1.16+ge20b240+chromium-74.0.3729.131_linux64.tar.bz2(フレームワークのバイナリディストリビューション)をダウンロードする。
フレームワーク入門
セットアップ
クロスプラットフォームのオープンソースビルドシステム CMake をインストールする。バージョン2.8.12.1以降が必要。
$ sudo dnf install cmake
Python をインストールする。バージョン 2.x が必要。
$ sudo dnf install python3
プラットフォーム固有のビルドツールをインストールする。
$ sudo dnf groupinstall "Development Tools" $ sudo dnf install gcc-c++ gtk2-devel gtkglext-devel
ダウンロードページから、Git コマンドラインツールを使用して、cef-project のソースコードをダウンロードする。
$ git clone https://bitbucket.org/chromiumembedded/cef-project.git
ビルド
Chromium Embedded Framework (CEF) のバイナリディストリビューションを解凍する。
$ tar jxvf cef_binary_74.1.16+ge20b240+chromium-74.0.3729.131_linux64.tar.bz2
Makefile を生成する。
$ cd cef_binary_74.1.16+ge20b240+chromium-74.0.3729.131_linux64/ $ mkdir build && cd build $ cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug ..
-- The C compiler identification is GNU 9.1.1 -- The CXX compiler identification is GNU 9.1.1 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done CMake Warning (dev) at CMakeLists.txt:187 (find_package): Policy CMP0074 is not set: find_package uses <PackageName>_ROOT variables. Run "cmake --help-policy CMP0074" for policy details. Use the cmake_policy command to set the policy and suppress this warning. CMake variable CEF_ROOT is set to: /home/tomoyan/my_projects/cef_binary_74.1.16+ge20b240+chromium-74.0.3729.131_linux64 For compatibility, CMake is ignoring the variable. This warning is for project developers. Use -Wno-dev to suppress it. -- Performing Test COMPILER_SUPPORTS_NO_UNDEFINED_VAR_TEMPLATE -- Performing Test COMPILER_SUPPORTS_NO_UNDEFINED_VAR_TEMPLATE - Success -- Performing Test COMPILER_SUPPORTS_NO_UNUSED_LOCAL_TYPEDEFS -- Performing Test COMPILER_SUPPORTS_NO_UNUSED_LOCAL_TYPEDEFS - Success -- Performing Test COMPILER_SUPPORTS_NO_LITERAL_SUFFIX -- Performing Test COMPILER_SUPPORTS_NO_LITERAL_SUFFIX - Success -- Performing Test COMPILER_SUPPORTS_NO_NARROWING -- Performing Test COMPILER_SUPPORTS_NO_NARROWING - Success -- *** CEF CONFIGURATION SETTINGS *** -- Generator: Unix Makefiles -- Platform: Linux -- Project architecture: x86_64 -- Build type: Debug -- Binary distribution root: /home/tomoyan/my_projects/cef_binary_74.1.16+ge20b240+chromium-74.0.3729.131_linux64 -- CEF sandbox: ON -- Standard libraries: X11 -- Compile defines: __STDC_CONSTANT_MACROS;__STDC_FORMAT_MACROS;_FILE_OFFSET_BITS=64;CEF_USE_SANDBOX -- Compile defines (Debug): -- Compile defines (Release): NDEBUG -- C compile flags: -fno-strict-aliasing;-fPIC;-fstack-protector;-funwind-tables;-fvisibility=hidden;--param=ssp-buffer-size=4;-pipe;-pthread;-Wall;-Werror;-Wno-missing-field-initializers;-Wno-unused-parameter;-Wno-error=comment;-Wno-comment;-m64;-march=x86-64 -std=c99;-Wno-unused-local-typedefs -- C compile flags (Debug): -O0;-g -- C compile flags (Release): -O2;-fdata-sections;-ffunction-sections;-fno-ident;-U_FORTIFY_SOURCE;-D_FORTIFY_SOURCE=2 -- C++ compile flags: -fno-strict-aliasing;-fPIC;-fstack-protector;-funwind-tables;-fvisibility=hidden;--param=ssp-buffer-size=4;-pipe;-pthread;-Wall;-Werror;-Wno-missing-field-initializers;-Wno-unused-parameter;-Wno-error=comment;-Wno-comment;-m64;-march=x86-64 -fno-exceptions;-fno-rtti;-fno-threadsafe-statics;-fvisibility-inlines-hidden;-std=gnu++11;-Wsign-compare;-Wno-undefined-var-template;-Wno-literal-suffix;-Wno-narrowing;-Wno-attributes -- C++ compile flags (Debug): -O0;-g -- C++ compile flags (Release): -O2;-fdata-sections;-ffunction-sections;-fno-ident;-U_FORTIFY_SOURCE;-D_FORTIFY_SOURCE=2 -- Exe link flags: -fPIC;-pthread;-Wl,--disable-new-dtags;-Wl,--fatal-warnings;-Wl,-rpath,.;-Wl,-z,noexecstack;-Wl,-z,now;-Wl,-z,relro;-m64 -- Exe link flags (Debug): -- Exe link flags (Release): -Wl,-O1;-Wl,--as-needed;-Wl,--gc-sections -- Shared link flags: -fPIC;-pthread;-Wl,--disable-new-dtags;-Wl,--fatal-warnings;-Wl,-rpath,.;-Wl,-z,noexecstack;-Wl,-z,now;-Wl,-z,relro;-m64 -- Shared link flags (Debug): -- Shared link flags (Release): -Wl,-O1;-Wl,--as-needed;-Wl,--gc-sections -- CEF Binary files: chrome-sandbox;libcef.so;libEGL.so;libGLESv2.so;natives_blob.bin;snapshot_blob.bin;v8_context_snapshot.bin;swiftshader -- CEF Resource files: cef.pak;cef_100_percent.pak;cef_200_percent.pak;cef_extensions.pak;devtools_resources.pak;icudtl.dat;locales -- Configuring done -- Generating done -- Build files have been written to: /home/tomoyan/my_projects/cef_binary_74.1.16+ge20b240+chromium-74.0.3729.131_linux64/build
CEF をビルドする。
$ make -j4
Scanning dependencies of target cef_gtest Scanning dependencies of target libcef_dll_wrapper [ 0%] Building CXX object tests/gtest/CMakeFiles/cef_gtest.dir/src/gtest-all.cc.o [ 0%] Building CXX object libcef_dll_wrapper/CMakeFiles/libcef_dll_wrapper.dir/shutdown_checker.cc.o [ 1%] Building CXX object libcef_dll_wrapper/CMakeFiles/libcef_dll_wrapper.dir/base/cef_atomicops_x86_gcc.cc.o 〜省略〜 [ 65%] Building CXX object tests/cefclient/CMakeFiles/cefclient.dir/browser/scheme_test.cc.o *** Run the following command manually to set SUID permissions *** EXE="/home/tomoyan/my_projects/cef_binary_74.1.16+ge20b240+chromium-74.0.3729.131_linux64/build/tests/cefsimple/Debug/chrome-sandbox" && sudo -- chown root:root $EXE && sudo -- chmod 4755 $EXE [ 65%] Built target cefsimple [ 66%] Building CXX object tests/cefclient/CMakeFiles/cefclient.dir/browser/server_test.cc.o 〜省略〜 [ 99%] Building CXX object tests/ceftests/CMakeFiles/ceftests.dir/views/textfield_unittest.cc.o [100%] Building CXX object tests/ceftests/CMakeFiles/ceftests.dir/views/window_unittest.cc.o [100%] Linking CXX executable Debug/ceftests *** Run the following command manually to set SUID permissions *** EXE="/home/tomoyan/my_projects/cef_binary_74.1.16+ge20b240+chromium-74.0.3729.131_linux64/build/tests/cefclient/Debug/chrome-sandbox" && sudo -- chown root:root $EXE && sudo -- chmod 4755 $EXE [100%] Built target cefclient *** Run the following command manually to set SUID permissions *** EXE="/home/tomoyan/my_projects/cef_binary_74.1.16+ge20b240+chromium-74.0.3729.131_linux64/build/tests/ceftests/Debug/chrome-sandbox" && sudo -- chown root:root $EXE && sudo -- chmod 4755 $EXE [100%] Built target ceftests
SUIDアクセス許可を設定
ビルドが終わったら指示にしたがって、手動で次のコマンドを実行して SUID アクセス許可を設定する。
$ EXE="/home/tomoyan/my_projects/cef_binary_74.1.16+ge20b240+chromium-74.0.3729.131_linux64/build/tests/ceftests/Debug/chrome-sandbox" && sudo -- chown root:root $EXE && sudo -- chmod 4755 $EXE
Sample の実行
cef-project のビルド
cef-project のダウンロード
$ git clone https://bitbucket.org/chromiumembedded/cef-project.git
Makefile の生成
cmake を実行すると cef_binary のダウンロードをしてから Makefile を生成してくれます。
$ cd cef-project $ mkdir build && cd build $ cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release ..
-- The C compiler identification is GNU 9.1.1 -- The CXX compiler identification is GNU 9.1.1 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done CMake Warning (dev) at CMakeLists.txt:54 (find_package): Policy CMP0074 is not set: find_package uses <PackageName>_ROOT variables. Run "cmake --help-policy CMP0074" for policy details. Use the cmake_policy command to set the policy and suppress this warning. CMake variable CEF_ROOT is set to: /home/tomoyan/my_projects/cef-project/third_party/cef/cef_binary_3.3538.1852.gcb937fc_linux64 For compatibility, CMake is ignoring the variable. This warning is for project developers. Use -Wno-dev to suppress it. -- Performing Test COMPILER_SUPPORTS_NO_UNUSED_LOCAL_TYPEDEFS -- Performing Test COMPILER_SUPPORTS_NO_UNUSED_LOCAL_TYPEDEFS - Success -- Performing Test COMPILER_SUPPORTS_NO_LITERAL_SUFFIX -- Performing Test COMPILER_SUPPORTS_NO_LITERAL_SUFFIX - Success -- Performing Test COMPILER_SUPPORTS_NO_NARROWING -- Performing Test COMPILER_SUPPORTS_NO_NARROWING - Success -- Found PythonInterp: /usr/bin/python (found version "2.7.16") -- Downloading clang-format from Google Storage... 〜省略〜 -- [download 98% complete] -- [download 99% complete] -- [download 100% complete] -- Extracting /home/tomoyan/my_projects/cef-project/third_party/cef/cef_binary_3.3538.1852.gcb937fc_linux64.tar.bz2... CMake Warning (dev) at CMakeLists.txt:54 (find_package): Policy CMP0074 is not set: find_package uses <PackageName>_ROOT variables. Run "cmake --help-policy CMP0074" for policy details. Use the cmake_policy command to set the policy and suppress this warning. CMake variable CEF_ROOT is set to: /home/tomoyan/my_projects/cef-project/third_party/cef/cef_binary_3.3538.1852.gcb937fc_linux64 For compatibility, CMake is ignoring the variable. This warning is for project developers. Use -Wno-dev to suppress it. -- Performing Test COMPILER_SUPPORTS_NO_UNUSED_LOCAL_TYPEDEFS -- Performing Test COMPILER_SUPPORTS_NO_UNUSED_LOCAL_TYPEDEFS - Success -- Performing Test COMPILER_SUPPORTS_NO_LITERAL_SUFFIX -- Performing Test COMPILER_SUPPORTS_NO_LITERAL_SUFFIX - Success -- Performing Test COMPILER_SUPPORTS_NO_NARROWING -- Performing Test COMPILER_SUPPORTS_NO_NARROWING - Success -- Found PythonInterp: /usr/bin/python (found version "2.7.15") -- Downloading clang-format from Google Storage... 0> File tools/buildtools/linux64/clang-format exists and SHA1 matches. Skipping. Success! Downloading 1 files took 0.005556 second(s) -- *** CEF CONFIGURATION SETTINGS *** -- Generator: Unix Makefiles -- Platform: Linux -- Project architecture: x86_64 -- Build type: Release -- Binary distribution root: /home/tomoyan/my_projects/cef-project/third_party/cef/cef_binary_3.3538.1852.gcb937fc_linux64 -- CEF sandbox: ON -- Standard libraries: X11 -- Compile defines: __STDC_CONSTANT_MACROS;__STDC_FORMAT_MACROS;_FILE_OFFSET_BITS=64;CEF_USE_SANDBOX -- Compile defines (Debug): -- Compile defines (Release): NDEBUG -- C compile flags: -fno-strict-aliasing;-fPIC;-fstack-protector;-funwind-tables;-fvisibility=hidden;--param=ssp-buffer-size=4;-pipe;-pthread;-Wall;-Werror;-Wno-missing-field-initializers;-Wno-unused-parameter;-Wno-error=comment;-Wno-comment;-m64;-march=x86-64 -std=c99;-Wno-unused-local-typedefs -- C compile flags (Debug): -O0;-g -- C compile flags (Release): -O2;-fdata-sections;-ffunction-sections;-fno-ident;-U_FORTIFY_SOURCE;-D_FORTIFY_SOURCE=2 -- C++ compile flags: -fno-strict-aliasing;-fPIC;-fstack-protector;-funwind-tables;-fvisibility=hidden;--param=ssp-buffer-size=4;-pipe;-pthread;-Wall;-Werror;-Wno-missing-field-initializers;-Wno-unused-parameter;-Wno-error=comment;-Wno-comment;-m64;-march=x86-64 -fno-exceptions;-fno-rtti;-fno-threadsafe-statics;-fvisibility-inlines-hidden;-std=gnu++11;-Wsign-compare;-Wno-literal-suffix;-Wno-narrowing -- C++ compile flags (Debug): -O0;-g -- C++ compile flags (Release): -O2;-fdata-sections;-ffunction-sections;-fno-ident;-U_FORTIFY_SOURCE;-D_FORTIFY_SOURCE=2 -- Exe link flags: -fPIC;-pthread;-Wl,--disable-new-dtags;-Wl,--fatal-warnings;-Wl,-rpath,.;-Wl,-z,noexecstack;-Wl,-z,now;-Wl,-z,relro;-m64 -- Exe link flags (Debug): -- Exe link flags (Release): -Wl,-O1;-Wl,--as-needed;-Wl,--gc-sections -- Shared link flags: -fPIC;-pthread;-Wl,--disable-new-dtags;-Wl,--fatal-warnings;-Wl,-rpath,.;-Wl,-z,noexecstack;-Wl,-z,now;-Wl,-z,relro;-m64 -- Shared link flags (Debug): -- Shared link flags (Release): -Wl,-O1;-Wl,--as-needed;-Wl,--gc-sections -- CEF Binary files: chrome-sandbox;libcef.so;libEGL.so;libGLESv2.so;natives_blob.bin;snapshot_blob.bin;v8_context_snapshot.bin;swiftshader -- CEF Resource files: cef.pak;cef_100_percent.pak;cef_200_percent.pak;cef_extensions.pak;devtools_resources.pak;icudtl.dat;locales -- Configuring done -- Generating done -- Build files have been written to: /home/tomoyan/my_projects/cef-project/build
ビルド
cef-project をビルドする。
$ make -j4
CMake Warning (dev) at CMakeLists.txt:54 (find_package): Policy CMP0074 is not set: find_package uses <PackageName>_ROOT variables. Run "cmake --help-policy CMP0074" for policy details. Use the cmake_policy command to set the policy and suppress this warning. CMake variable CEF_ROOT is set to: /home/tomoyan/my_projects/cef-project/third_party/cef/cef_binary_3.3538.1852.gcb937fc_linux64 For compatibility, CMake is ignoring the variable. This warning is for project developers. Use -Wno-dev to suppress it. -- Downloading clang-format from Google Storage... 0> File tools/buildtools/linux64/clang-format exists and SHA1 matches. Skipping. Success! 〜省略〜 [100%] Building CXX object third_party/cef/cef_binary_3.3538.1852.gcb937fc_linux64/tests/ceftests/CMakeFiles/ceftests.dir/views/window_unittest.cc.o [100%] Linking CXX executable Release/ceftests *** Run the following command manually to set SUID permissions *** EXE="/home/tomoyan/my_projects/cef-project/build/third_party/cef/cef_binary_3.3538.1852.gcb937fc_linux64/tests/ceftests/Release/chrome-sandbox" && sudo -- chown root:root $EXE && sudo -- chmod 4755 $EXE [100%] Built target ceftests
SUIDアクセス許可を設定
ビルドが終わったら指示にしたがって、手動で次のコマンドを実行して SUID アクセス許可を設定する。
$ EXE="/home/tomoyan/my_projects/cef-project/build/third_party/cef/cef_binary_3.3538.1852.gcb937fc_linux64/tests/ceftests/Release/chrome-sandbox" && sudo -- chown root:root $EXE && sudo -- chmod 4755 $EXE