Skip to content

Commit 9c4274d

Browse files
authored
Enable dullahan Linux builds (#4)
* Update cmake minimum requirement to 3.11 * Enable PIC generation * Remove Linux64 archive (was pointing to an internal HTTP server anyway) * Wire up a Linux build. As we have no prebuild CEF from LL yet, consume a prebuild CEF from spotify. This will obviously miss the proprietary codecs, but it's still better than no CEF at all * Enable Ubuntu 22.04 runner * Update build-cmd.sh Cleanup, install will duplicate files into bin/release and lib/release. Delete the shared library files in bin/release to avoid duplicate files in final archive * Enable C++11 ABI
1 parent 474c1c4 commit 9c4274d

File tree

4 files changed

+113
-89
lines changed

4 files changed

+113
-89
lines changed

.github/workflows/build.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,14 @@ jobs:
88
build:
99
strategy:
1010
matrix:
11-
os: [windows-2022, macos-13]
11+
os: [windows-2022, macos-13, ubuntu-22.04]
1212
addrsize: ["64"]
1313
runs-on: ${{ matrix.os }}
1414
steps:
15+
- name: Install Linux dependencies
16+
if: runner.os == 'linux'
17+
run: sudo apt update && sudo apt install -y ninja-build
18+
1519
- uses: secondlife/action-autobuild@v3
1620
with:
1721
addrsize: ${{ matrix.addrsize }}

CMakeLists.txt

Lines changed: 99 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@
22
# Dullahan CMake file - Callum Prentice - 2020-05-03
33

44
###############################################################################
5-
cmake_minimum_required(VERSION 3.4.3)
5+
cmake_minimum_required(VERSION 3.11)
6+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
7+
set(CMAKE_CXX_STANDARD 17)
8+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
9+
10+
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
11+
add_compile_options("-Wno-array-bounds")
12+
endif()
613

714
###############################################################################
815
# Dullahan main project/solution
@@ -18,24 +25,50 @@ function(check_exists variable)
1825
endif()
1926
endfunction()
2027

21-
###############################################################################
22-
# The user must pass in CEF_WRAPPER_DIR and CEF_WRAPPER_BUILD_DIR then we
23-
# derrive all the other ones we need based on those
24-
set(CEF_INCLUDE_DIR ${CEF_WRAPPER_DIR}/include)
25-
set(CEF_RELEASE_LIB_DIR ${CEF_WRAPPER_DIR}/Release)
26-
set(CEF_RELEASE_DLL_LIB_DIR ${CEF_WRAPPER_BUILD_DIR}/libcef_dll_wrapper/Release)
27-
set(CEF_RELEASE_BIN_DIR ${CEF_WRAPPER_DIR}/Release)
28-
set(CEF_RESOURCES_DIR ${CEF_WRAPPER_DIR}/Resources)
29-
30-
# Check if all our variables exist and bail with
31-
# a fatal error if any of them are missing
32-
check_exists(CEF_WRAPPER_DIR)
33-
check_exists(CEF_WRAPPER_BUILD_DIR)
34-
check_exists(CEF_INCLUDE_DIR)
35-
check_exists(CEF_RELEASE_LIB_DIR)
36-
check_exists(CEF_RELEASE_DLL_LIB_DIR)
37-
check_exists(CEF_RELEASE_BIN_DIR)
38-
check_exists(CEF_RESOURCES_DIR)
28+
option( USE_SPOTIFY_CEF "Use a prebuild CEF from spotify" Off )
29+
option( SPOTIFY_CEF_URL "URL to the prebuild CEF from spotify" "" )
30+
31+
if( USE_SPOTIFY_CEF )
32+
include(FetchContent)
33+
34+
FetchContent_Declare( cef_prebuild URL ${SPOTIFY_CEF_URL} )
35+
FetchContent_MakeAvailable(cef_prebuild)
36+
37+
set(CEF_ROOT "${cef_prebuild_SOURCE_DIR}")
38+
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${cef_prebuild_SOURCE_DIR}/cmake")
39+
find_package(CEF REQUIRED)
40+
endif()
41+
42+
43+
if( NOT USE_SPOTIFY_CEF )
44+
###############################################################################
45+
# The user must pass in CEF_WRAPPER_DIR and CEF_WRAPPER_BUILD_DIR then we
46+
# derrive all the other ones we need based on those
47+
set(CEF_INCLUDE_DIR ${CEF_WRAPPER_DIR}/include)
48+
set(CEF_RELEASE_LIB_DIR ${CEF_WRAPPER_DIR}/Release)
49+
set(CEF_RELEASE_DLL_LIB_DIR ${CEF_WRAPPER_BUILD_DIR}/libcef_dll_wrapper/Release)
50+
set(CEF_RELEASE_BIN_DIR ${CEF_WRAPPER_DIR}/Release)
51+
set(CEF_RESOURCES_DIR ${CEF_WRAPPER_DIR}/Resources)
52+
53+
# Check if all our variables exist and bail with
54+
# a fatal error if any of them are missing
55+
check_exists(CEF_WRAPPER_DIR)
56+
check_exists(CEF_WRAPPER_BUILD_DIR)
57+
check_exists(CEF_INCLUDE_DIR)
58+
check_exists(CEF_RELEASE_LIB_DIR)
59+
check_exists(CEF_RELEASE_DLL_LIB_DIR)
60+
check_exists(CEF_RELEASE_BIN_DIR)
61+
check_exists(CEF_RESOURCES_DIR)
62+
else()
63+
set(CEF_INCLUDE_DIR ${cef_prebuild_SOURCE_DIR}/include)
64+
set(CEF_RELEASE_LIB_DIR ${cef_prebuild_SOURCE_DIR}/Release)
65+
set(CEF_RELEASE_DLL_LIB_DIR ${CEF_WRAPPER_BUILD_DIR}/libcef_dll_wrapper/Release)
66+
set(CEF_RELEASE_BIN_DIR ${cef_prebuild_SOURCE_DIR}/Release)
67+
set(CEF_RESOURCES_DIR ${cef_prebuild_SOURCE_DIR}/Resources)
68+
69+
set( CEF_DLL_LIBRARY libcef_dll_wrapper )
70+
set( CEF_LIBRARY ${CEF_LIB_RELEASE} )
71+
endif()
3972

4073
###############################################################################
4174
# location of CEF libraries we link against
@@ -77,27 +110,32 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
77110
check_exists(COCOA_FRAMEWORK)
78111
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
79112
set(CMAKE_CXX_LINK_FLAGS "-Wl,--no-keep-memory -Wl,--build-id -Wl,-rpath,'$ORIGIN:$ORIGIN/../lib' -Wl,--exclude-libs,ALL")
80-
find_library(
81-
CEF_LIBRARY_RELEASE
82-
NAMES libcef.so
83-
PATHS ${CEF_RELEASE_LIB_DIR}
84-
PATH_SUFFIXES release
85-
)
86-
find_library(
87-
CEF_DLL_LIBRARY_RELEASE
88-
NAMES libcef_dll_wrapper.a
89-
PATHS ${CEF_WRAPPER_BUILD_DIR}/libcef_dll_wrapper/
90-
PATH_SUFFIXES release
91-
)
113+
114+
if( NOT USE_SPOTIFY_CEF )
115+
find_library(
116+
CEF_LIBRARY_RELEASE
117+
NAMES libcef.so
118+
PATHS ${CEF_RELEASE_LIB_DIR}
119+
PATH_SUFFIXES release
120+
)
121+
find_library(
122+
CEF_DLL_LIBRARY_RELEASE
123+
NAMES libcef_dll_wrapper.a
124+
PATHS ${CEF_WRAPPER_BUILD_DIR}/libcef_dll_wrapper/
125+
PATH_SUFFIXES release
126+
)
127+
set(CEF_LIBRARY ${CEF_LIBRARY_RELEASE} )
128+
set(CEF_DLL_LIBRARY ${CEF_DLL_LIBRARY_RELEASE} )
129+
else()
130+
set( CEF_DLL_LIBRARY libcef_dll_wrapper )
131+
set( CEF_LIBRARY ${CEF_LIB_RELEASE} )
132+
endif()
92133
endif()
93134

94135
###############################################################################
95136
# Final layer of finding the right libs for each combination
96137
# of name, platform, configuration, type etc.
97-
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
98-
set(CEF_LIBRARY ${CEF_LIBRARY_RELEASE} )
99-
set(CEF_DLL_LIBRARY ${CEF_DLL_LIBRARY_RELEASE} )
100-
else()
138+
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Linux")
101139
set(CEF_LIBRARY
102140
optimized ${CEF_LIBRARY_RELEASE}
103141
)
@@ -121,7 +159,7 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
121159
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=c++11 -xobjective-c++")
122160
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
123161
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
124-
if( NOT ENABLE_CXX11_ABI )
162+
if( NOT ENABLE_CXX11_ABI )
125163
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)
126164
endif()
127165
endif()
@@ -274,7 +312,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
274312
COMMENT "Adding custom manifest...")
275313
endif()
276314

