chromium: refactor out configure library
This commit is contained in:
@@ -3,97 +3,83 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { spawn } from 'child_process';
|
import { spawn } from 'child_process';
|
||||||
import * as crypto from 'crypto';
|
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { promisifySpawn } from '../cli.js';
|
|
||||||
import * as gn from '../commands/gn.js';
|
import * as gn from '../commands/gn.js';
|
||||||
import { systemdRunOptions } from '../commands/systemd.js';
|
import { projectRoot } from '../environment/index.js';
|
||||||
import { lycEnv, projectRoot } from '../environment/index.js';
|
import { chromiumSource } from '../chromium.js';
|
||||||
|
import { undefList } from '../commands/common.js';
|
||||||
|
|
||||||
export const chromiumSource = '/home/lyc/swchromium-102.0.5005.115';
|
export interface GNArgs {
|
||||||
|
clangBasePath: string;
|
||||||
|
symbolLevel?: 0 | 1 | 2;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Arguments to GN build, copied from README.
|
* Generate gn args from chromium's GNOptions.
|
||||||
*
|
* Some default args are copied from README
|
||||||
*/
|
*/
|
||||||
export const gnArgs = (llvmInstall: string) => [
|
function gnArgsToList(o: GNArgs) {
|
||||||
'is_clang=true',
|
return [
|
||||||
'clang_use_chrome_plugins=false',
|
'is_clang=true',
|
||||||
'is_debug=false',
|
'clang_use_chrome_plugins=false',
|
||||||
'use_goma=false',
|
'is_debug=false',
|
||||||
'use_sysroot=false',
|
'use_goma=false',
|
||||||
'use_openh264=false',
|
'use_sysroot=false',
|
||||||
'use_allocator="none"',
|
'use_openh264=false',
|
||||||
'use_libjpeg_turbo=true',
|
'use_allocator="none"',
|
||||||
'use_gnome_keyring=false',
|
'use_libjpeg_turbo=true',
|
||||||
'use_unofficial_version_number=false',
|
'use_gnome_keyring=false',
|
||||||
'enable_nacl=false',
|
'use_unofficial_version_number=false',
|
||||||
'enable_nacl_nonsfi=false',
|
'enable_nacl=false',
|
||||||
'enable_swiftshader=false',
|
'enable_nacl_nonsfi=false',
|
||||||
'enable_reading_list=false',
|
'enable_swiftshader=false',
|
||||||
'enable_iterator_debugging=false',
|
'enable_reading_list=false',
|
||||||
'enable_hangout_services_extension=false',
|
'enable_iterator_debugging=false',
|
||||||
'optimize_webui=false',
|
'enable_hangout_services_extension=false',
|
||||||
'treat_warnings_as_errors=false',
|
'optimize_webui=false',
|
||||||
'linux_use_bundled_binutils=false',
|
'treat_warnings_as_errors=false',
|
||||||
'remove_webcore_debug_symbols=true',
|
'linux_use_bundled_binutils=false',
|
||||||
'use_gio=true',
|
'remove_webcore_debug_symbols=true',
|
||||||
'use_vaapi=false',
|
'use_gio=true',
|
||||||
'use_pulseaudio=true',
|
'use_vaapi=false',
|
||||||
'link_pulseaudio=true',
|
'use_pulseaudio=true',
|
||||||
'enable_widevine=true',
|
'link_pulseaudio=true',
|
||||||
'v8_enable_backtrace=true',
|
'enable_widevine=true',
|
||||||
'use_system_zlib=true',
|
'v8_enable_backtrace=true',
|
||||||
'use_system_lcms2=true',
|
'use_system_zlib=true',
|
||||||
'use_system_libjpeg=true',
|
'use_system_lcms2=true',
|
||||||
'use_system_harfbuzz=false',
|
'use_system_libjpeg=true',
|
||||||
'use_jumbo_build=true',
|
'use_system_harfbuzz=false',
|
||||||
'jumbo_file_merge_limit=8',
|
'use_jumbo_build=true',
|
||||||
'concurrent_links=1',
|
'jumbo_file_merge_limit=8',
|
||||||
'proprietary_codecs=true',
|
'concurrent_links=1',
|
||||||
'ffmpeg_branding="Chrome"',
|
'proprietary_codecs=true',
|
||||||
'fieldtrial_testing_like_official_build=true',
|
'ffmpeg_branding="Chrome"',
|
||||||
'host_cpu="sw_64"',
|
'fieldtrial_testing_like_official_build=true',
|
||||||
'use_lld=false',
|
'host_cpu="sw_64"',
|
||||||
'enable_dav1d_decoder=false',
|
'use_lld=false',
|
||||||
'rtc_include_dav1d_in_internal_decoder_factory=false',
|
'enable_dav1d_decoder=false',
|
||||||
'dcheck_always_on=false',
|
'rtc_include_dav1d_in_internal_decoder_factory=false',
|
||||||
'enable_libaom=false',
|
'dcheck_always_on=false',
|
||||||
`clang_base_path="${llvmInstall}"`
|
'enable_libaom=false',
|
||||||
];
|
`clang_base_path="${o.clangBasePath}"`,
|
||||||
|
...undefList(o.symbolLevel, x => `symbol_level=${x}`),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoke meta-build system "gn", returns the process.
|
* Invoke meta-build system "gn", returns the process.
|
||||||
*/
|
*/
|
||||||
export function configure(source: string, gnExe: string, outDir: string, gnArgs: string[]) {
|
export function configure(source: string, gnExe: string, outDir: string, gnArgs: GNArgs) {
|
||||||
return spawn(gnExe, [
|
return spawn(gnExe, [
|
||||||
'gen',
|
'gen',
|
||||||
outDir,
|
outDir,
|
||||||
...gn.generalOptions({ args: gnArgs }),
|
...gn.generalOptions({ args: gnArgsToList(gnArgs) }),
|
||||||
], { cwd: source });
|
], { cwd: source });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function enableSIMDFromSource() {
|
||||||
|
|
||||||
const gnExe = path.resolve(chromiumSource, 'buildtools', 'linux64', 'gn-linux-sw64');
|
|
||||||
|
|
||||||
async function configureNoSIMD() {
|
|
||||||
const hash = '7081b8371ae6460baabc370de4570ebd7e67f923';
|
|
||||||
|
|
||||||
const outDir = path.resolve(chromiumSource, 'out', 'Release');
|
|
||||||
|
|
||||||
await promisifySpawn(configure(chromiumSource, gnExe, outDir, gnArgs(path.resolve(lycEnv.sharedLLVMInstall, hash))));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
interface ConfigureOptions {
|
|
||||||
buildDir: string;
|
|
||||||
|
|
||||||
gnArgs: string[];
|
|
||||||
}
|
|
||||||
|
|
||||||
async function enableSIMDFromSource() {
|
|
||||||
const assets = path.resolve(projectRoot, 'assets');
|
const assets = path.resolve(projectRoot, 'assets');
|
||||||
|
|
||||||
|
|
||||||
@@ -102,35 +88,3 @@ async function enableSIMDFromSource() {
|
|||||||
|
|
||||||
await fs.promises.copyFile(chromiumSIMDGN, chromiumBuildGN);
|
await fs.promises.copyFile(chromiumSIMDGN, chromiumBuildGN);
|
||||||
}
|
}
|
||||||
|
|
||||||
await invokeNinja();
|
|
||||||
async function invokeNinja() {
|
|
||||||
const hash = 'c9094783eb43868cdbcf26b3266b0231d8fbd6e6';
|
|
||||||
|
|
||||||
const uuid = crypto.randomUUID();
|
|
||||||
|
|
||||||
const buildDir = path.resolve(chromiumSource, 'out', hash, 'Release');
|
|
||||||
|
|
||||||
await enableSIMDFromSource();
|
|
||||||
|
|
||||||
const configureProcess = configure(chromiumSource, gnExe, buildDir, gnArgs(`/tmp/llvm-ly-install/${hash}`));
|
|
||||||
|
|
||||||
configureProcess.stdout.pipe(process.stdout);
|
|
||||||
configureProcess.stderr.pipe(process.stderr);
|
|
||||||
|
|
||||||
await promisifySpawn(configureProcess);
|
|
||||||
|
|
||||||
const systemdUnitName = uuid;
|
|
||||||
|
|
||||||
console.log(`Running chromium build (hash: ${hash}) as ${systemdUnitName}`);
|
|
||||||
|
|
||||||
await promisifySpawn(spawn('systemd-run',
|
|
||||||
[
|
|
||||||
...systemdRunOptions({ user: true, unit: systemdUnitName }),
|
|
||||||
'ninja',
|
|
||||||
'-C',
|
|
||||||
buildDir,
|
|
||||||
'chrome'
|
|
||||||
]
|
|
||||||
))
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user