docs: improve e build --target documentation (#635)

* docs: improve e build --target documentation

* Update README.md

Co-authored-by: David Sanders <dsanders11@ucsbalum.com>

* refactor: remove build aliases

---------

Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
This commit is contained in:
Shelley Vohr 2024-09-16 20:43:50 +02:00 коммит произвёл GitHub
Родитель e95ea26533
Коммит b0f21f7d61
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
5 изменённых файлов: 56 добавлений и 68 удалений

Просмотреть файл

@ -195,20 +195,58 @@ $ e build --help
```
Once you have the source, the next step is to build it with `e build [target]`.
These build targets are supported:
Some of the build targets you may want to build include:
| Target | Description |
|:--------------|:---------------------------------------------------------|
| breakpad | Builds the breakpad `dump_syms` binary |
| chromedriver | Builds the `chromedriver` binary |
| electron | Builds the Electron binary **(Default)** |
| electron:dist | Builds the Electron binary and generates a dist zip file |
| mksnapshot | Builds the `mksnapshot` binary |
| node:headers | Builds the node headers `.tar.gz` file |
| third_party/breakpad:dump_syms | Builds the breakpad `dump_syms` binary |
| electron:electron_chromedriver_zip | Builds the `chromedriver` binary |
| electron | Builds the Electron binary **(Default)** |
| electron:electron_dist_zip | Builds the Electron binary and generates a dist zip file |
| electron:electron_mksnapshot_zip | Builds the `mksnapshot` binary |
| electron:node_headers | Builds the node headers `.tar.gz` file |
| electron:electron_symbols | Generate the breakpad symbols in release builds |
As with syncing, `e build [target]` is usually all you need. Any extra
args are passed along to [ninja][ninja], so for example `e build -v`
runs a verbose build.
To build a specific ninja target, run `e build --target [target]`:
```sh
$ e build --target electron:node_headers
```
Running `e build` with no target will build `electron` by default.
Any extra args are passed along to [ninja][ninja], so for example
`e build -v` runs a verbose build of `electron`.
To see an exhaustive list of all possible build targets, you can run `e d gn ls out/[TYPE]`,
where `[TYPE]` is e.g. `Testing` or `Release` depending on your build type. This will log a long
list of targets to the console and also allow you to build some of Chromium's targets.
For example, running `e d gn ls out/Testing | grep "//ui/views/"` produces something like:
```console
//ui/views/controls/webview:test_support
//ui/views/controls/webview:webview
//ui/views/debug:views_debug
//ui/views/examples:copy_content_resources
//ui/views/examples:views_examples
//ui/views/examples:views_examples_lib
//ui/views/examples:views_examples_proc
//ui/views/examples:views_examples_resources_grd
//ui/views/examples:views_examples_resources_grd_grit
//ui/views/examples:views_examples_resources_pak
//ui/views/examples:views_examples_unittests
//ui/views/examples:views_examples_unittests__runner
//ui/views/examples:views_examples_with_content
//ui/views/examples:views_examples_with_content_lib
//ui/views/resources:resources
//ui/views/resources:resources_grd
//ui/views/resources:resources_grd_grit
//ui/views/window/vector_icons:vector_icons
//ui/views/window/vector_icons:window_control_vector_icons
```
You could then run `e build --target ui/views/examples:views_examples_with_content` to produce Chrome's `//ui/views` example executable and run it with `./out/Testing/views_examples_with_content`.
## Using Electron

Просмотреть файл

@ -86,34 +86,25 @@ function runNinja(config, target, ninjaArgs) {
}
program
.arguments('[target] [ninjaArgs...]')
.arguments('[ninjaArgs...]')
.description('Build Electron and other targets.')
.option('--list-targets', 'Show all supported build targets', false)
.option('--only-gen', 'Only run `gn gen`', false)
.option('-t|--target [target]', 'Forces a specific ninja target')
.option('-t|--target [target]', 'Build a specific ninja target')
.option('--no-remote', 'Build without remote execution (entirely locally)')
.allowUnknownOption()
.action((target, ninjaArgs, options) => {
.action((ninjaArgs, options) => {
try {
const config = evmConfig.current();
const targets = evmConfig.buildTargets();
reclient.usingRemote = options.remote;
reclient.downloadAndPrepare(config);
if (options.listTargets) {
Object.keys(targets)
.sort()
.forEach(target => console.log(`${target} --> ${color.config(targets[target])}`));
return;
}
if (process.platform === 'darwin') {
if (config.onlySdk) {
ensureSDK();
} else {
loadXcode({ target, quiet: true });
loadXcode({ quiet: true });
}
}
@ -122,37 +113,8 @@ program
return;
}
if (options.target) {
// User forced a target, so any arguments are ninjaArgs
if (target) {
ninjaArgs.unshift(target);
}
target = options.target;
} else if (Object.keys(targets).includes(target)) {
target = targets[target];
} else {
// No forced target and no target matched, so use the
// default target and assume any arguments are ninjaArgs
if (target) {
ninjaArgs.unshift(target);
}
target = targets['default'];
}
try {
runNinja(config, target, ninjaArgs);
} catch (ex) {
if (target === targets['node:headers']) {
// Older versions of electron use a different target for node headers so try that if the new one fails.
const olderTarget = 'third_party/electron_node:headers';
console.info(
`${color.info} Error building ${target}; trying older ${olderTarget} target`,
);
runNinja(config, olderTarget, ninjaArgs);
} else {
throw ex;
}
}
const buildTarget = options.target || evmConfig.getDefaultTarget();
runNinja(config, buildTarget, ninjaArgs);
} catch (e) {
fatal(e);
}

Просмотреть файл

@ -77,7 +77,7 @@ function runGClientSync(syncArgs, syncOpts) {
}
// Only set remotes if we're building an Electron target.
if (config.defaultTarget !== evmConfig.buildTargets().chromium) {
if (config.defaultTarget !== 'chrome') {
const electronPath = path.resolve(srcdir, 'electron');
setRemotes(electronPath, config.remotes.electron);
}

Просмотреть файл

@ -32,17 +32,6 @@ const getDefaultTarget = () => {
return result || 'electron';
};
const buildTargets = () => ({
breakpad: 'third_party/breakpad:dump_syms',
chromedriver: 'electron:electron_chromedriver_zip',
electron: 'electron',
chromium: 'chrome',
'electron:dist': 'electron:electron_dist_zip',
mksnapshot: 'electron:electron_mksnapshot_zip',
'node:headers': 'electron:node_headers',
default: getDefaultTarget(),
});
function buildPath(name, suffix) {
return path.resolve(configRoot(), `evm.${name}.${suffix}`);
}
@ -319,7 +308,7 @@ function remove(name) {
}
module.exports = {
buildTargets,
getDefaultTarget,
current: () => sanitizeConfigWithName(currentName()),
maybeCurrent: () => (getCurrentFileName() ? sanitizeConfigWithName(currentName()) : {}),
currentName,

Просмотреть файл

@ -10,7 +10,6 @@ const Xcode = require('./xcode');
const evmConfig = require('../evm-config');
function loadXcode(options = {}) {
const target = options.target || 'electron';
const quiet = options.quiet || false;
if (process.platform !== 'darwin') {