Skip to content

Commit 3f0e8e3

Browse files
committed
Add Travis CI support
Signed-off-by: Ce Gao <ce.gao@outlook.com>
1 parent 7ba3317 commit 3f0e8e3

File tree

6 files changed

+218
-8
lines changed

6 files changed

+218
-8
lines changed

.ci/init.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env bash
2+
3+
# init.sh establishes a initial environment to build Processing.R in travis.
4+
# Most of the code is copied from `scripts/generate-ant-file.sh`
5+
6+
# Timestamped log, e.g. log "cluster created".
7+
#
8+
# Input:
9+
# $1 Log string.
10+
function log {
11+
echo -e "[`TZ=Asia/Shanghai date`] ${1}"
12+
}
13+
14+
root=$(dirname "${BASH_SOURCE}")/..
15+
16+
# Paths
17+
# Those paths are not needed when building runner.jar,
18+
# but will be used in the future to package the mode.
19+
modes="/mock-user/modes"
20+
executable="/mock-user/Processing"
21+
# Those paths are important to build runner.jar.
22+
processing="$HOME/processing"
23+
core="$HOME/processing/core/library/"
24+
pde="$HOME/processing/app/"
25+
renjin="lib/renjin-script-engine-0.8.2194-jar-with-dependencies.jar"
26+
27+
# Build core.jar.
28+
cd ${core}/..
29+
ant build
30+
cd - > /dev/null
31+
32+
# Build pde.jar.
33+
cd ${pde}
34+
ant build
35+
cd - > /dev/null
36+
37+
cd ${root}
38+
cp build.xml.template build.xml
39+
# Interpret config template.
40+
log "Inject the config to build.xml.template"
41+
perl -i -pe "s|\@\@modes\@\@|${modes}|g" build.xml
42+
perl -i -pe "s|\@\@executable\@\@|${executable}|g" build.xml
43+
perl -i -pe "s|\@\@processing\@\@|${processing}|g" build.xml
44+
perl -i -pe "s|\@\@core\@\@|${core}|g" build.xml
45+
perl -i -pe "s|\@\@pde\@\@|${pde}|g" build.xml
46+
perl -i -pe "s|\@\@renjin\@\@|${renjin}|g" build.xml
47+
cd - > /dev/null

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ dist/
1818
build/
1919
try/
2020
*.log
21+
build.xml
2122

2223
# Demo
2324
*.mov

.travis.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
language: java
2+
sudo: false
3+
4+
jdk:
5+
- oraclejdk8
6+
7+
before_install:
8+
- git clone --depth 1 https://github.com/processing/processing $HOME/processing
9+
- .ci/init.sh
10+
11+
install:
12+
- ant info
13+
- ant try
14+
15+
script:
16+
- echo "No test now."

build.xml.template

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
<?xml version="1.0"?>
2+
<project name="processing.r" default="install" basedir="./">
3+
<property name="mode.name" value="RLangMode" />
4+
<!-- folder to install modes in (probably a folder called "modes" inside your sketchbook folder) -->
5+
<property name="processing.modes" location="@@modes@@" />
6+
<!-- path to your processing executable. -->
7+
<property name="processing.executable" location="@@executable@@" />
8+
<property name="processing" value="@@processing@@" />
9+
<!-- location of processing jars (core.jar, pde.jar, ..) -->
10+
<property name="processing.classes.core" location="@@core@@" />
11+
<property name="processing.classes.pde" location="@@pde@@" />
12+
<property name="renjin" value="@@renjin@@" />
13+
<property name="java.target.version" value="1.8" />
14+
<!-- Folder -->
15+
<property name="try" value="try" />
16+
<property name="lib" value="lib" />
17+
<property name="src" value="src" />
18+
<property name="build" value="build" />
19+
<property name="bin" value="bin" />
20+
<property name="dist" value="dist" />
21+
<path id="library-classpath">
22+
<fileset dir="${processing.classes.core}">
23+
<include name="*.jar" />
24+
</fileset>
25+
<fileset dir="${processing.classes.pde}">
26+
<include name="*.jar" />
27+
</fileset>
28+
<fileset dir="lib">
29+
<include name="*.jar" />
30+
</fileset>
31+
</path>
32+
<target name="try" depends="build">
33+
<propertyfile file="build.number" />
34+
<!-- create the build.number file if it doesn't exist -->
35+
<buildnumber file="build.number" />
36+
<mkdir dir="${try}" />
37+
<jar jarfile="try/${mode.name}.jar" basedir="build">
38+
<manifest>
39+
<attribute name="Main-Class" value="rprocessing.Runner" />
40+
</manifest>
41+
<zipgroupfileset dir="${processing.classes.core}" includes="**/*.jar" />
42+
<zipgroupfileset dir="${lib}" includes="**/*.jar" />
43+
</jar>
44+
</target>
45+
<target name="build">
46+
<mkdir dir="build" />
47+
<javac destdir="build" includeantruntime="false">
48+
<src path="src" />
49+
<classpath>
50+
<path refid="library-classpath" />
51+
</classpath>
52+
</javac>
53+
<copy todir="build">
54+
<fileset dir="src" excludes="**/*.java" />
55+
</copy>
56+
</target>
57+
<target name="info">
58+
<echo>This is the R mode for Processing, powered by github.com/gaocegege</echo>
59+
</target>
60+
<!-- - - - - - - - - - - - - - - - - - - - - - -
61+
PACKAGE
62+
- - - - - - - - - - - - - - - - - - - - - - - -->
63+
<target name="package" depends="build">
64+
<delete dir="${dist}" />
65+
<property name="bundle" value="${dist}/${mode.name}" />
66+
<mkdir dir="${bundle}" />
67+
<mkdir dir="${bundle}/mode" />
68+
<jar jarfile="${bundle}/mode/${mode.name}.jar" basedir="build" />
69+
<!--zip destfile="${dist}/mode/${mode.name}.jar" excludes="**/*.MF">
70+
<zipgroupfileset dir="lib" includes="*.jar" />
71+
</zip-->
72+
<copy todir="${bundle}">
73+
<fileset dir="resources/" />
74+
</copy>
75+
<copy todir="${bundle}/mode">
76+
<fileset dir="lib/" />
77+
</copy>
78+
<replaceregexp file="${bundle}/mode.properties" flags="g" match="@@version@@" replace="11" />
79+
<replaceregexp file="${bundle}/mode.properties" flags="g" match="@@pretty-version@@" replace="1" />
80+
</target>
81+
<!-- - - - - - - - - - - - - - - - - - - - - - -
82+
INSTALL
83+
- - - - - - - - - - - - - - - - - - - - - - - -->
84+
<target name="install" depends="package">
85+
<delete dir="${processing.modes}/${mode.name}" />
86+
<copy todir="${processing.modes}/">
87+
<fileset dir="${dist}" />
88+
</copy>
89+
</target>
90+
<!-- - - - - - - - - - - - - - - - - - - - - - -
91+
CLEAN
92+
- - - - - - - - - - - - - - - - - - - - - - - -->
93+
<target name="clean">
94+
<delete dir="${build}" />
95+
<delete dir="${dist}" />
96+
<delete dir="${try}" />
97+
</target>
98+
<!-- - - - - - - - - - - - - - - - - - - - - - -
99+
RUN
100+
- - - - - - - - - - - - - - - - - - - - - - - -->
101+
<target name="run" depends="install">
102+
<exec executable="${processing.executable}" spawn="false" />
103+
</target>
104+
</project>

