Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

Commit

Permalink
Replace create_standalone_js.py with a custom GWT linker
Browse files Browse the repository at this point in the history
Instead of processing the GWT output to strip out boilerplate, fork
SingleSourceScriptLinker from GWT to produce output that is ready to use.

BUG=437113
R=cjhopman@chromium.org

Review URL: https://codereview.chromium.org/1058973003

Patch from mrobinson <mrobinson@igalia.com>.
  • Loading branch information
mrobinson authored and wychen committed Apr 27, 2015
1 parent 10bc28c commit b27ab2b
Show file tree
Hide file tree
Showing 8 changed files with 211 additions and 131 deletions.
3 changes: 3 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ Copyright 2007 Timepedia.org
third_party/gwt-2.5.1
Copyright 2008 Google

java/org/chromium/distiller/dev
Copyright 2008 Google

Apache License

Version 2.0, January 2004
Expand Down
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,9 @@ is:
- `ant test -Dtest.filter=$FILTER_PATTERN` where `$FILTER_PATTERN` is a regexp
pattern. For example `^FilterTest.*` would run all tests with a name starting
with `FilterTest`.
- `ant gwtc` compiles .class+.java files to JavaScript
- `ant extractjs` creates standalone JavaScript from output of ant gwtc, the
compiled JavaScript file is available at `out/domdistiller.js`.
- `ant extractjs.jstests` creates a standalone JavaScript for the tests.
- `ant gwtc` compiles .class+.java files to JavaScript. Standalone JavaScript
is available at `war/domdistiller/domdistiller.nocache.js`.
- `ant gwtc.jstests` creates a standalone JavaScript for the tests.
- `ant package` Copies the main build artifacts into the `out/package` folder,
typically the extracted JS and protocol buffer files.

Expand Down Expand Up @@ -289,7 +288,7 @@ distill http://example.com/article.html
## Interactive debugging

You can use the Chrome Developer Tools to debug DOM Distiller:
- Update the test JavaScript by running `ant extractjs.jstests` or `ant test`.
- Update the test JavaScript by running `ant gwtc.jstests` or `ant test`.
- Open `war/test.html` in Chrome desktop
- Open the `Console` panel in Developer Tools (**Ctrl-Shift-J**).
On Mac OS X you can use **&#x2325;-&#x2318;-I** (uppercase `I`) as the shortcut.
Expand Down
31 changes: 7 additions & 24 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -138,36 +138,27 @@
</java>
</target>

<target name="extractjs" depends="gwtc" description="Extract standalone JavaScript from compiled JavaScript">
<exec executable="python" failonerror="true">
<arg value="create_standalone_js.py"/>
<arg line="--module domdistiller"/>
<arg value="--auto"/>
</exec>
</target>

<target name="extractwrappedjs" depends="extractjs"
<target name="extractwrappedjs" depends="gwtc"
description="Create wrapped standalone JavaScript from compiled JavaScript for direct inclusion in Chrome">
<exec executable="python" failonerror="true">
<arg value="create_wrapped_standalone_js.py"/>
<arg value="--templatefile=war/wrapped_domdistiller_template.js"/>
<arg value="--infile=out/domdistiller.js"/>
<arg value="--infile=war/domdistiller/domdistiller.nocache.js"/>
<arg value="--outfile=out/domdistiller_wrapped.js"/>
</exec>
</target>

<target name="package" depends="extractjs, extractwrappedjs, extractjs.jstests, protoc.json"
<target name="package" depends="gwtc, extractwrappedjs, gwtc.jstests, protoc.json"
description="Copy the main build artifacts into the out/package directory" >
<mkdir dir="out/extension"/>
<mkdir dir="out/package"/>
<mkdir dir="out/package/js"/>
<mkdir dir="out/package/proto"/>
<mkdir dir="out/package/test"/>
<mkdir dir="out/package/test/data"/>
<mkdir dir="out/package/test/data/out"/>
<mkdir dir="out/package/test/data/war"/>

<copy file="out/domdistiller.js" todir="out/package/js" />
<copy file="war/domdistiller/domdistiller.nocache.js" tofile="out/package/js/domdistiller.js" />
<copy file="out/domdistiller_wrapped.js" todir="out/package/js" />
<copy todir="out/package/proto_gen">
<fileset dir="out/proto/json"/>
Expand All @@ -176,12 +167,12 @@
<fileset dir="proto"/>
</copy>

<copy file="out/domdistiller.js" todir="out/extension" />
<copy file="war/domdistiller/domdistiller.nocache.js" tofile="out/extension/domdistiller.js" />
<copy todir="out/extension">
<fileset dir="extension"/>
</copy>

<copy file="out/domdistillerjstest.js" todir="out/package/test/data/out" />
<copy file="war/domdistillerjstest/domdistillerjstest.nocache.js" todir="out/package/test/data/war/domdistillerjstest" />
<copy file="war/test.html" todir="out/package/test/data/war" />
</target>

Expand Down Expand Up @@ -229,14 +220,6 @@
</java>
</target>

<target name="extractjs.jstests" depends="gwtc.jstests" description="Extract standalone JavaScript from compiled JavaScript">
<exec executable="python" failonerror="true">
<arg value="create_standalone_js.py"/>
<arg line="--module domdistillerjstest"/>
<arg value="--auto"/>
<arg value="--sourcemaps"/>
</exec>
</target>

<!-- Run jstests for the Linux platform -->
<target name="-jstests.linux" if="isLinux">
Expand All @@ -261,7 +244,7 @@
<target name="-jstests" depends="-jstests.linux, -jstests.mac" />

<target name="test"
depends="extractjs.jstests, -jstests"
depends="gwtc.jstests, -jstests"
description="Run tests">
</target>

Expand Down
95 changes: 0 additions & 95 deletions create_standalone_js.py

This file was deleted.

8 changes: 5 additions & 3 deletions java/DomDistiller.gwt.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
<entry-point class='org.chromium.distiller.DomDistillerEntry'/>

<!-- Specify the paths for translatable code -->
<source path='org/chromium/distiller'/>
<source path='org/chromium/distiller'>
<exclude name="dev/*" />
</source>

<!-- Use the SingleScriptLinker. -->
<add-linker name='sso'/>
<define-linker name="distillerlinker" class="org.chromium.distiller.dev.DistillerScriptLinker" />
<add-linker name='distillerlinker'/>
</module>
Loading

0 comments on commit b27ab2b

Please sign in to comment.