Skip to content

Commit 2119748

Browse files
committed
First attempt to compile with TeaVM
1 parent 2d8506d commit 2119748

File tree

6 files changed

+127
-6
lines changed

6 files changed

+127
-6
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,7 @@ debug.sh
2727
core/TODO*.txt
2828
srtmprovider/
2929
core/docs/
30-
.*#
30+
.*#
31+
.project
32+
.settings
33+
.classpath

core/src/main/java/com/graphhopper/util/Helper.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -392,10 +392,8 @@ public Object run() throws Exception
392392

393393
public static String nf( long no )
394394
{
395-
// I like french localization the most: 123654 will be 123 654 instead
396-
// of comma vs. point confusion for english/german guys.
397-
// NumberFormat is not thread safe => but getInstance looks like it's cached
398-
return NumberFormat.getInstance(Locale.FRANCE).format(no);
395+
// Simplify for TeaVM. May be implement Locale and NumberFormat someday.
396+
return String.valueOf(no);
399397
}
400398

401399
public static String firstBig( String sayText )

graphhopper-teavm/pom.xml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<parent>
6+
<groupId>com.graphhopper</groupId>
7+
<artifactId>graphhopper-parent</artifactId>
8+
<version>0.3-SNAPSHOT</version>
9+
</parent>
10+
<artifactId>graphhopper-teavm</artifactId>
11+
12+
<dependencies>
13+
<dependency>
14+
<groupId>com.graphhopper</groupId>
15+
<artifactId>graphhopper</artifactId>
16+
<version>0.3-SNAPSHOT</version>
17+
</dependency>
18+
</dependencies>
19+
20+
<build>
21+
<plugins>
22+
<plugin>
23+
<groupId>org.teavm</groupId>
24+
<artifactId>teavm-maven-plugin</artifactId>
25+
<version>0.2-SNAPSHOT</version>
26+
<dependencies>
27+
<dependency>
28+
<groupId>org.teavm</groupId>
29+
<artifactId>teavm-classlib</artifactId>
30+
<version>0.2-SNAPSHOT</version>
31+
</dependency>
32+
</dependencies>
33+
<executions>
34+
<execution>
35+
<id>generate-javascript</id>
36+
<goals>
37+
<goal>build-javascript</goal>
38+
</goals>
39+
<phase>process-classes</phase>
40+
<configuration>
41+
<minifying>true</minifying>
42+
<mainClass>com.graphhopper.teavm.Main</mainClass>
43+
<mainPageIncluded>true</mainPageIncluded>
44+
</configuration>
45+
</execution>
46+
</executions>
47+
</plugin>
48+
</plugins>
49+
</build>
50+
</project>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package com.graphhopper.teavm;
2+
3+
import java.nio.ByteOrder;
4+
import com.graphhopper.storage.DAType;
5+
import com.graphhopper.storage.DataAccess;
6+
import com.graphhopper.storage.Directory;
7+
8+
/**
9+
*
10+
* @author Alexey Andreev <[email protected]>
11+
*/
12+
public class InMemoryDirectory implements Directory {
13+
@Override
14+
public String getLocation() {
15+
return null;
16+
}
17+
18+
@Override
19+
public ByteOrder getByteOrder() {
20+
return null;
21+
}
22+
23+
@Override
24+
public DataAccess find(String name) {
25+
return null;
26+
}
27+
28+
@Override
29+
public DataAccess find(String name, DAType type) {
30+
return null;
31+
}
32+
33+
@Override
34+
public void clear() {
35+
}
36+
37+
@Override
38+
public void remove(DataAccess da) {
39+
}
40+
41+
@Override
42+
public DAType getDefaultType() {
43+
return null;
44+
}
45+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.graphhopper.teavm;
2+
3+
import com.graphhopper.routing.DijkstraBidirection;
4+
import com.graphhopper.routing.util.*;
5+
import com.graphhopper.storage.GraphHopperStorage;
6+
7+
/**
8+
*
9+
* @author Alexey Andreev <[email protected]>
10+
*/
11+
public class Main {
12+
public static void main(String[] args) {
13+
InMemoryDirectory directory = new InMemoryDirectory();
14+
GraphHopperStorage graph = new GraphHopperStorage(directory, new EncodingManager(EncodingManager.BIKE), false);
15+
graph.loadExisting();
16+
17+
EncodingManager encodingManager = graph.getEncodingManager();
18+
FlagEncoder encoder = encodingManager.getSingle();
19+
20+
Weighting weighting = new FastestWeighting(encoder);
21+
DijkstraBidirection algo = new DijkstraBidirection(graph, encoder, weighting);
22+
algo.calcPath(0, 1);
23+
}
24+
}

pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@
7777
<module>core</module>
7878
<module>tools</module>
7979
<module>web</module>
80-
<module>android</module>
80+
<!-- <module>android</module> -->
81+
<module>graphhopper-teavm</module>
8182
</modules>
8283

8384
<build>

0 commit comments

Comments
 (0)