Skip to content

Commit

Permalink
Modify resources in prep for Bazel build support
Browse files Browse the repository at this point in the history
- Move win/mac folders out of the resources folder.
- Mac: Rename plist files to plist.in and add version placeholder.
- Win: Use full paths in .rc files.
- Win: Chain multiple .rc files using #includes.
- Win: Move resource.h next to resource_util_win_impl.cc.
  • Loading branch information
magreenblatt committed Jul 31, 2024
1 parent ad97ea5 commit 987ee7d
Show file tree
Hide file tree
Showing 30 changed files with 169 additions and 55 deletions.
22 changes: 10 additions & 12 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,25 @@
if(OS_MAC)
# Shared macOS resources (menus, icons, etc).
set(SHARED_RESOURCES_SRCS
../shared/resources/mac/English.lproj/InfoPlist.strings
../shared/resources/mac/English.lproj/MainMenu.xib
../shared/resources/mac/Info.plist
../shared/resources/mac/shared.icns
../shared/mac/English.lproj/InfoPlist.strings
../shared/mac/English.lproj/MainMenu.xib
../shared/mac/shared.icns
)

# Info.plist files used for main and helper app bundles.
set(SHARED_INFO_PLIST ../shared/resources/mac/Info.plist)
set(SHARED_HELPER_INFO_PLIST ../shared/resources/mac/helper-Info.plist)
set(SHARED_INFO_PLIST ../shared/mac/Info.plist.in)
set(SHARED_HELPER_INFO_PLIST ../shared/mac/helper-Info.plist.in)
elseif(OS_WINDOWS)
# Shared Windows resources (version information, icons).
set(SHARED_RESOURCES_SRCS
../shared/resources/win/big.ico
../shared/resources/win/resource.h
../shared/resources/win/shared.rc
../shared/resources/win/small.ico
../shared/win/big.ico
../shared/win/resource.h
../shared/win/small.ico
)

# Manifest files used for executables.
set(SHARED_EXE_MANIFEST ../shared/resources/win/shared.exe.manifest)
set(SHARED_COMPATIBILITY_MANIFEST ../shared/resources/win/compatibility.manifest)
set(SHARED_EXE_MANIFEST ../shared/win/shared.exe.manifest)
set(SHARED_COMPATIBILITY_MANIFEST ../shared/win/compatibility.manifest)
endif()


Expand Down
8 changes: 4 additions & 4 deletions examples/message_router/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ set(EXAMPLE_SRCS
client_impl.h
)
set(EXAMPLE_SRCS_WINDOWS
resource.h
resource_util_win_impl.cc
)
APPEND_PLATFORM_SOURCES(EXAMPLE_SRCS)
Expand All @@ -40,8 +41,7 @@ set(EXAMPLE_RESOURCES_SRCS
)
set(EXAMPLE_RESOURCES_SRCS_WINDOWS
# Resources that embed "message_router.html" in the executable.
resources/win/resource.h
resources/win/resource.rc
win/resource.rc
)
APPEND_PLATFORM_SOURCES(EXAMPLE_RESOURCES_SRCS)

