build: allow use of BUILDFLAG directives from within JS code (#20328)

This commit is contained in:
Milan Burda 2020-05-11 01:06:07 +02:00 committed by GitHub
parent f9c04449f4
commit 392ea320cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 132 additions and 74 deletions

View file

@ -5,7 +5,6 @@ const fs = require('fs');
const eventBinding = process.electronBinding('event');
const clipboard = process.electronBinding('clipboard');
const features = process.electronBinding('features');
const { ipcMainInternal } = require('@electron/internal/browser/ipc-main-internal');
const ipcMainUtils = require('@electron/internal/browser/ipc-main-internal-utils');
@ -60,7 +59,7 @@ ipcMainUtils.handleSync('ELECTRON_BROWSER_CLIPBOARD_SYNC', function (event, meth
return typeUtils.serialize(electron.clipboard[method](...typeUtils.deserialize(args)));
});
if (features.isDesktopCapturerEnabled()) {
if (BUILDFLAG(ENABLE_DESKTOP_CAPTURER)) {
const desktopCapturer = require('@electron/internal/browser/desktop-capturer');
ipcMainInternal.handle('ELECTRON_BROWSER_DESKTOP_CAPTURER_GET_SOURCES', function (event, options, stack) {
@ -76,7 +75,7 @@ if (features.isDesktopCapturerEnabled()) {
});
}
const isRemoteModuleEnabled = features.isRemoteModuleEnabled()
const isRemoteModuleEnabled = BUILDFLAG(ENABLE_REMOTE_MODULE)
? require('@electron/internal/browser/remote/server').isRemoteModuleEnabled
: () => false;