Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(458)

Unified Diff: mojo/tools/mopy/paths.py

Issue 1144673003: Fix and cleanup Mojo and Mandoline python scripts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update comments. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/tools/mopy/gtest.py ('k') | mojo/tools/mopy/test_util.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/tools/mopy/paths.py
diff --git a/mojo/tools/mopy/paths.py b/mojo/tools/mopy/paths.py
index 751629a3c85a8f52c64eea23cdd3a294ea272588..22b418096878dbff29db4e030b3db6f7c4aa2be9 100644
--- a/mojo/tools/mopy/paths.py
+++ b/mojo/tools/mopy/paths.py
@@ -5,43 +5,40 @@
import os
from .config import Config
-from .gn import BuildDirectoryForConfig
+
class Paths(object):
"""Provides commonly used paths"""
- def __init__(self, config=None, build_dir=None):
- """Specify either a config or a build_dir to generate paths to binary
- artifacts."""
+ def __init__(self, config):
+ """Generate paths to binary artifacts from a Config object."""
self.src_root = os.path.abspath(os.path.join(__file__,
os.pardir, os.pardir, os.pardir, os.pardir))
self.mojo_dir = os.path.join(self.src_root, "mojo")
self.adb_path = os.path.join(self.src_root, 'third_party', 'android_tools',
'sdk', 'platform-tools', 'adb')
- if config:
- self.build_dir = BuildDirectoryForConfig(config, self.src_root)
- elif build_dir is not None:
- self.build_dir = os.path.abspath(build_dir)
- else:
- self.build_dir = None
-
- if self.build_dir is not None:
- self.mojo_shell_path = os.path.join(self.build_dir, "mojo_runner")
- # TODO(vtl): Use the host OS here, since |config| may not be available.
- # In any case, if the target is Windows, but the host isn't, using
- # |os.path| isn't correct....
- if Config.GetHostOS() == Config.OS_WINDOWS:
- self.mojo_shell_path += ".exe"
- if config and config.target_os == Config.OS_ANDROID:
- self.target_mojo_shell_path = os.path.join(self.build_dir,
- "apks",
- config.apk_name)
- else:
- self.target_mojo_shell_path = self.mojo_shell_path
- else:
- self.mojo_shell_path = None
- self.target_mojo_shell_path = None
+ self.build_dir = config.build_dir
+ if self.build_dir is None:
+ subdir = ""
+ if config.target_os == Config.OS_ANDROID:
+ subdir += "android_"
+ if config.target_cpu != Config.ARCH_ARM:
+ subdir += config.target_cpu + "_"
+ elif config.target_os == Config.OS_CHROMEOS:
+ subdir += "chromeos_"
+ subdir += "Debug" if config.is_debug else "Release"
+ if config.is_asan:
+ subdir += "_asan"
+ if not(config.is_debug) and config.dcheck_always_on:
+ subdir += "_dcheck"
+ self.build_dir = os.path.join(self.src_root, "out", subdir)
+
+ self.mojo_runner = os.path.join(self.build_dir, "mojo_runner")
+ if config.target_os == Config.OS_WINDOWS:
+ self.mojo_runner += ".exe"
+ if config.target_os == Config.OS_ANDROID:
+ self.mojo_runner = os.path.join(self.build_dir, "apks", config.apk_name)
def RelPath(self, path):
"""Returns the given path, relative to the current directory."""
@@ -50,20 +47,3 @@ class Paths(object):
def SrcRelPath(self, path):
"""Returns the given path, relative to self.src_root."""
return os.path.relpath(path, self.src_root)
-
- def FileFromUrl(self, url):
- """Given an app URL (<scheme>:<appname>), return 'build_dir/appname.mojo'.
- If self.build_dir is None, just return appname.mojo
- """
- (_, name) = url.split(':')
- if self.build_dir:
- return os.path.join(self.build_dir, name + '.mojo')
- return name + '.mojo'
-
- @staticmethod
- def IsValidAppUrl(url):
- """Returns False if url is malformed, True otherwise."""
- try:
- return len(url.split(':')) == 2
- except ValueError:
- return False
« no previous file with comments | « mojo/tools/mopy/gtest.py ('k') | mojo/tools/mopy/test_util.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698