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
|
SHASUMS256.txt
|
||||||
**/package-lock.json
|
**/package-lock.json
|
||||||
**/yarn.lock
|
**/yarn.lock
|
||||||
|
compile_commands.json
|
||||||
|
.envrc
|
||||||
|
|
||||||
# npm package
|
# npm package
|
||||||
/npm/dist
|
/npm/dist
|
||||||
/npm/path.txt
|
/npm/path.txt
|
||||||
|
|
|
@ -63,6 +63,13 @@ $ cd electron
|
||||||
$ ./script/bootstrap.py --verbose
|
$ ./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
|
### Cross compilation
|
||||||
|
|
||||||
If you want to build for an `arm` target you should also install the following
|
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
|
$ ./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
|
## Building
|
||||||
|
|
||||||
Build both `Release` and `Debug` targets:
|
Build both `Release` and `Debug` targets:
|
||||||
|
|
|
@ -56,7 +56,14 @@ def main():
|
||||||
env = build_env()
|
env = build_env()
|
||||||
for config in args.configuration:
|
for config in args.configuration:
|
||||||
build_path = os.path.join('out', config[0])
|
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:
|
if ret != 0:
|
||||||
sys.exit(ret)
|
sys.exit(ret)
|
||||||
|
|
||||||
|
@ -86,6 +93,12 @@ def parse_args():
|
||||||
parser.add_argument('--ninja-path',
|
parser.add_argument('--ninja-path',
|
||||||
help='Path of ninja command to use.',
|
help='Path of ninja command to use.',
|
||||||
required=False)
|
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()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue