mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-30 04:17:31 +09:00
Fix generation of developer tools' static CSS properties database
- Remove `resolve_path` method and use `mozpath` instead for path operations - Store target developer tools path as an instance variable to avoid duplicate checks for path existence
This commit is contained in:
parent
317b7dec08
commit
30e2ac2c21
1 changed files with 22 additions and 13 deletions
|
|
@ -13,19 +13,19 @@ import os
|
||||||
import sys
|
import sys
|
||||||
import string
|
import string
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
import mozpack.path as mozpath
|
||||||
|
|
||||||
from mozbuild.base import (
|
from mozbuild.base import (
|
||||||
MozbuildObject,
|
MozbuildObject,
|
||||||
MachCommandBase,
|
MachCommandBase,
|
||||||
)
|
)
|
||||||
|
|
||||||
from mach.decorators import (
|
from mach.decorators import (
|
||||||
CommandProvider,
|
CommandProvider,
|
||||||
Command,
|
Command,
|
||||||
)
|
)
|
||||||
|
|
||||||
def resolve_path(start, relativePath):
|
|
||||||
"""Helper to resolve a path from a start, and a relative path"""
|
|
||||||
return os.path.normpath(os.path.join(start, relativePath))
|
|
||||||
|
|
||||||
def stringify(obj):
|
def stringify(obj):
|
||||||
"""Helper to stringify to JSON"""
|
"""Helper to stringify to JSON"""
|
||||||
return json.dumps(obj, sort_keys=True, indent=2, separators=(',', ': '))
|
return json.dumps(obj, sort_keys=True, indent=2, separators=(',', ': '))
|
||||||
|
|
@ -38,6 +38,15 @@ class MachCommands(MachCommandBase):
|
||||||
def generate_css_db(self):
|
def generate_css_db(self):
|
||||||
"""Generate the static css properties database for devtools and write it to file."""
|
"""Generate the static css properties database for devtools and write it to file."""
|
||||||
|
|
||||||
|
generated_dir = mozpath.join(self.topsrcdir,
|
||||||
|
'devtools/shared/css/generated')
|
||||||
|
if not os.path.exists(generated_dir):
|
||||||
|
generated_dir = mozpath.join(self.topsrcdir, 'platform',
|
||||||
|
'devtools/shared/css/generated')
|
||||||
|
else:
|
||||||
|
raise Exception('Directory expected at %s does not exist.' % generated_dir)
|
||||||
|
self.generated_dir = generated_dir
|
||||||
|
|
||||||
print("Re-generating the css properties database...")
|
print("Re-generating the css properties database...")
|
||||||
db = self.get_properties_db_from_xpcshell()
|
db = self.get_properties_db_from_xpcshell()
|
||||||
|
|
||||||
|
|
@ -47,13 +56,13 @@ class MachCommands(MachCommandBase):
|
||||||
|
|
||||||
def get_properties_db_from_xpcshell(self):
|
def get_properties_db_from_xpcshell(self):
|
||||||
"""Generate the static css properties db for devtools from an xpcshell script."""
|
"""Generate the static css properties db for devtools from an xpcshell script."""
|
||||||
build = MozbuildObject.from_environment()
|
build = MozbuildObject.from_environment(cwd=self.topobjdir)
|
||||||
|
|
||||||
# Get the paths
|
# Get the paths
|
||||||
script_path = resolve_path(self.topsrcdir,
|
script_path = mozpath.join(self.generated_dir,
|
||||||
'devtools/shared/css/generated/generate-properties-db.js')
|
'generate-properties-db.js')
|
||||||
gre_path = resolve_path(self.topobjdir, 'dist/bin')
|
gre_path = mozpath.join(self.topobjdir, 'dist/bin')
|
||||||
browser_path = resolve_path(self.topobjdir, 'dist/bin/browser')
|
browser_path = mozpath.join(self.topobjdir, 'dist/bin/browser')
|
||||||
xpcshell_path = build.get_binary_path(what='xpcshell')
|
xpcshell_path = build.get_binary_path(what='xpcshell')
|
||||||
print(browser_path)
|
print(browser_path)
|
||||||
|
|
||||||
|
|
@ -74,10 +83,10 @@ class MachCommands(MachCommandBase):
|
||||||
|
|
||||||
def output_template(self, substitutions):
|
def output_template(self, substitutions):
|
||||||
"""Output a the properties-db.js from a template."""
|
"""Output a the properties-db.js from a template."""
|
||||||
js_template_path = resolve_path(self.topsrcdir,
|
js_template_path = mozpath.join(self.generated_dir,
|
||||||
'devtools/shared/css/generated/properties-db.js.in')
|
'properties-db.js.in')
|
||||||
destination_path = resolve_path(self.topsrcdir,
|
destination_path = mozpath.join(self.generated_dir,
|
||||||
'devtools/shared/css/generated/properties-db.js')
|
'properties-db.js')
|
||||||
|
|
||||||
with open(js_template_path, 'rb') as handle:
|
with open(js_template_path, 'rb') as handle:
|
||||||
js_template = handle.read()
|
js_template = handle.read()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue