chore(build): support generating compilation db (#12104)
This commit is contained in:
parent
6bfb122cd1
commit
dabd61bf80
4 changed files with 31 additions and 2 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -44,7 +44,9 @@ node_modules/
|
|||
SHASUMS256.txt
|
||||
**/package-lock.json
|
||||
**/yarn.lock
|
||||
compile_commands.json
|
||||
.envrc
|
||||
|
||||
# npm package
|
||||
/npm/dist
|
||||
/npm/path.txt
|
||||
/npm/path.txt
|
||||
|
|
|
@ -63,6 +63,13 @@ $ cd electron
|
|||
$ ./script/bootstrap.py --verbose
|
||||
```
|
||||
|
||||
If you are using editor supports [JSON compilation database](http://clang.llvm.org/docs/JSONCompilationDatabase.html) based
|
||||
language server, you can generate it:
|
||||
|
||||
```sh
|
||||
$ ./script/build.py --compdb
|
||||
```
|
||||
|
||||
### Cross compilation
|
||||
|
||||
If you want to build for an `arm` target you should also install the following
|
||||
|
|
|
@ -56,6 +56,13 @@ $ cd electron
|
|||
$ ./script/bootstrap.py -v
|
||||
```
|
||||
|
||||
If you are using editor supports [JSON compilation database](http://clang.llvm.org/docs/JSONCompilationDatabase.html) based
|
||||
language server, you can generate it:
|
||||
|
||||
```sh
|
||||
$ ./script/build.py --compdb
|
||||
```
|
||||
|
||||
## Building
|
||||
|
||||
Build both `Release` and `Debug` targets:
|
||||
|
|
|
@ -56,7 +56,14 @@ def main():
|
|||
env = build_env()
|
||||
for config in args.configuration:
|
||||
build_path = os.path.join('out', config[0])
|
||||
ret = subprocess.call(ninja + ['-C', build_path, args.target], env=env)
|
||||
build_args = ['-C', build_path, args.target]
|
||||
if args.compdb:
|
||||
build_args += ['-t', 'compdb', 'cxx', 'cc']
|
||||
compdb = open(r'compile_commands.json','w')
|
||||
ret = subprocess.call(ninja + build_args, env=env, stdout=compdb)
|
||||
compdb.close()
|
||||
else:
|
||||
ret = subprocess.call(ninja + build_args, env=env)
|
||||
if ret != 0:
|
||||
sys.exit(ret)
|
||||
|
||||
|
@ -86,6 +93,12 @@ def parse_args():
|
|||
parser.add_argument('--ninja-path',
|
||||
help='Path of ninja command to use.',
|
||||
required=False)
|
||||
parser.add_argument('--compdb',
|
||||
help=(
|
||||
'Generate JSON compilation database. This will not '
|
||||
'trigger actual build. '
|
||||
),
|
||||
action='store_true', default=False)
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue