Skip to content

Commit 8815bb9

Browse files
committed
Extracted Mako compilation to separate .py files.
This breaks out some of the parts on servo#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.
1 parent 4807dad commit 8815bb9

File tree

4 files changed

+41
-32
lines changed

4 files changed

+41
-32
lines changed

components/style/build.rs

+1-13
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,7 @@ fn main() {
4343
.env("PYTHONPATH", &mako)
4444
.env("TEMPLATE", &template)
4545
.env("PRODUCT", product)
46-
.arg("-c")
47-
.arg(r#"
48-
import os
49-
import sys
50-
from mako.template import Template
51-
from mako import exceptions
52-
try:
53-
template = Template(open(os.environ['TEMPLATE'], 'rb').read(), input_encoding='utf8')
54-
print(template.render(PRODUCT=os.environ['PRODUCT']).encode('utf8'))
55-
except:
56-
sys.stderr.write(exceptions.text_error_template().render().encode('utf8'))
57-
sys.exit(1)
58-
"#)
46+
.arg("generate_properties_rs.py")
5947
.stderr(Stdio::inherit())
6048
.output()
6149
.unwrap();
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# This Source Code Form is subject to the terms of the Mozilla Public
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this
3+
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
4+
5+
import os
6+
import sys
7+
8+
from mako import exceptions
9+
from mako.template import Template
10+
11+
try:
12+
template = Template(open(os.environ['TEMPLATE'], 'rb').read(),
13+
input_encoding='utf8')
14+
print(template.render(PRODUCT=os.environ['PRODUCT']).encode('utf8'))
15+
except:
16+
sys.stderr.write(exceptions.text_error_template().render().encode('utf8'))
17+
sys.exit(1)

ports/geckolib/build.rs

+1-19
Original file line numberDiff line numberDiff line change
@@ -50,25 +50,7 @@ fn main() {
5050
.env("PYTHONPATH", &mako)
5151
.env("STYLE_TEMPLATE", &style_template)
5252
.env("GECKOLIB_TEMPLATE", &geckolib_template)
53-
.arg("-c")
54-
.arg(r#"
55-
import json
56-
import os
57-
import sys
58-
from mako.template import Template
59-
from mako import exceptions
60-
try:
61-
style_template = Template(filename=os.environ['STYLE_TEMPLATE'], input_encoding='utf8')
62-
style_template.render(PRODUCT='gecko')
63-
64-
geckolib_template = Template(filename=os.environ['GECKOLIB_TEMPLATE'], input_encoding='utf8')
65-
output = geckolib_template.render(STYLE_STRUCTS = style_template.module.STYLE_STRUCTS,
66-
to_rust_ident = style_template.module.to_rust_ident)
67-
print(output.encode('utf8'))
68-
except:
69-
sys.stderr.write(exceptions.text_error_template().render().encode('utf8'))
70-
sys.exit(1)
71-
"#)
53+
.arg("ports/geckolib/generate_properties_rs.py")
7254
.stderr(Stdio::inherit())
7355
.output()
7456
.unwrap();
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# This Source Code Form is subject to the terms of the Mozilla Public
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this
3+
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
4+
5+
import os
6+
import sys
7+
8+
from mako import exceptions
9+
from mako.template import Template
10+
11+
try:
12+
style_template = Template(filename=os.environ['STYLE_TEMPLATE'],
13+
input_encoding='utf8')
14+
style_template.render(PRODUCT='gecko')
15+
16+
geckolib_template = Template(filename=os.environ['GECKOLIB_TEMPLATE'], input_encoding='utf8')
17+
output = geckolib_template.render(STYLE_STRUCTS=style_template.module.STYLE_STRUCTS,
18+
to_rust_ident=style_template.module.to_rust_ident)
19+
print(output.encode('utf8'))
20+
except:
21+
sys.stderr.write(exceptions.text_error_template().render().encode('utf8'))
22+
sys.exit(1)

0 commit comments

Comments
 (0)