Expand Down Expand Up @@ -139,7 +139,7 @@ if(OS_MAC)
# manually because the configure_file command (which is executed as part of
# MACOSX_BUNDLE_INFO_PLIST) uses global env variables and would insert the
# wrong values with multiple targets.
set(_helper_info_plist "${CMAKE_CURRENT_BINARY_DIR}/helper-Info${_target_suffix}.plist")
set(_helper_info_plist "${CMAKE_CURRENT_BINARY_DIR}/helper-Info${_target_suffix}.plist.in")
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/${SHARED_HELPER_INFO_PLIST}" _plist_contents)
string(REPLACE "\${EXECUTABLE_NAME}" "${_helper_output_name}" _plist_contents ${_plist_contents})
string(REPLACE "\${PRODUCT_NAME}" "${_helper_output_name}" _plist_contents ${_plist_contents})
Expand Down Expand Up @@ -179,7 +179,7 @@ if(OS_MAC)
# directive but that doesn't properly handle nested resource directories.
# Remove these prefixes from input file paths.
set(PREFIXES
"../shared/resources/mac/"
"../shared/mac/"
)
COPY_MAC_RESOURCES("${EXAMPLE_RESOURCES_SRCS}" "${PREFIXES}" "${EXAMPLE_TARGET}" "${CMAKE_CURRENT_SOURCE_DIR}" "${EXAMPLE_APP}")
endif()
Expand Down
2 changes: 1 addition & 1 deletion examples/message_router/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The "message_router" target is implemented as follows:
* Creates a `CefMessageRouterBrowserSide` instance to handle the browser side of message routing.
* Creates a `CefMessageRouterBrowserSide::Handler` instance to handle messages specific to the test code in [message_router.html](resources/message_router.html).
* Implements the `GetResourceHandler` method to support loading of [message_router.html](resources/message_router.html) via https://example.com/message_router.html.
* Windows resource loading implementation in [resource_util_win_impl.cc](resource_util_win_impl.cc) and [resource.rc](resources/win/resource.rc).
* Windows resource loading implementation in [resource_util_win_impl.cc](resource_util_win_impl.cc) and [resource.rc](win/resource.rc).
* Implements the [shared::GetResourceId](../shared/resource_util.h) method to map resource paths to BINARY ID values.
* Defines a BINARY resource to include [message_router.html](resources/message_router.html) in the executable.

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/message_router/resource_util_win_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "examples/shared/resource_util.h"

#include "examples/message_router/resources/win/resource.h"
#include "examples/message_router/resource.h"

namespace shared {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#include "examples/message_router/resource.h"

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
Expand All @@ -23,14 +23,15 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32

// Include the shared RC file.
#include "examples/shared/win/shared.rc"

/////////////////////////////////////////////////////////////////////////////
//
// Binary
//

IDS_LOGO_PNG BINARY "..\\logo.png"
IDS_RESOURCE_MANAGER_HTML BINARY "..\\resource_manager.html"
IDS_MESSAGE_ROUTER_HTML BINARY "examples\\message_router\\resources\\message_router.html"


#ifdef APSTUDIO_INVOKED
Expand Down
20 changes: 17 additions & 3 deletions examples/minimal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ set(EXAMPLE_SRCS
client_minimal.h
main_minimal.cc
)

set(EXAMPLE_SRCS_WINDOWS
resource.h
)
APPEND_PLATFORM_SOURCES(EXAMPLE_SRCS)

if(OS_LINUX OR OS_WINDOWS)
# On Windows and Linux the same executable is used for all processes.
set(EXAMPLE_SRCS
Expand All @@ -30,9 +34,19 @@ elseif(OS_MAC)
)
endif()

# Main executable resources.
set(EXAMPLE_RESOURCES_SRCS
)
set(EXAMPLE_RESOURCES_SRCS_WINDOWS
# Resources that embed the *.html and *.png files in the executable.
win/resource.rc
)
APPEND_PLATFORM_SOURCES(EXAMPLE_RESOURCES_SRCS)

if(OS_MACOSX OR OS_WINDOWS)
# On macOS and Windows include the shared resources.
set(EXAMPLE_RESOURCES_SRCS
${EXAMPLE_RESOURCES_SRCS}
${SHARED_RESOURCES_SRCS}
)
endif()
Expand Down Expand Up @@ -120,7 +134,7 @@ if(OS_MAC)
# manually because the configure_file command (which is executed as part of
# MACOSX_BUNDLE_INFO_PLIST) uses global env variables and would insert the
# wrong values with multiple targets.
set(_helper_info_plist "${CMAKE_CURRENT_BINARY_DIR}/helper-Info${_target_suffix}.plist")
set(_helper_info_plist "${CMAKE_CURRENT_BINARY_DIR}/helper-Info${_target_suffix}.plist.in")
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/${SHARED_HELPER_INFO_PLIST}" _plist_contents)
string(REPLACE "\${EXECUTABLE_NAME}" "${_helper_output_name}" _plist_contents ${_plist_contents})
string(REPLACE "\${PRODUCT_NAME}" "${_helper_output_name}" _plist_contents ${_plist_contents})
Expand Down Expand Up @@ -160,7 +174,7 @@ if(OS_MAC)
# directive but that doesn't properly handle nested resource directories.
# Remove these prefixes from input file paths.
set(PREFIXES
"../shared/resources/mac/"
"../shared/mac/"
)
COPY_MAC_RESOURCES("${EXAMPLE_RESOURCES_SRCS}" "${PREFIXES}" "${EXAMPLE_TARGET}" "${CMAKE_CURRENT_SOURCE_DIR}" "${EXAMPLE_APP}")
endif()
Expand Down
23 changes: 23 additions & 0 deletions examples/minimal/resource.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) 2017 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.