277-
# Windows commands to copy CEF binaries and 'resources' folders to
315+
# Windows commands to copy CEF binaries and 'resources' folders to
278316
# executable dir since they're needed at runtime
279317

280318
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
@@ -524,3 +562,27 @@ endif()
524562
if(CMAKE_CONFIGURATION_TYPES)
525563
set(CMAKE_CONFIGURATION_TYPES "Release")
526564
endif()
565+
566+
# Install the Dullahan library and host executable
567+
568+
if( USE_SPOTIFY_CEF )
569+
install( TARGETS dullahan_host DESTINATION bin/release )
570+
install( TARGETS dullahan ${CEF_DLL_LIBRARY} DESTINATION lib/release )
571+
572+
foreach(binFile IN LISTS CEF_BINARY_FILES)
573+
if(IS_DIRECTORY ${CEF_BINARY_DIR_RELEASE}/${binFile} )
574+
install( DIRECTORY ${CEF_BINARY_DIR_RELEASE}/${binFile} DESTINATION lib/release )
575+
install( DIRECTORY ${CEF_BINARY_DIR_RELEASE}/${binFile} DESTINATION bin/release )
576+
else()
577+
install( PROGRAMS ${CEF_BINARY_DIR_RELEASE}/${binFile} DESTINATION lib/release )
578+
install( PROGRAMS ${CEF_BINARY_DIR_RELEASE}/${binFile} DESTINATION bin/release )
579+
endif()
580+
endforeach()
581+
foreach(resFile IN LISTS CEF_RESOURCE_FILES)
582+
if(IS_DIRECTORY ${CEF_RESOURCE_DIR}/${resFile} )
583+
install( DIRECTORY ${CEF_RESOURCE_DIR}/${resFile} DESTINATION resources)
584+
else()
585+
install( FILES ${CEF_RESOURCE_DIR}/${resFile} DESTINATION resources)
586+
endif()
587+
endforeach()
588+
endif()

autobuild.xml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,6 @@
2828
<key>name</key>
2929
<string>darwin64</string>
3030
</map>
31-
<key>linux64</key>
32-
<map>
33-
<key>archive</key>
34-
<map>
35-
<key>hash</key>
36-
<string>fe4c980f5e42196e4ba554e2093dfb3a</string>
37-
<key>url</key>
38-
<string>http://192.168.1.115/dev/pkg/cef_bin-81.3.10_gb223419_chromium-81.0.4044.138.201451352-linux64-201451352.tar.bz2</string>
39-
</map>
40-
<key>name</key>
41-
<string>darwin64</string>
42-
</map>
4331
<key>windows</key>
4432
<map>
4533
<key>archive</key>

build-cmd.sh

Lines changed: 9 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -232,53 +232,23 @@ case "$AUTOBUILD_PLATFORM" in
232232
#Force version regeneration.
233233
rm -f src/dullahan_version.h
234234

235-
# build the CEF c->C++ wrapper "libcef_dll_wrapper"
236-
cd "${cef_no_wrapper_dir}"
237-
rm -rf "${cef_no_wrapper_build_dir}"
238-
mkdir -p "${cef_no_wrapper_build_dir}"
239-
cd "${cef_no_wrapper_build_dir}"
240-
opts="$LL_BUILD_RELEASE -m${AUTOBUILD_ADDRSIZE}"
241-
plainopts="$(remove_cxxstd $opts)"
242-
cmake -G Ninja \
243-
-DCMAKE_C_FLAGS="$plainopts" \
244-
-DCMAKE_CXX_FLAGS="$opts" \
245-
$(cmake_cxx_standard $LL_BUILD_RELEASE) \
246-
..
247-
ninja libcef_dll_wrapper
248-
249-
cd "$stage"
250-
cmake .. -G Ninja \
251-
-DCEF_WRAPPER_DIR="${cef_no_wrapper_dir}" \
252-
-DCEF_WRAPPER_BUILD_DIR="${cef_no_wrapper_build_dir}" \
253-
-DCMAKE_CXX_FLAGS:STRING="$opts" \
254-
$(cmake_cxx_standard $LL_BUILD_RELEASE)
235+
cmake -S . -B stage/build -DCMAKE_BUILD_TYPE=Release -G Ninja -DCMAKE_INSTALL_PREFIX=stage -DENABLE_CXX11_ABI=ON \
236+
-DUSE_SPOTIFY_CEF=TRUE -DSPOTIFY_CEF_URL=https://cef-builds.spotifycdn.com/cef_binary_118.4.1%2Bg3dd6078%2Bchromium-118.0.5993.54_linux64_beta_minimal.tar.bz2
237+
cmake --build stage/build
238+
cmake --install stage/build
255239

