mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-13 15:16:16 +00:00
BUILD.gn: Remove use of exec_script
Chromium's BUILD files try to avoid uses of exec_script when possible because they slow down every GN invocation. In preparation for building Dawn inside Chromium, the calls to exec_script for the code generator are removed. In GN, the generator now outputs a "JSON tarball", a dictionnary mapping filenames to content. This allows us to use the "depfile" feature of GN to avoid the exec_script call to gather the script's inputs. Outputs of the generator are now listed in the BUILD.gn files. To keep it in sync with the generator, GN outputs a file containing "expected outputs" that is checked by the code generator. Finally the dawn_generator GN template doesn't create a target anymore, but users are expected to gather outputs using get_target_outputs.
This commit is contained in:
committed by
Corentin Wallez
parent
d273d33a63
commit
59e7fad99b
35
generator/extract_json.py
Normal file
35
generator/extract_json.py
Normal file
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env python2
|
||||
# Copyright 2018 The Dawn Authors
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
import os, sys, json
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) != 3:
|
||||
print("Usage: extract_json.py JSON DIR")
|
||||
sys.exit(1)
|
||||
|
||||
with open(sys.argv[1]) as f:
|
||||
files = json.loads(f.read())
|
||||
|
||||
output_dir = sys.argv[2]
|
||||
|
||||
for (name, content) in files.iteritems():
|
||||
output_file = output_dir + os.path.sep + name
|
||||
|
||||
directory = os.path.dirname(output_file)
|
||||
if not os.path.exists(directory):
|
||||
os.makedirs(directory)
|
||||
|
||||
with open(output_file, 'w') as outfile:
|
||||
outfile.write(content)
|
||||
Reference in New Issue
Block a user