diff options
author | FranklinDM <mrmineshafter17@gmail.com> | 2022-04-01 22:31:30 +0800 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2022-05-03 09:14:57 +0000 |
commit | 40c079132027e363ea0e330e540dffdab89c1dd7 (patch) | |
tree | 9cb0dc552f92c777e8e28ee4f791a6ebfb2dea7f /devtools | |
parent | ab0be54f2dedc7c6d1aa047cb746ba9da183a4e3 (diff) | |
download | uxp-40c079132027e363ea0e330e540dffdab89c1dd7.tar.gz |
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
Diffstat (limited to 'devtools')
-rw-r--r-- | devtools/shared/css/generated/mach_commands.py | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/devtools/shared/css/generated/mach_commands.py b/devtools/shared/css/generated/mach_commands.py index 4d6016276a..56f321a6f2 100644 --- a/devtools/shared/css/generated/mach_commands.py +++ b/devtools/shared/css/generated/mach_commands.py @@ -13,19 +13,19 @@ import os import sys import string import subprocess + +import mozpack.path as mozpath + from mozbuild.base import ( MozbuildObject, MachCommandBase, ) + from mach.decorators import ( CommandProvider, 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): """Helper to stringify to JSON""" return json.dumps(obj, sort_keys=True, indent=2, separators=(',', ': ')) @@ -38,6 +38,15 @@ class MachCommands(MachCommandBase): def generate_css_db(self): """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...") db = self.get_properties_db_from_xpcshell() @@ -47,13 +56,13 @@ class MachCommands(MachCommandBase): def get_properties_db_from_xpcshell(self): """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 - script_path = resolve_path(self.topsrcdir, - 'devtools/shared/css/generated/generate-properties-db.js') - gre_path = resolve_path(self.topobjdir, 'dist/bin') - browser_path = resolve_path(self.topobjdir, 'dist/bin/browser') + script_path = mozpath.join(self.generated_dir, + 'generate-properties-db.js') + gre_path = mozpath.join(self.topobjdir, 'dist/bin') + browser_path = mozpath.join(self.topobjdir, 'dist/bin/browser') xpcshell_path = build.get_binary_path(what='xpcshell') print(browser_path) @@ -74,10 +83,10 @@ class MachCommands(MachCommandBase): def output_template(self, substitutions): """Output a the properties-db.js from a template.""" - js_template_path = resolve_path(self.topsrcdir, - 'devtools/shared/css/generated/properties-db.js.in') - destination_path = resolve_path(self.topsrcdir, - 'devtools/shared/css/generated/properties-db.js') + js_template_path = mozpath.join(self.generated_dir, + 'properties-db.js.in') + destination_path = mozpath.join(self.generated_dir, + 'properties-db.js') with open(js_template_path, 'rb') as handle: js_template = handle.read() |