mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Extracted Mako compilation to separate .py files.
This breaks out some of the parts on #10586, that should be easily mergeable. The idea would be to let you review & merge it first, and then I'll complete the other PR rebase off of this stuff.
This commit is contained in:
parent
4807dadf19
commit
8815bb9594
4 changed files with 41 additions and 32 deletions
|
@ -43,19 +43,7 @@ fn main() {
|
||||||
.env("PYTHONPATH", &mako)
|
.env("PYTHONPATH", &mako)
|
||||||
.env("TEMPLATE", &template)
|
.env("TEMPLATE", &template)
|
||||||
.env("PRODUCT", product)
|
.env("PRODUCT", product)
|
||||||
.arg("-c")
|
.arg("generate_properties_rs.py")
|
||||||
.arg(r#"
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
from mako.template import Template
|
|
||||||
from mako import exceptions
|
|
||||||
try:
|
|
||||||
template = Template(open(os.environ['TEMPLATE'], 'rb').read(), input_encoding='utf8')
|
|
||||||
print(template.render(PRODUCT=os.environ['PRODUCT']).encode('utf8'))
|
|
||||||
except:
|
|
||||||
sys.stderr.write(exceptions.text_error_template().render().encode('utf8'))
|
|
||||||
sys.exit(1)
|
|
||||||
"#)
|
|
||||||
.stderr(Stdio::inherit())
|
.stderr(Stdio::inherit())
|
||||||
.output()
|
.output()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
17
components/style/generate_properties_rs.py
Normal file
17
components/style/generate_properties_rs.py
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from mako import exceptions
|
||||||
|
from mako.template import Template
|
||||||
|
|
||||||
|
try:
|
||||||
|
template = Template(open(os.environ['TEMPLATE'], 'rb').read(),
|
||||||
|
input_encoding='utf8')
|
||||||
|
print(template.render(PRODUCT=os.environ['PRODUCT']).encode('utf8'))
|
||||||
|
except:
|
||||||
|
sys.stderr.write(exceptions.text_error_template().render().encode('utf8'))
|
||||||
|
sys.exit(1)
|
|
@ -50,25 +50,7 @@ fn main() {
|
||||||
.env("PYTHONPATH", &mako)
|
.env("PYTHONPATH", &mako)
|
||||||
.env("STYLE_TEMPLATE", &style_template)
|
.env("STYLE_TEMPLATE", &style_template)
|
||||||
.env("GECKOLIB_TEMPLATE", &geckolib_template)
|
.env("GECKOLIB_TEMPLATE", &geckolib_template)
|
||||||
.arg("-c")
|
.arg("ports/geckolib/generate_properties_rs.py")
|
||||||
.arg(r#"
|
|
||||||
import json
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
from mako.template import Template
|
|
||||||
from mako import exceptions
|
|
||||||
try:
|
|
||||||
style_template = Template(filename=os.environ['STYLE_TEMPLATE'], input_encoding='utf8')
|
|
||||||
style_template.render(PRODUCT='gecko')
|
|
||||||
|
|
||||||
geckolib_template = Template(filename=os.environ['GECKOLIB_TEMPLATE'], input_encoding='utf8')
|
|
||||||
output = geckolib_template.render(STYLE_STRUCTS = style_template.module.STYLE_STRUCTS,
|
|
||||||
to_rust_ident = style_template.module.to_rust_ident)
|
|
||||||
print(output.encode('utf8'))
|
|
||||||
except:
|
|
||||||
sys.stderr.write(exceptions.text_error_template().render().encode('utf8'))
|
|
||||||
sys.exit(1)
|
|
||||||
"#)
|
|
||||||
.stderr(Stdio::inherit())
|
.stderr(Stdio::inherit())
|
||||||
.output()
|
.output()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
22
ports/geckolib/generate_properties_rs.py
Normal file
22
ports/geckolib/generate_properties_rs.py
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from mako import exceptions
|
||||||
|
from mako.template import Template
|
||||||
|
|
||||||
|
try:
|
||||||
|
style_template = Template(filename=os.environ['STYLE_TEMPLATE'],
|
||||||
|
input_encoding='utf8')
|
||||||
|
style_template.render(PRODUCT='gecko')
|
||||||
|
|
||||||
|
geckolib_template = Template(filename=os.environ['GECKOLIB_TEMPLATE'], input_encoding='utf8')
|
||||||
|
output = geckolib_template.render(STYLE_STRUCTS=style_template.module.STYLE_STRUCTS,
|
||||||
|
to_rust_ident=style_template.module.to_rust_ident)
|
||||||
|
print(output.encode('utf8'))
|
||||||
|
except:
|
||||||
|
sys.stderr.write(exceptions.text_error_template().render().encode('utf8'))
|
||||||
|
sys.exit(1)
|
Loading…
Add table
Add a link
Reference in a new issue