//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by cefsimple.rc
//

// Avoid files associated with MacOS
#define _X86_

// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 32700
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 102
#endif
#endif
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#include "examples/minimal/resource.h"

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
Expand All @@ -23,14 +23,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32


/////////////////////////////////////////////////////////////////////////////
//
// Binary
//

IDS_MESSAGE_ROUTER_HTML BINARY "..\\message_router.html"

// Include the shared RC file.
#include "examples/shared/win/shared.rc"

#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
Expand Down
8 changes: 4 additions & 4 deletions examples/resource_manager/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ set(EXAMPLE_SRCS
client_impl.h
)
set(EXAMPLE_SRCS_WINDOWS
resource.h
resource_util_win_impl.cc
)
APPEND_PLATFORM_SOURCES(EXAMPLE_SRCS)
Expand Down Expand Up @@ -41,8 +42,7 @@ set(EXAMPLE_RESOURCES_SRCS
)
set(EXAMPLE_RESOURCES_SRCS_WINDOWS
# Resources that embed the *.html and *.png files in the executable.
resources/win/resource.h
resources/win/resource.rc
win/resource.rc
)
APPEND_PLATFORM_SOURCES(EXAMPLE_RESOURCES_SRCS)

Expand Down Expand Up @@ -140,7 +140,7 @@ if(OS_MAC)
# manually because the configure_file command (which is executed as part of
# MACOSX_BUNDLE_INFO_PLIST) uses global env variables and would insert the
# wrong values with multiple targets.
set(_helper_info_plist "${CMAKE_CURRENT_BINARY_DIR}/helper-Info${_target_suffix}.plist")
set(_helper_info_plist "${CMAKE_CURRENT_BINARY_DIR}/helper-Info${_target_suffix}.plist.in")
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/${SHARED_HELPER_INFO_PLIST}" _plist_contents)
string(REPLACE "\${EXECUTABLE_NAME}" "${_helper_output_name}" _plist_contents ${_plist_contents})
string(REPLACE "\${PRODUCT_NAME}" "${_helper_output_name}" _plist_contents ${_plist_contents})
Expand Down Expand Up @@ -180,7 +180,7 @@ if(OS_MAC)
# directive but that doesn't properly handle nested resource directories.
# Remove these prefixes from input file paths.
set(PREFIXES
"../shared/resources/mac/"
"../shared/mac/"
)
COPY_MAC_RESOURCES("${EXAMPLE_RESOURCES_SRCS}" "${PREFIXES}" "${EXAMPLE_TARGET}" "${CMAKE_CURRENT_SOURCE_DIR}" "${EXAMPLE_APP}")
endif()
Expand Down
2 changes: 1 addition & 1 deletion examples/resource_manager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The "resource_manager" target is implemented as follows:
* Creates a `CefResourceManager` instance to handle resource requests.
* Defines a `RequestDumpResourceProvider` class to demonstrate custom `CefResourceManager::Provider` handling.
* Registers the `CefResourceManager::Provider` instances with the `CefResourceManager`.
* Windows resource loading implementation in [resource_util_win_impl.cc](resource_util_win_impl.cc) and [resource.rc](resources/win/resource.rc).
* Windows resource loading implementation in [resource_util_win_impl.cc](resource_util_win_impl.cc) and [resource.rc](win/resource.rc).
* Implements the [shared::GetResourceId](../shared/resource_util.h) method to map resource paths to BINARY ID values.
* Defines a BINARY resource to include [logo.png](resources/logo.png) and [resource_manager.html](resources/resource_manager.html) in the executable.

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/resource_manager/resource_util_win_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "examples/shared/resource_util.h"

#include "examples/resource_manager/resources/win/resource.h"
#include "examples/resource_manager/resource.h"

