Support dev servers defined in a mojoconfig file.
This patch allows one to define local servers to be set up by devtools
(`mojo_run` / `mojo_test`) in a config file. Each server is described as a
dictionary defining the host and the mappings:
{
'host': 'https://core.mojoapps.io/',
'mappings': [
('packages/', ['@{BUILD_DIR}/gen/dart-pkg/packages']),
('', ['@{BUILD_DIR}']),
],
},
This allows us to support running 'exploded' dart apps, see
https://github.com/domokit/devtools/issues/30 .
This patch also adds an example config file for the setup we will want to use
in the Mojo repo. As of this CL one has to explicitly pass --config-file
mojoconfig to make use of the config file. We will probably want to make
devtools discover this file automatically.
R=qsr@chromium.org
Review URL: https://codereview.chromium.org/1259793008 .
diff --git a/mojoconfig b/mojoconfig
new file mode 100644
index 0000000..6290531
--- /dev/null
+++ b/mojoconfig
@@ -0,0 +1,23 @@
+# This is a configuration file for devtools (`mojo_run`, `mojo_test) running
+# within a Mojo checkout.
+
+# The content has to parse to a Python dictionary literal. Strings of the form
+# '@{ABC}' are aliases that will be substituted for their values before
+# evaluation:
+# '@{BUILD_DIR}': path to the output directory
+
+{
+ # Each dev server will be configured as specified and mapped for the
+ # indicated host using --map-origin.
+ 'dev_servers': [
+ {
+ 'host': 'https://core.mojoapps.io/',
+ # First matching prefix will apply. Within the directiories specified for
+ # a prefix, first location that contains the requested path will apply.
+ 'mappings': [
+ ('packages/', ['@{BUILD_DIR}/gen/dart-pkg/packages']),
+ ('', ['@{BUILD_DIR}']),
+ ],
+ },
+ ],
+}