256-
ninja
240+
strip stage/lib/release/libcef.so
241+
rm stage/bin/release/*.so*
242+
rm stage/bin/release/*.json
257243

258-
g++ -std=c++11 -I "${cef_no_wrapper_dir}/include" -I "${dullahan_source_dir}" -o "$stage/version" "$top/tools/autobuild_version.cpp"
244+
g++ -std=c++17 -I "${cef_no_wrapper_dir}/include" -I "${dullahan_source_dir}" -o "$stage/version" "$top/tools/autobuild_version.cpp"
259245

260246
"$stage/version" > "$stage/VERSION.txt"
261247
rm "$stage/version"
262-
248+
263249
mkdir -p "$stage/LICENSES"
264-
mkdir -p "$stage/bin/release/"
265-
mkdir -p "$stage/include"
266250
mkdir -p "$stage/include/cef"
267-
mkdir -p "$stage/lib/release/swiftshader"
268-
mkdir -p "$stage/resources"
269-
270-
cp libdullahan.a ${stage}/lib/release/
271-
cp ${cef_no_wrapper_build_dir}/libcef_dll_wrapper/libcef_dll_wrapper.a $stage/lib/release
272-
273-
cp -a ${cef_no_wrapper_dir}/Release/*.so ${stage}/lib/release/
274-
cp -a ${cef_no_wrapper_dir}/Release/swiftshader/* ${stage}/lib/release/swiftshader/
275-
276-
cp dullahan_host ${stage}/bin/release/
277-
278-
cp -a ${cef_no_wrapper_dir}/Release/*.bin ${stage}/bin/release/
279-
cp -a ${cef_no_wrapper_dir}/Release/chrome-sandbox ${stage}/bin/release/
280251

281-
cp -R ${cef_no_wrapper_dir}/Resources/* ${stage}/resources/
282252
cp ${dullahan_source_dir}/dullahan.h ${stage}/include/cef/
283253
cp ${dullahan_source_dir}/dullahan_version.h ${stage}/include/cef/
284254
cp "$top/CEF_LICENSE.txt" "$stage/LICENSES"

0 commit comments

Comments
 (0)