1
+ "use strict" ;
1
2
/*---------------------------------------------------------------------------------------------
2
3
* Copyright (c) Microsoft Corporation. All rights reserved.
3
4
* Licensed under the MIT License. See License.txt in the project root for license information.
4
5
*--------------------------------------------------------------------------------------------*/
5
- 'use strict' ;
6
6
Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
7
- exports . getDependencies = void 0 ;
7
+ exports . generatePackageDeps = void 0 ;
8
8
const child_process_1 = require ( "child_process" ) ;
9
9
const fs_1 = require ( "fs" ) ;
10
10
const os_1 = require ( "os" ) ;
11
11
const path = require ( "path" ) ;
12
- const dep_lists_1 = require ( "./dep-lists" ) ;
13
12
const manifests = require ( "../../../cgmanifest.json" ) ;
14
- // A flag that can easily be toggled.
15
- // Make sure to compile the build directory after toggling the value.
16
- // If false, we warn about new dependencies if they show up
17
- // while running the Debian prepare package task for a release.
18
- // If true, we fail the build if there are new dependencies found during that task.
19
- // The reference dependencies, which one has to update when the new dependencies
20
- // are valid, are in dep-lists.ts
21
- const FAIL_BUILD_FOR_NEW_DEPENDENCIES = true ;
22
- function getDependencies ( buildDir , applicationName , arch , sysroot ) {
23
- // Get the files for which we want to find dependencies.
24
- const nativeModulesPath = path . join ( buildDir , 'resources' , 'app' , 'node_modules.asar.unpacked' ) ;
25
- const findResult = ( 0 , child_process_1 . spawnSync ) ( 'find' , [ nativeModulesPath , '-name' , '*.node' ] ) ;
26
- if ( findResult . status ) {
27
- console . error ( 'Error finding files:' ) ;
28
- console . error ( findResult . stderr . toString ( ) ) ;
29
- return [ ] ;
30
- }
31
- const files = findResult . stdout . toString ( ) . trimEnd ( ) . split ( '\n' ) ;
32
- const appPath = path . join ( buildDir , applicationName ) ;
33
- files . push ( appPath ) ;
34
- // Add chrome sandbox and crashpad handler.
35
- files . push ( path . join ( buildDir , 'chrome-sandbox' ) ) ;
36
- files . push ( path . join ( buildDir , 'chrome_crashpad_handler' ) ) ;
37
- // Generate the dependencies.
38
- const dependencies = files . map ( ( file ) => calculatePackageDeps ( file , arch , sysroot ) ) ;
39
- // Add additional dependencies.
13
+ const dep_lists_1 = require ( "./dep-lists" ) ;
14
+ function generatePackageDeps ( files , arch , sysroot ) {
15
+ const dependencies = files . map ( file => calculatePackageDeps ( file , arch , sysroot ) ) ;
40
16
const additionalDepsSet = new Set ( dep_lists_1 . additionalDeps ) ;
41
17
dependencies . push ( additionalDepsSet ) ;
42
- // Merge all the dependencies.
43
- const mergedDependencies = mergePackageDeps ( dependencies ) ;
44
- let sortedDependencies = [ ] ;
45
- for ( const dependency of mergedDependencies ) {
46
- sortedDependencies . push ( dependency ) ;
47
- }
48
- sortedDependencies . sort ( ) ;
49
- // Exclude bundled dependencies
50
- sortedDependencies = sortedDependencies . filter ( dependency => {
51
- return ! dep_lists_1 . bundledDeps . some ( bundledDep => dependency . startsWith ( bundledDep ) ) ;
52
- } ) ;
53
- const referenceGeneratedDeps = dep_lists_1 . referenceGeneratedDepsByArch [ arch ] ;
54
- if ( JSON . stringify ( sortedDependencies ) !== JSON . stringify ( referenceGeneratedDeps ) ) {
55
- const failMessage = 'The dependencies list has changed.'
56
- + '\nOld:\n' + referenceGeneratedDeps . join ( '\n' )
57
- + '\nNew:\n' + sortedDependencies . join ( '\n' ) ;
58
- if ( FAIL_BUILD_FOR_NEW_DEPENDENCIES ) {
59
- throw new Error ( failMessage ) ;
60
- }
61
- else {
62
- console . warn ( failMessage ) ;
63
- }
64
- }
65
- return sortedDependencies ;
18
+ return dependencies ;
66
19
}
67
- exports . getDependencies = getDependencies ;
20
+ exports . generatePackageDeps = generatePackageDeps ;
68
21
// Based on https://source.chromium.org/chromium/chromium/src/+/main:chrome/installer/linux/debian/calculate_package_deps.py.
69
22
function calculatePackageDeps ( binaryPath , arch , sysroot ) {
70
23
try {
@@ -97,8 +50,6 @@ function calculatePackageDeps(binaryPath, arch, sysroot) {
97
50
case 'arm64' :
98
51
cmd . push ( `-l${ sysroot } /usr/lib/aarch64-linux-gnu` , `-l${ sysroot } /lib/aarch64-linux-gnu` ) ;
99
52
break ;
100
- default :
101
- throw new Error ( 'Unsupported architecture ' + arch ) ;
102
53
}
103
54
cmd . push ( `-l${ sysroot } /usr/lib` ) ;
104
55
cmd . push ( '-O' , '-e' , path . resolve ( binaryPath ) ) ;
@@ -117,17 +68,3 @@ function calculatePackageDeps(binaryPath, arch, sysroot) {
117
68
const requires = new Set ( depsStr . split ( ', ' ) . sort ( ) ) ;
118
69
return requires ;
119
70
}
120
- // Based on https://source.chromium.org/chromium/chromium/src/+/main:chrome/installer/linux/rpm/merge_package_deps.py.
121
- function mergePackageDeps ( inputDeps ) {
122
- // For now, see if directly appending the dependencies helps.
123
- const requires = new Set ( ) ;
124
- for ( const depSet of inputDeps ) {
125
- for ( const dep of depSet ) {
126
- const trimmedDependency = dep . trim ( ) ;
127
- if ( trimmedDependency . length && ! trimmedDependency . startsWith ( '#' ) ) {
128
- requires . add ( trimmedDependency ) ;
129
- }
130
- }
131
- }
132
- return requires ;
133
- }
0 commit comments