-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
22 changed files
with
1,913 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: Java CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
- $default-branch | ||
- $protected-branches | ||
pull_request: | ||
branches: | ||
- master | ||
- $default-branch | ||
workflow_dispatch: | ||
|
||
permissions: | ||
id-token: write | ||
attestations: write | ||
contents: write | ||
packages: write | ||
|
||
jobs: | ||
call-workflow: | ||
strategy: | ||
matrix: | ||
josm-revision: ["", "r19067"] | ||
uses: JOSM/JOSMPluginAction/.github/workflows/ant.yml@v3 | ||
with: | ||
java-version: 22 | ||
josm-revision: ${{ matrix.josm-revision }} | ||
perform-revision-tagging: ${{ matrix.josm-revision == 'r19067' && github.repository == 'JOSM/routing2' && github.ref_type == 'branch' && github.ref_name == 'master' && github.event_name != 'schedule' && github.event_name != 'pull_request' }} | ||
secrets: inherit | ||
build-valhalla: | ||
uses: ./.github/workflows/valhalla.yaml | ||
upload-valhalla: | ||
runs-on: ubuntu-latest | ||
needs: [build-valhalla, call-workflow] | ||
if: needs.call-workflow.outputs.tag | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
steps: | ||
- name: Get macos build | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: macOS-build-valhalla-fat | ||
- run: gh release upload --repo ${{ github.repository }} ${{ needs.call-workflow.outputs.tag }} valhalla-*-Darwin.tar.gz | ||
- name: Get linux build | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: Linux-build-valhalla-X64 | ||
- run: gh release upload --repo ${{ github.repository }} ${{ needs.call-workflow.outputs.tag }} valhalla-*-Linux.tar.gz | ||
- name: Get Windows build | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: Windows-build-valhalla-X64 | ||
- run: gh release upload --repo ${{ github.repository }} ${{ needs.call-workflow.outputs.tag }} valhalla-*-Windows.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,208 @@ | ||
on: | ||
workflow_call: | ||
inputs: | ||
valhalla_ref: | ||
type: string | ||
default: 3.5.1 | ||
description: The valhalla version to build | ||
required: false | ||
vcpkg_ref: | ||
type: string | ||
default: 2024.10.21 | ||
description: The vcpkg version to use | ||
required: false | ||
|
||
jobs: | ||
build_unix: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [macos-latest, macos-13, ubuntu-22.04, windows-2019] | ||
steps: | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.8' | ||
- uses: actions/checkout@v4 | ||
with: | ||
repository: valhalla/valhalla | ||
ref: ${{ inputs.valhalla_ref }} | ||
submodules: 'recursive' | ||
- uses: actions/checkout@v4 | ||
with: | ||
repository: microsoft/vcpkg | ||
ref: 2024.10.21 | ||
path: vcpkg | ||
submodules: 'recursive' | ||
- name: Cache dependencies | ||
id: dependency-cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: vcpkg/downloads | ||
key: valhalla-${{ inputs.valhalla_ref }}-${{ inputs.vcpkg_ref }}-vcpkg-downloads-${{ runner.os }}-${{ runner.arch }} | ||
- name: Cache build | ||
id: build-cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: build/valhalla-${{ inputs.valhalla_ref }}-${{ runner.os == 'macos' && 'Darwin' || runner.os }}.tar.gz | ||
key: ${{ runner.os }}-${{ runner.arch }}-valhalla-${{ inputs.valhalla_ref }} | ||
- name: Build valhalla | ||
if: steps.build-cache.outputs.cache-hit != 'true' | ||
shell: bash | ||
run: | | ||
set -ex | ||
if [ "${{ runner.os }}" == "macOS" ]; then | ||
brew install automake cmake bash coreutils binutils libtool autoconf automake autoconf-archive pkg-config autoconf | ||
os="osx" | ||
elif [ "${{ runner.os }}" == "Linux" ]; then | ||
apt-get update && apt-get install -y curl zip unzip tar npm pkg-config autoconf libtool python3 cmake git build-essential gcc g++ make | ||
os="linux" | ||
elif [ "${{ runner.os }}" == "Windows" ]; then | ||
os="windows-static" | ||
cat <<EOF > 1.patch | ||
diff --git a/scripts/valhalla_build_extract b/scripts/valhalla_build_extract | ||
index 236822513..0ccafabf6 100755 | ||
--- a/scripts/valhalla_build_extract | ||
+++ b/scripts/valhalla_build_extract | ||
@@ -95,7 +95,7 @@ class TileResolver: | ||
tar.addfile(tar_member, self._tar_obj.extractfile(tar_member.name)) | ||
else: | ||
tar.add(str(self.path.joinpath(t)), arcname=t) | ||
- tar_member = tar.getmember(str(t)) | ||
+ #tar_member = tar.getmember(str(t)) | ||
description = "Builds a tar extract from the tiles in mjolnir.tile_dir to the path specified in mjolnir.tile_extract." | ||
EOF | ||
git apply 1.patch | ||
fi | ||
export VCPKG_ROOT=$(pwd)/vcpkg | ||
./vcpkg/bootstrap-vcpkg.sh | ||
if [ "${{ runner.arch }}" == "X64" ]; then | ||
echo "set(VCPKG_BUILD_TYPE release)" >> vcpkg/triplets/x64-${os}.cmake | ||
else | ||
if [ "${{ runner.os }}" == "macOS" ]; then brew install vcpkg; fi | ||
echo "set(VCPKG_BUILD_TYPE release)" >> vcpkg/triplets/arm64-${os}.cmake | ||
fi | ||
npm install --ignore-scripts | ||
mkdir build | ||
# We don't need python bindings | ||
sed -i.bak '/pybind11/d' vcpkg.json | ||
# We don't need gdal (we disable compile-time support for it) | ||
sed -i.bak '/gdal/d' vcpkg.json | ||
export CMAKE_MAKE_PROGRAM=make && export CMAKE_CXX_COMPILER=g++ && export CMAKE_C_COMPILER=gcc | ||
cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=$PWD/vcpkg/scripts/buildsystems/vcpkg.cmake -DDENABLE_STATIC_LIBRARY_MODULES=ON -DBUILD_SHARED_LIBS=OFF -DDENABLE_GDAL=OFF -DENABLE_SERVICES=OFF -DENABLE_SINGLE_FILES_WERROR=OFF | ||
if [ "${{ runner.os }}" == "Windows" ]; then cmake --build build --config Release -- //clp:ErrorsOnly //p:BuildInParallel=true //m:8 | ||
elif [ "${{ runner.os }}" == "macOS" ]; then cmake --build build -- -j$(sysctl -n hw.physicalcpu) | ||
elif [ "${{ runner.os }}" == "Linux" ]; then cmake --build build -- -j"$(nproc)" | ||
fi | ||
if [ "${{ runner.os }}" == "Windows" ]; then | ||
ls build | ||
ls build/Release | ||
pip install -U pyinstaller | ||
# Create static python files | ||
$(cd build && pyinstaller valhalla_build_config && pyinstaller valhalla_build_extract) | ||
ls build/dist/valhalla_build_config | ||
cp build/dist/valhalla_build_config/valhalla_build_config.exe build/Release | ||
cp build/dist/valhalla_build_extract/valhalla_build_extract.exe build/Release | ||
cp build/valhalla_build_timezones build/Release | ||
cp -r build/dist/valhalla_build_config/_internal build/Release | ||
cp -r build/dist/valhalla_build_extract/_internal build/Release | ||
tar -cavf build/valhalla-${{ inputs.valhalla_ref }}-Windows.tar.gz -C build/Release . | ||
else sudo cmake --build build -- package | ||
fi | ||
if [ "${{ runner.os }}" == "Linux" ]; then | ||
# Strip first path component. | ||
mkdir tmp | ||
tar -xf build/valhalla-${{ inputs.valhalla_ref }}-Linux.tar.gz -C tmp | ||
rm build/valhalla-${{ inputs.valhalla_ref }}-Linux.tar.gz | ||
tar -cavf build/valhalla-${{ inputs.valhalla_ref }}-Linux.tar.gz -C tmp/valhalla-${{ inputs.valhalla_ref }}-Linux . | ||
fi | ||
ls build | ||
- name: Debug output | ||
if: failure() | ||
run: | | ||
git diff | ||
ls build/vcpkg_installed | ||
find . -iname '*-err.log' -print -exec cat {} \; | ||
- name: Upload mac build | ||
id: upload-mac-build | ||
if: runner.os == 'macOS' | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ runner.os }}-build-valhalla-${{ runner.arch }} | ||
path: | | ||
build/valhalla-${{ inputs.valhalla_ref }}-Darwin.tar.gz | ||
- name: Upload linux build | ||
id: upload-linux-build | ||
if: runner.os == 'Linux' | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ runner.os }}-build-valhalla-${{ runner.arch }} | ||
path: | | ||
build/valhalla-${{ inputs.valhalla_ref }}-Linux.tar.gz | ||
- name: Upload Windows build | ||
id: upload-windows-build | ||
if: runner.os == 'Windows' | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ runner.os }}-build-valhalla-${{ runner.arch }} | ||
path: | | ||
build/valhalla-${{ inputs.valhalla_ref }}-Windows.tar.gz | ||
combine_macos: | ||
runs-on: macos-latest | ||
needs: [build_unix] | ||
steps: | ||
- name: Cache build | ||
id: build-cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: valhalla-${{ inputs.valhalla_ref }}-Darwin.tar.gz | ||
key: ${{ runner.os }}-fat-valhalla-${{ inputs.valhalla_ref }}-${{ github.workflow_sha }} | ||
- name: Get macos arm build | ||
if: steps.build-cache.outputs.cache-hit != 'true' | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: macOS-build-valhalla-ARM64 | ||
- name: Extract arm build | ||
if: steps.build-cache.outputs.cache-hit != 'true' | ||
run: | | ||
mkdir arm64 | ||
tar -xf valhalla-${{ inputs.valhalla_ref }}-Darwin.tar.gz -C arm64 | ||
rm valhalla-${{ inputs.valhalla_ref }}-Darwin.tar.gz | ||
- name: Get macos x64 build | ||
if: steps.build-cache.outputs.cache-hit != 'true' | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: macOS-build-valhalla-X64 | ||
- name: Build fat binaries | ||
if: steps.build-cache.outputs.cache-hit != 'true' | ||
run: | | ||
mkdir x86 | ||
tar -xf valhalla-${{ inputs.valhalla_ref }}-Darwin.tar.gz -C x86 | ||
rm valhalla-${{ inputs.valhalla_ref }}-Darwin.tar.gz | ||
# Now create the fat files | ||
mkdir fat | ||
function makefat() { | ||
echo "${1}" | ||
echo "${@}" | ||
file="${1#x86/}" | ||
file="${file#arm64/}" | ||
if [ -f "${1}" ]; then | ||
mkdir -p "fat/${file%/*}" | ||
# Account for platform specific resource files | ||
cp "${1}" "fat/${file}" | ||
lipo -create -output "fat/${file}" "x86/${file}" "arm64/${file}" | ||
fi | ||
} | ||
export -f makefat | ||
find x86 -type f -exec bash -c 'makefat "${0}"' {} \; | ||
find arm64 -type f -exec bash -c 'makefat "${0}"' {} \; | ||
tar -czf valhalla-${{ inputs.valhalla_ref }}-Darwin.tar.gz -C fat/valhalla-${{ inputs.valhalla_ref }}-Darwin . | ||
- name: Upload mac build | ||
id: upload-mac-build | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: macOS-build-valhalla-fat | ||
path: | | ||
valhalla-${{ inputs.valhalla_ref }}-Darwin.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# The routing plugin | ||
## Supported engines | ||
### Valhalla | ||
Valhalla is supported using the valhalla CLI interface. | ||
|
||
## Usage | ||
1. Install the `routing2` plugin | ||
2. Download data | ||
3. Open `Routing` toggle dialog (`Windows` -> `Routing`) | ||
4. Input start/end points into dialog. HINT: `ctrl`+`shift`+`c` will copy a node's coordinates! | ||
5. `Calculate Route` | ||
6. Wait for route to be calculated. The more data you have, the longer it will take. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<project name="routing2" default="dist" basedir="."> | ||
<property name="plugin.src.dir" value="src/main/java"/> | ||
<property name="plugin.test.dir" value="src/test/java"/> | ||
<property name="plugin.resources.dir" value="src/main/resources"/> | ||
|
||
<property name="java.lang.version" value="21"/> | ||
<property name="plugin.main.version" value="19044"/> | ||
<property name="plugin.author" value="Taylor Smock" /> | ||
<property name="plugin.class" value="org.openstreetmap.josm.plugins.routing2.Routing2Plugin"/> | ||
<property name="plugin.description" value="Production-ready routing with valhalla"/> | ||
<property name="plugin.requires" value="apache-commons;pbf" /> | ||
<property name="plugin.link" value="https://github.com/tsmock/routing2"/> | ||
<property name="plugin.canloadatruntime" value="true" /> | ||
<property name="plugin.minimum.java.version" value="21"/> | ||
|
||
<!-- ** include targets that all plugins have in common ** --> | ||
<import file="../build-common.xml"/> | ||
|
||
<!-- Override the `setup-dist-default` task from build-common.xml --> | ||
<target name="setup-dist-default"> | ||
<copy todir="${plugin.build.dir}" failonerror="no" includeemptydirs="no"> | ||
<fileset dir="${plugin.resources.dir}"/> | ||
</copy> | ||
<copy todir="${plugin.build.dir}"> | ||
<fileset dir="."> | ||
<include name="README"/> | ||
<include name="LICENSE*"/> | ||
<include name="*GPL*"/> | ||
<include name="*.md"/> | ||
</fileset> | ||
</copy> | ||
</target> | ||
|
||
<fileset id="plugin.requires.jars" dir="${plugin.dist.dir}"> | ||
<include name="apache-commons.jar"/> | ||
<include name="pbf.jar"/> | ||
</fileset> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#!/usr/bin/env bash | ||
# We need to build bindings for the engines so we can use them in Java | ||
if [ ! -d "engines" ]; then mkdir engines; fi | ||
cd "engines" || exit 1 | ||
function jextract_get() { | ||
if [ ! -d "jextract-22" ]; then | ||
curl -L "https://download.java.net/java/early_access/jextract/22/5/openjdk-22-jextract+5-33_macos-x64_bin.tar.gz" -o jextract.tar.gz | ||
tar xf jextract.tar.gz | ||
rm jextract.tar.gz | ||
fi | ||
PATH="$(pwd)/jextract-22/bin:${PATH}" | ||
} | ||
function git_latest_tag() { | ||
### Checkout the latest tag | ||
local tag | ||
tag="$(git describe origin/master --abbrev=0 --tags)" | ||
git checkout "${tag}" | ||
} | ||
|
||
function prime_server() { | ||
if [ ! -d prime_server ]; then git clone https://github.com/kevinkreiser/prime_server.git ; else git -C prime_server remote update; fi | ||
cd prime_server || exit 1 | ||
# latest tag (0.7.0) is years old | ||
git checkout master && git pull | ||
#git_latest_tag | ||
git submodule update --init --recursive | ||
./autogen.sh | ||
./configure | ||
make test -j8 | ||
#sudo make install | ||
cd .. | ||
} | ||
|
||
function valhalla() { | ||
## Valhalla | ||
### Clone valhalla | ||
if [ ! -d "valhalla" ]; then git clone https://github.com/valhalla/valhalla.git; else git -C valhalla remote update; fi | ||
cd "valhalla" || exit 1 | ||
git checkout master && git pull | ||
git checkout 3.5.1 | ||
npm install --ignore-scripts | ||
git submodule update --init --recursive | ||
if [ -d build ] ; then rm -rf build; fi | ||
mkdir build | ||
cd build || exit 1 | ||
cmake .. -DCMAKE_BUILD_TYPE=Release -DDENABLE_STATIC_LIBRARY_MODULES=On -DDENABLE_GDAL=OFF -DENABLE_SERVICES=OFF | ||
make -j"$(nproc)" | ||
make package | ||
#sudo make install | ||
cd ../../../ | ||
|
||
mkdir -p valhalla_tiles | ||
./engines/valhalla/build/valhalla_build_config --mjolnir-tile-dir $(pwd)/valhalla_tiles --mjolnir-tile-extract $(pwd)/valhalla_tiles.tar --mjolnir-timezone $(pwd)/valhalla_tiles/timezones.sqlite --mjolnir-admin $(pwd)/valhalla_tiles/admins.sqlite > valhalla.json | ||
./engines/valhalla/build/valhalla_build_timezones > valhalla_tiles/timezones.sqlite | ||
./engines/valhalla/build/valhalla_build_admins -c valhalla.json ~/Downloads/colorado-latest.osm.pbf | ||
./engines/valhalla/build/valhalla_build_tiles -c valhalla.json ~/Downloads/colorado-latest.osm.pbf | ||
./engines/valhalla/build/valhalla_build_extract -c valhalla.json -v --overwrite | ||
# Test install | ||
./engines/valhalla/build/valhalla_run_route --config valhalla.json --json '{"locations": [{"lat":39.0776524, "lon":-108.4588285}, {"lat":39.0676135, "lon":-108.5601538}], "costing":"auto","directions_options":{"units":"miles"}}' --verbose-lanes | ||
./engines/valhalla/build/valhalla_service valhalla.json route '{"locations": [{"lat":39.0776524, "lon":-108.4588285}, {"lat":39.0676135, "lon":-108.5601538}], "costing":"auto","directions_options":{"units":"miles"}}' | ||
|
||
# Note: future versions of jextract *may* be able to take multiple header files. TODO change trailing \; to \+ | ||
# Important file is tyr/actor.h anyway. | ||
find engines/valhalla/valhalla -name '*.h' -exec jextract \ | ||
--include-dir /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/c++/v1 \ | ||
--target-package org.openstreetmap.josm.plugins.routing2.lib.valhalla \ | ||
--output src/main/java \ | ||
{} \; | ||
|
||
} | ||
jextract_get | ||
prime_server | ||
set -ex | ||
valhalla | ||
|
Oops, something went wrong.