namespace shared {

Expand Down
80 changes: 80 additions & 0 deletions examples/resource_manager/win/resource.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// Microsoft Visual C++ generated resource script.
//
#include "examples/resource_manager/resource.h"

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#define APSTUDIO_HIDDEN_SYMBOLS
#include "windows.h"
#undef APSTUDIO_HIDDEN_SYMBOLS

/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32

// Include the shared RC file.
#include "examples/shared/win/shared.rc"

/////////////////////////////////////////////////////////////////////////////
//
// Binary
//

IDS_LOGO_PNG BINARY "examples\\resource_manager\\resources\\logo.png"
IDS_RESOURCE_MANAGER_HTML BINARY "examples\\resource_manager\\resources\\resource_manager.html"


#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//

1 TEXTINCLUDE
BEGIN
"resource.h\0"
END

2 TEXTINCLUDE
BEGIN
"#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
"#include ""windows.h""\r\n"
"#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
"\0"
END

3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END

#endif // APSTUDIO_INVOKED


#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////



#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//


/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

8 changes: 4 additions & 4 deletions examples/scheme_handler/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ set(EXAMPLE_SRCS
scheme_handler_impl.h
)
set(EXAMPLE_SRCS_WINDOWS
resource.h
resource_util_win_impl.cc
)
APPEND_PLATFORM_SOURCES(EXAMPLE_SRCS)
Expand All @@ -49,8 +50,7 @@ set(EXAMPLE_RESOURCES_SRCS
)
set(EXAMPLE_RESOURCES_SRCS_WINDOWS
# Resources that embed the *.html and *.png files in the executable.
resources/win/resource.h
resources/win/resource.rc
win/resource.rc
)
APPEND_PLATFORM_SOURCES(EXAMPLE_RESOURCES_SRCS)

Expand Down Expand Up @@ -148,7 +148,7 @@ if(OS_MAC)
# manually because the configure_file command (which is executed as part of
# MACOSX_BUNDLE_INFO_PLIST) uses global env variables and would insert the
# wrong values with multiple targets.
set(_helper_info_plist "${CMAKE_CURRENT_BINARY_DIR}/helper-Info${_target_suffix}.plist")
set(_helper_info_plist "${CMAKE_CURRENT_BINARY_DIR}/helper-Info${_target_suffix}.plist.in")
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/${SHARED_HELPER_INFO_PLIST}" _plist_contents)
string(REPLACE "\${EXECUTABLE_NAME}" "${_helper_output_name}" _plist_contents ${_plist_contents})
string(REPLACE "\${PRODUCT_NAME}" "${_helper_output_name}" _plist_contents ${_plist_contents})
Expand Down Expand Up @@ -188,7 +188,7 @@ if(OS_MAC)
# directive but that doesn't properly handle nested resource directories.
# Remove these prefixes from input file paths.
set(PREFIXES
"../shared/resources/mac/"
"../shared/mac/"
)
COPY_MAC_RESOURCES("${EXAMPLE_RESOURCES_SRCS}" "${PREFIXES}" "${EXAMPLE_TARGET}" "${CMAKE_CURRENT_SOURCE_DIR}" "${EXAMPLE_APP}")
endif()
Expand Down
2 changes: 1 addition & 1 deletion examples/scheme_handler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The "scheme_handler" target is implemented as follows:
* Register the custom scheme name in [OnRegisterCustomSchemes](https://bitbucket.org/chromiumembedded/cef/wiki/GeneralUsage.md#markdown-header-request-handling).
* Provide a concrete [CefClient](https://bitbucket.org/chromiumembedded/cef/wiki/GeneralUsage.md#markdown-header-cefclient) implementation to handle [CefBrowser](https://bitbucket.org/chromiumembedded/cef/wiki/GeneralUsage.md#markdown-header-cefbrowser-and-cefframe) callbacks.
* Uses the [minimal target](../minimal) implementation.
* Windows resource loading implementation in [resource_util_win_impl.cc](resource_util_win_impl.cc) and [resource.rc](resources/win/resource.rc).
* Windows resource loading implementation in [resource_util_win_impl.cc](resource_util_win_impl.cc) and [resource.rc](win/resource.rc).
* Implements the [shared::GetResourceId](../shared/resource_util.h) method to map resource paths to BINARY ID values.
* Defines a BINARY resource to include [logo.png](resources/logo.png) and [scheme_handler.html](resources/scheme_handler.html) in the executable.

Expand Down
File renamed without changes.
Loading

0 comments on commit 987ee7d

Please sign in to comment.