docs/howto.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
# HOWTO
22

3-
### Editor Support
3+
## Requirements
44

5-
Change `processing.modes` in build.xml, and run `ant install`, you will get a mode in `processing/modes`.
5+
* Clone [processing/processing](https://github.com/processing/processing)
6+
* Install JDK 1.8
7+
* Install Processing app
68

7-
```xml
8-
<!-- folder to install modes in (probably a folder called "modes" inside your sketchbook folder) -->
9-
<property name="processing.modes" location="/Users/<username>/Documents/Processing/modes" />
10-
<!-- path to your processing executable. -->
11-
<property name="processing.executable" location="/Applications/Processing.app/Contents/MacOS/Processing" />
12-
```
9+
### Editor Support
10+
11+
* Replace paths in `./scripts/generate-ant-file.sh` with the paths in your environment.
12+
* Run `./scripts/generate-ant-file.sh` to get a valid build.xml
13+
* Run `ant install`, you will get a mode in `processing/modes`.
1314

1415
<img src="./docs/img/editor.png" width="600">
1516

scripts/generate-ant-file.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env bash
2+
3+
# Timestamped log, e.g. log "cluster created".
4+
#
5+
# Input:
6+
# $1 Log string.
7+
function log {
8+
echo -e "[`TZ=Asia/Shanghai date`] ${1}"
9+
}
10+
11+
root=$(dirname "${BASH_SOURCE}")/..
12+
13+
# Path
14+
modes="/Users/gaoce/Documents/Processing/modes"
15+
executable="/Applications/Processing.app/Contents/MacOS/Processing"
16+
processing="../processing"
17+
core="../processing/core/library/"
18+
pde="../processing/app/"
19+
renjin="lib/renjin-script-engine-0.8.2194-jar-with-dependencies.jar"
20+
21+
# Build core.jar.
22+
cd ${core}/..
23+
ant build
24+
cd - > /dev/null
25+
26+
# Build pde.jar.
27+
cd ${pde}
28+
ant build
29+
cd - > /dev/null
30+
31+
cd ${root}
32+
cp build.xml.template build.xml
33+
# Interpret config template.
34+
log "Inject the config to build.xml.template"
35+
perl -i -pe "s|\@\@modes\@\@|${modes}|g" build.xml
36+
perl -i -pe "s|\@\@executable\@\@|${executable}|g" build.xml
37+
perl -i -pe "s|\@\@processing\@\@|${processing}|g" build.xml
38+
perl -i -pe "s|\@\@core\@\@|${core}|g" build.xml
39+
perl -i -pe "s|\@\@pde\@\@|${pde}|g" build.xml
40+
perl -i -pe "s|\@\@renjin\@\@|${renjin}|g" build.xml
41+
cd - > /dev/null

0 commit comments

Comments
 (0)