Compare commits
3 commits
master
...
vng-bookma
Author | SHA1 | Date | |
---|---|---|---|
|
454338996c | ||
|
906a98ef7b | ||
|
57fcae75b4 |
|
@ -21,7 +21,7 @@ IndentCaseLabels: false
|
|||
NamespaceIndentation: None
|
||||
PointerAlignment: Middle
|
||||
SortIncludes: true
|
||||
Standard: c++20
|
||||
Standard: c++17
|
||||
IncludeBlocks: Regroup
|
||||
IncludeCategories:
|
||||
# Tests --------------------------------------------------------------------------------------------
|
||||
|
@ -163,6 +163,8 @@ IncludeCategories:
|
|||
- Regex: '^"openlr/openlr_stat/'
|
||||
Priority: 19400
|
||||
|
||||
- Regex: '^"mapshot/'
|
||||
Priority: 19500
|
||||
|
||||
- Regex: '^"search/search_quality/booking_dataset_generator/'
|
||||
Priority: 19707
|
||||
|
@ -258,6 +260,9 @@ IncludeCategories:
|
|||
- Regex: '^"editor/'
|
||||
Priority: 48310
|
||||
|
||||
- Regex: '^"software_renderer/'
|
||||
Priority: 48400
|
||||
|
||||
- Regex: '^"drape_frontend/'
|
||||
Priority: 48500
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
6aa73face8b5eb8e026cfafa40d1983d4a0502c0
|
||||
480fa6c2fcf53be296504ac6ba8e6b3d70f92b42
|
||||
a6ede2b1466f0c9d8a443600ef337ba6b5832e58
|
||||
1377b81bf1cac72bb6da192da7fed6696d5d5281
|
||||
|
|
69
.github/CODEOWNERS
vendored
|
@ -1,69 +0,0 @@
|
|||
# All non-assigned.
|
||||
* @organicmaps/mergers
|
||||
# Visual design.
|
||||
/android/app/src/main/res/drawable*/ @organicmaps/design
|
||||
/android/app/src/main/res/font/ @organicmaps/design
|
||||
/android/app/src/main/res/mipmap*/ @organicmaps/design
|
||||
/data/*.ttf @organicmaps/design
|
||||
/data/resources-svg/ @organicmaps/design
|
||||
/data/search-icons/ @organicmaps/design
|
||||
/iphone/Maps/Images.xcassets/ @organicmaps/design
|
||||
# Android.
|
||||
/android/ @organicmaps/android
|
||||
/android/app/src/main/java/app/organicmaps/car/ @organicmaps/android-auto
|
||||
/docs/ANDROID_LOCATION_TEST.md @organicmaps/android
|
||||
/docs/JAVA_STYLE.md @organicmaps/android
|
||||
# no owner for translation changes
|
||||
/android/app/src/main/res/values*/strings.xml
|
||||
# iOS.
|
||||
/iphone/ @organicmaps/ios
|
||||
/xcode/ @organicmaps/ios
|
||||
/docs/OBJC_STYLE.md @organicmaps/ios
|
||||
# no owner for translation changes
|
||||
/iphone/plist.txt
|
||||
/iphone/Maps/LocalizedStrings/
|
||||
# Qt
|
||||
/qt/ @organicmaps/qt
|
||||
# Rendering
|
||||
/drape/ @organicmaps/rendering
|
||||
/drape_frontend/ @organicmaps/rendering
|
||||
# Map Data.
|
||||
/tools/python/maps_generator/ @organicmaps/data
|
||||
/generator/ @organicmaps/data
|
||||
/topography_generator/ @organicmaps/data
|
||||
/data/borders/ @organicmaps/data
|
||||
/data/conf/isolines/ @organicmaps/data
|
||||
/docs/SUBWAY_GENERATION.md @organicmaps/data
|
||||
/docs/MAPS.md @organicmaps/data
|
||||
/docs/EXPERIMENTAL_PUBLIC_TRANSPORT_SUPPORT.md @organicmaps/data
|
||||
# no owner (changed often to add a new POI)
|
||||
/generator/generator_tests/osm_type_test.cpp
|
||||
# Map Styles.
|
||||
/data/styles/ @organicmaps/styles
|
||||
/data/types.txt @organicmaps/styles
|
||||
/data/visibility.txt @organicmaps/styles
|
||||
/data/mapcss-mapping.csv @organicmaps/styles
|
||||
/data/replaced_tags.txt @organicmaps/styles
|
||||
/data/classificator.txt @organicmaps/styles
|
||||
/data/drules_* @organicmaps/styles
|
||||
/docs/STYLES.md
|
||||
/tools/kothic/ @organicmaps/styles
|
||||
# DevOps.
|
||||
/.github/workflows @organicmaps/devops
|
||||
/android/*gradle* @organicmaps/devops
|
||||
/docs/RELEASE_MANAGEMENT.md @organicmaps/devops
|
||||
/xcode/fastlane/ @organicmaps/devops
|
||||
# Growth.
|
||||
README.md @organicmaps/growth
|
||||
/.github/FUNDING.yml @organicmaps/growth
|
||||
/android/app/src/fdroid/play/ @organicmaps/growth
|
||||
/android/app/src/google/play/ @organicmaps/growth
|
||||
/iphone/metadata/ @organicmaps/growth
|
||||
# Legal.
|
||||
LEGAL @organicmaps/legal
|
||||
LICENSE @organicmaps/legal
|
||||
NOTICE @organicmaps/legal
|
||||
CONTRIBUTORS @organicmaps/legal
|
||||
/docs/CODE_OF_CONDUCT.md @organicmaps/legal
|
||||
/docs/DCO.md @organicmaps/legal
|
||||
/docs/GOVERNANCE.md @organicmaps/legal
|
3
.github/FUNDING.yml
vendored
|
@ -1,4 +1,3 @@
|
|||
github: organicmaps
|
||||
liberapay: OrganicMaps
|
||||
open_collective: organicmaps
|
||||
custom: ["https://organicmaps.app/donate/", "https://donate.organicmaps.app/"]
|
||||
custom: ["https://organicmaps.app/donate"]
|
||||
|
|
19
.github/ISSUE_TEMPLATE/bug_report.md
vendored
|
@ -1,17 +1,14 @@
|
|||
---
|
||||
name: Bug Report
|
||||
about: Describe your issue in detail to help us improve Organic Maps
|
||||
about: Describe your issue in details to help us improve Organic Maps
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
⚠ Have you searched for similar, already existing issues?
|
||||
|
||||
**Describe the issue**
|
||||
Please write a clear and concise description of the issue here.
|
||||
|
||||
Please write here a clear and concise description of what the bug/issue is about.
|
||||
|
||||
**Steps to reproduce**
|
||||
1. Go to '...'
|
||||
|
@ -19,20 +16,16 @@ Please write a clear and concise description of the issue here.
|
|||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
|
||||
**Expected behaviour**
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots or screen recordings to help explain your problem.
|
||||
|
||||
|
||||
**System information:**
|
||||
- Operating system and its version: [iOS 12, Android 10, Ubuntu 22, MacOS Big Sur, etc.]
|
||||
- Organic Maps version: [you can find it by tapping the button with the green Organic Maps logo]
|
||||
- Device Model: [e.g. iPhone 6, Samsung S22]
|
||||
|
||||
- Organic Maps version: [you can find it by tapping the button with the green OrganicMaps logo, bottom left of the main screen on Android, or the `?` button on iOS]
|
||||
- Device Model: [e.g. iPhone6, Samsung S22]
|
||||
|
||||
**Additional context**
|
||||
Please add any other context or comments here that may be useful.
|
||||
Please add any other context and important details/notes/comments about the problem here.
|
||||
|
|
4
.github/ISSUE_TEMPLATE/config.yml
vendored
|
@ -2,10 +2,10 @@ blank_issues_enabled: true
|
|||
contact_links:
|
||||
- name: Discussions
|
||||
url: https://github.com/organicmaps/organicmaps/discussions
|
||||
about: Discuss the usage of Organic Maps, ask questions, or talk about ideas that aren't yet actionable.
|
||||
about: Discuss the usage of OrganicMaps, ask questions, or talk about ideas that are not yet actionable.
|
||||
- name: Translations
|
||||
url: https://github.com/organicmaps/organicmaps/blob/master/docs/TRANSLATIONS.md
|
||||
about: Translate Organic Maps into your language
|
||||
- name: News
|
||||
url: https://organicmaps.app/news/
|
||||
about: Check the latest project news
|
||||
about: Check the latest project news
|
13
.github/ISSUE_TEMPLATE/feature_request.md
vendored
|
@ -1,27 +1,22 @@
|
|||
---
|
||||
name: Feature Request
|
||||
about: Suggest an idea for Organic Maps
|
||||
name: Feature request
|
||||
about: Suggest an idea for OrganicMaps
|
||||
title: ''
|
||||
labels: []
|
||||
labels: [Enhancement]
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
⚠ Have you searched for similar, already existing issues?
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. For example:
|
||||
I'm always frustrated when [...]
|
||||
|
||||
|
||||
**Describe the ideal solution**
|
||||
**Describe the solution you would like**
|
||||
A clear and concise description of what you want to see in Organic Maps.
|
||||
|
||||
|
||||
**Describe alternatives you have considered**
|
||||
- How do you solve this issue now with Organic Maps or other apps?
|
||||
- Attach any examples, screenshots, or screen recordings from other apps that help us to better understand the idea.
|
||||
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
|
|
35
.github/workflows/android-beta.yaml
vendored
|
@ -19,12 +19,6 @@ on:
|
|||
- docs/**
|
||||
- generator/**
|
||||
- packaging/**
|
||||
- platform/*apple*
|
||||
- platform/*_ios*
|
||||
- platform/*_linux*
|
||||
- platform/*_mac*
|
||||
- platform/*qt*
|
||||
- platform/*_win*
|
||||
- pyhelpers/**
|
||||
- qt*/**
|
||||
- skin_generator/**
|
||||
|
@ -56,24 +50,19 @@ jobs:
|
|||
shell: bash
|
||||
run: git submodule update --depth 1 --init --recursive --jobs=$(($(nproc) * 20))
|
||||
|
||||
- name: Restore beta keys
|
||||
- name: Checkout private keys
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: ${{ secrets.PRIVATE_REPO }}
|
||||
ssh-key: ${{ secrets.PRIVATE_SSH_KEY }}
|
||||
ref: master
|
||||
path: private.git
|
||||
|
||||
- name: Configure repo with private keys
|
||||
shell: bash
|
||||
run: |
|
||||
echo "$PRIVATE_H" | base64 -d > private.h
|
||||
echo "$FIREBASE_APP_DISTRIBUTION_JSON" | base64 -d > android/app/firebase-app-distribution.json
|
||||
echo "$GOOGLE_SERVICES_JSON" | base64 -d > android/app/google-services.json
|
||||
echo "$SECURE_PROPERTIES" | base64 -d > android/app/secure.properties
|
||||
echo "$RELEASE_KEYSTORE" | base64 -d > android/app/release.keystore
|
||||
env:
|
||||
PRIVATE_H: ${{ secrets.PRIVATE_H }}
|
||||
FIREBASE_APP_DISTRIBUTION_JSON: ${{ secrets.FIREBASE_APP_DISTRIBUTION_JSON }}
|
||||
GOOGLE_SERVICES_JSON: ${{ secrets.GOOGLE_SERVICES_JSON }}
|
||||
SECURE_PROPERTIES: ${{ secrets.SECURE_PROPERTIES }}
|
||||
RELEASE_KEYSTORE: ${{ secrets.RELEASE_KEYSTORE }}
|
||||
|
||||
- name: Configure repository
|
||||
shell: bash
|
||||
run: ./configure.sh
|
||||
./configure.sh ./private.git
|
||||
rm -rf ./private.git
|
||||
|
||||
- name: Compile
|
||||
shell: bash
|
||||
|
@ -81,7 +70,7 @@ jobs:
|
|||
run: |
|
||||
cmake --version
|
||||
ninja --version
|
||||
./gradlew -Pfirebase assembleGoogleBeta uploadCrashlyticsSymbolFileGoogleBeta uploadCrashlyticsMappingFileGoogleBeta
|
||||
./gradlew -Pfirebase -x lint -x lintVitalGoogleBeta assembleGoogleBeta uploadCrashlyticsSymbolFileGoogleBeta uploadCrashlyticsMappingFileGoogleBeta
|
||||
|
||||
- name: Upload beta apk to App Distribution
|
||||
shell: bash
|
||||
|
|
|
@ -15,11 +15,6 @@ jobs:
|
|||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
sparse-checkout: |
|
||||
android
|
||||
tools/python/check_store_metadata.py
|
||||
|
||||
- name: Check metadata
|
||||
run: ./tools/python/check_store_metadata.py android
|
||||
|
|
25
.github/workflows/android-check.yaml
vendored
|
@ -21,12 +21,6 @@ on:
|
|||
- docs/**
|
||||
- generator/**
|
||||
- packaging/**
|
||||
- platform/*apple*
|
||||
- platform/*_ios*
|
||||
- platform/*_linux*
|
||||
- platform/*_mac*
|
||||
- platform/*qt*
|
||||
- platform/*_win*
|
||||
- pyhelpers/**
|
||||
- qt*/**
|
||||
- skin_generator/**
|
||||
|
@ -51,7 +45,7 @@ jobs:
|
|||
shell: bash
|
||||
run: git submodule update --depth 1 --init --recursive --jobs=$(($(nproc) * 20))
|
||||
|
||||
- name: Configure repository
|
||||
- name: Configure in Open Source mode
|
||||
shell: bash
|
||||
run: ./configure.sh
|
||||
|
||||
|
@ -66,12 +60,7 @@ jobs:
|
|||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
flavor: [WebDebug, FdroidDebug]
|
||||
include:
|
||||
- flavor: WebDebug
|
||||
arch: arm64
|
||||
- flavor: FdroidDebug
|
||||
arch: arm32
|
||||
flavor: [WebDebug, FdroidBeta]
|
||||
# Cancels previous jobs if the same branch or PR was updated again.
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ matrix.flavor }}-${{ github.event.pull_request.number || github.ref }}
|
||||
|
@ -93,7 +82,7 @@ jobs:
|
|||
shell: bash
|
||||
run: git submodule update --depth 1 --init --recursive --jobs=$(($(nproc) * 20))
|
||||
|
||||
- name: Configure repository
|
||||
- name: Configure in Open Source mode
|
||||
shell: bash
|
||||
run: ./configure.sh
|
||||
|
||||
|
@ -111,11 +100,11 @@ jobs:
|
|||
run: |
|
||||
cmake --version
|
||||
ninja --version
|
||||
./gradlew -P${{ matrix.arch }} assemble${{ matrix.flavor }}
|
||||
./gradlew -Parm64 assemble${{ matrix.flavor }}
|
||||
|
||||
- name: Upload ${{ matrix.flavor }} apk
|
||||
uses: actions/upload-artifact@v4
|
||||
- name: Upload arm64-v8a ${{ matrix.flavor }} apk
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: android-${{ matrix.flavor }}
|
||||
name: android-arm64-v8a-${{ matrix.flavor }}
|
||||
path: android/app/build/outputs/apk/**/OrganicMaps-*.apk
|
||||
if-no-files-found: error
|
||||
|
|
61
.github/workflows/android-monkey.yaml
vendored
|
@ -2,7 +2,7 @@ name: Android Monkey
|
|||
on:
|
||||
workflow_dispatch: # Manual trigger
|
||||
schedule:
|
||||
- cron: '0 5 * * 0' # Once per week at 05:00 UTC
|
||||
- cron: '0 5 * * *' # Once per day at 05:00 UTC
|
||||
|
||||
env:
|
||||
JAVA_HOME: /usr/lib/jvm/temurin-17-jdk-amd64 # Java 17 is required for Android Gradle 8 plugin
|
||||
|
@ -13,7 +13,7 @@ jobs:
|
|||
name: Check preconditions
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 1000 # fetch month or so
|
||||
|
||||
|
@ -31,8 +31,8 @@ jobs:
|
|||
outputs:
|
||||
updated: ${{ steps.check.outputs.updated }}
|
||||
|
||||
android-google-beta:
|
||||
name: Android Google Beta
|
||||
android-google-debug:
|
||||
name: Android Google Debug
|
||||
runs-on: ubuntu-latest
|
||||
needs: precondition
|
||||
if: ${{ needs.precondition.outputs.updated != '' }}
|
||||
|
@ -56,26 +56,19 @@ jobs:
|
|||
shell: bash
|
||||
run: git submodule update --depth 1 --init --recursive --jobs=$(($(nproc) * 20))
|
||||
|
||||
- name: Restore beta keys
|
||||
- name: Checkout private keys
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: ${{ secrets.PRIVATE_REPO }}
|
||||
ssh-key: ${{ secrets.PRIVATE_SSH_KEY }}
|
||||
ref: master
|
||||
path: private.git
|
||||
|
||||
- name: Configure repo with private keys
|
||||
shell: bash
|
||||
run: |
|
||||
echo "$PRIVATE_H" | base64 -d > private.h
|
||||
echo "$FIREBASE_TEST_LAB_JSON" | base64 -d > android/app/firebase-test-lab.json
|
||||
echo "$FIREBASE_APP_DISTRIBUTION_JSON" | base64 -d > android/app/firebase-app-distribution.json
|
||||
echo "$GOOGLE_SERVICES_JSON" | base64 -d > android/app/google-services.json
|
||||
echo "$SECURE_PROPERTIES" | base64 -d > android/app/secure.properties
|
||||
echo "$RELEASE_KEYSTORE" | base64 -d > android/app/release.keystore
|
||||
env:
|
||||
PRIVATE_H: ${{ secrets.PRIVATE_H }}
|
||||
FIREBASE_TEST_LAB_JSON: ${{ secrets.FIREBASE_TEST_LAB_JSON }}
|
||||
FIREBASE_APP_DISTRIBUTION_JSON: ${{ secrets.FIREBASE_APP_DISTRIBUTION_JSON }}
|
||||
GOOGLE_SERVICES_JSON: ${{ secrets.GOOGLE_SERVICES_JSON }}
|
||||
SECURE_PROPERTIES: ${{ secrets.SECURE_PROPERTIES }}
|
||||
RELEASE_KEYSTORE: ${{ secrets.RELEASE_KEYSTORE }}
|
||||
|
||||
- name: Configure repository
|
||||
shell: bash
|
||||
run: ./configure.sh
|
||||
./configure.sh ./private.git
|
||||
rm -rf ./private.git
|
||||
|
||||
- name: Compile
|
||||
shell: bash
|
||||
|
@ -83,20 +76,24 @@ jobs:
|
|||
run: |
|
||||
cmake --version
|
||||
ninja --version
|
||||
./gradlew -Pfirebase -Parm64 -Parmeabi-v7a assembleGoogleBeta uploadCrashlyticsSymbolFileGoogleBeta uploadCrashlyticsMappingFileGoogleBeta
|
||||
./gradlew -Pfirebase -Parm64-v8a -Parmeabi-v7a -Px86_64 assembleGoogleDebug uploadCrashlyticsSymbolFileGoogleDebug
|
||||
|
||||
- name: Run monkey
|
||||
run: |
|
||||
gcloud auth activate-service-account --key-file android/app/firebase-test-lab.json
|
||||
gcloud config set project omapsapp
|
||||
gcloud firebase test android run --app ./android/app/build/outputs/apk/google/beta/OrganicMaps-*-google-beta.apk \
|
||||
--device model=husky,version=34 \
|
||||
--device model=tangorpro,version=33,orientation=landscape \
|
||||
gcloud firebase test android run --app ./android/app/build/outputs/apk/google/debug/OrganicMaps-*-google-debug.apk \
|
||||
--device model=panther,version=33 \
|
||||
--device model=bluejay,version=32 \
|
||||
--device model=a51,version=31 \
|
||||
--device model=f2q,version=30,orientation=landscape \
|
||||
--device model=a10,version=29,orientation=landscape \
|
||||
--device model=cactus,version=27 \
|
||||
--device model=sailfish,version=25 \
|
||||
--device model=harpia,version=23 \
|
||||
--device model=b2q,version=31 \
|
||||
--device model=f2q,version=30 \
|
||||
--device model=a10,version=29 \
|
||||
--device model=Pixel2.arm,version=30 \
|
||||
--device model=MediumPhone.arm,version=29 \
|
||||
--device model=MediumPhone.arm,version=28 \
|
||||
--device model=MediumPhone.arm,version=27 \
|
||||
--device model=Pixel2.arm,version=26,orientation=landscape \
|
||||
--device model=Nexus6,version=25 \
|
||||
--device model=NexusLowRes,version=24 \
|
||||
--device model=NexusLowRes,version=23,orientation=landscape \
|
||||
--timeout 15m
|
||||
|
|
19
.github/workflows/android-release-metadata.yaml
vendored
|
@ -12,7 +12,7 @@ jobs:
|
|||
environment: production
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Parallel submodules checkout
|
||||
shell: bash
|
||||
|
@ -26,14 +26,19 @@ jobs:
|
|||
ref: master
|
||||
path: screenshots
|
||||
|
||||
- name: Restore release keys
|
||||
- name: Checkout private keys
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: ${{ secrets.PRIVATE_REPO }}
|
||||
ssh-key: ${{ secrets.PRIVATE_SSH_KEY }}
|
||||
ref: master
|
||||
path: private.git
|
||||
|
||||
- name: Configure repo with private keys
|
||||
shell: bash
|
||||
run: |
|
||||
echo "$PRIVATE_H" | base64 -d > private.h
|
||||
echo "$GOOGLE_PLAY_JSON" | base64 -d > android/app/google-play.json
|
||||
env:
|
||||
PRIVATE_H: ${{ secrets.PRIVATE_H }}
|
||||
GOOGLE_PLAY_JSON: ${{ secrets.GOOGLE_PLAY_JSON }}
|
||||
./configure.sh ./private.git
|
||||
rm -rf ./private.git
|
||||
|
||||
- name: Upload
|
||||
shell: bash
|
||||
|
|
44
.github/workflows/android-release.yaml
vendored
|
@ -29,7 +29,7 @@ jobs:
|
|||
version=$(tools/unix/version.sh ios_version)
|
||||
# +1 because below a "Bump versions" commit is created.
|
||||
# TODO: Find a way to refactor FDroid versioning without that additional commit.
|
||||
build=$(($(tools/unix/version.sh count) + 1))
|
||||
build=$(($(tools/unix/version.sh ios_build) + 1))
|
||||
code=$(($(tools/unix/version.sh android_code) + 1))
|
||||
tag=$version-$build-android
|
||||
echo "::set-output name=version::$version"
|
||||
|
@ -100,30 +100,23 @@ jobs:
|
|||
ref: master
|
||||
path: screenshots
|
||||
|
||||
- name: Restore release keys
|
||||
- name: Checkout private keys
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: ${{ secrets.PRIVATE_REPO }}
|
||||
ssh-key: ${{ secrets.PRIVATE_SSH_KEY }}
|
||||
ref: master
|
||||
path: private.git
|
||||
|
||||
- name: Configure repo with private keys
|
||||
shell: bash
|
||||
run: |
|
||||
echo "$PRIVATE_H" | base64 -d > private.h
|
||||
echo "$GOOGLE_PLAY_JSON" | base64 -d > android/app/google-play.json
|
||||
echo "$HUAWEI_APPGALLERY_JSON" | base64 -d > android/app/huawei-appgallery.json
|
||||
echo "$AGCONNECT_SERVICES_JSON" | base64 -d > android/app/agconnect-services.json
|
||||
echo "$SECURE_PROPERTIES" | base64 -d > android/app/secure.properties
|
||||
echo "$RELEASE_KEYSTORE" | base64 -d > android/app/release.keystore
|
||||
env:
|
||||
PRIVATE_H: ${{ secrets.PRIVATE_H }}
|
||||
GOOGLE_PLAY_JSON: ${{ secrets.GOOGLE_PLAY_JSON }}
|
||||
HUAWEI_APPGALLERY_JSON: ${{ secrets.HUAWEI_APPGALLERY_JSON }}
|
||||
AGCONNECT_SERVICES_JSON: ${{ secrets.AGCONNECT_SERVICES_JSON }}
|
||||
SECURE_PROPERTIES: ${{ secrets.SECURE_PROPERTIES }}
|
||||
RELEASE_KEYSTORE: ${{ secrets.RELEASE_KEYSTORE }}
|
||||
|
||||
- name: Configure repository
|
||||
shell: bash
|
||||
run: ./configure.sh
|
||||
./configure.sh ./private.git
|
||||
rm -rf ./private.git
|
||||
|
||||
- name: Set up SDK
|
||||
shell: bash
|
||||
run: echo "sdk.dir=$ANDROID_SDK_ROOT" > android/local.properties
|
||||
run: (cd tools/android; ./set_up_android.py --sdk $ANDROID_SDK_ROOT)
|
||||
|
||||
- name: Compile and upload to Google Play
|
||||
shell: bash
|
||||
|
@ -151,16 +144,14 @@ jobs:
|
|||
if: ${{ matrix.flavor == 'web' }}
|
||||
shell: bash
|
||||
run: |
|
||||
(cd ./android/app/build/outputs/apk/web/release/ && sha256sum OrganicMaps-${{ needs.tag.outputs.code }}-web-release.apk > OrganicMaps-${{ needs.tag.outputs.code }}-web-release.apk.sha256sum)
|
||||
{
|
||||
cat ${{ env.RELEASE_NOTES }}
|
||||
echo ""
|
||||
echo "See [a detailed announce](https://organicmaps.app/news/) on our website when app updates are published in all stores."
|
||||
echo "You can get automatic app updates from GitHub [using Obtainium](https://github.com/organicmaps/organicmaps/wiki/Installing-Organic-Maps-from-GitHub-using-Obtainium)."
|
||||
echo "See [more details](https://organicmaps.app/news/) on our website when apps are published."
|
||||
echo ""
|
||||
echo "sha256sum:"
|
||||
echo -e '\n```'
|
||||
tr -d '\n' < ./android/app/build/outputs/apk/web/release/OrganicMaps-${{ needs.tag.outputs.code }}-web-release.apk.sha256sum
|
||||
(cd ./android/app/build/outputs/apk/web/release/ && sha256sum OrganicMaps-${{ needs.tag.outputs.code }}-web-release.apk) | tr -d '\n'
|
||||
echo -e '\n```'
|
||||
} > ${{ runner.temp }}/release-notes.txt
|
||||
|
||||
|
@ -173,8 +164,5 @@ jobs:
|
|||
name: ${{ needs.tag.outputs.tag }}
|
||||
tag_name: ${{ needs.tag.outputs.tag }}
|
||||
discussion_category_name: 'Announcements'
|
||||
prerelease: true
|
||||
files: |
|
||||
./android/app/build/outputs/apk/web/release/OrganicMaps-${{ needs.tag.outputs.code }}-web-release.apk
|
||||
./android/app/build/outputs/apk/web/release/OrganicMaps-${{ needs.tag.outputs.code }}-web-release.apk.sha256sum
|
||||
files: ./android/app/build/outputs/apk/web/release/OrganicMaps-${{ needs.tag.outputs.code }}-web-release.apk
|
||||
fail_on_unmatched_files: true
|
||||
|
|
19
.github/workflows/appstream-check.yaml
vendored
|
@ -9,32 +9,21 @@ on:
|
|||
jobs:
|
||||
validate-appstream:
|
||||
name: Validate appstream metadata xml
|
||||
runs-on: ubuntu-24.04
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
sparse-checkout: |
|
||||
packaging/app.organicmaps.desktop.metainfo.xml
|
||||
|
||||
- name: Install appstream validator and flatpak Builder
|
||||
- name: Install appstream validator
|
||||
shell: bash
|
||||
run: |
|
||||
sudo apt update -y
|
||||
sudo apt install -y \
|
||||
flatpak
|
||||
sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
|
||||
sudo flatpak install -y org.freedesktop.appstream-glib org.flatpak.Builder
|
||||
# We get it from flathub to ensure we have a recent version
|
||||
sudo flatpak install -y org.freedesktop.appstream-glib
|
||||
|
||||
- name: Validate appstream data
|
||||
shell: bash
|
||||
run: flatpak run org.freedesktop.appstream-glib validate --nonet packaging/app.organicmaps.desktop.metainfo.xml
|
||||
|
||||
- name: Lint appstream data with flatpak Builder
|
||||
shell: bash
|
||||
run: flatpak run --command=flatpak-builder-lint org.flatpak.Builder appstream packaging/app.organicmaps.desktop.metainfo.xml
|
||||
|
||||
- name: Run appstreamcli in pedantic mode
|
||||
shell: bash
|
||||
run: flatpak run --command=appstreamcli org.flatpak.Builder validate --pedantic packaging/app.organicmaps.desktop.metainfo.xml
|
||||
|
|
10
.github/workflows/cleanup_caches.yml
vendored
|
@ -9,18 +9,22 @@ jobs:
|
|||
cleanup:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Cleanup
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
REPO: ${{ github.repository }}
|
||||
BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge
|
||||
run: |
|
||||
gh extension install actions/gh-actions-cache
|
||||
|
||||
REPO=${{ github.repository }}
|
||||
BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge"
|
||||
|
||||
echo "Fetching list of cache key"
|
||||
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 )
|
||||
|
||||
## Setting this to not fail the workflow while deleting cache keys.
|
||||
## Setting this to not fail the workflow while deleting cache keys.
|
||||
set +e
|
||||
echo "Deleting caches..."
|
||||
for cacheKey in $cacheKeysForPR
|
||||
|
|
162
.github/workflows/coverage-check.yaml
vendored
|
@ -1,162 +0,0 @@
|
|||
name: Coverage Report
|
||||
on:
|
||||
workflow_dispatch: # Manual trigger
|
||||
pull_request:
|
||||
types:
|
||||
- opened
|
||||
- synchronize
|
||||
- labeled
|
||||
- unlabeled
|
||||
paths-ignore:
|
||||
- .gitignore
|
||||
- CONTRIBUTORS
|
||||
- LICENSE
|
||||
- NOTICE
|
||||
- README.md
|
||||
- docs/**
|
||||
- packaging/**
|
||||
- platform/*apple*
|
||||
- platform/*_android*
|
||||
- platform/*_ios*
|
||||
- platform/*_mac*
|
||||
- platform/*_win*
|
||||
- pyhelpers/**
|
||||
- tools/**
|
||||
- '!tools/python/test_server/**'
|
||||
- xcode/**
|
||||
|
||||
# Cancels previous jobs if the same branch or PR was updated again.
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-coverage-${{ github.event.pull_request.number || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
should-run-check:
|
||||
name: Should run coverage
|
||||
runs-on: ubuntu-24.04
|
||||
outputs:
|
||||
run-from-pr: ${{ steps.run-from-pr.outputs.run-from-pr }}
|
||||
manually-triggered: ${{ steps.manually-triggered.outputs.manually-triggered }}
|
||||
steps:
|
||||
- name: Check if PR has 'Coverage' label
|
||||
id: run-from-pr
|
||||
if: github.event_name == 'pull_request'
|
||||
env:
|
||||
PR_NUMBER: ${{ github.event.pull_request.number }}
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
LABEL_NAME="Coverage"
|
||||
LABELS=$(gh pr view https://github.com/$GITHUB_REPOSITORY/pull/$PR_NUMBER --json labels)
|
||||
if echo "$LABELS" | jq -e '.labels[].name' | grep -q "$LABEL_NAME"; then
|
||||
echo "run-from-pr=true" >> $GITHUB_OUTPUT
|
||||
echo "'Coverage' label found in PR."
|
||||
fi
|
||||
- name: Check if manually triggered
|
||||
id: manually-triggered
|
||||
if: github.event_name == 'workflow_dispatch'
|
||||
run: echo "manually-triggered=true" >> $GITHUB_OUTPUT
|
||||
|
||||
coverage:
|
||||
needs: should-run-check
|
||||
name: Generate coverage report
|
||||
runs-on: ubuntu-24.04
|
||||
if: ${{ needs.should-run-check.outputs.run-from-pr == 'true' || needs.should-run-check.outputs.manually-triggered == 'true'}}
|
||||
steps:
|
||||
- name: Free disk space by removing .NET, Android and Haskell
|
||||
shell: bash
|
||||
run: |
|
||||
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc
|
||||
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 100 # enough to get all commits for the current day
|
||||
|
||||
- name: Parallel submodules checkout
|
||||
shell: bash
|
||||
run: git submodule update --depth 1 --init --recursive --jobs=$(($(nproc) * 20))
|
||||
|
||||
- name: Install build tools and dependencies
|
||||
shell: bash
|
||||
run: |
|
||||
sudo apt update -y
|
||||
sudo apt install -y \
|
||||
ninja-build \
|
||||
libgl1-mesa-dev \
|
||||
libglvnd-dev \
|
||||
qt6-base-dev \
|
||||
libfreetype-dev \
|
||||
libharfbuzz-dev \
|
||||
libqt6svg6-dev \
|
||||
qt6-positioning-dev \
|
||||
libqt6positioning6-plugins \
|
||||
libqt6positioning6 \
|
||||
llvm \
|
||||
gcovr
|
||||
|
||||
- name: Configure repository
|
||||
shell: bash
|
||||
run: ./configure.sh
|
||||
|
||||
- name: Configure ccache
|
||||
uses: hendrikmuhs/ccache-action@v1.2
|
||||
with:
|
||||
key: ${{ github.workflow }}-coverage
|
||||
|
||||
- name: CMake
|
||||
shell: bash
|
||||
env:
|
||||
CC: clang-18
|
||||
CXX: clang++-18
|
||||
CMAKE_C_COMPILER_LAUNCHER: ccache
|
||||
CMAKE_CXX_COMPILER_LAUNCHER: ccache
|
||||
# -g1 should slightly reduce build time.
|
||||
run: |
|
||||
cmake . -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug \
|
||||
-DCMAKE_CXX_FLAGS=-g1 -DCOVERAGE_REPORT=ON
|
||||
|
||||
- name: Compile
|
||||
shell: bash
|
||||
working-directory: build
|
||||
run: ninja
|
||||
|
||||
- name: Tests
|
||||
shell: bash
|
||||
working-directory: build
|
||||
env:
|
||||
QT_QPA_PLATFORM: "offscreen"
|
||||
# generator_integration_tests - https://github.com/organicmaps/organicmaps/issues/225
|
||||
# opening_hours_integration_tests - https://github.com/organicmaps/organicmaps/issues/219
|
||||
# opening_hours_supported_features_tests - https://github.com/organicmaps/organicmaps/issues/219
|
||||
# routing_integration_tests - https://github.com/organicmaps/organicmaps/issues/221
|
||||
# shaders_tests - https://github.com/organicmaps/organicmaps/issues/223
|
||||
# world_feed_integration_tests - https://github.com/organicmaps/organicmaps/issues/215
|
||||
CTEST_EXCLUDE_REGEX: "generator_integration_tests|opening_hours_integration_tests|opening_hours_supported_features_tests|routing_benchmarks|routing_integration_tests|routing_quality_tests|search_quality_tests|storage_integration_tests|shaders_tests|world_feed_integration_tests"
|
||||
run: |
|
||||
sudo locale-gen en_US
|
||||
sudo locale-gen en_US.UTF-8
|
||||
sudo locale-gen es_ES
|
||||
sudo locale-gen es_ES.UTF-8
|
||||
sudo locale-gen fr_FR
|
||||
sudo locale-gen fr_FR.UTF-8
|
||||
sudo locale-gen ru_RU
|
||||
sudo locale-gen ru_RU.UTF-8
|
||||
sudo update-locale
|
||||
ctest -L "omim-test" -E "$CTEST_EXCLUDE_REGEX" --output-on-failure
|
||||
|
||||
- name: Run coverage report generation
|
||||
shell: bash
|
||||
working-directory: build
|
||||
run: |
|
||||
cmake --build . --target omim_coverage
|
||||
cat coverage_report/summary.txt
|
||||
|
||||
- name: Archive the coverage report
|
||||
working-directory: build/coverage_report
|
||||
run: zip -r coverage_report.zip html/
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: coverage-report
|
||||
path: build/coverage_report/coverage_report.zip
|
30
.github/workflows/desktop-file-check.yaml
vendored
|
@ -1,30 +0,0 @@
|
|||
name: Validate .desktop file
|
||||
on:
|
||||
workflow_dispatch: # Manual trigger
|
||||
pull_request:
|
||||
paths:
|
||||
- qt/res/app.organicmaps.desktop.desktop
|
||||
- .github/workflows/desktop-file-check.yaml # Run check on self change
|
||||
|
||||
jobs:
|
||||
validate-desktop-file:
|
||||
name: Validate .desktop file
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
sparse-checkout: |
|
||||
qt/res/app.organicmaps.desktop.desktop
|
||||
|
||||
- name: Install desktop-file-validate tool
|
||||
shell: bash
|
||||
run: |
|
||||
sudo apt update -y
|
||||
sudo apt install -y \
|
||||
desktop-file-utils
|
||||
|
||||
- name: Validate desktop file
|
||||
shell: bash
|
||||
run: desktop-file-validate qt/res/app.organicmaps.desktop.desktop && echo "Successfully validated .desktop file"
|
43
.github/workflows/ios-beta.yaml
vendored
|
@ -19,11 +19,6 @@ on:
|
|||
- docs/**
|
||||
- generator/**
|
||||
- packaging/**
|
||||
- platform/*_android*
|
||||
- platform/*_linux*
|
||||
- platform/*_mac*
|
||||
- platform/*qt*
|
||||
- platform/*_win*
|
||||
- pyhelpers/**
|
||||
- qt*/**
|
||||
- skin_generator/**
|
||||
|
@ -33,9 +28,8 @@ on:
|
|||
jobs:
|
||||
ios-beta:
|
||||
name: Apple TestFlight
|
||||
runs-on: macos-15
|
||||
runs-on: macos-12
|
||||
env:
|
||||
DEVELOPER_DIR: /Applications/Xcode_16.app/Contents/Developer
|
||||
LANG: en_US.UTF-8 # Fastlane complains that the terminal is using ASCII.
|
||||
LANGUAGE: en_US.UTF-8
|
||||
LC_ALL: en_US.UTF-8
|
||||
|
@ -52,35 +46,28 @@ jobs:
|
|||
- name: Parallel submodules checkout
|
||||
run: git submodule update --depth 1 --init --recursive --jobs=$(($(sysctl -n hw.logicalcpu) * 20))
|
||||
|
||||
- name: Restore beta keys
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p xcode/keys
|
||||
echo "$PRIVATE_H" | base64 -d > private.h
|
||||
echo "$APPSTORE_JSON" | base64 -d > xcode/keys/appstore.json
|
||||
echo "$CERTIFICATES_DEV_P12" | base64 -d > xcode/keys/CertificatesDev.p12
|
||||
echo "$CERTIFICATES_DISTR_P12" | base64 -d > xcode/keys/CertificatesDistr.p12
|
||||
env:
|
||||
PRIVATE_H: ${{ secrets.PRIVATE_H }}
|
||||
APPSTORE_JSON: ${{ secrets.APPSTORE_JSON }}
|
||||
CERTIFICATES_DEV_P12: ${{ secrets.CERTIFICATES_DEV_P12 }}
|
||||
CERTIFICATES_DISTR_P12: ${{ secrets.CERTIFICATES_DISTR_P12 }}
|
||||
- name: Checkout private keys
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: ${{ secrets.PRIVATE_REPO }}
|
||||
ssh-key: ${{ secrets.PRIVATE_SSH_KEY }}
|
||||
ref: master
|
||||
path: private.git
|
||||
|
||||
- name: Configure repository
|
||||
shell: bash
|
||||
run: ./configure.sh
|
||||
- name: Configure repo with private keys
|
||||
run: |
|
||||
./configure.sh ./private.git
|
||||
rm -rf ./private.git
|
||||
|
||||
- name: Compile and upload to TestFlight
|
||||
run: |
|
||||
echo "IOS_VERSION=$(../tools/unix/version.sh ios_version)-$(../tools/unix/version.sh ios_build)" >> "$GITHUB_ENV"
|
||||
./fastlane.sh upload_testflight
|
||||
run: ./fastlane.sh upload_testflight
|
||||
env:
|
||||
APPSTORE_CERTIFICATE_PASSWORD: '${{ secrets.APPSTORE_CERTIFICATE_PASSWORD }}'
|
||||
working-directory: xcode
|
||||
|
||||
- name: Upload ipa and DSYMs artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ipa and DSYM archive ${{ env.IOS_VERSION }}
|
||||
name: ipa and DSYM archive
|
||||
path: xcode/build/*
|
||||
if-no-files-found: error
|
||||
|
|
5
.github/workflows/ios-check-metadata.yaml
vendored
|
@ -14,11 +14,6 @@ jobs:
|
|||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
sparse-checkout: |
|
||||
iphone/metadata
|
||||
tools/python/check_store_metadata.py
|
||||
|
||||
- name: Check metadata
|
||||
run: ./tools/python/check_store_metadata.py ios
|
||||
|
|
53
.github/workflows/ios-check.yaml
vendored
|
@ -21,11 +21,6 @@ on:
|
|||
- generator/**
|
||||
- iphone/metadata/**
|
||||
- packaging/**
|
||||
- platform/*_android*
|
||||
- platform/*_linux*
|
||||
- platform/*_mac*
|
||||
- platform/*qt*
|
||||
- platform/*_win*
|
||||
- pyhelpers/**
|
||||
- qt*/**
|
||||
- skin_generator/**
|
||||
|
@ -35,13 +30,11 @@ on:
|
|||
jobs:
|
||||
ios-check:
|
||||
name: Build iOS
|
||||
runs-on: macos-15
|
||||
runs-on: macos-12
|
||||
env:
|
||||
DEVELOPER_DIR: /Applications/Xcode_16.app/Contents/Developer
|
||||
LANG: en_US.UTF-8 # Fastlane complains that the terminal is using ASCII.
|
||||
LANGUAGE: en_US.UTF-8
|
||||
LC_ALL: en_US.UTF-8
|
||||
TEST_RESULTS_BUNDLE_NAME: OMaps-Test-Results
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
|
@ -59,48 +52,24 @@ jobs:
|
|||
shell: bash
|
||||
run: git submodule update --depth 1 --init --recursive --jobs=$(($(sysctl -n hw.logicalcpu) * 20))
|
||||
|
||||
- name: Configure repository
|
||||
- name: Configure
|
||||
shell: bash
|
||||
run: ./configure.sh
|
||||
|
||||
- name: Configure XCode cache
|
||||
uses: irgaly/xcode-cache@v1
|
||||
- name: Configure ccache
|
||||
uses: mikehardy/buildcache-action@v2.1.0
|
||||
with:
|
||||
key: xcode-cache-deriveddata-${{ github.workflow }}-${{ matrix.buildType }}-${{ github.sha }}
|
||||
restore-keys: xcode-cache-deriveddata-${{ github.workflow }}-${{ matrix.buildType }}
|
||||
cache_key: ${{ github.workflow }}-${{ matrix.buildType }}
|
||||
|
||||
- name: Build and Run Tests (Debug)
|
||||
if: matrix.buildType == 'Debug'
|
||||
- name: Compile
|
||||
shell: bash
|
||||
# Check for compilation errors.
|
||||
run: |
|
||||
xcodebuild test \
|
||||
xcodebuild \
|
||||
CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ \
|
||||
-workspace xcode/omim.xcworkspace \
|
||||
-scheme OMaps \
|
||||
-configuration Debug \
|
||||
-sdk iphonesimulator \
|
||||
-destination 'platform=iOS Simulator,name=iPhone 16 Pro Max,OS=latest' \
|
||||
-quiet \
|
||||
-resultBundlePath ${{ env.TEST_RESULTS_BUNDLE_NAME }}.xcresult \
|
||||
-configuration ${{ matrix.buildType }} build \
|
||||
'generic/platform=iOS' \
|
||||
CODE_SIGNING_REQUIRED=NO \
|
||||
CODE_SIGNING_ALLOWED=NO
|
||||
|
||||
- name: Upload Test Results On Failure (Debug)
|
||||
if: ${{ matrix.buildType == 'Debug' && failure() }}
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ env.TEST_RESULTS_BUNDLE_NAME }}-${{ github.run_number }}.xcresult
|
||||
path: ${{ env.TEST_RESULTS_BUNDLE_NAME }}.xcresult
|
||||
if-no-files-found: error
|
||||
|
||||
- name: Build (Release)
|
||||
if: matrix.buildType == 'Release'
|
||||
shell: bash
|
||||
run: |
|
||||
xcodebuild build \
|
||||
-workspace xcode/omim.xcworkspace \
|
||||
-scheme OMaps \
|
||||
-configuration Release \
|
||||
-destination 'generic/platform=iOS' \
|
||||
-quiet \
|
||||
CODE_SIGNING_REQUIRED=NO \
|
||||
CODE_SIGNING_ALLOWED=NO
|
22
.github/workflows/ios-release.yaml
vendored
|
@ -5,24 +5,30 @@ on:
|
|||
jobs:
|
||||
ios-release:
|
||||
name: iOS Release
|
||||
runs-on: macos-15
|
||||
runs-on: macos-12
|
||||
env:
|
||||
DEVELOPER_DIR: /Applications/Xcode_16.app/Contents/Developer
|
||||
LANG: en_US.UTF-8 # Fastlane complains that the terminal is using ASCII.
|
||||
LANGUAGE: en_US.UTF-8
|
||||
LC_ALL: en_US.UTF-8
|
||||
environment: production
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Restore release keys
|
||||
- name: Checkout private keys
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: ${{ secrets.PRIVATE_REPO }}
|
||||
ssh-key: ${{ secrets.PRIVATE_SSH_KEY }}
|
||||
ref: master
|
||||
path: ./private.git
|
||||
|
||||
- name: Configure repo with private keys
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p xcode/keys
|
||||
echo "$APPSTORE_JSON" | base64 -d > xcode/keys/appstore.json
|
||||
env:
|
||||
APPSTORE_JSON: ${{ secrets.APPSTORE_JSON }}
|
||||
mkdir -p xcode/keys/
|
||||
cp -p ./private.git/xcode/keys/appstore.json xcode/keys/
|
||||
rm -rf ./private.git
|
||||
|
||||
- name: Checkout screenshots
|
||||
uses: actions/checkout@v4
|
||||
|
|
38
.github/workflows/linux-check.yaml
vendored
|
@ -18,11 +18,6 @@ on:
|
|||
- data/strings/**
|
||||
- docs/**
|
||||
- packaging/**
|
||||
- platform/*apple*
|
||||
- platform/*_android*
|
||||
- platform/*_ios*
|
||||
- platform/*_mac*
|
||||
- platform/*_win*
|
||||
- pyhelpers/**
|
||||
- tools/**
|
||||
- '!tools/python/test_server/**'
|
||||
|
@ -31,7 +26,7 @@ on:
|
|||
jobs:
|
||||
linux-no-unity:
|
||||
name: Linux no unity build
|
||||
runs-on: ubuntu-24.04
|
||||
runs-on: ubuntu-22.04
|
||||
# Cancels previous jobs if the same branch or PR was updated again.
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-no-unity-${{ github.event.pull_request.number || github.ref }}
|
||||
|
@ -60,18 +55,13 @@ jobs:
|
|||
ninja-build \
|
||||
libgl1-mesa-dev \
|
||||
libglvnd-dev \
|
||||
libharfbuzz-dev \
|
||||
libxrandr-dev \
|
||||
libxinerama-dev \
|
||||
libxcursor-dev \
|
||||
libxi-dev \
|
||||
qt6-base-dev \
|
||||
libqt6svg6-dev \
|
||||
qt6-positioning-dev \
|
||||
libqt6positioning6-plugins \
|
||||
libqt6positioning6
|
||||
|
||||
- name: Configure repository
|
||||
- name: Configure
|
||||
shell: bash
|
||||
run: ./configure.sh
|
||||
|
||||
|
@ -83,8 +73,8 @@ jobs:
|
|||
- name: CMake
|
||||
shell: bash
|
||||
env:
|
||||
CC: clang-18
|
||||
CXX: clang++-18
|
||||
CC: clang-14
|
||||
CXX: clang++-14
|
||||
CMAKE_C_COMPILER_LAUNCHER: ccache
|
||||
CMAKE_CXX_COMPILER_LAUNCHER: ccache
|
||||
# -g1 should slightly reduce build time.
|
||||
|
@ -99,11 +89,11 @@ jobs:
|
|||
|
||||
linux-matrix:
|
||||
name: Linux builds and tests
|
||||
runs-on: ubuntu-24.04
|
||||
runs-on: ubuntu-22.04
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
compiler: [{ CXX: g++-14, CC: gcc-14 }, { CXX: clang++-18, CC: clang-18 }]
|
||||
compiler: [{ CXX: g++-12, CC: gcc-12 }, { CXX: clang++-14, CC: clang-14 }]
|
||||
CMAKE_BUILD_TYPE: [Debug, RelWithDebInfo]
|
||||
# Cancels previous jobs if the same branch or PR was updated again.
|
||||
concurrency:
|
||||
|
@ -128,21 +118,18 @@ jobs:
|
|||
run: |
|
||||
sudo apt update -y
|
||||
sudo apt install -y \
|
||||
g++-12 \
|
||||
gcc-12 \
|
||||
ninja-build \
|
||||
libgl1-mesa-dev \
|
||||
libglvnd-dev \
|
||||
libharfbuzz-dev \
|
||||
libxrandr-dev \
|
||||
libxinerama-dev \
|
||||
libxcursor-dev \
|
||||
libxi-dev \
|
||||
qt6-base-dev \
|
||||
libqt6svg6-dev \
|
||||
qt6-positioning-dev \
|
||||
libqt6positioning6-plugins \
|
||||
libqt6positioning6
|
||||
|
||||
- name: Configure repository
|
||||
- name: Configure
|
||||
shell: bash
|
||||
run: ./configure.sh
|
||||
|
||||
|
@ -173,14 +160,14 @@ jobs:
|
|||
shell: bash
|
||||
working-directory: build
|
||||
env:
|
||||
QT_QPA_PLATFORM: "offscreen"
|
||||
# drape_tests - requires X Window
|
||||
# generator_integration_tests - https://github.com/organicmaps/organicmaps/issues/225
|
||||
# opening_hours_integration_tests - https://github.com/organicmaps/organicmaps/issues/219
|
||||
# opening_hours_supported_features_tests - https://github.com/organicmaps/organicmaps/issues/219
|
||||
# routing_integration_tests - https://github.com/organicmaps/organicmaps/issues/221
|
||||
# shaders_tests - https://github.com/organicmaps/organicmaps/issues/223
|
||||
# world_feed_integration_tests - https://github.com/organicmaps/organicmaps/issues/215
|
||||
CTEST_EXCLUDE_REGEX: "generator_integration_tests|opening_hours_integration_tests|opening_hours_supported_features_tests|routing_benchmarks|routing_integration_tests|routing_quality_tests|search_quality_tests|storage_integration_tests|shaders_tests|world_feed_integration_tests"
|
||||
CTEST_EXCLUDE_REGEX: "drape_tests|generator_integration_tests|opening_hours_integration_tests|opening_hours_supported_features_tests|routing_benchmarks|routing_integration_tests|routing_quality_tests|search_quality_tests|storage_integration_tests|shaders_tests|world_feed_integration_tests"
|
||||
run: |
|
||||
sudo locale-gen en_US
|
||||
sudo locale-gen en_US.UTF-8
|
||||
|
@ -191,4 +178,5 @@ jobs:
|
|||
sudo locale-gen ru_RU
|
||||
sudo locale-gen ru_RU.UTF-8
|
||||
sudo update-locale
|
||||
ctest -L "omim-test" -E "$CTEST_EXCLUDE_REGEX" --output-on-failure
|
||||
ln -s ../data data
|
||||
ctest -LE "fixture" -E "$CTEST_EXCLUDE_REGEX" --output-on-failure
|
||||
|
|
14
.github/workflows/macos-check.yaml
vendored
|
@ -18,10 +18,6 @@ on:
|
|||
- data/strings/**
|
||||
- docs/**
|
||||
- packaging/**
|
||||
- platform/*_android*
|
||||
- platform/*_ios*
|
||||
- platform/*_linux*
|
||||
- platform/*_win*
|
||||
- pyhelpers/**
|
||||
- tools/**
|
||||
- '!tools/python/test_server/**'
|
||||
|
@ -30,9 +26,8 @@ on:
|
|||
jobs:
|
||||
macos-matrix:
|
||||
name: macOS builds and tests
|
||||
runs-on: macos-15
|
||||
runs-on: macos-12
|
||||
env:
|
||||
DEVELOPER_DIR: /Applications/Xcode_16.app/Contents/Developer
|
||||
HOMEBREW_NO_ANALYTICS: 1
|
||||
HOMEBREW_NO_INSTALL_CLEANUP: 1
|
||||
strategy:
|
||||
|
@ -55,9 +50,9 @@ jobs:
|
|||
- name: Install build tools and dependencies
|
||||
shell: bash
|
||||
run: |
|
||||
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 brew install ninja qt@6
|
||||
brew install ninja qt@6
|
||||
|
||||
- name: Configure repository
|
||||
- name: Configure
|
||||
shell: bash
|
||||
run: ./configure.sh
|
||||
|
||||
|
@ -94,4 +89,5 @@ jobs:
|
|||
# world_feed_integration_tests - https://github.com/organicmaps/organicmaps/issues/215
|
||||
CTEST_EXCLUDE_REGEX: "drape_tests|generator_integration_tests|opening_hours_integration_tests|opening_hours_supported_features_tests|routing_benchmarks|routing_integration_tests|routing_quality_tests|search_quality_tests|storage_integration_tests|shaders_tests|world_feed_integration_tests"
|
||||
run: |
|
||||
ctest -L "omim-test" -E "$CTEST_EXCLUDE_REGEX" --output-on-failure
|
||||
ln -s ../data data
|
||||
ctest -LE "fixture" -E "$CTEST_EXCLUDE_REGEX" --output-on-failure
|
||||
|
|
22
.github/workflows/stale.yml
vendored
|
@ -1,22 +0,0 @@
|
|||
name: Close stale PRs
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 0 * * *" # Runs every day at midnight
|
||||
|
||||
jobs:
|
||||
stale:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
pull-requests: write
|
||||
steps:
|
||||
- uses: actions/stale@v9
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
days-before-pr-stale: 180 # 6 months before warning
|
||||
days-before-pr-close: 365 # Closed after 12 months
|
||||
stale-pr-label: "stale"
|
||||
stale-pr-message: "Hi! This PR has been inactive for 6 months. If it's still relevant, please update it to let us know you’d like to keep it open 😊"
|
||||
close-pr-message: "This PR has been automatically closed after 12 months of inactivity."
|
||||
days-before-issue-stale: -1 # Issues are never stale
|
||||
days-before-issue-close: -1 # Issues are never closed
|
||||
remove-stale-when-updated: true
|
26
.github/workflows/strings-check.yaml
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
name: Validate translation strings
|
||||
on:
|
||||
workflow_dispatch: # Manual trigger
|
||||
pull_request:
|
||||
paths:
|
||||
- .github/workflows/strings-check.yaml # Run check on self change
|
||||
- data/countries_names.txt
|
||||
- data/strings/*
|
||||
- tools/python/strings_utils.py
|
||||
|
||||
jobs:
|
||||
validate-translation-strings:
|
||||
name: Validate translation strings
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3'
|
||||
|
||||
- name: Validate strings.txt and types_strings.txt files
|
||||
shell: bash
|
||||
run: |
|
||||
./tools/python/strings_utils.py --validate
|
||||
./tools/python/strings_utils.py --types-strings --validate
|
10
.gitignore
vendored
|
@ -16,11 +16,10 @@ screenlog.0
|
|||
|
||||
data/styles/*/*/out/*
|
||||
data/resources-*_design/*
|
||||
data/drules_proto_default_design.bin
|
||||
data/drules_proto_design.bin
|
||||
data/colors_design.txt
|
||||
data/patterns_design.txt
|
||||
data/bookmarks
|
||||
data/edits.xml
|
||||
|
||||
# Compiled Python
|
||||
*.pyc
|
||||
|
@ -85,7 +84,7 @@ data/[0-9][0-9][0-9][0-9][0-9][0-9]
|
|||
data/gps_track.dat
|
||||
# temporary files for downloader
|
||||
data/settings.ini
|
||||
data/test_data/world_feed_integration_tests_data
|
||||
data/world_feed_integration_tests_data
|
||||
|
||||
# benchmark results
|
||||
data/benchmarks/*.trace
|
||||
|
@ -124,7 +123,6 @@ tizen/*/.*
|
|||
tizen/*/crash-info/*
|
||||
.idea/*
|
||||
.idea
|
||||
!android/.idea/icon.svg
|
||||
|
||||
# Private repository files.
|
||||
.private_repository_url
|
||||
|
@ -147,7 +145,6 @@ iphone/Maps/app.omaps/
|
|||
|
||||
*.autosave
|
||||
|
||||
# CMake
|
||||
cmake-build-*
|
||||
build/
|
||||
|
||||
|
@ -178,9 +175,6 @@ tools/python/routing/etc/*.ini
|
|||
/node_modules/
|
||||
/package-lock.json
|
||||
|
||||
# Visual Studio
|
||||
.vs
|
||||
|
||||
# VS Code
|
||||
.vscode
|
||||
|
||||
|
|
60
.gitmodules
vendored
|
@ -1,23 +1,29 @@
|
|||
[submodule "tools/osmctools"]
|
||||
path = tools/osmctools
|
||||
url = https://git.omaps.dev/organicmaps/osmctools.git
|
||||
url = https://github.com/organicmaps/osmctools.git
|
||||
[submodule "tools/kothic"]
|
||||
path = tools/kothic
|
||||
url = https://git.omaps.dev/organicmaps/kothic.git
|
||||
url = https://github.com/organicmaps/kothic.git
|
||||
[submodule "tools/macdeployqtfix"]
|
||||
path = tools/macdeployqtfix
|
||||
url = https://github.com/aurelien-rainone/macdeployqtfix.git
|
||||
[submodule "3party/protobuf/protobuf"]
|
||||
path = 3party/protobuf/protobuf
|
||||
url = https://git.omaps.dev/organicmaps/protobuf.git
|
||||
url = https://github.com/organicmaps/protobuf.git
|
||||
[submodule "tools/twine"]
|
||||
path = tools/twine
|
||||
url = https://github.com/organicmaps/twine.git
|
||||
[submodule "3party/Vulkan-Headers"]
|
||||
path = 3party/Vulkan-Headers
|
||||
url = https://github.com/KhronosGroup/Vulkan-Headers.git
|
||||
[submodule "3party/boost"]
|
||||
path = 3party/boost
|
||||
url = https://github.com/boostorg/boost.git
|
||||
branch = boost-1.85.0
|
||||
branch = boost-1.76.0
|
||||
ignore = dirty
|
||||
[submodule "3party/just_gtfs"]
|
||||
path = 3party/just_gtfs
|
||||
url = https://git.omaps.dev/organicmaps/just_gtfs.git
|
||||
url = https://github.com/organicmaps/just_gtfs.git
|
||||
branch = for-usage-as-submodule
|
||||
[submodule "3party/expat"]
|
||||
path = 3party/expat
|
||||
|
@ -30,38 +36,26 @@
|
|||
path = 3party/icu/icu
|
||||
url = https://github.com/unicode-org/icu.git
|
||||
[submodule "3party/freetype/freetype"]
|
||||
path = 3party/freetype/freetype
|
||||
url = https://git.omaps.dev/organicmaps/freetype.git
|
||||
path = 3party/freetype/freetype
|
||||
url = https://github.com/organicmaps/freetype.git
|
||||
[submodule "3party/googletest"]
|
||||
path = 3party/googletest
|
||||
url = https://github.com/google/googletest.git
|
||||
path = 3party/googletest
|
||||
url = https://github.com/google/googletest.git
|
||||
[submodule "3party/fast_double_parser"]
|
||||
path = 3party/fast_double_parser
|
||||
url = https://github.com/lemire/fast_double_parser.git
|
||||
path = 3party/fast_double_parser
|
||||
url = https://github.com/lemire/fast_double_parser.git
|
||||
[submodule "3party/pugixml/pugixml"]
|
||||
path = 3party/pugixml/pugixml
|
||||
url = https://github.com/zeux/pugixml.git
|
||||
path = 3party/pugixml/pugixml
|
||||
url = https://github.com/zeux/pugixml.git
|
||||
[submodule "3party/jansson/jansson"]
|
||||
path = 3party/jansson/jansson
|
||||
url = https://github.com/akheron/jansson.git
|
||||
path = 3party/jansson/jansson
|
||||
url = https://github.com/akheron/jansson.git
|
||||
[submodule "3party/gflags"]
|
||||
path = 3party/gflags
|
||||
url = https://github.com/gflags/gflags
|
||||
path = 3party/gflags
|
||||
url = https://github.com/gflags/gflags
|
||||
[submodule "3party/fast_obj"]
|
||||
path = 3party/fast_obj
|
||||
url = https://github.com/thisistherk/fast_obj
|
||||
path = 3party/fast_obj
|
||||
url = https://github.com/thisistherk/fast_obj
|
||||
[submodule "3party/harfbuzz/harfbuzz"]
|
||||
path = 3party/harfbuzz/harfbuzz
|
||||
url = https://github.com/harfbuzz/harfbuzz.git
|
||||
[submodule "3party/utfcpp"]
|
||||
path = 3party/utfcpp
|
||||
url = https://github.com/nemtrif/utfcpp.git
|
||||
[submodule "3party/glfw"]
|
||||
path = 3party/glfw
|
||||
url = https://github.com/glfw/glfw.git
|
||||
[submodule "3party/CMake-MetalShaderSupport"]
|
||||
path = 3party/CMake-MetalShaderSupport
|
||||
url = https://github.com/dpogue/CMake-MetalShaderSupport.git
|
||||
[submodule "3party/imgui/imgui"]
|
||||
path = 3party/imgui/imgui
|
||||
url = https://github.com/ocornut/imgui
|
||||
path = 3party/harfbuzz/harfbuzz
|
||||
url = https://github.com/harfbuzz/harfbuzz.git
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 989857d2e5e54869c35ad06fb21a67d12a2dbc67
|
|
@ -3,14 +3,10 @@
|
|||
set(CMAKE_WARN_DEPRECATED OFF CACHE BOOL "" FORCE)
|
||||
|
||||
if (NOT WITH_SYSTEM_PROVIDED_3PARTY)
|
||||
# Suppress "Policy CMP0077 is not set: option() honors normal variables"
|
||||
# for the freetype, expat and jansson options.
|
||||
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
|
||||
# Suppress "Policy CMP0063 is not set: Honor visibility properties for all target types."
|
||||
# for jansson
|
||||
set(CMAKE_POLICY_DEFAULT_CMP0063 NEW)
|
||||
|
||||
# Configure expat library.
|
||||
# Suppress "Policy CMP0077 is not set: option() honors normal variables"
|
||||
# for the expat options below.
|
||||
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
|
||||
set(EXPAT_BUILD_TOOLS OFF)
|
||||
set(EXPAT_BUILD_EXAMPLES OFF)
|
||||
set(EXPAT_BUILD_TESTS OFF)
|
||||
|
@ -18,9 +14,6 @@ if (NOT WITH_SYSTEM_PROVIDED_3PARTY)
|
|||
set(EXPAT_BUILD_PKGCONFIG OFF)
|
||||
set(EXPAT_ENABLE_INSTALL OFF)
|
||||
set(EXPAT_SHARED_LIBS OFF)
|
||||
set(EXPAT_GE OFF)
|
||||
set(EXPAT_DTD OFF)
|
||||
set(EXPAT_NS ON)
|
||||
add_subdirectory(expat/expat)
|
||||
|
||||
# Configure Jansson library.
|
||||
|
@ -31,7 +24,6 @@ if (NOT WITH_SYSTEM_PROVIDED_3PARTY)
|
|||
set(JANSSON_WITHOUT_TESTS ON)
|
||||
add_subdirectory(jansson/jansson/)
|
||||
target_include_directories(jansson INTERFACE "${PROJECT_BINARY_DIR}/3party/jansson/jansson/include")
|
||||
add_library(jansson::jansson ALIAS jansson)
|
||||
|
||||
# Add gflags library.
|
||||
add_subdirectory(gflags)
|
||||
|
@ -42,23 +34,22 @@ if (NOT WITH_SYSTEM_PROVIDED_3PARTY)
|
|||
|
||||
# Add protobuf library.
|
||||
add_subdirectory(protobuf)
|
||||
|
||||
if (NOT PLATFORM_LINUX)
|
||||
add_subdirectory(freetype)
|
||||
add_subdirectory(icu)
|
||||
add_subdirectory(harfbuzz)
|
||||
endif()
|
||||
|
||||
add_library(utf8cpp INTERFACE)
|
||||
add_library(utf8cpp::utf8cpp ALIAS utf8cpp)
|
||||
target_include_directories(utf8cpp INTERFACE "${OMIM_ROOT}/3party/utfcpp/source")
|
||||
endif()
|
||||
|
||||
add_subdirectory(agg)
|
||||
add_subdirectory(bsdiff-courgette)
|
||||
|
||||
if (NOT LINUX_DETECTED)
|
||||
add_subdirectory(freetype)
|
||||
add_subdirectory(icu)
|
||||
endif()
|
||||
|
||||
add_subdirectory(harfbuzz)
|
||||
add_subdirectory(liboauthcpp)
|
||||
add_subdirectory(minizip)
|
||||
add_subdirectory(open-location-code)
|
||||
add_subdirectory(opening_hours)
|
||||
add_subdirectory(sdf_image)
|
||||
add_subdirectory(stb_image)
|
||||
add_subdirectory(succinct)
|
||||
|
||||
|
@ -66,19 +57,4 @@ add_subdirectory(vulkan_wrapper)
|
|||
|
||||
if (PLATFORM_DESKTOP)
|
||||
add_subdirectory(libtess2)
|
||||
|
||||
set(GLFW_BUILD_DOCS OFF CACHE BOOL "")
|
||||
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "")
|
||||
set(GLFW_BUILD_TESTS OFF CACHE BOOL "")
|
||||
set(GLFW_INSTALL OFF CACHE BOOL "")
|
||||
set(GLFW_VULKAN_STATIC OFF CACHE BOOL "")
|
||||
set(GLFW_BUILD_WAYLAND OFF CACHE BOOL "")
|
||||
# Disable ARC for glfw and re-enable after it because it's globally set in the root CMakeLists.txt
|
||||
set(CMAKE_OBJC_FLAGS "")
|
||||
add_subdirectory(glfw)
|
||||
set_target_properties(glfw PROPERTIES UNITY_BUILD OFF)
|
||||
set_target_properties(glfw PROPERTIES XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC NO)
|
||||
set(CMAKE_OBJC_FLAGS -fobjc-arc)
|
||||
|
||||
add_subdirectory(imgui)
|
||||
endif()
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 595c8d4794410a4e64b98dc58d27c0310d7ea2fd
|
||||
Subproject commit 83e1a9ed8ce289cebb1c02c8167d663dc1befb24
|
|
@ -1 +1 @@
|
|||
Subproject commit ab7968a0bbcf574a7859240d1d8443f58ed6f6cf
|
||||
Subproject commit 564e2ac16907019696cdaba8a93e3588ec596062
|
|
@ -1 +1 @@
|
|||
Subproject commit a0dc7d5efacbe2b744211289c276e2b9168bd4ae
|
||||
Subproject commit 654d2de0da85662fcc7644a7acd7c2dd2cfb21f0
|
|
@ -1 +1 @@
|
|||
Subproject commit 252029ddac664370bdda3f0761675785d92a1573
|
||||
Subproject commit efec03532ef65984786e5e32dbc81f6e6a55a115
|
|
@ -1 +1 @@
|
|||
Subproject commit 42629f744269e004907a6fb4f16c6c7f69acc586
|
||||
Subproject commit 1a8060257a96401a9555a476bd13c3a87502c9b5
|
|
@ -1 +1 @@
|
|||
Subproject commit 97069edd163b66ce11e8152bee3055b2fa627e15
|
||||
Subproject commit e4586d960f339cf75e2e0b34aee30a0ed8353c0d
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 21fea01161e0d6b70c0c5c1f52dc8e7a7df14a50
|
|
@ -17,7 +17,6 @@ target_compile_options(${PROJECT_NAME}
|
|||
-fno-rtti
|
||||
-fno-exceptions
|
||||
-fno-threadsafe-statics
|
||||
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:-Wno-format-pedantic>
|
||||
)
|
||||
|
||||
target_compile_definitions(${PROJECT_NAME}
|
||||
|
@ -37,5 +36,3 @@ target_compile_definitions(${PROJECT_NAME}
|
|||
)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} Freetype::Freetype)
|
||||
|
||||
add_library(harfbuzz::harfbuzz ALIAS harfbuzz)
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 788b469ad5e5f78611f665b6eb17afd0eb040f21
|
||||
Subproject commit e8eb1dc5ff695427abc137d3d15c4eec64ab6c78
|
|
@ -32,13 +32,10 @@ add_library(icuuc
|
|||
icu/icu4c/source/common/locbased.h
|
||||
icu/icu4c/source/common/locid.cpp
|
||||
icu/icu4c/source/common/loclikely.cpp
|
||||
icu/icu4c/source/common/loclikelysubtags.cpp
|
||||
icu/icu4c/source/common/loclikelysubtags.h
|
||||
icu/icu4c/source/common/locmap.cpp
|
||||
icu/icu4c/source/common/locutil.cpp
|
||||
icu/icu4c/source/common/locutil.h
|
||||
icu/icu4c/source/common/lsr.h
|
||||
icu/icu4c/source/common/lsr.cpp
|
||||
icu/icu4c/source/common/messageimpl.h
|
||||
icu/icu4c/source/common/msvcres.h
|
||||
icu/icu4c/source/common/mutex.h
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 7750081bda4b3bc1768ae03849ec70f67ea10625
|
||||
Subproject commit 680f521746a3bd6a86f25f25ee50a62d88b489cf
|
|
@ -1,16 +0,0 @@
|
|||
project(imgui)
|
||||
|
||||
set(SRC
|
||||
imgui/imgui_draw.cpp
|
||||
imgui/imgui_tables.cpp
|
||||
imgui/imgui_widgets.cpp
|
||||
imgui/imgui.cpp
|
||||
imgui/backends/imgui_impl_glfw.cpp
|
||||
)
|
||||
|
||||
add_library(${PROJECT_NAME} ${SRC})
|
||||
target_include_directories(${PROJECT_NAME}
|
||||
PRIVATE ${OMIM_ROOT}/3party/glfw/include
|
||||
PUBLIC ${OMIM_ROOT}/3party/imgui/imgui
|
||||
PUBLIC .
|
||||
)
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 6982ce43f5b143c5dce5fab0ce07dd4867b705ae
|
|
@ -1 +1 @@
|
|||
Subproject commit 61fc3d0e28e1a35410af42e329cd977095ec32d2
|
||||
Subproject commit e23f5580072cb64ce3ab27de2b5110d7ac252424
|
9
3party/liboauthcpp/.gitignore
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
# Build (by)products
|
||||
build/CMakeCache.txt
|
||||
build/CMakeFiles
|
||||
build/Makefile
|
||||
build/cmake_install.cmake
|
||||
build/liboauthcpp.a
|
||||
build/simple_auth
|
||||
build/simple_request
|
||||
build/tests
|
21
3party/liboauthcpp/CMakeLists.txt
Normal file
|
@ -0,0 +1,21 @@
|
|||
project(oauthcpp)
|
||||
|
||||
set(SRC
|
||||
include/liboauthcpp/liboauthcpp.h
|
||||
src/base64.cpp
|
||||
src/HMAC_SHA1.cpp
|
||||
src/SHA1.cpp
|
||||
src/urlencode.cpp
|
||||
src/liboauthcpp.cpp
|
||||
)
|
||||
|
||||
add_library(${PROJECT_NAME} ${SRC})
|
||||
|
||||
target_include_directories(${PROJECT_NAME}
|
||||
PRIVATE src
|
||||
PUBLIC include
|
||||
)
|
||||
|
||||
target_compile_options(${PROJECT_NAME}
|
||||
PRIVATE $<$<CXX_COMPILER_ID:AppleClang,Clang>:-Wno-shorten-64-to-32>
|
||||
)
|
21
3party/liboauthcpp/LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
|||
Copyright (c) 2011 Stanford University (liboauthcpp)
|
||||
Copyright (C) 2011 by swatkat (swatkat.thinkdigitATgmailDOTcom) (libtwitcurl)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
172
3party/liboauthcpp/README.md
Normal file
|
@ -0,0 +1,172 @@
|
|||
liboauthcpp
|
||||
-----------
|
||||
|
||||
liboauthcpp is a pure C++ library for performing OAuth requests. It
|
||||
doesn't contain any networking code -- you provide for performing HTTP
|
||||
requests yourself, however you like -- instead focusing on performing
|
||||
OAuth-specific functionality and providing a nice interface for it.
|
||||
If you already have infrastructure for making HTTP requests and are
|
||||
looking to add OAuth support, liboauthcpp is for you.
|
||||
|
||||
liboauthcpp currently implements OAuth 1.0a (see
|
||||
http://tools.ietf.org/html/rfc5849).
|
||||
|
||||
Buildbot
|
||||
--------
|
||||
[](http://travis-ci.org/sirikata/liboauthcpp)
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
You should only need:
|
||||
|
||||
* CMake
|
||||
* A C++ compiler for your platform (e.g. g++, Microsoft Visual C++)
|
||||
|
||||
Compiling
|
||||
---------
|
||||
|
||||
The build process is simple:
|
||||
|
||||
cd liboauthcpp
|
||||
cd build
|
||||
cmake .
|
||||
make # or open Visual Studio and build the solution
|
||||
|
||||
If your own project uses CMake you can also include
|
||||
build/CMakeLists.txt directly into your project and reference the
|
||||
target "oauthcpp", a static library, in your project.
|
||||
|
||||
Percent (URL) Encoding
|
||||
----------------------
|
||||
|
||||
To get correct results, you need to pass your URL properly encoded to
|
||||
liboauthcpp. If you are not at all familiar, you should probably start
|
||||
by reading the [URI Spec](http://tools.ietf.org/html/rfc3986), especially
|
||||
Section 2. Alternatively,
|
||||
[this article](http://blog.lunatech.com/2009/02/03/what-every-web-developer-must-know-about-url-encoding)
|
||||
gives a more readable overview.
|
||||
|
||||
The basic idea is that there are 3 classes of characters: reserved,
|
||||
unreserved, and other. Reserved characters are special characters that
|
||||
are used in the URI syntax itself, e.g. ':' (after the scheme), '/'
|
||||
(the hierarchical path separator), and '?' (prefixing the query
|
||||
string). Unreserved characters are characters that are always safe to
|
||||
include unencoded, e.g. the alphanumerics. Other characters must
|
||||
always be encoded, mainly covering special characters like ' ', '<' or
|
||||
'>', and '{' or '}'.
|
||||
|
||||
The basic rule is that reserved characters must be encoded if they
|
||||
appear in any part of the URI when not being used as a
|
||||
separator. Unreserved characters are always safe. And the other
|
||||
characters they didn't know if they would be safe or not so they must
|
||||
always be encoded.
|
||||
|
||||
Unfortunately, the reserved set is a bit more complicated. They are
|
||||
broken down into 'general delimiters' and 'sub delimiters'. The ones
|
||||
already mentioned, like ':', can appear in many forms of URIs (say,
|
||||
http, ftp, about, gopher, mailto, etc. Those are called general
|
||||
delimiters. Others (e.g. '(', ')', '!', '$', '+', ',', '=', and more)
|
||||
are called subdelimiters because their use depends on the URI
|
||||
scheme. Worse, their use depends on the *part of the URI*. Depending
|
||||
on the particular URI scheme, these may or may not have to be encoded,
|
||||
and it might also depend on where they appear. (As an example, an '&'
|
||||
in an http URI isn't an issue if it appears in the path -- before the
|
||||
query string -- i.e. before a '?' appears. Worse, '=' can appear unencoded in
|
||||
the path, or in a query parameter value, but not in a query parameter key since
|
||||
it would be interpreted as the end of the key.)
|
||||
|
||||
*Additionally*, in many cases it is permitted to encode a character
|
||||
unnecessarily and the result is supposed to be the same. This means
|
||||
that it's possible to percent encode some URLs in multiple ways
|
||||
(e.g. encoding the unreserved set unnecessarily). It is possible, but not
|
||||
guaranteed, that if you pass *exactly* the same URI to liboauthcpp and the
|
||||
OAuth server, it will handle it regardless of the variant of encoding, so long
|
||||
as it is a valid encoding.
|
||||
|
||||
The short version: percent encoding a URL properly is non-trivial and
|
||||
you can even encode the same URL multiple ways, but has to be done
|
||||
correctly so that the OAuth signature can be computed. Sadly,
|
||||
"correctly" in this case really means "in whatever way the server your
|
||||
interacting with wants it encoded".
|
||||
|
||||
Internally, liboauthcpp needs to do another step of percent encoding,
|
||||
but the OAuth spec is very precise about how that works (none of these
|
||||
scheme-dependent issues). liboauth applies this percent encoding, but
|
||||
assumes that you have encoded your URLs properly. This assumption
|
||||
makes sense since the actual request is made separately, and the URI
|
||||
has to be specified in it, so you should already have a form which the
|
||||
server will accept.
|
||||
|
||||
However, in order to aid you, a very simple percent encoding API is exposed. It
|
||||
should help you encode URLs minimally and in a way that many services accept. In
|
||||
most cases you should use `HttpPercentEncodePath()`,
|
||||
`HttpPercentEncodeQueryKey()`, and `HttpPercentEncodeQueryValue()` to encode
|
||||
those parts of your http URL, then combine them and pass them to liboauthcpp for
|
||||
signing.
|
||||
|
||||
|
||||
Thread Safety
|
||||
-------------
|
||||
|
||||
liboauthcpp doesn't provide any thread safety guarantees. That said, there is
|
||||
very little shared state, and some classes (e.g. Consumer) are naturally
|
||||
immutable and therefore thread safe. Similarly, nearly the entire library uses
|
||||
no static/shared state, so as long as you create separate objects for separate
|
||||
threads, you should be safe.
|
||||
|
||||
The one exception is nonces: the Client class needs to generate a nonce for
|
||||
authorization. To do so, the random number generator needs to be seeded. We do
|
||||
this with the current time, but fast, repeated use of the Client class from
|
||||
different threads could result in the same nonce. To avoid requiring an entire
|
||||
thread library just for this one case, you can call Client::initialize()
|
||||
explicitly before using the Client from multiple threads. For single-threaded
|
||||
use, you are not required to call it.
|
||||
|
||||
Demos
|
||||
-----
|
||||
There are two demos included in the demos/ directory, and they are built by
|
||||
default with the instructions above. In both, you enter key/secret information
|
||||
and it generates URLs for you to visit (in a browser) and copy data back into
|
||||
the program.
|
||||
|
||||
simple_auth should be executed first. It starts with only a consumer key and
|
||||
secret and performs 3-legged auth: you enter in consumer keys, it generates URLs
|
||||
to authenticate the user and generate access tokens. It requires 3 steps:
|
||||
request_token, authorize, and access_token (which correspond the URLs
|
||||
accessed). At the end of this process, you'll be provided an access key/secret
|
||||
pair which you can use to access actual resources.
|
||||
|
||||
simple_request actually does something useful now that your application is
|
||||
authorized. Enter your consumer key/secret and the access key/secret from
|
||||
simple_auth (or which you've generated elsewhere) and it will generate a URL you
|
||||
can use to access your home timeline in JSON format. It adds a parameter to ask
|
||||
for only 5 entries (demonstrating that signing works properly over additional
|
||||
query parameters). This is a one-step process -- it just gives you the URL and
|
||||
you get the results in your browser.
|
||||
|
||||
In both, the URLs accessed are specified at the top of the demo
|
||||
files. simple_auth requires URLs for request_token, authorize_url, and
|
||||
access_token. Some providers require additional parameters (notably an
|
||||
oauth_callback for Twitter, even if its out of band, or oob), which you can also
|
||||
specify in that location. simple_request only needs the URL of the resource
|
||||
being accessed (i.e. the URL for the home_timeline JSON data used by default in
|
||||
the demo), with optional parameters stored as a query string.
|
||||
|
||||
Both demos only use GET requests with query strings, but all HTTP methods
|
||||
(e.g. POST, PUT, DELETE) and approaches to sending parameters (e.g. HTTP
|
||||
headers, url-encoded body) should be supported in the API.
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
liboauthcpp is MIT licensed. See the LICENSE file for more details.
|
||||
|
||||
liboauthcpp is mostly taken from libtwitcurl
|
||||
(http://code.google.com/p/twitcurl/), which is similarly licensed. It
|
||||
mostly serves to isolate the OAuth code from libtwitcurl's Twitter and
|
||||
cURL specific code.
|
||||
|
||||
libtwitcurl also borrowed code from other projects:
|
||||
twitcurl uses HMAC_SHA1 from http://www.codeproject.com/KB/recipes/HMACSHA1class.aspx
|
||||
twitcurl uses base64 from http://www.adp-gmbh.ch/cpp/common/base64.html
|
286
3party/liboauthcpp/include/liboauthcpp/liboauthcpp.h
Normal file
|
@ -0,0 +1,286 @@
|
|||
#ifndef __LIBOAUTHCPP_LIBOAUTHCPP_H__
|
||||
#define __LIBOAUTHCPP_LIBOAUTHCPP_H__
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <stdexcept>
|
||||
#include <ctime>
|
||||
|
||||
namespace OAuth {
|
||||
|
||||
namespace Http {
|
||||
typedef enum _RequestType
|
||||
{
|
||||
Invalid = 0,
|
||||
Head,
|
||||
Get,
|
||||
Post,
|
||||
Delete,
|
||||
Put
|
||||
} RequestType;
|
||||
} // namespace Http
|
||||
|
||||
typedef std::list<std::string> KeyValueList;
|
||||
typedef std::multimap<std::string, std::string> KeyValuePairs;
|
||||
|
||||
typedef enum _LogLevel
|
||||
{
|
||||
LogLevelNone = 0,
|
||||
LogLevelDebug = 1
|
||||
} LogLevel;
|
||||
|
||||
/** Set the log level. Log messages are sent to stderr. Currently, and for the
|
||||
* foreseeable future, logging only consists of debug messages to help track
|
||||
* down protocol implementation issues.
|
||||
*/
|
||||
void SetLogLevel(LogLevel lvl);
|
||||
|
||||
/** Deprecated. Complete percent encoding of URLs. Equivalent to
|
||||
* PercentEncode.
|
||||
*/
|
||||
std::string URLEncode(const std::string& decoded);
|
||||
|
||||
/** Percent encode a string value. This version is *thorough* about
|
||||
* encoding: it encodes all reserved characters (even those safe in
|
||||
* http URLs) and "other" characters not specified by the URI
|
||||
* spec. If you're looking to encode http:// URLs, see the
|
||||
* HttpEncode* functions.
|
||||
*/
|
||||
std::string PercentEncode(const std::string& decoded);
|
||||
|
||||
/** Percent encodes the path portion of an http URL (i.e. the /foo/bar
|
||||
* in http://foo/bar?a=1&b=2). This encodes minimally, so reserved
|
||||
* subdelimiters that have no meaning in the path are *not* encoded.
|
||||
*/
|
||||
std::string HttpEncodePath(const std::string& decoded);
|
||||
|
||||
/** Percent encodes a query string key in an http URL (i.e. 'a', 'b' in
|
||||
* http://foo/bar?a=1&b=2). This encodes minimally, so reserved subdelimiters
|
||||
* that have no meaning in the query string are *not* encoded.
|
||||
*/
|
||||
std::string HttpEncodeQueryKey(const std::string& decoded);
|
||||
|
||||
/** Percent encodes a query string value in an http URL (i.e. '1', '2' in
|
||||
* http://foo/bar?a=1&b=2). This encodes minimally, so reserved subdelimiters
|
||||
* that have no meaning in the query string are *not* encoded.
|
||||
*/
|
||||
std::string HttpEncodeQueryValue(const std::string& decoded);
|
||||
|
||||
/** Parses key value pairs into a map.
|
||||
* \param encoded the encoded key value pairs, i.e. the url encoded parameters
|
||||
* \returns a map of string keys to string values
|
||||
* \throws ParseError if the encoded data cannot be decoded
|
||||
*/
|
||||
KeyValuePairs ParseKeyValuePairs(const std::string& encoded);
|
||||
|
||||
class ParseError : public std::runtime_error {
|
||||
public:
|
||||
ParseError(const std::string msg)
|
||||
: std::runtime_error(msg)
|
||||
{}
|
||||
};
|
||||
|
||||
class MissingKeyError : public std::runtime_error {
|
||||
public:
|
||||
MissingKeyError(const std::string msg)
|
||||
: std::runtime_error(msg)
|
||||
{}
|
||||
};
|
||||
|
||||
/** A consumer of OAuth-protected services. It is the client to an
|
||||
* OAuth service provider and is usually registered with the service
|
||||
* provider, resulting in a consumer *key* and *secret* used to
|
||||
* identify the consumer. The key is included in all requests and the
|
||||
* secret is used to *sign* all requests. Signed requests allow the
|
||||
* consumer to securely perform operations, including kicking off
|
||||
* three-legged authentication to enable performing operations on
|
||||
* behalf of a user of the service provider.
|
||||
*/
|
||||
class Consumer {
|
||||
public:
|
||||
Consumer(const std::string& key, const std::string& secret);
|
||||
|
||||
const std::string& key() const { return mKey; }
|
||||
const std::string& secret() const { return mSecret; }
|
||||
|
||||
private:
|
||||
const std::string mKey;
|
||||
const std::string mSecret;
|
||||
};
|
||||
|
||||
/** An OAuth credential used to request authorization or a protected
|
||||
* resource.
|
||||
*
|
||||
* Tokens in OAuth comprise a *key* and a *secret*. The key is
|
||||
* included in requests to identify the token being used, but the
|
||||
* secret is used only in the signature, to prove that the requester
|
||||
* is who the server gave the token to.
|
||||
*
|
||||
* When first negotiating the authorization, the consumer asks for a
|
||||
* *request token* that the live user authorizes with the service
|
||||
* provider. The consumer then exchanges the request token for an
|
||||
* *access token* that can be used to access protected resources.
|
||||
*/
|
||||
class Token {
|
||||
public:
|
||||
Token(const std::string& key, const std::string& secret);
|
||||
Token(const std::string& key, const std::string& secret, const std::string& pin);
|
||||
|
||||
/** Construct a token, extracting the key and secret from a set of
|
||||
* key-value pairs (e.g. those parsed from an request or access
|
||||
* token request).
|
||||
*/
|
||||
static Token extract(const KeyValuePairs& response);
|
||||
/** Construct a token, extracting the key and secret from a raw,
|
||||
* encoded response.
|
||||
*/
|
||||
static Token extract(const std::string& requestTokenResponse);
|
||||
|
||||
const std::string& key() const { return mKey; }
|
||||
const std::string& secret() const { return mSecret; }
|
||||
|
||||
const std::string& pin() const { return mPin; }
|
||||
void setPin(const std::string& pin_) { mPin = pin_; }
|
||||
|
||||
private:
|
||||
|
||||
const std::string mKey;
|
||||
const std::string mSecret;
|
||||
std::string mPin;
|
||||
};
|
||||
|
||||
class Client {
|
||||
public:
|
||||
/** Perform static initialization. This will be called automatically, but
|
||||
* you can call it explicitly to ensure thread safety. If you do not call
|
||||
* this explicitly before using the Client class, the same nonce may be
|
||||
* generated twice.
|
||||
*/
|
||||
static void initialize();
|
||||
/** Alternative initialize method which lets you specify the seed and
|
||||
* control the timestamp used in generating signatures. This only exists
|
||||
* for testing purposes and should not be used in practice.
|
||||
*/
|
||||
static void initialize(int nonce, time_t timestamp);
|
||||
|
||||
/** Exposed for testing only.
|
||||
*/
|
||||
static void __resetInitialize();
|
||||
|
||||
/** Construct an OAuth Client using only a consumer key and
|
||||
* secret. You can use this to start a three-legged
|
||||
* authentication (to acquire an access token for a user) or for
|
||||
* simple two-legged authentication (signing with empty access
|
||||
* token info).
|
||||
*
|
||||
* \param consumer Consumer information. The caller must ensure
|
||||
* it remains valid during the lifetime of this object
|
||||
*/
|
||||
Client(const Consumer* consumer);
|
||||
/** Construct an OAuth Client with consumer key and secret (yours)
|
||||
* and access token key and secret (acquired and stored during
|
||||
* three-legged authentication).
|
||||
*
|
||||
* \param consumer Consumer information. The caller must ensure
|
||||
* it remains valid during the lifetime of this object
|
||||
* \param token Access token information. The caller must ensure
|
||||
* it remains valid during the lifetime of this object
|
||||
*/
|
||||
Client(const Consumer* consumer, const Token* token);
|
||||
|
||||
~Client();
|
||||
|
||||
/** Build an OAuth HTTP header for the given request. This version provides
|
||||
* only the field value.
|
||||
*
|
||||
* \param eType the HTTP request type, e.g. GET or POST
|
||||
* \param rawUrl the raw request URL (should include query parameters)
|
||||
* \param rawData the raw HTTP request data (can be empty)
|
||||
* \param includeOAuthVerifierPin if true, adds oauth_verifier parameter
|
||||
* \returns a string containing the HTTP header
|
||||
*/
|
||||
std::string getHttpHeader(const Http::RequestType eType,
|
||||
const std::string& rawUrl,
|
||||
const std::string& rawData = "",
|
||||
const bool includeOAuthVerifierPin = false);
|
||||
/** Build an OAuth HTTP header for the given request. This version gives a
|
||||
* fully formatted header, i.e. including the header field name.
|
||||
*
|
||||
* \param eType the HTTP request type, e.g. GET or POST
|
||||
* \param rawUrl the raw request URL (should include query parameters)
|
||||
* \param rawData the raw HTTP request data (can be empty)
|
||||
* \param includeOAuthVerifierPin if true, adds oauth_verifier parameter
|
||||
* \returns a string containing the HTTP header
|
||||
*/
|
||||
std::string getFormattedHttpHeader(const Http::RequestType eType,
|
||||
const std::string& rawUrl,
|
||||
const std::string& rawData = "",
|
||||
const bool includeOAuthVerifierPin = false);
|
||||
/** Build an OAuth HTTP header for the given request.
|
||||
*
|
||||
* \param eType the HTTP request type, e.g. GET or POST
|
||||
* \param rawUrl the raw request URL (should include query parameters)
|
||||
* \param rawData the raw HTTP request data (can be empty)
|
||||
* \param includeOAuthVerifierPin if true, adds oauth_verifier parameter
|
||||
* \returns a string containing the query string, including the query
|
||||
* parameters in the rawUrl
|
||||
*/
|
||||
std::string getURLQueryString(const Http::RequestType eType,
|
||||
const std::string& rawUrl,
|
||||
const std::string& rawData = "",
|
||||
const bool includeOAuthVerifierPin = false);
|
||||
private:
|
||||
/** Disable default constructur -- must provide consumer
|
||||
* information.
|
||||
*/
|
||||
Client();
|
||||
|
||||
static bool initialized;
|
||||
static int testingNonce;
|
||||
static time_t testingTimestamp;
|
||||
|
||||
/* OAuth data */
|
||||
const Consumer* mConsumer;
|
||||
const Token* mToken;
|
||||
std::string m_nonce;
|
||||
std::string m_timeStamp;
|
||||
|
||||
/* OAuth related utility methods */
|
||||
bool buildOAuthTokenKeyValuePairs( const bool includeOAuthVerifierPin, /* in */
|
||||
const std::string& rawData, /* in */
|
||||
const std::string& oauthSignature, /* in */
|
||||
KeyValuePairs& keyValueMap /* out */,
|
||||
const bool urlEncodeValues /* in */,
|
||||
const bool generateTimestamp /* in */);
|
||||
|
||||
bool getStringFromOAuthKeyValuePairs( const KeyValuePairs& rawParamMap, /* in */
|
||||
std::string& rawParams, /* out */
|
||||
const std::string& paramsSeperator /* in */ );
|
||||
|
||||
typedef enum _ParameterStringType {
|
||||
QueryStringString,
|
||||
AuthorizationHeaderString
|
||||
} ParameterStringType;
|
||||
// Utility for building OAuth HTTP header or query string. The string type
|
||||
// controls the separator and also filters parameters: for query strings,
|
||||
// all parameters are included. For HTTP headers, only auth parameters are
|
||||
// included.
|
||||
std::string buildOAuthParameterString(
|
||||
ParameterStringType string_type,
|
||||
const Http::RequestType eType,
|
||||
const std::string& rawUrl,
|
||||
const std::string& rawData,
|
||||
const bool includeOAuthVerifierPin);
|
||||
|
||||
bool getSignature( const Http::RequestType eType, /* in */
|
||||
const std::string& rawUrl, /* in */
|
||||
const KeyValuePairs& rawKeyValuePairs, /* in */
|
||||
std::string& oAuthSignature /* out */ );
|
||||
|
||||
void generateNonceTimeStamp();
|
||||
};
|
||||
|
||||
} // namespace OAuth
|
||||
|
||||
#endif // __LIBOAUTHCPP_LIBOAUTHCPP_H__
|
59
3party/liboauthcpp/src/HMAC_SHA1.cpp
Normal file
|
@ -0,0 +1,59 @@
|
|||
//******************************************************************************
|
||||
//* HMAC_SHA1.cpp : Implementation of HMAC SHA1 algorithm
|
||||
//* Comfort to RFC 2104
|
||||
//*
|
||||
//******************************************************************************
|
||||
#include "HMAC_SHA1.h"
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
|
||||
|
||||
void CHMAC_SHA1::HMAC_SHA1(BYTE *text, int text_len, BYTE *key, int key_len, BYTE *digest)
|
||||
{
|
||||
memset(SHA1_Key, 0, SHA1_BLOCK_SIZE);
|
||||
|
||||
/* repeated 64 times for values in ipad and opad */
|
||||
memset(m_ipad, 0x36, sizeof(m_ipad));
|
||||
memset(m_opad, 0x5c, sizeof(m_opad));
|
||||
|
||||
/* STEP 1 */
|
||||
if (key_len > SHA1_BLOCK_SIZE)
|
||||
{
|
||||
CSHA1::Reset();
|
||||
CSHA1::Update((UINT_8 *)key, key_len);
|
||||
CSHA1::Final();
|
||||
|
||||
CSHA1::GetHash((UINT_8 *)SHA1_Key);
|
||||
}
|
||||
else
|
||||
memcpy(SHA1_Key, key, key_len);
|
||||
|
||||
/* STEP 2 */
|
||||
for (int i=0; i<(int)sizeof(m_ipad); i++)
|
||||
{
|
||||
m_ipad[i] ^= SHA1_Key[i];
|
||||
}
|
||||
|
||||
/* STEP 4 */
|
||||
CSHA1::Reset();
|
||||
CSHA1::Update((UINT_8 *)m_ipad, sizeof(m_ipad));
|
||||
CSHA1::Update((UINT_8 *)text, text_len);
|
||||
CSHA1::Final();
|
||||
|
||||
char szReport[SHA1_DIGEST_LENGTH];
|
||||
CSHA1::GetHash((UINT_8 *)szReport);
|
||||
|
||||
/* STEP 5 */
|
||||
for (int j=0; j<(int)sizeof(m_opad); j++)
|
||||
{
|
||||
m_opad[j] ^= SHA1_Key[j];
|
||||
}
|
||||
|
||||
/*STEP 7 */
|
||||
CSHA1::Reset();
|
||||
CSHA1::Update((UINT_8 *)m_opad, sizeof(m_opad));
|
||||
CSHA1::Update((UINT_8 *)szReport, SHA1_DIGEST_LENGTH);
|
||||
CSHA1::Final();
|
||||
|
||||
CSHA1::GetHash((UINT_8 *)digest);
|
||||
}
|
37
3party/liboauthcpp/src/HMAC_SHA1.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
100% free public domain implementation of the HMAC-SHA1 algorithm
|
||||
by Chien-Chung, Chung (Jim Chung) <jimchung1221@gmail.com>
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __HMAC_SHA1_H__
|
||||
#define __HMAC_SHA1_H__
|
||||
|
||||
#include "SHA1.h"
|
||||
|
||||
typedef unsigned char BYTE ;
|
||||
|
||||
class CHMAC_SHA1 : public CSHA1
|
||||
{
|
||||
public:
|
||||
|
||||
enum {
|
||||
SHA1_DIGEST_LENGTH = 20,
|
||||
SHA1_BLOCK_SIZE = 64
|
||||
} ;
|
||||
|
||||
private:
|
||||
BYTE m_ipad[SHA1_BLOCK_SIZE];
|
||||
BYTE m_opad[SHA1_BLOCK_SIZE];
|
||||
|
||||
// This holds one SHA1 block's worth of data, zero padded if necessary.
|
||||
char SHA1_Key[SHA1_BLOCK_SIZE];
|
||||
|
||||
public:
|
||||
CHMAC_SHA1() {}
|
||||
|
||||
void HMAC_SHA1(BYTE *text, int text_len, BYTE *key, int key_len, BYTE *digest);
|
||||
};
|
||||
|
||||
|
||||
#endif /* __HMAC_SHA1_H__ */
|
277
3party/liboauthcpp/src/SHA1.cpp
Normal file
|
@ -0,0 +1,277 @@
|
|||
/*
|
||||
100% free public domain implementation of the SHA-1 algorithm
|
||||
by Dominik Reichl <dominik.reichl@t-online.de>
|
||||
Web: http://www.dominik-reichl.de/
|
||||
|
||||
Version 1.6 - 2005-02-07 (thanks to Howard Kapustein for patches)
|
||||
- You can set the endianness in your files, no need to modify the
|
||||
header file of the CSHA1 class any more
|
||||
- Aligned data support
|
||||
- Made support/compilation of the utility functions (ReportHash
|
||||
and HashFile) optional (useful, if bytes count, for example in
|
||||
embedded environments)
|
||||
|
||||
Version 1.5 - 2005-01-01
|
||||
- 64-bit compiler compatibility added
|
||||
- Made variable wiping optional (define SHA1_WIPE_VARIABLES)
|
||||
- Removed unnecessary variable initializations
|
||||
- ROL32 improvement for the Microsoft compiler (using _rotl)
|
||||
|
||||
======== Test Vectors (from FIPS PUB 180-1) ========
|
||||
|
||||
SHA1("abc") =
|
||||
A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D
|
||||
|
||||
SHA1("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq") =
|
||||
84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1
|
||||
|
||||
SHA1(A million repetitions of "a") =
|
||||
34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
|
||||
*/
|
||||
|
||||
#include "SHA1.h"
|
||||
#include <cassert>
|
||||
|
||||
#ifdef SHA1_UTILITY_FUNCTIONS
|
||||
#define SHA1_MAX_FILE_BUFFER 8000
|
||||
#endif
|
||||
|
||||
// Rotate x bits to the left
|
||||
#ifndef ROL32
|
||||
#ifdef _MSC_VER
|
||||
#define ROL32(_val32, _nBits) _rotl(_val32, _nBits)
|
||||
#else
|
||||
#define ROL32(_val32, _nBits) (((_val32)<<(_nBits))|((_val32)>>(32-(_nBits))))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef SHA1_LITTLE_ENDIAN
|
||||
#define SHABLK0(i) (m_block->l[i] = \
|
||||
(ROL32(m_block->l[i],24) & 0xFF00FF00) | (ROL32(m_block->l[i],8) & 0x00FF00FF))
|
||||
#else
|
||||
#define SHABLK0(i) (m_block->l[i])
|
||||
#endif
|
||||
|
||||
#define SHABLK(i) (m_block->l[i&15] = ROL32(m_block->l[(i+13)&15] ^ m_block->l[(i+8)&15] \
|
||||
^ m_block->l[(i+2)&15] ^ m_block->l[i&15],1))
|
||||
|
||||
// SHA-1 rounds
|
||||
#define _R0(v,w,x,y,z,i) { z+=((w&(x^y))^y)+SHABLK0(i)+0x5A827999+ROL32(v,5); w=ROL32(w,30); }
|
||||
#define _R1(v,w,x,y,z,i) { z+=((w&(x^y))^y)+SHABLK(i)+0x5A827999+ROL32(v,5); w=ROL32(w,30); }
|
||||
#define _R2(v,w,x,y,z,i) { z+=(w^x^y)+SHABLK(i)+0x6ED9EBA1+ROL32(v,5); w=ROL32(w,30); }
|
||||
#define _R3(v,w,x,y,z,i) { z+=(((w|x)&y)|(w&x))+SHABLK(i)+0x8F1BBCDC+ROL32(v,5); w=ROL32(w,30); }
|
||||
#define _R4(v,w,x,y,z,i) { z+=(w^x^y)+SHABLK(i)+0xCA62C1D6+ROL32(v,5); w=ROL32(w,30); }
|
||||
|
||||
CSHA1::CSHA1()
|
||||
{
|
||||
m_block = (SHA1_WORKSPACE_BLOCK *)m_workspace;
|
||||
|
||||
Reset();
|
||||
}
|
||||
|
||||
CSHA1::~CSHA1()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
void CSHA1::Reset()
|
||||
{
|
||||
// SHA1 initialization constants
|
||||
m_state[0] = 0x67452301;
|
||||
m_state[1] = 0xEFCDAB89;
|
||||
m_state[2] = 0x98BADCFE;
|
||||
m_state[3] = 0x10325476;
|
||||
m_state[4] = 0xC3D2E1F0;
|
||||
|
||||
m_count[0] = 0;
|
||||
m_count[1] = 0;
|
||||
}
|
||||
|
||||
void CSHA1::Transform(UINT_32 *state, UINT_8 *buffer)
|
||||
{
|
||||
// Copy state[] to working vars
|
||||
UINT_32 a = state[0], b = state[1], c = state[2], d = state[3], e = state[4];
|
||||
|
||||
memcpy(m_block, buffer, 64);
|
||||
|
||||
// 4 rounds of 20 operations each. Loop unrolled.
|
||||
_R0(a,b,c,d,e, 0); _R0(e,a,b,c,d, 1); _R0(d,e,a,b,c, 2); _R0(c,d,e,a,b, 3);
|
||||
_R0(b,c,d,e,a, 4); _R0(a,b,c,d,e, 5); _R0(e,a,b,c,d, 6); _R0(d,e,a,b,c, 7);
|
||||
_R0(c,d,e,a,b, 8); _R0(b,c,d,e,a, 9); _R0(a,b,c,d,e,10); _R0(e,a,b,c,d,11);
|
||||
_R0(d,e,a,b,c,12); _R0(c,d,e,a,b,13); _R0(b,c,d,e,a,14); _R0(a,b,c,d,e,15);
|
||||
_R1(e,a,b,c,d,16); _R1(d,e,a,b,c,17); _R1(c,d,e,a,b,18); _R1(b,c,d,e,a,19);
|
||||
_R2(a,b,c,d,e,20); _R2(e,a,b,c,d,21); _R2(d,e,a,b,c,22); _R2(c,d,e,a,b,23);
|
||||
_R2(b,c,d,e,a,24); _R2(a,b,c,d,e,25); _R2(e,a,b,c,d,26); _R2(d,e,a,b,c,27);
|
||||
_R2(c,d,e,a,b,28); _R2(b,c,d,e,a,29); _R2(a,b,c,d,e,30); _R2(e,a,b,c,d,31);
|
||||
_R2(d,e,a,b,c,32); _R2(c,d,e,a,b,33); _R2(b,c,d,e,a,34); _R2(a,b,c,d,e,35);
|
||||
_R2(e,a,b,c,d,36); _R2(d,e,a,b,c,37); _R2(c,d,e,a,b,38); _R2(b,c,d,e,a,39);
|
||||
_R3(a,b,c,d,e,40); _R3(e,a,b,c,d,41); _R3(d,e,a,b,c,42); _R3(c,d,e,a,b,43);
|
||||
_R3(b,c,d,e,a,44); _R3(a,b,c,d,e,45); _R3(e,a,b,c,d,46); _R3(d,e,a,b,c,47);
|
||||
_R3(c,d,e,a,b,48); _R3(b,c,d,e,a,49); _R3(a,b,c,d,e,50); _R3(e,a,b,c,d,51);
|
||||
_R3(d,e,a,b,c,52); _R3(c,d,e,a,b,53); _R3(b,c,d,e,a,54); _R3(a,b,c,d,e,55);
|
||||
_R3(e,a,b,c,d,56); _R3(d,e,a,b,c,57); _R3(c,d,e,a,b,58); _R3(b,c,d,e,a,59);
|
||||
_R4(a,b,c,d,e,60); _R4(e,a,b,c,d,61); _R4(d,e,a,b,c,62); _R4(c,d,e,a,b,63);
|
||||
_R4(b,c,d,e,a,64); _R4(a,b,c,d,e,65); _R4(e,a,b,c,d,66); _R4(d,e,a,b,c,67);
|
||||
_R4(c,d,e,a,b,68); _R4(b,c,d,e,a,69); _R4(a,b,c,d,e,70); _R4(e,a,b,c,d,71);
|
||||
_R4(d,e,a,b,c,72); _R4(c,d,e,a,b,73); _R4(b,c,d,e,a,74); _R4(a,b,c,d,e,75);
|
||||
_R4(e,a,b,c,d,76); _R4(d,e,a,b,c,77); _R4(c,d,e,a,b,78); _R4(b,c,d,e,a,79);
|
||||
|
||||
// Add the working vars back into state
|
||||
state[0] += a;
|
||||
state[1] += b;
|
||||
state[2] += c;
|
||||
state[3] += d;
|
||||
state[4] += e;
|
||||
|
||||
// Wipe variables
|
||||
#ifdef SHA1_WIPE_VARIABLES
|
||||
a = b = c = d = e = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Use this function to hash in binary data and strings
|
||||
void CSHA1::Update(UINT_8 *data, UINT_32 len)
|
||||
{
|
||||
UINT_32 i, j;
|
||||
|
||||
j = (m_count[0] >> 3) & 63;
|
||||
|
||||
if((m_count[0] += len << 3) < (len << 3)) m_count[1]++;
|
||||
|
||||
m_count[1] += (len >> 29);
|
||||
|
||||
if((j + len) > 63)
|
||||
{
|
||||
i = 64 - j;
|
||||
memcpy(&m_buffer[j], data, i);
|
||||
Transform(m_state, m_buffer);
|
||||
|
||||
for(; i + 63 < len; i += 64) Transform(m_state, &data[i]);
|
||||
|
||||
j = 0;
|
||||
}
|
||||
else i = 0;
|
||||
|
||||
memcpy(&m_buffer[j], &data[i], len - i);
|
||||
}
|
||||
|
||||
#ifdef SHA1_UTILITY_FUNCTIONS
|
||||
// Hash in file contents
|
||||
bool CSHA1::HashFile(char *szFileName)
|
||||
{
|
||||
unsigned long ulFileSize, ulRest, ulBlocks;
|
||||
unsigned long i;
|
||||
UINT_8 uData[SHA1_MAX_FILE_BUFFER];
|
||||
FILE *fIn;
|
||||
|
||||
if(szFileName == NULL) return false;
|
||||
|
||||
fIn = fopen(szFileName, "rb");
|
||||
if(fIn == NULL) return false;
|
||||
|
||||
fseek(fIn, 0, SEEK_END);
|
||||
ulFileSize = (unsigned long)ftell(fIn);
|
||||
fseek(fIn, 0, SEEK_SET);
|
||||
|
||||
if(ulFileSize != 0)
|
||||
{
|
||||
ulBlocks = ulFileSize / SHA1_MAX_FILE_BUFFER;
|
||||
ulRest = ulFileSize % SHA1_MAX_FILE_BUFFER;
|
||||
}
|
||||
else
|
||||
{
|
||||
ulBlocks = 0;
|
||||
ulRest = 0;
|
||||
}
|
||||
|
||||
for(i = 0; i < ulBlocks; i++)
|
||||
{
|
||||
size_t nread = fread(uData, 1, SHA1_MAX_FILE_BUFFER, fIn);
|
||||
assert(nread == SHA1_MAX_FILE_BUFFER);
|
||||
Update((UINT_8 *)uData, SHA1_MAX_FILE_BUFFER);
|
||||
}
|
||||
|
||||
if(ulRest != 0)
|
||||
{
|
||||
size_t nread = fread(uData, 1, ulRest, fIn);
|
||||
assert(nread == ulRest);
|
||||
Update((UINT_8 *)uData, ulRest);
|
||||
}
|
||||
|
||||
fclose(fIn); fIn = NULL;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
void CSHA1::Final()
|
||||
{
|
||||
UINT_32 i;
|
||||
UINT_8 finalcount[8];
|
||||
|
||||
for(i = 0; i < 8; i++)
|
||||
finalcount[i] = (UINT_8)((m_count[((i >= 4) ? 0 : 1)]
|
||||
>> ((3 - (i & 3)) * 8) ) & 255); // Endian independent
|
||||
|
||||
Update((UINT_8 *)"\200", 1);
|
||||
|
||||
while ((m_count[0] & 504) != 448)
|
||||
Update((UINT_8 *)"\0", 1);
|
||||
|
||||
Update(finalcount, 8); // Cause a SHA1Transform()
|
||||
|
||||
for(i = 0; i < 20; i++)
|
||||
{
|
||||
m_digest[i] = (UINT_8)((m_state[i >> 2] >> ((3 - (i & 3)) * 8) ) & 255);
|
||||
}
|
||||
|
||||
// Wipe variables for security reasons
|
||||
#ifdef SHA1_WIPE_VARIABLES
|
||||
i = 0;
|
||||
memset(m_buffer, 0, 64);
|
||||
memset(m_state, 0, 20);
|
||||
memset(m_count, 0, 8);
|
||||
memset(finalcount, 0, 8);
|
||||
Transform(m_state, m_buffer);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef SHA1_UTILITY_FUNCTIONS
|
||||
// Get the final hash as a pre-formatted string
|
||||
void CSHA1::ReportHash(char *szReport, unsigned char uReportType)
|
||||
{
|
||||
unsigned char i;
|
||||
char szTemp[16];
|
||||
|
||||
if(szReport == NULL) return;
|
||||
|
||||
if(uReportType == REPORT_HEX)
|
||||
{
|
||||
snprintf(szTemp, sizeof(szTemp), "%02X", m_digest[0]);
|
||||
strcat(szReport, szTemp);
|
||||
|
||||
for(i = 1; i < 20; i++)
|
||||
{
|
||||
snprintf(szTemp, sizeof(szTemp), " %02X", m_digest[i]);
|
||||
strcat(szReport, szTemp);
|
||||
}
|
||||
}
|
||||
else if(uReportType == REPORT_DIGIT)
|
||||
{
|
||||
snprintf(szTemp, sizeof(szTemp), "%u", m_digest[0]);
|
||||
strcat(szReport, szTemp);
|
||||
|
||||
for(i = 1; i < 20; i++)
|
||||
{
|
||||
snprintf(szTemp, sizeof(szTemp), " %u", m_digest[i]);
|
||||
strcat(szReport, szTemp);
|
||||
}
|
||||
}
|
||||
else strcpy(szReport, "Error: Unknown report type!");
|
||||
}
|
||||
#endif
|
||||
|
||||
// Get the raw message digest
|
||||
void CSHA1::GetHash(UINT_8 *puDest)
|
||||
{
|
||||
memcpy(puDest, m_digest, 20);
|
||||
}
|
148
3party/liboauthcpp/src/SHA1.h
Normal file
|
@ -0,0 +1,148 @@
|
|||
/*
|
||||
100% free public domain implementation of the SHA-1 algorithm
|
||||
by Dominik Reichl <dominik.reichl@t-online.de>
|
||||
Web: http://www.dominik-reichl.de/
|
||||
|
||||
Version 1.6 - 2005-02-07 (thanks to Howard Kapustein for patches)
|
||||
- You can set the endianness in your files, no need to modify the
|
||||
header file of the CSHA1 class any more
|
||||
- Aligned data support
|
||||
- Made support/compilation of the utility functions (ReportHash
|
||||
and HashFile) optional (useful, if bytes count, for example in
|
||||
embedded environments)
|
||||
|
||||
Version 1.5 - 2005-01-01
|
||||
- 64-bit compiler compatibility added
|
||||
- Made variable wiping optional (define SHA1_WIPE_VARIABLES)
|
||||
- Removed unnecessary variable initializations
|
||||
- ROL32 improvement for the Microsoft compiler (using _rotl)
|
||||
|
||||
======== Test Vectors (from FIPS PUB 180-1) ========
|
||||
|
||||
SHA1("abc") =
|
||||
A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D
|
||||
|
||||
SHA1("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq") =
|
||||
84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1
|
||||
|
||||
SHA1(A million repetitions of "a") =
|
||||
34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
|
||||
*/
|
||||
|
||||
#ifndef ___SHA1_HDR___
|
||||
#define ___SHA1_HDR___
|
||||
|
||||
#if !defined(SHA1_UTILITY_FUNCTIONS) && !defined(SHA1_NO_UTILITY_FUNCTIONS)
|
||||
#define SHA1_UTILITY_FUNCTIONS
|
||||
#endif
|
||||
|
||||
#include <memory.h> // Needed for memset and memcpy
|
||||
|
||||
#ifdef SHA1_UTILITY_FUNCTIONS
|
||||
#include <stdio.h> // Needed for file access and sprintf
|
||||
#include <string.h> // Needed for strcat and strcpy
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
// You can define the endian mode in your files, without modifying the SHA1
|
||||
// source files. Just #define SHA1_LITTLE_ENDIAN or #define SHA1_BIG_ENDIAN
|
||||
// in your files, before including the SHA1.h header file. If you don't
|
||||
// define anything, the class defaults to little endian.
|
||||
|
||||
#if !defined(SHA1_LITTLE_ENDIAN) && !defined(SHA1_BIG_ENDIAN)
|
||||
#define SHA1_LITTLE_ENDIAN
|
||||
#endif
|
||||
|
||||
// Same here. If you want variable wiping, #define SHA1_WIPE_VARIABLES, if
|
||||
// not, #define SHA1_NO_WIPE_VARIABLES. If you don't define anything, it
|
||||
// defaults to wiping.
|
||||
|
||||
#if !defined(SHA1_WIPE_VARIABLES) && !defined(SHA1_NO_WIPE_VARIABLES)
|
||||
#define SHA1_WIPE_VARIABLES
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Define 8- and 32-bit variables
|
||||
|
||||
#ifndef UINT_32
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
#define UINT_8 unsigned __int8
|
||||
#define UINT_32 unsigned __int32
|
||||
|
||||
#else
|
||||
|
||||
#define UINT_8 unsigned char
|
||||
|
||||
#if (ULONG_MAX == 0xFFFFFFFF && UINT_MAX < ULONG_MAX)
|
||||
#define UINT_32 unsigned long
|
||||
#else
|
||||
#define UINT_32 unsigned int
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Declare SHA1 workspace
|
||||
|
||||
typedef union
|
||||
{
|
||||
UINT_8 c[64];
|
||||
UINT_32 l[16];
|
||||
} SHA1_WORKSPACE_BLOCK;
|
||||
|
||||
class CSHA1
|
||||
{
|
||||
public:
|
||||
#ifdef SHA1_UTILITY_FUNCTIONS
|
||||
// Two different formats for ReportHash(...)
|
||||
enum
|
||||
{
|
||||
REPORT_HEX = 0,
|
||||
REPORT_DIGIT = 1
|
||||
};
|
||||
#endif
|
||||
|
||||
// Constructor and Destructor
|
||||
CSHA1();
|
||||
~CSHA1();
|
||||
|
||||
UINT_32 m_state[5];
|
||||
UINT_32 m_count[2];
|
||||
UINT_32 __reserved1[1];
|
||||
UINT_8 m_buffer[64];
|
||||
UINT_8 m_digest[20];
|
||||
UINT_32 __reserved2[3];
|
||||
|
||||
void Reset();
|
||||
|
||||
// Update the hash value
|
||||
void Update(UINT_8 *data, UINT_32 len);
|
||||
#ifdef SHA1_UTILITY_FUNCTIONS
|
||||
bool HashFile(char *szFileName);
|
||||
#endif
|
||||
|
||||
// Finalize hash and report
|
||||
void Final();
|
||||
|
||||
// Report functions: as pre-formatted and raw data
|
||||
#ifdef SHA1_UTILITY_FUNCTIONS
|
||||
void ReportHash(char *szReport, unsigned char uReportType = REPORT_HEX);
|
||||
#endif
|
||||
void GetHash(UINT_8 *puDest);
|
||||
|
||||
private:
|
||||
// Private SHA-1 transformation
|
||||
void Transform(UINT_32 *state, UINT_8 *buffer);
|
||||
|
||||
// Member variables
|
||||
UINT_8 m_workspace[64];
|
||||
SHA1_WORKSPACE_BLOCK *m_block; // SHA1 pointer to the byte array above
|
||||
};
|
||||
|
||||
#endif
|
123
3party/liboauthcpp/src/base64.cpp
Normal file
|
@ -0,0 +1,123 @@
|
|||
/*
|
||||
base64.cpp and base64.h
|
||||
|
||||
Copyright (C) 2004-2008 René Nyffenegger
|
||||
|
||||
This source code is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the author be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this source code must not be misrepresented; you must not
|
||||
claim that you wrote the original source code. If you use this source code
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original source code.
|
||||
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
René Nyffenegger rene.nyffenegger@adp-gmbh.ch
|
||||
|
||||
*/
|
||||
|
||||
#include "base64.h"
|
||||
#include <iostream>
|
||||
|
||||
static const std::string base64_chars =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
"abcdefghijklmnopqrstuvwxyz"
|
||||
"0123456789+/";
|
||||
|
||||
|
||||
static inline bool is_base64(unsigned char c) {
|
||||
return (isalnum(c) || (c == '+') || (c == '/'));
|
||||
}
|
||||
|
||||
std::string base64_encode(unsigned char const* bytes_to_encode, unsigned int in_len) {
|
||||
std::string ret;
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
unsigned char char_array_3[3];
|
||||
unsigned char char_array_4[4];
|
||||
|
||||
while (in_len--) {
|
||||
char_array_3[i++] = *(bytes_to_encode++);
|
||||
if (i == 3) {
|
||||
char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
|
||||
char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
|
||||
char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
|
||||
char_array_4[3] = char_array_3[2] & 0x3f;
|
||||
|
||||
for(i = 0; (i <4) ; i++)
|
||||
ret += base64_chars[char_array_4[i]];
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (i)
|
||||
{
|
||||
for(j = i; j < 3; j++)
|
||||
char_array_3[j] = '\0';
|
||||
|
||||
char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
|
||||
char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
|
||||
char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
|
||||
char_array_4[3] = char_array_3[2] & 0x3f;
|
||||
|
||||
for (j = 0; (j < i + 1); j++)
|
||||
ret += base64_chars[char_array_4[j]];
|
||||
|
||||
while((i++ < 3))
|
||||
ret += '=';
|
||||
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
std::string base64_decode(std::string const& encoded_string) {
|
||||
int in_len = encoded_string.size();
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
int in_ = 0;
|
||||
unsigned char char_array_4[4], char_array_3[3];
|
||||
std::string ret;
|
||||
|
||||
while (in_len-- && ( encoded_string[in_] != '=') && is_base64(encoded_string[in_])) {
|
||||
char_array_4[i++] = encoded_string[in_]; in_++;
|
||||
if (i ==4) {
|
||||
for (i = 0; i <4; i++)
|
||||
char_array_4[i] = base64_chars.find(char_array_4[i]);
|
||||
|
||||
char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
|
||||
char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
|
||||
char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
|
||||
|
||||
for (i = 0; (i < 3); i++)
|
||||
ret += char_array_3[i];
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (i) {
|
||||
for (j = i; j <4; j++)
|
||||
char_array_4[j] = 0;
|
||||
|
||||
for (j = 0; j <4; j++)
|
||||
char_array_4[j] = base64_chars.find(char_array_4[j]);
|
||||
|
||||
char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
|
||||
char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
|
||||
char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
|
||||
|
||||
for (j = 0; (j < i - 1); j++) ret += char_array_3[j];
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
4
3party/liboauthcpp/src/base64.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
#include <string>
|
||||
|
||||
std::string base64_encode(unsigned char const* , unsigned int len);
|
||||
std::string base64_decode(std::string const& s);
|
621
3party/liboauthcpp/src/liboauthcpp.cpp
Normal file
|
@ -0,0 +1,621 @@
|
|||
#include <liboauthcpp/liboauthcpp.h>
|
||||
#include "HMAC_SHA1.h"
|
||||
#include "base64.h"
|
||||
#include "urlencode.h"
|
||||
#include <cstdlib>
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
namespace OAuth {
|
||||
|
||||
namespace Defaults
|
||||
{
|
||||
/* Constants */
|
||||
const int BUFFSIZE = 1024;
|
||||
const int BUFFSIZE_LARGE = 1024;
|
||||
const std::string CONSUMERKEY_KEY = "oauth_consumer_key";
|
||||
const std::string CALLBACK_KEY = "oauth_callback";
|
||||
const std::string VERSION_KEY = "oauth_version";
|
||||
const std::string SIGNATUREMETHOD_KEY = "oauth_signature_method";
|
||||
const std::string SIGNATURE_KEY = "oauth_signature";
|
||||
const std::string TIMESTAMP_KEY = "oauth_timestamp";
|
||||
const std::string NONCE_KEY = "oauth_nonce";
|
||||
const std::string TOKEN_KEY = "oauth_token";
|
||||
const std::string TOKENSECRET_KEY = "oauth_token_secret";
|
||||
const std::string VERIFIER_KEY = "oauth_verifier";
|
||||
|
||||
const std::string AUTHHEADER_FIELD = "Authorization: ";
|
||||
const std::string AUTHHEADER_PREFIX = "OAuth ";
|
||||
};
|
||||
|
||||
/** std::string -> std::string conversion function */
|
||||
typedef std::string(*StringConvertFunction)(const std::string&);
|
||||
|
||||
LogLevel gLogLevel = LogLevelNone;
|
||||
|
||||
void SetLogLevel(LogLevel lvl) {
|
||||
gLogLevel = lvl;
|
||||
}
|
||||
#define LOG(lvl, msg) \
|
||||
do { \
|
||||
if (lvl <= gLogLevel) std::cerr << "OAUTH: " << msg << std::endl; \
|
||||
} while(0)
|
||||
|
||||
std::string PercentEncode(const std::string& decoded) {
|
||||
return urlencode(decoded, URLEncode_Everything);
|
||||
}
|
||||
|
||||
std::string URLEncode(const std::string& decoded) {
|
||||
return PercentEncode(decoded);
|
||||
}
|
||||
|
||||
std::string HttpEncodePath(const std::string& decoded) {
|
||||
return urlencode(decoded, URLEncode_Path);
|
||||
}
|
||||
|
||||
std::string HttpEncodeQueryKey(const std::string& decoded) {
|
||||
return urlencode(decoded, URLEncode_QueryKey);
|
||||
}
|
||||
|
||||
std::string HttpEncodeQueryValue(const std::string& decoded) {
|
||||
return urlencode(decoded, URLEncode_QueryValue);
|
||||
}
|
||||
|
||||
namespace {
|
||||
std::string PassThrough(const std::string& decoded) {
|
||||
return decoded;
|
||||
}
|
||||
|
||||
std::string RequestTypeString(const Http::RequestType rt) {
|
||||
switch(rt) {
|
||||
case Http::Invalid: return "Invalid Request Type"; break;
|
||||
case Http::Head: return "HEAD"; break;
|
||||
case Http::Get: return "GET"; break;
|
||||
case Http::Post: return "POST"; break;
|
||||
case Http::Delete: return "DELETE"; break;
|
||||
case Http::Put: return "PUT"; break;
|
||||
default: return "Unknown Request Type"; break;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
// Parse a single key-value pair
|
||||
static std::pair<std::string, std::string> ParseKeyValuePair(const std::string& encoded) {
|
||||
std::size_t eq_pos = encoded.find("=");
|
||||
if (eq_pos == std::string::npos)
|
||||
throw ParseError("Failed to find '=' in key-value pair.");
|
||||
return std::pair<std::string, std::string>(
|
||||
encoded.substr(0, eq_pos),
|
||||
encoded.substr(eq_pos+1)
|
||||
);
|
||||
}
|
||||
|
||||
KeyValuePairs ParseKeyValuePairs(const std::string& encoded) {
|
||||
KeyValuePairs result;
|
||||
|
||||
if (encoded.length() == 0) return result;
|
||||
|
||||
// Split by &
|
||||
std::size_t last_amp = 0;
|
||||
// We can bail when the last one "found" was the end of the string
|
||||
while(true) {
|
||||
std::size_t next_amp = encoded.find('&', last_amp+1);
|
||||
std::string keyval =
|
||||
(next_amp == std::string::npos) ?
|
||||
encoded.substr(last_amp) :
|
||||
encoded.substr(last_amp, next_amp-last_amp);
|
||||
result.insert(ParseKeyValuePair(keyval));
|
||||
// Track spot after the & so the first iteration works without dealing
|
||||
// with -1 index
|
||||
last_amp = next_amp+1;
|
||||
|
||||
// Exit condition
|
||||
if (next_amp == std::string::npos) break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Helper for parameters in key-value pair lists that should only appear
|
||||
// once. Either replaces an existing entry or adds a new entry.
|
||||
static void ReplaceOrInsertKeyValuePair(KeyValuePairs& kvp, const std::string& key, const std::string& value) {
|
||||
assert(kvp.count(key) <= 1);
|
||||
KeyValuePairs::iterator it = kvp.find(key);
|
||||
if (it != kvp.end())
|
||||
it->second = value;
|
||||
else
|
||||
kvp.insert(KeyValuePairs::value_type(key, value));
|
||||
}
|
||||
|
||||
Consumer::Consumer(const std::string& key, const std::string& secret)
|
||||
: mKey(key), mSecret(secret)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
Token::Token(const std::string& key, const std::string& secret)
|
||||
: mKey(key), mSecret(secret)
|
||||
{
|
||||
}
|
||||
|
||||
Token::Token(const std::string& key, const std::string& secret, const std::string& pin)
|
||||
: mKey(key), mSecret(secret), mPin(pin)
|
||||
{
|
||||
}
|
||||
|
||||
Token Token::extract(const std::string& response) {
|
||||
return Token::extract(ParseKeyValuePairs(response));
|
||||
}
|
||||
|
||||
Token Token::extract(const KeyValuePairs& response) {
|
||||
std::string token_key, token_secret;
|
||||
|
||||
KeyValuePairs::const_iterator it = response.find(Defaults::TOKEN_KEY);
|
||||
if (it == response.end())
|
||||
throw MissingKeyError("Couldn't find oauth_token in response");
|
||||
token_key = it->second;
|
||||
|
||||
it = response.find(Defaults::TOKENSECRET_KEY);
|
||||
if (it == response.end())
|
||||
throw MissingKeyError("Couldn't find oauth_token_secret in response");
|
||||
token_secret = it->second;
|
||||
|
||||
return Token(token_key, token_secret);
|
||||
}
|
||||
|
||||
|
||||
bool Client::initialized = false;
|
||||
int Client::testingNonce = 0;
|
||||
time_t Client::testingTimestamp = 0;
|
||||
|
||||
void Client::initialize() {
|
||||
if(!initialized) {
|
||||
srand( time( NULL ) );
|
||||
initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
void Client::initialize(int nonce, time_t timestamp) {
|
||||
if(!initialized) {
|
||||
testingNonce = nonce;
|
||||
testingTimestamp = timestamp;
|
||||
initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
void Client::__resetInitialize() {
|
||||
testingNonce = 0;
|
||||
testingTimestamp = 0;
|
||||
initialized = false;
|
||||
}
|
||||
|
||||
Client::Client(const Consumer* consumer)
|
||||
: mConsumer(consumer),
|
||||
mToken(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
Client::Client(const Consumer* consumer, const Token* token)
|
||||
: mConsumer(consumer),
|
||||
mToken(token)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Client::~Client()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*++
|
||||
* @method: Client::generateNonceTimeStamp
|
||||
*
|
||||
* @description: this method generates nonce and timestamp for OAuth header
|
||||
*
|
||||
* @input: none
|
||||
*
|
||||
* @output: none
|
||||
*
|
||||
* @remarks: internal method
|
||||
*
|
||||
*--*/
|
||||
void Client::generateNonceTimeStamp()
|
||||
{
|
||||
// Make sure the random seed has been initialized
|
||||
Client::initialize();
|
||||
|
||||
char szTime[Defaults::BUFFSIZE];
|
||||
char szRand[Defaults::BUFFSIZE];
|
||||
memset( szTime, 0, Defaults::BUFFSIZE );
|
||||
memset( szRand, 0, Defaults::BUFFSIZE );
|
||||
|
||||
// Any non-zero timestamp triggers testing mode with fixed values. Fixing
|
||||
// both values makes life easier because generating a signature is
|
||||
// idempotent -- otherwise using macros can cause double evaluation and
|
||||
// incorrect results because of repeated calls to rand().
|
||||
snprintf( szRand, sizeof(szRand), "%x", ((testingTimestamp != 0) ? testingNonce : rand()) );
|
||||
snprintf( szTime, sizeof(szTime), "%ld", ((testingTimestamp != 0) ? testingTimestamp : time( NULL )) );
|
||||
|
||||
m_nonce.assign( szTime );
|
||||
m_nonce.append( szRand );
|
||||
|
||||
m_timeStamp.assign( szTime );
|
||||
}
|
||||
|
||||
/*++
|
||||
* @method: Client::buildOAuthTokenKeyValuePairs
|
||||
*
|
||||
* @description: this method prepares key-value pairs required for OAuth header
|
||||
* and signature generation.
|
||||
*
|
||||
* @input: includeOAuthVerifierPin - flag to indicate whether oauth_verifer key-value
|
||||
* pair needs to be included. oauth_verifer is only
|
||||
* used during exchanging request token with access token.
|
||||
* rawData - url encoded data. this is used during signature generation.
|
||||
* oauthSignature - base64 and url encoded OAuth signature.
|
||||
* generateTimestamp - If true, then generate new timestamp for nonce.
|
||||
*
|
||||
* @input: urlEncodeValues - if true, URLEncode the values inserted into the
|
||||
* output keyValueMap
|
||||
* @output: keyValueMap - map in which key-value pairs are populated
|
||||
*
|
||||
* @remarks: internal method
|
||||
*
|
||||
*--*/
|
||||
bool Client::buildOAuthTokenKeyValuePairs( const bool includeOAuthVerifierPin,
|
||||
const std::string& rawData,
|
||||
const std::string& oauthSignature,
|
||||
KeyValuePairs& keyValueMap,
|
||||
const bool urlEncodeValues,
|
||||
const bool generateTimestamp )
|
||||
{
|
||||
// Encodes value part of key-value pairs depending on type of output (query
|
||||
// string vs. HTTP headers.
|
||||
StringConvertFunction value_encoder = (urlEncodeValues ? HttpEncodeQueryValue : PassThrough);
|
||||
|
||||
/* Generate nonce and timestamp if required */
|
||||
if( generateTimestamp )
|
||||
{
|
||||
generateNonceTimeStamp();
|
||||
}
|
||||
|
||||
/* Consumer key and its value */
|
||||
ReplaceOrInsertKeyValuePair(keyValueMap, Defaults::CONSUMERKEY_KEY, value_encoder(mConsumer->key()));
|
||||
|
||||
/* Nonce key and its value */
|
||||
ReplaceOrInsertKeyValuePair(keyValueMap, Defaults::NONCE_KEY, value_encoder(m_nonce));
|
||||
|
||||
/* Signature if supplied */
|
||||
if( oauthSignature.length() )
|
||||
{
|
||||
// Signature is exempt from encoding. The procedure for
|
||||
// computing it already percent-encodes it as required by the
|
||||
// spec for both query string and Auth header
|
||||
// methods. Therefore, it's pass-through in both cases.
|
||||
ReplaceOrInsertKeyValuePair(keyValueMap, Defaults::SIGNATURE_KEY, oauthSignature);
|
||||
}
|
||||
|
||||
/* Signature method, only HMAC-SHA1 as of now */
|
||||
ReplaceOrInsertKeyValuePair(keyValueMap, Defaults::SIGNATUREMETHOD_KEY, std::string( "HMAC-SHA1" ));
|
||||
|
||||
/* Timestamp */
|
||||
ReplaceOrInsertKeyValuePair(keyValueMap, Defaults::TIMESTAMP_KEY, value_encoder(m_timeStamp));
|
||||
|
||||
/* Token */
|
||||
if( mToken && mToken->key().length() )
|
||||
{
|
||||
ReplaceOrInsertKeyValuePair(keyValueMap, Defaults::TOKEN_KEY, value_encoder(mToken->key()));
|
||||
}
|
||||
|
||||
/* Verifier */
|
||||
if( includeOAuthVerifierPin && mToken && mToken->pin().length() )
|
||||
{
|
||||
ReplaceOrInsertKeyValuePair(keyValueMap, Defaults::VERIFIER_KEY, value_encoder(mToken->pin()));
|
||||
}
|
||||
|
||||
/* Version */
|
||||
ReplaceOrInsertKeyValuePair(keyValueMap, Defaults::VERSION_KEY, std::string( "1.0" ));
|
||||
|
||||
/* Data if it's present */
|
||||
if( rawData.length() )
|
||||
{
|
||||
/* Data should already be urlencoded once */
|
||||
std::string dummyStrKey;
|
||||
std::string dummyStrValue;
|
||||
size_t nPos = rawData.find_first_of( "=" );
|
||||
if( std::string::npos != nPos )
|
||||
{
|
||||
dummyStrKey = rawData.substr( 0, nPos );
|
||||
dummyStrValue = rawData.substr( nPos + 1 );
|
||||
ReplaceOrInsertKeyValuePair(keyValueMap, dummyStrKey, dummyStrValue);
|
||||
}
|
||||
}
|
||||
|
||||
return ( keyValueMap.size() ) ? true : false;
|
||||
}
|
||||
|
||||
/*++
|
||||
* @method: Client::getSignature
|
||||
*
|
||||
* @description: this method calculates HMAC-SHA1 signature of OAuth header
|
||||
*
|
||||
* @input: eType - HTTP request type
|
||||
* rawUrl - raw url of the HTTP request
|
||||
* rawKeyValuePairs - key-value pairs containing OAuth headers and HTTP data
|
||||
*
|
||||
* @output: oAuthSignature - base64 and url encoded signature
|
||||
*
|
||||
* @remarks: internal method
|
||||
*
|
||||
*--*/
|
||||
bool Client::getSignature( const Http::RequestType eType,
|
||||
const std::string& rawUrl,
|
||||
const KeyValuePairs& rawKeyValuePairs,
|
||||
std::string& oAuthSignature )
|
||||
{
|
||||
std::string rawParams;
|
||||
std::string paramsSeperator;
|
||||
std::string sigBase;
|
||||
|
||||
/* Initially empty signature */
|
||||
oAuthSignature.assign( "" );
|
||||
|
||||
/* Build a string using key-value pairs */
|
||||
paramsSeperator = "&";
|
||||
getStringFromOAuthKeyValuePairs( rawKeyValuePairs, rawParams, paramsSeperator );
|
||||
LOG(LogLevelDebug, "Normalized parameters: " << rawParams);
|
||||
|
||||
/* Start constructing base signature string. Refer http://dev.twitter.com/auth#intro */
|
||||
switch( eType )
|
||||
{
|
||||
case Http::Head:
|
||||
{
|
||||
sigBase.assign( "HEAD&" );
|
||||
}
|
||||
break;
|
||||
|
||||
case Http::Get:
|
||||
{
|
||||
sigBase.assign( "GET&" );
|
||||
}
|
||||
break;
|
||||
|
||||
case Http::Post:
|
||||
{
|
||||
sigBase.assign( "POST&" );
|
||||
}
|
||||
break;
|
||||
|
||||
case Http::Delete:
|
||||
{
|
||||
sigBase.assign( "DELETE&" );
|
||||
}
|
||||
break;
|
||||
|
||||
case Http::Put:
|
||||
{
|
||||
sigBase.assign( "PUT&" );
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
sigBase.append( PercentEncode( rawUrl ) );
|
||||
sigBase.append( "&" );
|
||||
sigBase.append( PercentEncode( rawParams ) );
|
||||
LOG(LogLevelDebug, "Signature base string: " << sigBase);
|
||||
|
||||
/* Now, hash the signature base string using HMAC_SHA1 class */
|
||||
CHMAC_SHA1 objHMACSHA1;
|
||||
std::string secretSigningKey;
|
||||
unsigned char strDigest[Defaults::BUFFSIZE_LARGE];
|
||||
|
||||
memset( strDigest, 0, Defaults::BUFFSIZE_LARGE );
|
||||
|
||||
/* Signing key is composed of consumer_secret&token_secret */
|
||||
secretSigningKey.assign( PercentEncode(mConsumer->secret()) );
|
||||
secretSigningKey.append( "&" );
|
||||
if( mToken && mToken->secret().length() )
|
||||
{
|
||||
secretSigningKey.append( PercentEncode(mToken->secret()) );
|
||||
}
|
||||
|
||||
objHMACSHA1.HMAC_SHA1( (unsigned char*)sigBase.c_str(),
|
||||
sigBase.length(),
|
||||
(unsigned char*)secretSigningKey.c_str(),
|
||||
secretSigningKey.length(),
|
||||
strDigest );
|
||||
|
||||
/* Do a base64 encode of signature */
|
||||
std::string base64Str = base64_encode( strDigest, 20 /* SHA 1 digest is 160 bits */ );
|
||||
LOG(LogLevelDebug, "Signature: " << base64Str);
|
||||
|
||||
/* Do an url encode */
|
||||
oAuthSignature = PercentEncode( base64Str );
|
||||
LOG(LogLevelDebug, "Percent-encoded Signature: " << oAuthSignature);
|
||||
|
||||
return ( oAuthSignature.length() ) ? true : false;
|
||||
}
|
||||
|
||||
std::string Client::getHttpHeader(const Http::RequestType eType,
|
||||
const std::string& rawUrl,
|
||||
const std::string& rawData,
|
||||
const bool includeOAuthVerifierPin)
|
||||
{
|
||||
return Defaults::AUTHHEADER_PREFIX + buildOAuthParameterString(AuthorizationHeaderString, eType, rawUrl, rawData, includeOAuthVerifierPin);
|
||||
}
|
||||
|
||||
std::string Client::getFormattedHttpHeader(const Http::RequestType eType,
|
||||
const std::string& rawUrl,
|
||||
const std::string& rawData,
|
||||
const bool includeOAuthVerifierPin)
|
||||
{
|
||||
return Defaults::AUTHHEADER_FIELD + Defaults::AUTHHEADER_PREFIX + buildOAuthParameterString(AuthorizationHeaderString, eType, rawUrl, rawData, includeOAuthVerifierPin);
|
||||
}
|
||||
|
||||
std::string Client::getURLQueryString(const Http::RequestType eType,
|
||||
const std::string& rawUrl,
|
||||
const std::string& rawData,
|
||||
const bool includeOAuthVerifierPin)
|
||||
{
|
||||
return buildOAuthParameterString(QueryStringString, eType, rawUrl, rawData, includeOAuthVerifierPin);
|
||||
}
|
||||
|
||||
std::string Client::buildOAuthParameterString(
|
||||
ParameterStringType string_type,
|
||||
const Http::RequestType eType,
|
||||
const std::string& rawUrl,
|
||||
const std::string& rawData,
|
||||
const bool includeOAuthVerifierPin)
|
||||
{
|
||||
KeyValuePairs rawKeyValuePairs;
|
||||
std::string rawParams;
|
||||
std::string oauthSignature;
|
||||
std::string paramsSeperator;
|
||||
std::string pureUrl( rawUrl );
|
||||
|
||||
LOG(LogLevelDebug, "Signing request " << RequestTypeString(eType) << " " << rawUrl << " " << rawData);
|
||||
|
||||
std::string separator;
|
||||
bool do_urlencode;
|
||||
if (string_type == AuthorizationHeaderString) {
|
||||
separator = ",";
|
||||
do_urlencode = false;
|
||||
}
|
||||
else { // QueryStringString
|
||||
separator = "&";
|
||||
do_urlencode = true;
|
||||
}
|
||||
|
||||
/* Clear header string initially */
|
||||
rawKeyValuePairs.clear();
|
||||
|
||||
/* If URL itself contains ?key=value, then extract and put them in map */
|
||||
size_t nPos = rawUrl.find_first_of( "?" );
|
||||
if( std::string::npos != nPos )
|
||||
{
|
||||
/* Get only URL */
|
||||
pureUrl = rawUrl.substr( 0, nPos );
|
||||
|
||||
/* Get only key=value data part */
|
||||
std::string dataPart = rawUrl.substr( nPos + 1 );
|
||||
rawKeyValuePairs = ParseKeyValuePairs(dataPart);
|
||||
}
|
||||
|
||||
// NOTE: We always request URL encoding on the first pass so that the
|
||||
// signature generation works properly. This *relies* on
|
||||
// buildOAuthTokenKeyValuePairs overwriting values when we do the second
|
||||
// pass to get the values in the form we actually want. The signature and
|
||||
// rawdata are the only things that change, but the signature is only used
|
||||
// in the second pass and the rawdata is already encoded, regardless of
|
||||
// request type.
|
||||
|
||||
/* Build key-value pairs needed for OAuth request token, without signature */
|
||||
buildOAuthTokenKeyValuePairs( includeOAuthVerifierPin, rawData, std::string( "" ), rawKeyValuePairs, true, true );
|
||||
|
||||
/* Get url encoded base64 signature using request type, url and parameters */
|
||||
getSignature( eType, pureUrl, rawKeyValuePairs, oauthSignature );
|
||||
|
||||
/* Now, again build key-value pairs with signature this time */
|
||||
buildOAuthTokenKeyValuePairs( includeOAuthVerifierPin, std::string( "" ), oauthSignature, rawKeyValuePairs, do_urlencode, false );
|
||||
|
||||
/* Get OAuth header in string format. If we're getting the Authorization
|
||||
* header, we need to filter out other parameters.
|
||||
*/
|
||||
if (string_type == AuthorizationHeaderString) {
|
||||
KeyValuePairs oauthKeyValuePairs;
|
||||
std::vector<std::string> oauth_keys;
|
||||
oauth_keys.push_back(Defaults::CONSUMERKEY_KEY);
|
||||
oauth_keys.push_back(Defaults::NONCE_KEY);
|
||||
oauth_keys.push_back(Defaults::SIGNATURE_KEY);
|
||||
oauth_keys.push_back(Defaults::SIGNATUREMETHOD_KEY);
|
||||
oauth_keys.push_back(Defaults::TIMESTAMP_KEY);
|
||||
oauth_keys.push_back(Defaults::TOKEN_KEY);
|
||||
oauth_keys.push_back(Defaults::VERIFIER_KEY);
|
||||
oauth_keys.push_back(Defaults::VERSION_KEY);
|
||||
|
||||
for(size_t i = 0; i < oauth_keys.size(); i++) {
|
||||
assert(rawKeyValuePairs.count(oauth_keys[i]) <= 1);
|
||||
KeyValuePairs::iterator oauth_key_it = rawKeyValuePairs.find(oauth_keys[i]);
|
||||
if (oauth_key_it != rawKeyValuePairs.end())
|
||||
ReplaceOrInsertKeyValuePair(oauthKeyValuePairs, oauth_keys[i], oauth_key_it->second);
|
||||
}
|
||||
getStringFromOAuthKeyValuePairs( oauthKeyValuePairs, rawParams, separator );
|
||||
}
|
||||
else if (string_type == QueryStringString) {
|
||||
getStringFromOAuthKeyValuePairs( rawKeyValuePairs, rawParams, separator );
|
||||
}
|
||||
|
||||
/* Build authorization header */
|
||||
return rawParams;
|
||||
}
|
||||
|
||||
/*++
|
||||
* @method: Client::getStringFromOAuthKeyValuePairs
|
||||
*
|
||||
* @description: this method builds a sorted string from key-value pairs
|
||||
*
|
||||
* @input: rawParamMap - key-value pairs map
|
||||
* paramsSeperator - sepearator, either & or ,
|
||||
*
|
||||
* @output: rawParams - sorted string of OAuth parameters
|
||||
*
|
||||
* @remarks: internal method
|
||||
*
|
||||
*--*/
|
||||
bool Client::getStringFromOAuthKeyValuePairs( const KeyValuePairs& rawParamMap,
|
||||
std::string& rawParams,
|
||||
const std::string& paramsSeperator )
|
||||
{
|
||||
rawParams.assign( "" );
|
||||
if( rawParamMap.size() )
|
||||
{
|
||||
KeyValueList keyValueList;
|
||||
std::string dummyStr;
|
||||
|
||||
/* Push key-value pairs to a list of strings */
|
||||
keyValueList.clear();
|
||||
KeyValuePairs::const_iterator itMap = rawParamMap.begin();
|
||||
for( ; itMap != rawParamMap.end(); itMap++ )
|
||||
{
|
||||
dummyStr.assign( itMap->first );
|
||||
dummyStr.append( "=" );
|
||||
if( paramsSeperator == "," )
|
||||
{
|
||||
dummyStr.append( "\"" );
|
||||
}
|
||||
dummyStr.append( itMap->second );
|
||||
if( paramsSeperator == "," )
|
||||
{
|
||||
dummyStr.append( "\"" );
|
||||
}
|
||||
keyValueList.push_back( dummyStr );
|
||||
}
|
||||
|
||||
/* Sort key-value pairs based on key name */
|
||||
keyValueList.sort();
|
||||
|
||||
/* Now, form a string */
|
||||
dummyStr.assign( "" );
|
||||
KeyValueList::iterator itKeyValue = keyValueList.begin();
|
||||
for( ; itKeyValue != keyValueList.end(); itKeyValue++ )
|
||||
{
|
||||
if( dummyStr.length() )
|
||||
{
|
||||
dummyStr.append( paramsSeperator );
|
||||
}
|
||||
dummyStr.append( itKeyValue->c_str() );
|
||||
}
|
||||
rawParams.assign( dummyStr );
|
||||
}
|
||||
return ( rawParams.length() ) ? true : false;
|
||||
}
|
||||
|
||||
|
||||
} // namespace OAuth
|
102
3party/liboauthcpp/src/urlencode.cpp
Normal file
|
@ -0,0 +1,102 @@
|
|||
#include "urlencode.h"
|
||||
#include <cassert>
|
||||
|
||||
std::string char2hex( char dec )
|
||||
{
|
||||
char dig1 = (dec&0xF0)>>4;
|
||||
char dig2 = (dec&0x0F);
|
||||
if ( 0<= dig1 && dig1<= 9) dig1+=48; //0,48 in ascii
|
||||
if (10<= dig1 && dig1<=15) dig1+=65-10; //A,65 in ascii
|
||||
if ( 0<= dig2 && dig2<= 9) dig2+=48;
|
||||
if (10<= dig2 && dig2<=15) dig2+=65-10;
|
||||
|
||||
std::string r;
|
||||
r.append( &dig1, 1);
|
||||
r.append( &dig2, 1);
|
||||
return r;
|
||||
}
|
||||
|
||||
std::string urlencode( const std::string &c, URLEncodeType enctype)
|
||||
{
|
||||
|
||||
std::string escaped;
|
||||
int max = c.length();
|
||||
for(int i=0; i<max; i++)
|
||||
{
|
||||
// Unreserved chars
|
||||
if ( (48 <= c[i] && c[i] <= 57) ||//0-9
|
||||
(65 <= c[i] && c[i] <= 90) ||//ABC...XYZ
|
||||
(97 <= c[i] && c[i] <= 122) || //abc...xyz
|
||||
(c[i]=='~' || c[i]=='-' || c[i]=='_' || c[i]=='.')
|
||||
)
|
||||
{
|
||||
escaped.append( &c[i], 1);
|
||||
}
|
||||
else if (c[i] != ':' && c[i] != '/' && c[i] != '?' && c[i] != '#' &&
|
||||
c[i] != '[' && c[i] != ']' && c[i] != '@' && c[i] != '%' &&
|
||||
|
||||
c[i] != '!' && c[i] != '$' && c[i] != '&' && c[i] != '\'' &&
|
||||
c[i] != '(' && c[i] != ')' && c[i] != '*' && c[i] != '+' &&
|
||||
c[i] != ',' && c[i] != ';' && c[i] != '=')
|
||||
{
|
||||
// Characters not in unreserved (first if block) and not in
|
||||
// the reserved set are always encoded.
|
||||
escaped.append("%");
|
||||
escaped.append( char2hex(c[i]) );//converts char 255 to string "FF"
|
||||
}
|
||||
else
|
||||
{
|
||||
// Finally, the reserved set. Encoding here depends on the
|
||||
// context (where in the URI we are, what type of URI, and
|
||||
// which character).
|
||||
|
||||
bool enc = false;
|
||||
|
||||
// Always encode reserved gen-delims + '%' (which always
|
||||
// needs encoding
|
||||
if (c[i] == ':' || c[i] == '/' || c[i] == '?' || c[i] == '#' ||
|
||||
c[i] == '[' || c[i] == ']' || c[i] == '@' || c[i] == '%')
|
||||
{
|
||||
enc = true;
|
||||
}
|
||||
else {
|
||||
switch (enctype) {
|
||||
case URLEncode_Everything:
|
||||
enc = true;
|
||||
break;
|
||||
case URLEncode_Path:
|
||||
// Only reserved sub-delim that needs encoding is %,
|
||||
// taken care of above. Otherwise, leave unencoded
|
||||
enc = false;
|
||||
break;
|
||||
case URLEncode_QueryKey:
|
||||
if (c[i] == '&' ||
|
||||
c[i] == '+' ||
|
||||
c[i] == '=')
|
||||
enc = true;
|
||||
else
|
||||
enc = false;
|
||||
break;
|
||||
case URLEncode_QueryValue:
|
||||
if (c[i] == '&' ||
|
||||
c[i] == '+')
|
||||
enc = true;
|
||||
else
|
||||
enc = false;
|
||||
break;
|
||||
default:
|
||||
assert(false && "Unknown urlencode type");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (enc) {
|
||||
escaped.append("%");
|
||||
escaped.append( char2hex(c[i]) );//converts char 255 to string "FF"
|
||||
} else {
|
||||
escaped.append( &c[i], 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return escaped;
|
||||
}
|
16
3party/liboauthcpp/src/urlencode.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
#ifndef __URLENCODE_H__
|
||||
#define __URLENCODE_H__
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
std::string char2hex( char dec );
|
||||
enum URLEncodeType {
|
||||
URLEncode_Everything,
|
||||
URLEncode_Path,
|
||||
URLEncode_QueryKey,
|
||||
URLEncode_QueryValue,
|
||||
};
|
||||
std::string urlencode( const std::string &c, URLEncodeType enctype );
|
||||
|
||||
#endif // __URLENCODE_H__
|
|
@ -22,5 +22,3 @@ target_compile_definitions(${PROJECT_NAME}
|
|||
)
|
||||
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE $<$<C_COMPILER_ID:Clang,AppleClang,GNU>:-Wno-unused-value>)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC ZLIB::ZLIB)
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
|
||||
#include "codearea.h"
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
#include <iomanip>
|
||||
#include <ios>
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
@ -97,24 +96,26 @@ class StreamFlagsKeeper
|
|||
std::ios_base::fmtflags m_flags;
|
||||
};
|
||||
|
||||
|
||||
template <typename TNumber>
|
||||
constexpr bool IsChar(TNumber) noexcept
|
||||
{
|
||||
return std::is_same<signed char, TNumber>::value ||
|
||||
std::is_same<unsigned char, TNumber>::value ||
|
||||
std::is_same<char, TNumber>::value;
|
||||
};
|
||||
|
||||
template <typename TNumber, typename std::enable_if<!IsChar(TNumber{}), void*>::type = nullptr>
|
||||
void PrintPaddedNumber(std::ostream & ost, TNumber const number, uint32_t const padding = 1)
|
||||
{
|
||||
static constexpr bool isChar = std::is_same_v<signed char, TNumber> ||
|
||||
std::is_same_v<unsigned char, TNumber> ||
|
||||
std::is_same_v<char, TNumber>;
|
||||
static_assert(std::is_integral<TNumber>::value, "number should be of integral type.");
|
||||
StreamFlagsKeeper keeper(ost);
|
||||
ost << std::setw(padding) << std::setfill('0') << number;
|
||||
}
|
||||
|
||||
if constexpr (isChar)
|
||||
{
|
||||
PrintPaddedNumber(ost, static_cast<int32_t>(number), padding);
|
||||
}
|
||||
else
|
||||
{
|
||||
static_assert(std::is_integral<TNumber>::value, "number should be of integral type.");
|
||||
StreamFlagsKeeper keeper(ost);
|
||||
ost << std::setw(padding) << std::setfill('0') << number;
|
||||
}
|
||||
template <typename TNumber, typename std::enable_if<IsChar(TNumber{}), void*>::type = nullptr>
|
||||
void PrintPaddedNumber(std::ostream & ost, TNumber const number, uint32_t const padding = 1)
|
||||
{
|
||||
PrintPaddedNumber(ost, static_cast<int32_t>(number), padding);
|
||||
}
|
||||
|
||||
void PrintHoursMinutes(std::ostream & ost,
|
||||
|
|
|
@ -6,7 +6,13 @@ omim_add_test(${PROJECT_NAME} ${SRC} BOOST_TEST)
|
|||
|
||||
target_link_libraries(${PROJECT_NAME} opening_hours)
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
set(COPY_CMD cp -u)
|
||||
else()
|
||||
set(COPY_CMD rsync -a)
|
||||
endif()
|
||||
|
||||
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/opening-count.lst" "${CMAKE_BINARY_DIR}/"
|
||||
COMMAND ${COPY_CMD} "${CMAKE_CURRENT_SOURCE_DIR}/opening-count.lst" "${CMAKE_BINARY_DIR}/"
|
||||
COMMENT "Copying opening-count.lst file for testing"
|
||||
)
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit caade5a28aad86b92a4b5337a9dc70c4ba73c5eb
|
||||
Subproject commit a0e064336317c9347a91224112af9933598714e9
|
12
3party/sdf_image/CMakeLists.txt
Normal file
|
@ -0,0 +1,12 @@
|
|||
project(sdf_image)
|
||||
|
||||
set(SRC
|
||||
sdf_image.cpp
|
||||
sdf_image.h
|
||||
)
|
||||
|
||||
add_library(${PROJECT_NAME} ${SRC})
|
||||
|
||||
target_compile_options(${PROJECT_NAME}
|
||||
PRIVATE $<$<CXX_COMPILER_ID:AppleClang,Clang>:-Wno-shorten-64-to-32>
|
||||
)
|
510
3party/sdf_image/sdf_image.cpp
Normal file
|
@ -0,0 +1,510 @@
|
|||
/*
|
||||
Copyright (C) 2009 by Stefan Gustavson
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "3party/sdf_image/sdf_image.h"
|
||||
|
||||
#include "base/math.hpp"
|
||||
#include "base/scope_guard.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
|
||||
using namespace std::placeholders;
|
||||
|
||||
namespace sdf_image
|
||||
{
|
||||
namespace
|
||||
{
|
||||
float const SQRT2 = 1.4142136f;
|
||||
|
||||
float ComputeXGradient(float ul, float /*u*/, float ur, float l, float r, float dl, float /*d*/, float dr)
|
||||
{
|
||||
return (ur + SQRT2 * r + dr) - (ul + SQRT2 * l + dl);
|
||||
}
|
||||
|
||||
float ComputeYGradient(float ul, float u, float ur, float /*l*/, float /*r*/, float dl, float d, float dr)
|
||||
{
|
||||
return (ur + SQRT2 * d + dr) - (ul + SQRT2 * u + dl);
|
||||
}
|
||||
|
||||
}
|
||||
#define BIND_GRADIENT(f) std::bind(&f, _1, _2, _3, _4, _5, _6, _7, _8)
|
||||
#define TRANSFORM(offset, dx, dy) \
|
||||
if (Transform(i, offset, dx, dy, xDist, yDist, oldDist)) \
|
||||
{ \
|
||||
dist.m_data[i] = oldDist; \
|
||||
changed = true; \
|
||||
}
|
||||
|
||||
|
||||
SdfImage::SdfImage(uint32_t h, uint32_t w)
|
||||
: m_height(h)
|
||||
, m_width(w)
|
||||
{
|
||||
m_data.resize(m_width * m_height, 0);
|
||||
}
|
||||
|
||||
SdfImage::SdfImage(uint32_t h, uint32_t w, uint8_t * imageData, uint8_t border)
|
||||
{
|
||||
int8_t doubleBorder = 2 * border;
|
||||
m_width = w + doubleBorder;
|
||||
m_height = h + doubleBorder;
|
||||
|
||||
uint32_t floatCount = m_width * m_height;
|
||||
m_data.resize(floatCount, 0.0f);
|
||||
for (size_t row = border; row < h + border; ++row)
|
||||
{
|
||||
size_t dstBaseIndex = row * m_width;
|
||||
size_t srcBaseIndex = (row - border) * w;
|
||||
for (size_t column = border; column < w + border; ++column)
|
||||
m_data[dstBaseIndex + column] = (float)imageData[srcBaseIndex + column - border] / 255.0f;
|
||||
}
|
||||
}
|
||||
|
||||
SdfImage::SdfImage(SdfImage const & copy)
|
||||
{
|
||||
m_height = copy.m_height;
|
||||
m_width = copy.m_width;
|
||||
m_data = copy.m_data;
|
||||
}
|
||||
|
||||
uint32_t SdfImage::GetWidth() const
|
||||
{
|
||||
return m_width;
|
||||
}
|
||||
|
||||
uint32_t SdfImage::GetHeight() const
|
||||
{
|
||||
return m_height;
|
||||
}
|
||||
|
||||
void SdfImage::GetData(std::vector<uint8_t> & dst)
|
||||
{
|
||||
ASSERT(m_data.size() <= dst.size(), ());
|
||||
std::transform(m_data.begin(), m_data.end(), dst.begin(), [](float const & node)
|
||||
{
|
||||
return static_cast<uint8_t>(node * 255.0f);
|
||||
});
|
||||
}
|
||||
|
||||
void SdfImage::Scale()
|
||||
{
|
||||
float maxi = std::numeric_limits<float>::min();
|
||||
float mini = std::numeric_limits<float>::max();
|
||||
|
||||
std::for_each(m_data.begin(), m_data.end(), [&maxi, &mini](float const & node)
|
||||
{
|
||||
maxi = std::max(maxi, node);
|
||||
mini = std::min(mini, node);
|
||||
});
|
||||
|
||||
maxi -= mini;
|
||||
std::for_each(m_data.begin(), m_data.end(), [&maxi, &mini](float & node)
|
||||
{
|
||||
node = (node - mini) / maxi;
|
||||
});
|
||||
}
|
||||
|
||||
void SdfImage::Invert()
|
||||
{
|
||||
std::for_each(m_data.begin(), m_data.end(), [](float & node)
|
||||
{
|
||||
node = 1.0f - node;
|
||||
});
|
||||
}
|
||||
|
||||
void SdfImage::Minus(SdfImage & im)
|
||||
{
|
||||
ASSERT(m_data.size() == im.m_data.size(), ());
|
||||
std::transform(m_data.begin(), m_data.end(), im.m_data.begin(), m_data.begin(), [](float const & n1, float const & n2)
|
||||
{
|
||||
return n1 - n2;
|
||||
});
|
||||
}
|
||||
|
||||
void SdfImage::Distquant()
|
||||
{
|
||||
std::for_each(m_data.begin(), m_data.end(), [](float & node)
|
||||
{
|
||||
node = base::Clamp(0.5f + node * 0.0325f, 0.0f, 1.0f);
|
||||
});
|
||||
}
|
||||
|
||||
void SdfImage::GenerateSDF(float sc)
|
||||
{
|
||||
Scale();
|
||||
|
||||
SdfImage outside(m_height, m_width);
|
||||
SdfImage inside(m_height, m_width);
|
||||
|
||||
size_t shortCount = m_width * m_height;
|
||||
std::vector<short> xDist;
|
||||
std::vector<short> yDist;
|
||||
xDist.resize(shortCount, 0);
|
||||
yDist.resize(shortCount, 0);
|
||||
|
||||
MexFunction(*this, xDist, yDist, outside);
|
||||
|
||||
fill(xDist.begin(), xDist.end(), 0);
|
||||
fill(yDist.begin(), yDist.end(), 0);
|
||||
|
||||
Invert();
|
||||
MexFunction(*this, xDist, yDist, inside);
|
||||
|
||||
outside.Minus(inside);
|
||||
outside.Distquant();
|
||||
outside.Invert();
|
||||
*this = outside.Bilinear(sc);
|
||||
}
|
||||
|
||||
SdfImage SdfImage::Bilinear(float scale)
|
||||
{
|
||||
uint32_t srcWidth = GetWidth();
|
||||
uint32_t srcHeight = GetHeight();
|
||||
uint32_t dstWidth = std::round(srcWidth * scale);
|
||||
uint32_t dstHeight = std::round(srcHeight * scale);
|
||||
|
||||
SdfImage result(dstHeight, dstWidth);
|
||||
|
||||
float xRatio = static_cast<float>(srcWidth) / dstWidth;
|
||||
float yRatio = static_cast<float>(srcHeight) / dstHeight;
|
||||
for (uint32_t i = 0; i < dstHeight; i++)
|
||||
{
|
||||
uint32_t baseIndex = i * dstWidth;
|
||||
for (uint32_t j = 0; j < dstWidth; j++)
|
||||
{
|
||||
float fx = xRatio * j;
|
||||
float fy = yRatio * i;
|
||||
uint32_t x = static_cast<uint32_t>(fx);
|
||||
uint32_t y = static_cast<uint32_t>(fy);
|
||||
uint32_t index = y * srcWidth + x;
|
||||
ASSERT_LESS(index, m_data.size(), ());
|
||||
|
||||
// range is 0 to 255 thus bitwise AND with 0xff
|
||||
float A = m_data[index];
|
||||
float B = m_data[index + 1];
|
||||
float C = m_data[index + srcWidth];
|
||||
float D = m_data[index + srcWidth + 1];
|
||||
|
||||
float xDiff = fx - x;
|
||||
float yDiff = fy - y;
|
||||
float xInvertDiff = 1.0f - xDiff;
|
||||
float yInvertDiff = 1.0f - yDiff;
|
||||
|
||||
float gray = A * xInvertDiff * yInvertDiff + B * xDiff * yInvertDiff +
|
||||
C * xInvertDiff * yDiff + D * xDiff * yDiff;
|
||||
|
||||
result.m_data[baseIndex + j] = gray;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
float SdfImage::ComputeGradient(uint32_t x, uint32_t y, SdfImage::TComputeFn const & fn) const
|
||||
{
|
||||
if (x < 1 || x > m_width - 1 ||
|
||||
y < 1 || y > m_height - 1)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
size_t k = y * m_width + x;
|
||||
|
||||
uint32_t l = k - 1;
|
||||
uint32_t r = k + 1;
|
||||
uint32_t u = k - m_width;
|
||||
uint32_t d = k + m_width;
|
||||
uint32_t ul = u - 1;
|
||||
uint32_t dl = d -1;
|
||||
uint32_t ur = u + 1;
|
||||
uint32_t dr = d + 1;
|
||||
|
||||
if (m_data[k] > 0.0 && m_data[k] < 1.0)
|
||||
{
|
||||
return fn(m_data[ul], m_data[u], m_data[ur],
|
||||
m_data[l], m_data[r],
|
||||
m_data[dl], m_data[d], m_data[dr]);
|
||||
}
|
||||
else
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
void SdfImage::MexFunction(SdfImage const & img, std::vector<short> & xDist, std::vector<short> & yDist, SdfImage & out)
|
||||
{
|
||||
ASSERT_EQUAL(img.GetWidth(), out.GetWidth(), ());
|
||||
ASSERT_EQUAL(img.GetHeight(), out.GetHeight(), ());
|
||||
|
||||
img.EdtaA3(xDist, yDist, out);
|
||||
// Pixels with grayscale>0.5 will have a negative distance.
|
||||
// This is correct, but we don't want values <0 returned here.
|
||||
std::for_each(out.m_data.begin(), out.m_data.end(), [](float & n)
|
||||
{
|
||||
n = std::max(0.0f, n);
|
||||
});
|
||||
}
|
||||
|
||||
float SdfImage::DistaA3(int c, int xc, int yc, int xi, int yi) const
|
||||
{
|
||||
int closest = c - xc - yc * m_width; // Index to the edge pixel pointed to from c
|
||||
//if (closest < 0 || closest > m_data.size())
|
||||
// return 1000000.0;
|
||||
ASSERT_GREATER_OR_EQUAL(closest, 0, ());
|
||||
ASSERT_LESS(closest, m_data.size(), ());
|
||||
|
||||
float a = base::Clamp(m_data[closest], 0.0f, 1.0f); // Grayscale value at the edge pixel
|
||||
|
||||
if(a == 0.0)
|
||||
return 1000000.0; // Not an object pixel, return "very far" ("don't know yet")
|
||||
|
||||
double dx = static_cast<double>(xi);
|
||||
double dy = static_cast<double>(yi);
|
||||
double di = sqrt(dx * dx + dy * dy); // Length of integer vector, like a traditional EDT
|
||||
double df = 0.0;
|
||||
if(di == 0.0)
|
||||
{
|
||||
int y = closest / m_width;
|
||||
int x = closest % m_width;
|
||||
// Use local gradient only at edges
|
||||
// Estimate based on local gradient only
|
||||
df = EdgeDf(ComputeGradient(x, y, BIND_GRADIENT(ComputeXGradient)),
|
||||
ComputeGradient(x, y, BIND_GRADIENT(ComputeYGradient)), a);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Estimate gradient based on direction to edge (accurate for large di)
|
||||
df = EdgeDf(dx, dy, a);
|
||||
}
|
||||
return static_cast<float>(di + df); // Same metric as edtaa2, except at edges (where di=0)
|
||||
}
|
||||
|
||||
double SdfImage::EdgeDf(double gx, double gy, double a) const
|
||||
{
|
||||
double df = 0.0;
|
||||
|
||||
if ((gx == 0) || (gy == 0))
|
||||
{
|
||||
// Either A) gu or gv are zero
|
||||
// B) both
|
||||
df = 0.5 - a; // Linear approximation is A) correct or B) a fair guess
|
||||
}
|
||||
else
|
||||
{
|
||||
double glength = sqrt(gx * gx + gy * gy);
|
||||
if(glength > 0)
|
||||
{
|
||||
gx = gx / glength;
|
||||
gy = gy / glength;
|
||||
}
|
||||
|
||||
// Everything is symmetric wrt sign and transposition,
|
||||
// so move to first octant (gx>=0, gy>=0, gx>=gy) to
|
||||
// avoid handling all possible edge directions.
|
||||
|
||||
gx = fabs(gx);
|
||||
gy = fabs(gy);
|
||||
if (gx < gy)
|
||||
std::swap(gx, gy);
|
||||
|
||||
double a1 = 0.5 * gy / gx;
|
||||
if (a < a1)
|
||||
df = 0.5 * (gx + gy) - sqrt(2.0 * gx * gy * a);
|
||||
else if (a < (1.0 - a1))
|
||||
df = (0.5 - a) * gx;
|
||||
else
|
||||
df = -0.5 * (gx + gy) + sqrt(2.0 * gx * gy * (1.0 - a));
|
||||
}
|
||||
|
||||
return df;
|
||||
}
|
||||
|
||||
void SdfImage::EdtaA3(std::vector<short> & xDist, std::vector<short> & yDist, SdfImage & dist) const
|
||||
{
|
||||
ASSERT_EQUAL(dist.GetHeight(), GetHeight(), ());
|
||||
ASSERT_EQUAL(dist.GetWidth(), GetWidth(), ());
|
||||
ASSERT_EQUAL(dist.m_data.size(), m_data.size(), ());
|
||||
|
||||
int w = GetWidth();
|
||||
int h = GetHeight();
|
||||
|
||||
/* Initialize the distance SdfImages */
|
||||
for (size_t y = 0; y < h; ++y)
|
||||
{
|
||||
size_t baseIndex = y * w;
|
||||
for (size_t x = 0; x < w; ++x)
|
||||
{
|
||||
size_t index = baseIndex + x;
|
||||
if (m_data[index] <= 0.0)
|
||||
dist.m_data[index]= 1000000.0; // Big value, means "not set yet"
|
||||
else if (m_data[index] < 1.0)
|
||||
{
|
||||
dist.m_data[index] = EdgeDf(ComputeGradient(x, y, BIND_GRADIENT(ComputeXGradient)),
|
||||
ComputeGradient(x, y, BIND_GRADIENT(ComputeYGradient)),
|
||||
m_data[index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Initialize index offsets for the current SdfImage width */
|
||||
int offsetU = -w;
|
||||
int offsetD = w;
|
||||
int offsetR = 1;
|
||||
int offsetL = -1;
|
||||
int offsetRu = -w + 1;
|
||||
int offsetRd = w + 1;
|
||||
int offsetLd = w - 1;
|
||||
int offsetLu = -w - 1;
|
||||
|
||||
/* Perform the transformation */
|
||||
bool changed;
|
||||
do
|
||||
{
|
||||
changed = false;
|
||||
for(int y = 1; y < h; ++y)
|
||||
{
|
||||
int i = y * w;
|
||||
|
||||
/* scan right, propagate distances from above & left */
|
||||
/* Leftmost pixel is special, has no left neighbors */
|
||||
float oldDist = dist.m_data[i];
|
||||
if(oldDist > 0) // If non-zero distance or not set yet
|
||||
{
|
||||
TRANSFORM(offsetU, 0, 1);
|
||||
TRANSFORM(offsetRu, -1, 1);
|
||||
}
|
||||
|
||||
++i;
|
||||
|
||||
/* Middle pixels have all neighbors */
|
||||
for(int x = 1; x < w - 1; ++x, ++i)
|
||||
{
|
||||
oldDist = dist.m_data[i];
|
||||
if(oldDist > 0.0)
|
||||
{
|
||||
TRANSFORM(offsetL, 1, 0);
|
||||
TRANSFORM(offsetLu, 1, 1);
|
||||
TRANSFORM(offsetU, 0, 1);
|
||||
TRANSFORM(offsetRu, -1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Rightmost pixel of row is special, has no right neighbors */
|
||||
oldDist = dist.m_data[i];
|
||||
if(oldDist > 0)
|
||||
{
|
||||
TRANSFORM(offsetL, 1, 0);
|
||||
TRANSFORM(offsetLu, 1, 1);
|
||||
TRANSFORM(offsetU, 0, 1);
|
||||
}
|
||||
|
||||
/* Move index to second rightmost pixel of current row. */
|
||||
/* Rightmost pixel is skipped, it has no right neighbor. */
|
||||
i = y * w + w - 2;
|
||||
|
||||
/* scan left, propagate distance from right */
|
||||
for(int x = w - 2; x >= 0; --x, --i)
|
||||
{
|
||||
oldDist = dist.m_data[i];
|
||||
if(oldDist > 0.0)
|
||||
TRANSFORM(offsetR, -1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* Scan rows in reverse order, except last row */
|
||||
for(int y = h - 2; y >= 0; --y)
|
||||
{
|
||||
/* move index to rightmost pixel of current row */
|
||||
int i = y * w + w - 1;
|
||||
|
||||
/* Scan left, propagate distances from below & right */
|
||||
|
||||
/* Rightmost pixel is special, has no right neighbors */
|
||||
float oldDist = dist.m_data[i];
|
||||
if(oldDist > 0) // If not already zero distance
|
||||
{
|
||||
TRANSFORM(offsetD, 0, -1);
|
||||
TRANSFORM(offsetLd, 1, -1);
|
||||
}
|
||||
|
||||
--i;
|
||||
|
||||
/* Middle pixels have all neighbors */
|
||||
for(int x = w - 2; x > 0; --x, --i)
|
||||
{
|
||||
oldDist = dist.m_data[i];
|
||||
if(oldDist > 0.0)
|
||||
{
|
||||
TRANSFORM(offsetR, -1, 0);
|
||||
TRANSFORM(offsetRd, -1, -1);
|
||||
TRANSFORM(offsetD, 0, -1);
|
||||
TRANSFORM(offsetLd, 1, -1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Leftmost pixel is special, has no left neighbors */
|
||||
oldDist = dist.m_data[i];
|
||||
if(oldDist > 0)
|
||||
{
|
||||
TRANSFORM(offsetR, -1, 0);
|
||||
TRANSFORM(offsetRd, -1, -1);
|
||||
TRANSFORM(offsetD, 0, -1);
|
||||
}
|
||||
|
||||
/* Move index to second leftmost pixel of current row. */
|
||||
/* Leftmost pixel is skipped, it has no left neighbor. */
|
||||
i = y * w + 1;
|
||||
for(int x = 1; x < w; ++x, ++i)
|
||||
{
|
||||
/* scan right, propagate distance from left */
|
||||
oldDist = dist.m_data[i];
|
||||
if(oldDist > 0.0)
|
||||
TRANSFORM(offsetL, 1, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
while(changed);
|
||||
}
|
||||
|
||||
bool SdfImage::Transform(int baseIndex, int offset, int dx, int dy, std::vector<short> & xDist, std::vector<short> & yDist, float & oldDist) const
|
||||
{
|
||||
double const epsilon = 1e-3;
|
||||
ASSERT_EQUAL(xDist.size(), yDist.size(), ());
|
||||
ASSERT_GREATER_OR_EQUAL(baseIndex, 0, ());
|
||||
ASSERT_LESS(baseIndex, xDist.size(), ());
|
||||
|
||||
int candidate = baseIndex + offset;
|
||||
ASSERT_GREATER_OR_EQUAL(candidate, 0, ());
|
||||
ASSERT_LESS(candidate, xDist.size(), ());
|
||||
|
||||
int cDistX = xDist[candidate];
|
||||
int cDistY = yDist[candidate];
|
||||
int newDistX = cDistX + dx;
|
||||
int newDistY = cDistY + dy;
|
||||
float newDist = DistaA3(candidate, cDistX, cDistY, newDistX, newDistY);
|
||||
if(newDist < oldDist - epsilon)
|
||||
{
|
||||
xDist[baseIndex] = newDistX;
|
||||
yDist[baseIndex] = newDistY;
|
||||
oldDist = newDist;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
} // namespace sdf_image
|
81
3party/sdf_image/sdf_image.h
Normal file
|
@ -0,0 +1,81 @@
|
|||
#pragma once
|
||||
|
||||
// +----------------------------------------+
|
||||
// | |
|
||||
// | http://contourtextures.wikidot.com |
|
||||
// | |
|
||||
// +----------------------------------------+
|
||||
|
||||
/*
|
||||
Copyright (C) 2009 by Stefan Gustavson
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "base/buffer_vector.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
|
||||
namespace sdf_image
|
||||
{
|
||||
class SdfImage
|
||||
{
|
||||
public:
|
||||
SdfImage() = default;
|
||||
SdfImage(uint32_t h, uint32_t w);
|
||||
SdfImage(uint32_t h, uint32_t w, uint8_t * imageData, uint8_t border);
|
||||
SdfImage(SdfImage const & copy);
|
||||
|
||||
uint32_t GetWidth() const;
|
||||
uint32_t GetHeight() const;
|
||||
void GetData(std::vector<uint8_t> & dst);
|
||||
void GenerateSDF(float sc);
|
||||
|
||||
private:
|
||||
void Scale();
|
||||
void Invert();
|
||||
void Minus(SdfImage &im);
|
||||
void Distquant();
|
||||
SdfImage Bilinear(float Scale);
|
||||
|
||||
private:
|
||||
/// ul = up left
|
||||
/// u = up
|
||||
/// ...
|
||||
/// d = down
|
||||
/// dr = down right
|
||||
/// ul u ur l r dl d dr
|
||||
using TComputeFn = std::function<float (float, float, float, float, float, float, float, float)>;
|
||||
float ComputeGradient(uint32_t x, uint32_t y, TComputeFn const & fn) const;
|
||||
void MexFunction(SdfImage const & img, std::vector<short> & xDist, std::vector<short> & yDist,
|
||||
SdfImage & out);
|
||||
float DistaA3(int c, int xc, int yc, int xi, int yi) const;
|
||||
double EdgeDf(double gx, double gy, double a) const;
|
||||
void EdtaA3(std::vector<short> & xDist, std::vector<short> & yDist, SdfImage & dist) const;
|
||||
bool Transform(int baseIndex, int offset, int dx, int dy, std::vector<short> & xDist,
|
||||
std::vector<short> & yDist, float & oldDist) const;
|
||||
|
||||
private:
|
||||
uint32_t m_height = 0;
|
||||
uint32_t m_width = 0;
|
||||
buffer_vector<float, 512> m_data;
|
||||
};
|
||||
} // namespace sdf_image
|
|
@ -511,7 +511,7 @@ static int stbi_write_bmp_core(stbi__write_context *s, int x, int y, int comp, c
|
|||
|
||||
STBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data)
|
||||
{
|
||||
stbi__write_context s = {};
|
||||
stbi__write_context s = { 0 };
|
||||
stbi__start_write_callbacks(&s, func, context);
|
||||
return stbi_write_bmp_core(&s, x, y, comp, data);
|
||||
}
|
||||
|
@ -519,7 +519,7 @@ STBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int x,
|
|||
#ifndef STBI_WRITE_NO_STDIO
|
||||
STBIWDEF int stbi_write_bmp(char const *filename, int x, int y, int comp, const void *data)
|
||||
{
|
||||
stbi__write_context s = {};
|
||||
stbi__write_context s = { 0 };
|
||||
if (stbi__start_write_file(&s,filename)) {
|
||||
int r = stbi_write_bmp_core(&s, x, y, comp, data);
|
||||
stbi__end_write_file(&s);
|
||||
|
@ -610,7 +610,7 @@ static int stbi_write_tga_core(stbi__write_context *s, int x, int y, int comp, v
|
|||
|
||||
STBIWDEF int stbi_write_tga_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data)
|
||||
{
|
||||
stbi__write_context s = {};
|
||||
stbi__write_context s = { 0 };
|
||||
stbi__start_write_callbacks(&s, func, context);
|
||||
return stbi_write_tga_core(&s, x, y, comp, (void *) data);
|
||||
}
|
||||
|
@ -618,7 +618,7 @@ STBIWDEF int stbi_write_tga_to_func(stbi_write_func *func, void *context, int x,
|
|||
#ifndef STBI_WRITE_NO_STDIO
|
||||
STBIWDEF int stbi_write_tga(char const *filename, int x, int y, int comp, const void *data)
|
||||
{
|
||||
stbi__write_context s = {};
|
||||
stbi__write_context s = { 0 };
|
||||
if (stbi__start_write_file(&s,filename)) {
|
||||
int r = stbi_write_tga_core(&s, x, y, comp, (void *) data);
|
||||
stbi__end_write_file(&s);
|
||||
|
@ -786,14 +786,14 @@ static int stbi_write_hdr_core(stbi__write_context *s, int x, int y, int comp, f
|
|||
|
||||
STBIWDEF int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const float *data)
|
||||
{
|
||||
stbi__write_context s = {};
|
||||
stbi__write_context s = { 0 };
|
||||
stbi__start_write_callbacks(&s, func, context);
|
||||
return stbi_write_hdr_core(&s, x, y, comp, (float *) data);
|
||||
}
|
||||
|
||||
STBIWDEF int stbi_write_hdr(char const *filename, int x, int y, int comp, const float *data)
|
||||
{
|
||||
stbi__write_context s = {};
|
||||
stbi__write_context s = { 0 };
|
||||
if (stbi__start_write_file(&s,filename)) {
|
||||
int r = stbi_write_hdr_core(&s, x, y, comp, (float *) data);
|
||||
stbi__end_write_file(&s);
|
||||
|
@ -1606,7 +1606,7 @@ static int stbi_write_jpg_core(stbi__write_context *s, int width, int height, in
|
|||
|
||||
STBIWDEF int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int quality)
|
||||
{
|
||||
stbi__write_context s = {};
|
||||
stbi__write_context s = { 0 };
|
||||
stbi__start_write_callbacks(&s, func, context);
|
||||
return stbi_write_jpg_core(&s, x, y, comp, (void *) data, quality);
|
||||
}
|
||||
|
@ -1615,7 +1615,7 @@ STBIWDEF int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x,
|
|||
#ifndef STBI_WRITE_NO_STDIO
|
||||
STBIWDEF int stbi_write_jpg(char const *filename, int x, int y, int comp, const void *data, int quality)
|
||||
{
|
||||
stbi__write_context s = {};
|
||||
stbi__write_context s = { 0 };
|
||||
if (stbi__start_write_file(&s,filename)) {
|
||||
int r = stbi_write_jpg_core(&s, x, y, comp, data, quality);
|
||||
stbi__end_write_file(&s);
|
||||
|
|
|
@ -38,14 +38,14 @@ namespace succinct {
|
|||
|
||||
typedef std::vector<uint64_t> bits_type;
|
||||
|
||||
bit_vector_builder(uint64_t size = 0, bool initBit = false)
|
||||
bit_vector_builder(uint64_t size = 0, bool init = 0)
|
||||
: m_size(size)
|
||||
{
|
||||
m_bits.resize(detail::words_for(size), initBit ? uint64_t(-1) : 0);
|
||||
m_bits.resize(detail::words_for(size), uint64_t(-init));
|
||||
if (size) {
|
||||
m_cur_word = &m_bits.back();
|
||||
// clear padding bits
|
||||
if (initBit && size % 64) {
|
||||
if (init && size % 64) {
|
||||
*m_cur_word >>= 64 - (size % 64);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 6be08bbea14ffa0a5c594257fb6285a054395cd7
|
12
3party/utfcpp/doc/ReleaseNotes
Normal file
|
@ -0,0 +1,12 @@
|
|||
utf8 cpp library
|
||||
Release 2.3.4
|
||||
|
||||
A minor bug fix release. Thanks to all who reported bugs.
|
||||
|
||||
Note: Version 2.3.3 contained a regression, and therefore was removed.
|
||||
|
||||
Changes from version 2.3.2
|
||||
- Bug fix [39]: checked.h Line 273 and unchecked.h Line 182 have an extra ';'
|
||||
- Bug fix [36]: replace_invalid() only works with back_inserter
|
||||
|
||||
Files included in the release: utf8.h, core.h, checked.h, unchecked.h, utf8cpp.html, ReleaseNotes
|
1789
3party/utfcpp/doc/utf8cpp.html
Normal file
34
3party/utfcpp/source/utf8.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
// Copyright 2006 Nemanja Trifunovic
|
||||
|
||||
/*
|
||||
Permission is hereby granted, free of charge, to any person or organization
|
||||
obtaining a copy of the software and accompanying documentation covered by
|
||||
this license (the "Software") to use, reproduce, display, distribute,
|
||||
execute, and transmit the Software, and to prepare derivative works of the
|
||||
Software, and to permit third-parties to whom the Software is furnished to
|
||||
do so, all subject to the following:
|
||||
|
||||
The copyright notices in the Software and this entire statement, including
|
||||
the above license grant, this restriction and the following disclaimer,
|
||||
must be included in all copies of the Software, in whole or in part, and
|
||||
all derivative works of the Software, unless such copies or derivative
|
||||
works are solely in the form of machine-executable object code generated by
|
||||
a source language processor.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef UTF8_FOR_CPP_2675DCD0_9480_4c0c_B92A_CC14C027B731
|
||||
#define UTF8_FOR_CPP_2675DCD0_9480_4c0c_B92A_CC14C027B731
|
||||
|
||||
#include "utf8/checked.h"
|
||||
#include "utf8/unchecked.h"
|
||||
|
||||
#endif // header guard
|
335
3party/utfcpp/source/utf8/checked.h
Normal file
|
@ -0,0 +1,335 @@
|
|||
// Copyright 2006-2016 Nemanja Trifunovic
|
||||
|
||||
/*
|
||||
Permission is hereby granted, free of charge, to any person or organization
|
||||
obtaining a copy of the software and accompanying documentation covered by
|
||||
this license (the "Software") to use, reproduce, display, distribute,
|
||||
execute, and transmit the Software, and to prepare derivative works of the
|
||||
Software, and to permit third-parties to whom the Software is furnished to
|
||||
do so, all subject to the following:
|
||||
|
||||
The copyright notices in the Software and this entire statement, including
|
||||
the above license grant, this restriction and the following disclaimer,
|
||||
must be included in all copies of the Software, in whole or in part, and
|
||||
all derivative works of the Software, unless such copies or derivative
|
||||
works are solely in the form of machine-executable object code generated by
|
||||
a source language processor.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef UTF8_FOR_CPP_CHECKED_H_2675DCD0_9480_4c0c_B92A_CC14C027B731
|
||||
#define UTF8_FOR_CPP_CHECKED_H_2675DCD0_9480_4c0c_B92A_CC14C027B731
|
||||
|
||||
#include "core.h"
|
||||
#include <stdexcept>
|
||||
|
||||
namespace utf8
|
||||
{
|
||||
// Base for the exceptions that may be thrown from the library
|
||||
class exception : public ::std::exception {
|
||||
};
|
||||
|
||||
// Exceptions that may be thrown from the library functions.
|
||||
class invalid_code_point : public exception {
|
||||
uint32_t cp;
|
||||
public:
|
||||
invalid_code_point(uint32_t codepoint) : cp(codepoint) {}
|
||||
virtual const char* what() const UTF_CPP_NOEXCEPT UTF_CPP_OVERRIDE { return "Invalid code point"; }
|
||||
uint32_t code_point() const {return cp;}
|
||||
};
|
||||
|
||||
class invalid_utf8 : public exception {
|
||||
uint8_t u8;
|
||||
public:
|
||||
invalid_utf8 (uint8_t u) : u8(u) {}
|
||||
virtual const char* what() const UTF_CPP_NOEXCEPT UTF_CPP_OVERRIDE { return "Invalid UTF-8"; }
|
||||
uint8_t utf8_octet() const {return u8;}
|
||||
};
|
||||
|
||||
class invalid_utf16 : public exception {
|
||||
uint16_t u16;
|
||||
public:
|
||||
invalid_utf16 (uint16_t u) : u16(u) {}
|
||||
virtual const char* what() const UTF_CPP_NOEXCEPT UTF_CPP_OVERRIDE { return "Invalid UTF-16"; }
|
||||
uint16_t utf16_word() const {return u16;}
|
||||
};
|
||||
|
||||
class not_enough_room : public exception {
|
||||
public:
|
||||
virtual const char* what() const UTF_CPP_NOEXCEPT UTF_CPP_OVERRIDE { return "Not enough space"; }
|
||||
};
|
||||
|
||||
/// The library API - functions intended to be called by the users
|
||||
|
||||
template <typename octet_iterator>
|
||||
octet_iterator append(uint32_t cp, octet_iterator result)
|
||||
{
|
||||
if (!utf8::internal::is_code_point_valid(cp))
|
||||
throw invalid_code_point(cp);
|
||||
|
||||
if (cp < 0x80) // one octet
|
||||
*(result++) = static_cast<uint8_t>(cp);
|
||||
else if (cp < 0x800) { // two octets
|
||||
*(result++) = static_cast<uint8_t>((cp >> 6) | 0xc0);
|
||||
*(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
|
||||
}
|
||||
else if (cp < 0x10000) { // three octets
|
||||
*(result++) = static_cast<uint8_t>((cp >> 12) | 0xe0);
|
||||
*(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f) | 0x80);
|
||||
*(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
|
||||
}
|
||||
else { // four octets
|
||||
*(result++) = static_cast<uint8_t>((cp >> 18) | 0xf0);
|
||||
*(result++) = static_cast<uint8_t>(((cp >> 12) & 0x3f) | 0x80);
|
||||
*(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f) | 0x80);
|
||||
*(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename octet_iterator, typename output_iterator>
|
||||
output_iterator replace_invalid(octet_iterator start, octet_iterator end, output_iterator out, uint32_t replacement)
|
||||
{
|
||||
while (start != end) {
|
||||
octet_iterator sequence_start = start;
|
||||
internal::utf_error err_code = utf8::internal::validate_next(start, end);
|
||||
switch (err_code) {
|
||||
case internal::UTF8_OK :
|
||||
for (octet_iterator it = sequence_start; it != start; ++it)
|
||||
*out++ = *it;
|
||||
break;
|
||||
case internal::NOT_ENOUGH_ROOM:
|
||||
out = utf8::append (replacement, out);
|
||||
start = end;
|
||||
break;
|
||||
case internal::INVALID_LEAD:
|
||||
out = utf8::append (replacement, out);
|
||||
++start;
|
||||
break;
|
||||
case internal::INCOMPLETE_SEQUENCE:
|
||||
case internal::OVERLONG_SEQUENCE:
|
||||
case internal::INVALID_CODE_POINT:
|
||||
out = utf8::append (replacement, out);
|
||||
++start;
|
||||
// just one replacement mark for the sequence
|
||||
while (start != end && utf8::internal::is_trail(*start))
|
||||
++start;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
template <typename octet_iterator, typename output_iterator>
|
||||
inline output_iterator replace_invalid(octet_iterator start, octet_iterator end, output_iterator out)
|
||||
{
|
||||
static const uint32_t replacement_marker = utf8::internal::mask16(0xfffd);
|
||||
return utf8::replace_invalid(start, end, out, replacement_marker);
|
||||
}
|
||||
|
||||
template <typename octet_iterator>
|
||||
uint32_t next(octet_iterator& it, octet_iterator end)
|
||||
{
|
||||
uint32_t cp = 0;
|
||||
internal::utf_error err_code = utf8::internal::validate_next(it, end, cp);
|
||||
switch (err_code) {
|
||||
case internal::UTF8_OK :
|
||||
break;
|
||||
case internal::NOT_ENOUGH_ROOM :
|
||||
throw not_enough_room();
|
||||
case internal::INVALID_LEAD :
|
||||
case internal::INCOMPLETE_SEQUENCE :
|
||||
case internal::OVERLONG_SEQUENCE :
|
||||
throw invalid_utf8(*it);
|
||||
case internal::INVALID_CODE_POINT :
|
||||
throw invalid_code_point(cp);
|
||||
}
|
||||
return cp;
|
||||
}
|
||||
|
||||
template <typename octet_iterator>
|
||||
uint32_t peek_next(octet_iterator it, octet_iterator end)
|
||||
{
|
||||
return utf8::next(it, end);
|
||||
}
|
||||
|
||||
template <typename octet_iterator>
|
||||
uint32_t prior(octet_iterator& it, octet_iterator start)
|
||||
{
|
||||
// can't do much if it == start
|
||||
if (it == start)
|
||||
throw not_enough_room();
|
||||
|
||||
octet_iterator end = it;
|
||||
// Go back until we hit either a lead octet or start
|
||||
while (utf8::internal::is_trail(*(--it)))
|
||||
if (it == start)
|
||||
throw invalid_utf8(*it); // error - no lead byte in the sequence
|
||||
return utf8::peek_next(it, end);
|
||||
}
|
||||
|
||||
template <typename octet_iterator, typename distance_type>
|
||||
void advance (octet_iterator& it, distance_type n, octet_iterator end)
|
||||
{
|
||||
const distance_type zero(0);
|
||||
if (n < zero) {
|
||||
// backward
|
||||
for (distance_type i = n; i < zero; ++i)
|
||||
utf8::prior(it, end);
|
||||
} else {
|
||||
// forward
|
||||
for (distance_type i = zero; i < n; ++i)
|
||||
utf8::next(it, end);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename octet_iterator>
|
||||
typename std::iterator_traits<octet_iterator>::difference_type
|
||||
distance (octet_iterator first, octet_iterator last)
|
||||
{
|
||||
typename std::iterator_traits<octet_iterator>::difference_type dist;
|
||||
for (dist = 0; first < last; ++dist)
|
||||
utf8::next(first, last);
|
||||
return dist;
|
||||
}
|
||||
|
||||
template <typename u16bit_iterator, typename octet_iterator>
|
||||
octet_iterator utf16to8 (u16bit_iterator start, u16bit_iterator end, octet_iterator result)
|
||||
{
|
||||
while (start != end) {
|
||||
uint32_t cp = utf8::internal::mask16(*start++);
|
||||
// Take care of surrogate pairs first
|
||||
if (utf8::internal::is_lead_surrogate(cp)) {
|
||||
if (start != end) {
|
||||
uint32_t trail_surrogate = utf8::internal::mask16(*start++);
|
||||
if (utf8::internal::is_trail_surrogate(trail_surrogate))
|
||||
cp = (cp << 10) + trail_surrogate + internal::SURROGATE_OFFSET;
|
||||
else
|
||||
throw invalid_utf16(static_cast<uint16_t>(trail_surrogate));
|
||||
}
|
||||
else
|
||||
throw invalid_utf16(static_cast<uint16_t>(cp));
|
||||
|
||||
}
|
||||
// Lone trail surrogate
|
||||
else if (utf8::internal::is_trail_surrogate(cp))
|
||||
throw invalid_utf16(static_cast<uint16_t>(cp));
|
||||
|
||||
result = utf8::append(cp, result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename u16bit_iterator, typename octet_iterator>
|
||||
u16bit_iterator utf8to16 (octet_iterator start, octet_iterator end, u16bit_iterator result)
|
||||
{
|
||||
while (start < end) {
|
||||
uint32_t cp = utf8::next(start, end);
|
||||
if (cp > 0xffff) { //make a surrogate pair
|
||||
*result++ = static_cast<uint16_t>((cp >> 10) + internal::LEAD_OFFSET);
|
||||
*result++ = static_cast<uint16_t>((cp & 0x3ff) + internal::TRAIL_SURROGATE_MIN);
|
||||
}
|
||||
else
|
||||
*result++ = static_cast<uint16_t>(cp);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename octet_iterator, typename u32bit_iterator>
|
||||
octet_iterator utf32to8 (u32bit_iterator start, u32bit_iterator end, octet_iterator result)
|
||||
{
|
||||
while (start != end)
|
||||
result = utf8::append(*(start++), result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename octet_iterator, typename u32bit_iterator>
|
||||
u32bit_iterator utf8to32 (octet_iterator start, octet_iterator end, u32bit_iterator result)
|
||||
{
|
||||
while (start < end)
|
||||
(*result++) = utf8::next(start, end);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// The iterator class
|
||||
template <typename octet_iterator>
|
||||
class iterator {
|
||||
octet_iterator it;
|
||||
octet_iterator range_start;
|
||||
octet_iterator range_end;
|
||||
public:
|
||||
typedef uint32_t value_type;
|
||||
typedef uint32_t* pointer;
|
||||
typedef uint32_t& reference;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef std::bidirectional_iterator_tag iterator_category;
|
||||
iterator () {}
|
||||
explicit iterator (const octet_iterator& octet_it,
|
||||
const octet_iterator& rangestart,
|
||||
const octet_iterator& rangeend) :
|
||||
it(octet_it), range_start(rangestart), range_end(rangeend)
|
||||
{
|
||||
if (it < range_start || it > range_end)
|
||||
throw std::out_of_range("Invalid utf-8 iterator position");
|
||||
}
|
||||
// the default "big three" are OK
|
||||
octet_iterator base () const { return it; }
|
||||
uint32_t operator * () const
|
||||
{
|
||||
octet_iterator temp = it;
|
||||
return utf8::next(temp, range_end);
|
||||
}
|
||||
bool operator == (const iterator& rhs) const
|
||||
{
|
||||
if (range_start != rhs.range_start || range_end != rhs.range_end)
|
||||
throw std::logic_error("Comparing utf-8 iterators defined with different ranges");
|
||||
return (it == rhs.it);
|
||||
}
|
||||
bool operator != (const iterator& rhs) const
|
||||
{
|
||||
return !(operator == (rhs));
|
||||
}
|
||||
iterator& operator ++ ()
|
||||
{
|
||||
utf8::next(it, range_end);
|
||||
return *this;
|
||||
}
|
||||
iterator operator ++ (int)
|
||||
{
|
||||
iterator temp = *this;
|
||||
utf8::next(it, range_end);
|
||||
return temp;
|
||||
}
|
||||
iterator& operator -- ()
|
||||
{
|
||||
utf8::prior(it, range_start);
|
||||
return *this;
|
||||
}
|
||||
iterator operator -- (int)
|
||||
{
|
||||
iterator temp = *this;
|
||||
utf8::prior(it, range_start);
|
||||
return temp;
|
||||
}
|
||||
}; // class iterator
|
||||
|
||||
} // namespace utf8
|
||||
|
||||
#if UTF_CPP_CPLUSPLUS >= 201703L // C++ 17 or later
|
||||
#include "cpp17.h"
|
||||
#elif UTF_CPP_CPLUSPLUS >= 201103L // C++ 11 or later
|
||||
#include "cpp11.h"
|
||||
#endif // C++ 11 or later
|
||||
|
||||
#endif //header guard
|
||||
|
338
3party/utfcpp/source/utf8/core.h
Normal file
|
@ -0,0 +1,338 @@
|
|||
// Copyright 2006 Nemanja Trifunovic
|
||||
|
||||
/*
|
||||
Permission is hereby granted, free of charge, to any person or organization
|
||||
obtaining a copy of the software and accompanying documentation covered by
|
||||
this license (the "Software") to use, reproduce, display, distribute,
|
||||
execute, and transmit the Software, and to prepare derivative works of the
|
||||
Software, and to permit third-parties to whom the Software is furnished to
|
||||
do so, all subject to the following:
|
||||
|
||||
The copyright notices in the Software and this entire statement, including
|
||||
the above license grant, this restriction and the following disclaimer,
|
||||
must be included in all copies of the Software, in whole or in part, and
|
||||
all derivative works of the Software, unless such copies or derivative
|
||||
works are solely in the form of machine-executable object code generated by
|
||||
a source language processor.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef UTF8_FOR_CPP_CORE_H_2675DCD0_9480_4c0c_B92A_CC14C027B731
|
||||
#define UTF8_FOR_CPP_CORE_H_2675DCD0_9480_4c0c_B92A_CC14C027B731
|
||||
|
||||
#include <iterator>
|
||||
|
||||
// Determine the C++ standard version.
|
||||
// If the user defines UTF_CPP_CPLUSPLUS, use that.
|
||||
// Otherwise, trust the unreliable predefined macro __cplusplus
|
||||
|
||||
#if !defined UTF_CPP_CPLUSPLUS
|
||||
#define UTF_CPP_CPLUSPLUS __cplusplus
|
||||
#endif
|
||||
|
||||
#if UTF_CPP_CPLUSPLUS >= 201103L // C++ 11 or later
|
||||
#define UTF_CPP_OVERRIDE override
|
||||
#define UTF_CPP_NOEXCEPT noexcept
|
||||
#else // C++ 98/03
|
||||
#define UTF_CPP_OVERRIDE
|
||||
#define UTF_CPP_NOEXCEPT throw()
|
||||
#endif // C++ 11 or later
|
||||
|
||||
|
||||
namespace utf8
|
||||
{
|
||||
// The typedefs for 8-bit, 16-bit and 32-bit unsigned integers
|
||||
// You may need to change them to match your system.
|
||||
// These typedefs have the same names as ones from cstdint, or boost/cstdint
|
||||
typedef unsigned char uint8_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef unsigned int uint32_t;
|
||||
|
||||
// Helper code - not intended to be directly called by the library users. May be changed at any time
|
||||
namespace internal
|
||||
{
|
||||
// Unicode constants
|
||||
// Leading (high) surrogates: 0xd800 - 0xdbff
|
||||
// Trailing (low) surrogates: 0xdc00 - 0xdfff
|
||||
const uint16_t LEAD_SURROGATE_MIN = 0xd800u;
|
||||
const uint16_t LEAD_SURROGATE_MAX = 0xdbffu;
|
||||
const uint16_t TRAIL_SURROGATE_MIN = 0xdc00u;
|
||||
const uint16_t TRAIL_SURROGATE_MAX = 0xdfffu;
|
||||
const uint16_t LEAD_OFFSET = 0xd7c0u; // LEAD_SURROGATE_MIN - (0x10000 >> 10)
|
||||
const uint32_t SURROGATE_OFFSET = 0xfca02400u; // 0x10000u - (LEAD_SURROGATE_MIN << 10) - TRAIL_SURROGATE_MIN
|
||||
|
||||
// Maximum valid value for a Unicode code point
|
||||
const uint32_t CODE_POINT_MAX = 0x0010ffffu;
|
||||
|
||||
template<typename octet_type>
|
||||
inline uint8_t mask8(octet_type oc)
|
||||
{
|
||||
return static_cast<uint8_t>(0xff & oc);
|
||||
}
|
||||
template<typename u16_type>
|
||||
inline uint16_t mask16(u16_type oc)
|
||||
{
|
||||
return static_cast<uint16_t>(0xffff & oc);
|
||||
}
|
||||
template<typename octet_type>
|
||||
inline bool is_trail(octet_type oc)
|
||||
{
|
||||
return ((utf8::internal::mask8(oc) >> 6) == 0x2);
|
||||
}
|
||||
|
||||
template <typename u16>
|
||||
inline bool is_lead_surrogate(u16 cp)
|
||||
{
|
||||
return (cp >= LEAD_SURROGATE_MIN && cp <= LEAD_SURROGATE_MAX);
|
||||
}
|
||||
|
||||
template <typename u16>
|
||||
inline bool is_trail_surrogate(u16 cp)
|
||||
{
|
||||
return (cp >= TRAIL_SURROGATE_MIN && cp <= TRAIL_SURROGATE_MAX);
|
||||
}
|
||||
|
||||
template <typename u16>
|
||||
inline bool is_surrogate(u16 cp)
|
||||
{
|
||||
return (cp >= LEAD_SURROGATE_MIN && cp <= TRAIL_SURROGATE_MAX);
|
||||
}
|
||||
|
||||
template <typename u32>
|
||||
inline bool is_code_point_valid(u32 cp)
|
||||
{
|
||||
return (cp <= CODE_POINT_MAX && !utf8::internal::is_surrogate(cp));
|
||||
}
|
||||
|
||||
template <typename octet_iterator>
|
||||
inline typename std::iterator_traits<octet_iterator>::difference_type
|
||||
sequence_length(octet_iterator lead_it)
|
||||
{
|
||||
uint8_t lead = utf8::internal::mask8(*lead_it);
|
||||
if (lead < 0x80)
|
||||
return 1;
|
||||
else if ((lead >> 5) == 0x6)
|
||||
return 2;
|
||||
else if ((lead >> 4) == 0xe)
|
||||
return 3;
|
||||
else if ((lead >> 3) == 0x1e)
|
||||
return 4;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <typename octet_difference_type>
|
||||
inline bool is_overlong_sequence(uint32_t cp, octet_difference_type length)
|
||||
{
|
||||
if (cp < 0x80) {
|
||||
if (length != 1)
|
||||
return true;
|
||||
}
|
||||
else if (cp < 0x800) {
|
||||
if (length != 2)
|
||||
return true;
|
||||
}
|
||||
else if (cp < 0x10000) {
|
||||
if (length != 3)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
enum utf_error {UTF8_OK, NOT_ENOUGH_ROOM, INVALID_LEAD, INCOMPLETE_SEQUENCE, OVERLONG_SEQUENCE, INVALID_CODE_POINT};
|
||||
|
||||
/// Helper for get_sequence_x
|
||||
template <typename octet_iterator>
|
||||
utf_error increase_safely(octet_iterator& it, octet_iterator end)
|
||||
{
|
||||
if (++it == end)
|
||||
return NOT_ENOUGH_ROOM;
|
||||
|
||||
if (!utf8::internal::is_trail(*it))
|
||||
return INCOMPLETE_SEQUENCE;
|
||||
|
||||
return UTF8_OK;
|
||||
}
|
||||
|
||||
#define UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(IT, END) {utf_error ret = increase_safely(IT, END); if (ret != UTF8_OK) return ret;}
|
||||
|
||||
/// get_sequence_x functions decode utf-8 sequences of the length x
|
||||
template <typename octet_iterator>
|
||||
utf_error get_sequence_1(octet_iterator& it, octet_iterator end, uint32_t& code_point)
|
||||
{
|
||||
if (it == end)
|
||||
return NOT_ENOUGH_ROOM;
|
||||
|
||||
code_point = utf8::internal::mask8(*it);
|
||||
|
||||
return UTF8_OK;
|
||||
}
|
||||
|
||||
template <typename octet_iterator>
|
||||
utf_error get_sequence_2(octet_iterator& it, octet_iterator end, uint32_t& code_point)
|
||||
{
|
||||
if (it == end)
|
||||
return NOT_ENOUGH_ROOM;
|
||||
|
||||
code_point = utf8::internal::mask8(*it);
|
||||
|
||||
UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end)
|
||||
|
||||
code_point = ((code_point << 6) & 0x7ff) + ((*it) & 0x3f);
|
||||
|
||||
return UTF8_OK;
|
||||
}
|
||||
|
||||
template <typename octet_iterator>
|
||||
utf_error get_sequence_3(octet_iterator& it, octet_iterator end, uint32_t& code_point)
|
||||
{
|
||||
if (it == end)
|
||||
return NOT_ENOUGH_ROOM;
|
||||
|
||||
code_point = utf8::internal::mask8(*it);
|
||||
|
||||
UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end)
|
||||
|
||||
code_point = ((code_point << 12) & 0xffff) + ((utf8::internal::mask8(*it) << 6) & 0xfff);
|
||||
|
||||
UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end)
|
||||
|
||||
code_point += (*it) & 0x3f;
|
||||
|
||||
return UTF8_OK;
|
||||
}
|
||||
|
||||
template <typename octet_iterator>
|
||||
utf_error get_sequence_4(octet_iterator& it, octet_iterator end, uint32_t& code_point)
|
||||
{
|
||||
if (it == end)
|
||||
return NOT_ENOUGH_ROOM;
|
||||
|
||||
code_point = utf8::internal::mask8(*it);
|
||||
|
||||
UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end)
|
||||
|
||||
code_point = ((code_point << 18) & 0x1fffff) + ((utf8::internal::mask8(*it) << 12) & 0x3ffff);
|
||||
|
||||
UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end)
|
||||
|
||||
code_point += (utf8::internal::mask8(*it) << 6) & 0xfff;
|
||||
|
||||
UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end)
|
||||
|
||||
code_point += (*it) & 0x3f;
|
||||
|
||||
return UTF8_OK;
|
||||
}
|
||||
|
||||
#undef UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR
|
||||
|
||||
template <typename octet_iterator>
|
||||
utf_error validate_next(octet_iterator& it, octet_iterator end, uint32_t& code_point)
|
||||
{
|
||||
if (it == end)
|
||||
return NOT_ENOUGH_ROOM;
|
||||
|
||||
// Save the original value of it so we can go back in case of failure
|
||||
// Of course, it does not make much sense with i.e. stream iterators
|
||||
octet_iterator original_it = it;
|
||||
|
||||
uint32_t cp = 0;
|
||||
// Determine the sequence length based on the lead octet
|
||||
typedef typename std::iterator_traits<octet_iterator>::difference_type octet_difference_type;
|
||||
const octet_difference_type length = utf8::internal::sequence_length(it);
|
||||
|
||||
// Get trail octets and calculate the code point
|
||||
utf_error err = UTF8_OK;
|
||||
switch (length) {
|
||||
case 0:
|
||||
return INVALID_LEAD;
|
||||
case 1:
|
||||
err = utf8::internal::get_sequence_1(it, end, cp);
|
||||
break;
|
||||
case 2:
|
||||
err = utf8::internal::get_sequence_2(it, end, cp);
|
||||
break;
|
||||
case 3:
|
||||
err = utf8::internal::get_sequence_3(it, end, cp);
|
||||
break;
|
||||
case 4:
|
||||
err = utf8::internal::get_sequence_4(it, end, cp);
|
||||
break;
|
||||
}
|
||||
|
||||
if (err == UTF8_OK) {
|
||||
// Decoding succeeded. Now, security checks...
|
||||
if (utf8::internal::is_code_point_valid(cp)) {
|
||||
if (!utf8::internal::is_overlong_sequence(cp, length)){
|
||||
// Passed! Return here.
|
||||
code_point = cp;
|
||||
++it;
|
||||
return UTF8_OK;
|
||||
}
|
||||
else
|
||||
err = OVERLONG_SEQUENCE;
|
||||
}
|
||||
else
|
||||
err = INVALID_CODE_POINT;
|
||||
}
|
||||
|
||||
// Failure branch - restore the original value of the iterator
|
||||
it = original_it;
|
||||
return err;
|
||||
}
|
||||
|
||||
template <typename octet_iterator>
|
||||
inline utf_error validate_next(octet_iterator& it, octet_iterator end) {
|
||||
uint32_t ignored;
|
||||
return utf8::internal::validate_next(it, end, ignored);
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
||||
/// The library API - functions intended to be called by the users
|
||||
|
||||
// Byte order mark
|
||||
const uint8_t bom[] = {0xef, 0xbb, 0xbf};
|
||||
|
||||
template <typename octet_iterator>
|
||||
octet_iterator find_invalid(octet_iterator start, octet_iterator end)
|
||||
{
|
||||
octet_iterator result = start;
|
||||
while (result != end) {
|
||||
utf8::internal::utf_error err_code = utf8::internal::validate_next(result, end);
|
||||
if (err_code != internal::UTF8_OK)
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename octet_iterator>
|
||||
inline bool is_valid(octet_iterator start, octet_iterator end)
|
||||
{
|
||||
return (utf8::find_invalid(start, end) == end);
|
||||
}
|
||||
|
||||
template <typename octet_iterator>
|
||||
inline bool starts_with_bom (octet_iterator it, octet_iterator end)
|
||||
{
|
||||
return (
|
||||
((it != end) && (utf8::internal::mask8(*it++)) == bom[0]) &&
|
||||
((it != end) && (utf8::internal::mask8(*it++)) == bom[1]) &&
|
||||
((it != end) && (utf8::internal::mask8(*it)) == bom[2])
|
||||
);
|
||||
}
|
||||
} // namespace utf8
|
||||
|
||||
#endif // header guard
|
||||
|
||||
|
103
3party/utfcpp/source/utf8/cpp11.h
Normal file
|
@ -0,0 +1,103 @@
|
|||
// Copyright 2018 Nemanja Trifunovic
|
||||
|
||||
/*
|
||||
Permission is hereby granted, free of charge, to any person or organization
|
||||
obtaining a copy of the software and accompanying documentation covered by
|
||||
this license (the "Software") to use, reproduce, display, distribute,
|
||||
execute, and transmit the Software, and to prepare derivative works of the
|
||||
Software, and to permit third-parties to whom the Software is furnished to
|
||||
do so, all subject to the following:
|
||||
|
||||
The copyright notices in the Software and this entire statement, including
|
||||
the above license grant, this restriction and the following disclaimer,
|
||||
must be included in all copies of the Software, in whole or in part, and
|
||||
all derivative works of the Software, unless such copies or derivative
|
||||
works are solely in the form of machine-executable object code generated by
|
||||
a source language processor.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef UTF8_FOR_CPP_a184c22c_d012_11e8_a8d5_f2801f1b9fd1
|
||||
#define UTF8_FOR_CPP_a184c22c_d012_11e8_a8d5_f2801f1b9fd1
|
||||
|
||||
#include "checked.h"
|
||||
#include <string>
|
||||
|
||||
namespace utf8
|
||||
{
|
||||
|
||||
inline void append(char32_t cp, std::string& s)
|
||||
{
|
||||
append(uint32_t(cp), std::back_inserter(s));
|
||||
}
|
||||
|
||||
inline std::string utf16to8(const std::u16string& s)
|
||||
{
|
||||
std::string result;
|
||||
utf16to8(s.begin(), s.end(), std::back_inserter(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
inline std::u16string utf8to16(const std::string& s)
|
||||
{
|
||||
std::u16string result;
|
||||
utf8to16(s.begin(), s.end(), std::back_inserter(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
inline std::string utf32to8(const std::u32string& s)
|
||||
{
|
||||
std::string result;
|
||||
utf32to8(s.begin(), s.end(), std::back_inserter(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
inline std::u32string utf8to32(const std::string& s)
|
||||
{
|
||||
std::u32string result;
|
||||
utf8to32(s.begin(), s.end(), std::back_inserter(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
inline std::size_t find_invalid(const std::string& s)
|
||||
{
|
||||
std::string::const_iterator invalid = find_invalid(s.begin(), s.end());
|
||||
return (invalid == s.end()) ? std::string::npos : (invalid - s.begin());
|
||||
}
|
||||
|
||||
inline bool is_valid(const std::string& s)
|
||||
{
|
||||
return is_valid(s.begin(), s.end());
|
||||
}
|
||||
|
||||
inline std::string replace_invalid(const std::string& s, char32_t replacement)
|
||||
{
|
||||
std::string result;
|
||||
replace_invalid(s.begin(), s.end(), std::back_inserter(result), replacement);
|
||||
return result;
|
||||
}
|
||||
|
||||
inline std::string replace_invalid(const std::string& s)
|
||||
{
|
||||
std::string result;
|
||||
replace_invalid(s.begin(), s.end(), std::back_inserter(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
inline bool starts_with_bom(const std::string& s)
|
||||
{
|
||||
return starts_with_bom(s.begin(), s.end());
|
||||
}
|
||||
|
||||
} // namespace utf8
|
||||
|
||||
#endif // header guard
|
||||
|
103
3party/utfcpp/source/utf8/cpp17.h
Normal file
|
@ -0,0 +1,103 @@
|
|||
// Copyright 2018 Nemanja Trifunovic
|
||||
|
||||
/*
|
||||
Permission is hereby granted, free of charge, to any person or organization
|
||||
obtaining a copy of the software and accompanying documentation covered by
|
||||
this license (the "Software") to use, reproduce, display, distribute,
|
||||
execute, and transmit the Software, and to prepare derivative works of the
|
||||
Software, and to permit third-parties to whom the Software is furnished to
|
||||
do so, all subject to the following:
|
||||
|
||||
The copyright notices in the Software and this entire statement, including
|
||||
the above license grant, this restriction and the following disclaimer,
|
||||
must be included in all copies of the Software, in whole or in part, and
|
||||
all derivative works of the Software, unless such copies or derivative
|
||||
works are solely in the form of machine-executable object code generated by
|
||||
a source language processor.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef UTF8_FOR_CPP_7e906c01_03a3_4daf_b420_ea7ea952b3c9
|
||||
#define UTF8_FOR_CPP_7e906c01_03a3_4daf_b420_ea7ea952b3c9
|
||||
|
||||
#include "checked.h"
|
||||
#include <string>
|
||||
|
||||
namespace utf8
|
||||
{
|
||||
|
||||
inline void append(char32_t cp, std::string& s)
|
||||
{
|
||||
append(uint32_t(cp), std::back_inserter(s));
|
||||
}
|
||||
|
||||
inline std::string utf16to8(std::u16string_view s)
|
||||
{
|
||||
std::string result;
|
||||
utf16to8(s.begin(), s.end(), std::back_inserter(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
inline std::u16string utf8to16(std::string_view s)
|
||||
{
|
||||
std::u16string result;
|
||||
utf8to16(s.begin(), s.end(), std::back_inserter(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
inline std::string utf32to8(std::u32string_view s)
|
||||
{
|
||||
std::string result;
|
||||
utf32to8(s.begin(), s.end(), std::back_inserter(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
inline std::u32string utf8to32(std::string_view s)
|
||||
{
|
||||
std::u32string result;
|
||||
utf8to32(s.begin(), s.end(), std::back_inserter(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
inline std::size_t find_invalid(std::string_view s)
|
||||
{
|
||||
std::string_view::const_iterator invalid = find_invalid(s.begin(), s.end());
|
||||
return (invalid == s.end()) ? std::string_view::npos : (invalid - s.begin());
|
||||
}
|
||||
|
||||
inline bool is_valid(std::string_view s)
|
||||
{
|
||||
return is_valid(s.begin(), s.end());
|
||||
}
|
||||
|
||||
inline std::string replace_invalid(std::string_view s, char32_t replacement)
|
||||
{
|
||||
std::string result;
|
||||
replace_invalid(s.begin(), s.end(), std::back_inserter(result), replacement);
|
||||
return result;
|
||||
}
|
||||
|
||||
inline std::string replace_invalid(std::string_view s)
|
||||
{
|
||||
std::string result;
|
||||
replace_invalid(s.begin(), s.end(), std::back_inserter(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
inline bool starts_with_bom(std::string_view s)
|
||||
{
|
||||
return starts_with_bom(s.begin(), s.end());
|
||||
}
|
||||
|
||||
} // namespace utf8
|
||||
|
||||
#endif // header guard
|
||||
|
274
3party/utfcpp/source/utf8/unchecked.h
Normal file
|
@ -0,0 +1,274 @@
|
|||
// Copyright 2006 Nemanja Trifunovic
|
||||
|
||||
/*
|
||||
Permission is hereby granted, free of charge, to any person or organization
|
||||
obtaining a copy of the software and accompanying documentation covered by
|
||||
this license (the "Software") to use, reproduce, display, distribute,
|
||||
execute, and transmit the Software, and to prepare derivative works of the
|
||||
Software, and to permit third-parties to whom the Software is furnished to
|
||||
do so, all subject to the following:
|
||||
|
||||
The copyright notices in the Software and this entire statement, including
|
||||
the above license grant, this restriction and the following disclaimer,
|
||||
must be included in all copies of the Software, in whole or in part, and
|
||||
all derivative works of the Software, unless such copies or derivative
|
||||
works are solely in the form of machine-executable object code generated by
|
||||
a source language processor.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef UTF8_FOR_CPP_UNCHECKED_H_2675DCD0_9480_4c0c_B92A_CC14C027B731
|
||||
#define UTF8_FOR_CPP_UNCHECKED_H_2675DCD0_9480_4c0c_B92A_CC14C027B731
|
||||
|
||||
#include "core.h"
|
||||
|
||||
namespace utf8
|
||||
{
|
||||
namespace unchecked
|
||||
{
|
||||
template <typename octet_iterator>
|
||||
octet_iterator append(uint32_t cp, octet_iterator result)
|
||||
{
|
||||
if (cp < 0x80) // one octet
|
||||
*(result++) = static_cast<uint8_t>(cp);
|
||||
else if (cp < 0x800) { // two octets
|
||||
*(result++) = static_cast<uint8_t>((cp >> 6) | 0xc0);
|
||||
*(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
|
||||
}
|
||||
else if (cp < 0x10000) { // three octets
|
||||
*(result++) = static_cast<uint8_t>((cp >> 12) | 0xe0);
|
||||
*(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f) | 0x80);
|
||||
*(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
|
||||
}
|
||||
else { // four octets
|
||||
*(result++) = static_cast<uint8_t>((cp >> 18) | 0xf0);
|
||||
*(result++) = static_cast<uint8_t>(((cp >> 12) & 0x3f)| 0x80);
|
||||
*(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f) | 0x80);
|
||||
*(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename octet_iterator, typename output_iterator>
|
||||
output_iterator replace_invalid(octet_iterator start, octet_iterator end, output_iterator out, uint32_t replacement)
|
||||
{
|
||||
while (start != end) {
|
||||
octet_iterator sequence_start = start;
|
||||
internal::utf_error err_code = utf8::internal::validate_next(start, end);
|
||||
switch (err_code) {
|
||||
case internal::UTF8_OK :
|
||||
for (octet_iterator it = sequence_start; it != start; ++it)
|
||||
*out++ = *it;
|
||||
break;
|
||||
case internal::NOT_ENOUGH_ROOM:
|
||||
out = utf8::unchecked::append (replacement, out);
|
||||
start = end;
|
||||
break;
|
||||
case internal::INVALID_LEAD:
|
||||
out = utf8::unchecked::append (replacement, out);
|
||||
++start;
|
||||
break;
|
||||
case internal::INCOMPLETE_SEQUENCE:
|
||||
case internal::OVERLONG_SEQUENCE:
|
||||
case internal::INVALID_CODE_POINT:
|
||||
out = utf8::unchecked::append (replacement, out);
|
||||
++start;
|
||||
// just one replacement mark for the sequence
|
||||
while (start != end && utf8::internal::is_trail(*start))
|
||||
++start;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
template <typename octet_iterator, typename output_iterator>
|
||||
inline output_iterator replace_invalid(octet_iterator start, octet_iterator end, output_iterator out)
|
||||
{
|
||||
static const uint32_t replacement_marker = utf8::internal::mask16(0xfffd);
|
||||
return utf8::unchecked::replace_invalid(start, end, out, replacement_marker);
|
||||
}
|
||||
|
||||
template <typename octet_iterator>
|
||||
uint32_t next(octet_iterator& it)
|
||||
{
|
||||
uint32_t cp = utf8::internal::mask8(*it);
|
||||
typename std::iterator_traits<octet_iterator>::difference_type length = utf8::internal::sequence_length(it);
|
||||
switch (length) {
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
it++;
|
||||
cp = ((cp << 6) & 0x7ff) + ((*it) & 0x3f);
|
||||
break;
|
||||
case 3:
|
||||
++it;
|
||||
cp = ((cp << 12) & 0xffff) + ((utf8::internal::mask8(*it) << 6) & 0xfff);
|
||||
++it;
|
||||
cp += (*it) & 0x3f;
|
||||
break;
|
||||
case 4:
|
||||
++it;
|
||||
cp = ((cp << 18) & 0x1fffff) + ((utf8::internal::mask8(*it) << 12) & 0x3ffff);
|
||||
++it;
|
||||
cp += (utf8::internal::mask8(*it) << 6) & 0xfff;
|
||||
++it;
|
||||
cp += (*it) & 0x3f;
|
||||
break;
|
||||
}
|
||||
++it;
|
||||
return cp;
|
||||
}
|
||||
|
||||
template <typename octet_iterator>
|
||||
uint32_t peek_next(octet_iterator it)
|
||||
{
|
||||
return utf8::unchecked::next(it);
|
||||
}
|
||||
|
||||
template <typename octet_iterator>
|
||||
uint32_t prior(octet_iterator& it)
|
||||
{
|
||||
while (utf8::internal::is_trail(*(--it))) ;
|
||||
octet_iterator temp = it;
|
||||
return utf8::unchecked::next(temp);
|
||||
}
|
||||
|
||||
template <typename octet_iterator, typename distance_type>
|
||||
void advance (octet_iterator& it, distance_type n)
|
||||
{
|
||||
const distance_type zero(0);
|
||||
if (n < zero) {
|
||||
// backward
|
||||
for (distance_type i = n; i < zero; ++i)
|
||||
utf8::unchecked::prior(it);
|
||||
} else {
|
||||
// forward
|
||||
for (distance_type i = zero; i < n; ++i)
|
||||
utf8::unchecked::next(it);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename octet_iterator>
|
||||
typename std::iterator_traits<octet_iterator>::difference_type
|
||||
distance (octet_iterator first, octet_iterator last)
|
||||
{
|
||||
typename std::iterator_traits<octet_iterator>::difference_type dist;
|
||||
for (dist = 0; first < last; ++dist)
|
||||
utf8::unchecked::next(first);
|
||||
return dist;
|
||||
}
|
||||
|
||||
template <typename u16bit_iterator, typename octet_iterator>
|
||||
octet_iterator utf16to8 (u16bit_iterator start, u16bit_iterator end, octet_iterator result)
|
||||
{
|
||||
while (start != end) {
|
||||
uint32_t cp = utf8::internal::mask16(*start++);
|
||||
// Take care of surrogate pairs first
|
||||
if (utf8::internal::is_lead_surrogate(cp)) {
|
||||
uint32_t trail_surrogate = utf8::internal::mask16(*start++);
|
||||
cp = (cp << 10) + trail_surrogate + internal::SURROGATE_OFFSET;
|
||||
}
|
||||
result = utf8::unchecked::append(cp, result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename u16bit_iterator, typename octet_iterator>
|
||||
u16bit_iterator utf8to16 (octet_iterator start, octet_iterator end, u16bit_iterator result)
|
||||
{
|
||||
while (start < end) {
|
||||
uint32_t cp = utf8::unchecked::next(start);
|
||||
if (cp > 0xffff) { //make a surrogate pair
|
||||
*result++ = static_cast<uint16_t>((cp >> 10) + internal::LEAD_OFFSET);
|
||||
*result++ = static_cast<uint16_t>((cp & 0x3ff) + internal::TRAIL_SURROGATE_MIN);
|
||||
}
|
||||
else
|
||||
*result++ = static_cast<uint16_t>(cp);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename octet_iterator, typename u32bit_iterator>
|
||||
octet_iterator utf32to8 (u32bit_iterator start, u32bit_iterator end, octet_iterator result)
|
||||
{
|
||||
while (start != end)
|
||||
result = utf8::unchecked::append(*(start++), result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename octet_iterator, typename u32bit_iterator>
|
||||
u32bit_iterator utf8to32 (octet_iterator start, octet_iterator end, u32bit_iterator result)
|
||||
{
|
||||
while (start < end)
|
||||
(*result++) = utf8::unchecked::next(start);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// The iterator class
|
||||
template <typename octet_iterator>
|
||||
class iterator {
|
||||
octet_iterator it;
|
||||
public:
|
||||
typedef uint32_t value_type;
|
||||
typedef uint32_t* pointer;
|
||||
typedef uint32_t& reference;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef std::bidirectional_iterator_tag iterator_category;
|
||||
iterator () {}
|
||||
explicit iterator (const octet_iterator& octet_it): it(octet_it) {}
|
||||
// the default "big three" are OK
|
||||
octet_iterator base () const { return it; }
|
||||
uint32_t operator * () const
|
||||
{
|
||||
octet_iterator temp = it;
|
||||
return utf8::unchecked::next(temp);
|
||||
}
|
||||
bool operator == (const iterator& rhs) const
|
||||
{
|
||||
return (it == rhs.it);
|
||||
}
|
||||
bool operator != (const iterator& rhs) const
|
||||
{
|
||||
return !(operator == (rhs));
|
||||
}
|
||||
iterator& operator ++ ()
|
||||
{
|
||||
::std::advance(it, utf8::internal::sequence_length(it));
|
||||
return *this;
|
||||
}
|
||||
iterator operator ++ (int)
|
||||
{
|
||||
iterator temp = *this;
|
||||
::std::advance(it, utf8::internal::sequence_length(it));
|
||||
return temp;
|
||||
}
|
||||
iterator& operator -- ()
|
||||
{
|
||||
utf8::unchecked::prior(it);
|
||||
return *this;
|
||||
}
|
||||
iterator operator -- (int)
|
||||
{
|
||||
iterator temp = *this;
|
||||
utf8::unchecked::prior(it);
|
||||
return temp;
|
||||
}
|
||||
}; // class iterator
|
||||
|
||||
} // namespace utf8::unchecked
|
||||
} // namespace utf8
|
||||
|
||||
|
||||
#endif // header guard
|
||||
|
|
@ -7,19 +7,7 @@ set(SRC
|
|||
|
||||
add_library(${PROJECT_NAME} ${SRC})
|
||||
|
||||
if (WITH_SYSTEM_PROVIDED_3PARTY)
|
||||
find_package(VulkanHeaders REQUIRED)
|
||||
target_link_libraries(${PROJECT_NAME} Vulkan::Headers)
|
||||
else()
|
||||
set(VulkanHeaders_INCLUDE_DIR ../Vulkan-Headers/include)
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC ../Vulkan-Headers/include)
|
||||
endif()
|
||||
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC .)
|
||||
|
||||
if (PLATFORM_LINUX)
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE VK_USE_PLATFORM_XLIB_KHR)
|
||||
endif()
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC . ../Vulkan-Headers/include)
|
||||
|
||||
# dlopen
|
||||
target_link_libraries(${PROJECT_NAME} $<$<BOOL:CMAKE_DL_LIBS>:${CMAKE_DL_LIBS}>)
|
||||
|
|
|
@ -22,20 +22,7 @@ extern "C" {
|
|||
#include <dlfcn.h>
|
||||
|
||||
int InitVulkan(void) {
|
||||
#if defined(__APPLE__)
|
||||
void* libvulkan = dlopen("libvulkan.dylib", RTLD_NOW | RTLD_LOCAL);
|
||||
if (!libvulkan) {
|
||||
libvulkan = dlopen("libvulkan.1.dylib", RTLD_NOW | RTLD_LOCAL);
|
||||
}
|
||||
if (!libvulkan) {
|
||||
libvulkan = dlopen("libMoltenVK.dylib", RTLD_NOW | RTLD_LOCAL);
|
||||
}
|
||||
#else
|
||||
void* libvulkan = dlopen("libvulkan.so.1", RTLD_NOW | RTLD_LOCAL);
|
||||
if (!libvulkan) {
|
||||
libvulkan = dlopen("libvulkan.so", RTLD_NOW | RTLD_LOCAL);
|
||||
}
|
||||
#endif
|
||||
void* libvulkan = dlopen("libvulkan.so", RTLD_NOW | RTLD_LOCAL);
|
||||
if (!libvulkan) return 0;
|
||||
|
||||
// Vulkan supported, set function addresses
|
||||
|
@ -558,10 +545,6 @@ int InitVulkan(void) {
|
|||
vkDestroyDebugReportCallbackEXT = reinterpret_cast<PFN_vkDestroyDebugReportCallbackEXT>(dlsym(libvulkan, "vkDestroyDebugReportCallbackEXT"));
|
||||
vkDebugReportMessageEXT = reinterpret_cast<PFN_vkDebugReportMessageEXT>(dlsym(libvulkan, "vkDebugReportMessageEXT"));
|
||||
|
||||
#if defined(__APPLE__)
|
||||
vkCreateMacOSSurfaceMVK = reinterpret_cast<PFN_vkCreateMacOSSurfaceMVK>(dlsym(libvulkan, "vkCreateMacOSSurfaceMVK"));
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -978,10 +961,8 @@ PFN_vkDestroyPrivateDataSlotEXT vkDestroyPrivateDataSlotEXT;
|
|||
PFN_vkSetPrivateDataEXT vkSetPrivateDataEXT;
|
||||
PFN_vkGetPrivateDataEXT vkGetPrivateDataEXT;
|
||||
PFN_vkCmdSetFragmentShadingRateEnumNV vkCmdSetFragmentShadingRateEnumNV;
|
||||
#ifdef VK_USE_PLATFORM_WIN32_KHR
|
||||
PFN_vkAcquireWinrtDisplayNV vkAcquireWinrtDisplayNV;
|
||||
PFN_vkGetWinrtDisplayNV vkGetWinrtDisplayNV;
|
||||
#endif
|
||||
PFN_vkAcquireWinrtDisplayNV vkAcquireWinrtDisplayNV;
|
||||
PFN_vkGetWinrtDisplayNV vkGetWinrtDisplayNV;
|
||||
PFN_vkCmdSetVertexInputEXT vkCmdSetVertexInputEXT;
|
||||
PFN_vkGetDeviceSubpassShadingMaxWorkgroupSizeHUAWEI vkGetDeviceSubpassShadingMaxWorkgroupSizeHUAWEI;
|
||||
PFN_vkCmdSubpassShadingHUAWEI vkCmdSubpassShadingHUAWEI;
|
||||
|
@ -1154,10 +1135,6 @@ PFN_vkCmdDecodeVideoKHR vkCmdDecodeVideoKHR;
|
|||
PFN_vkCmdEncodeVideoKHR vkCmdEncodeVideoKHR;
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__)
|
||||
PFN_vkCreateMacOSSurfaceMVK vkCreateMacOSSurfaceMVK;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -25,10 +25,6 @@ extern "C" {
|
|||
#define VK_USE_PLATFORM_ANDROID_KHR 1
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#include <vulkan/vulkan_macos.h>
|
||||
#endif
|
||||
|
||||
/* Initialize the Vulkan function pointer variables declared in this header.
|
||||
* Returns 0 if vulkan is not available, non-zero if it is available.
|
||||
*/
|
||||
|
@ -504,10 +500,6 @@ extern PFN_vkCreateDebugReportCallbackEXT vkCreateDebugReportCallbackEXT;
|
|||
extern PFN_vkDestroyDebugReportCallbackEXT vkDestroyDebugReportCallbackEXT;
|
||||
extern PFN_vkDebugReportMessageEXT vkDebugReportMessageEXT;
|
||||
|
||||
#if defined(__APPLE__)
|
||||
extern PFN_vkCreateMacOSSurfaceMVK vkCreateMacOSSurfaceMVK;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
170
CMakeLists.txt
|
@ -1,21 +1,12 @@
|
|||
cmake_minimum_required(VERSION 3.22.1)
|
||||
cmake_minimum_required(VERSION 3.18)
|
||||
project(omim C CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_C_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
# Our code does not rely on gnu extensions.
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
set(CMAKE_C_EXTENSIONS OFF)
|
||||
|
||||
set(CMAKE_C_VISIBILITY_PRESET hidden)
|
||||
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
|
||||
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)
|
||||
|
||||
# Fixes warning ld: warning: ignoring duplicate libraries on Mac and Windows.
|
||||
if (POLICY CMP0156)
|
||||
cmake_policy(SET CMP0156 NEW)
|
||||
endif()
|
||||
|
||||
if (APPLE AND NOT ("${CMAKE_SYSTEM_NAME}" STREQUAL Android))
|
||||
# OBJC/OBJCXX are needed to skip m/mm files in Unity builds.
|
||||
# https://gitlab.kitware.com/cmake/cmake/-/issues/21963
|
||||
|
@ -23,18 +14,14 @@ if (APPLE AND NOT ("${CMAKE_SYSTEM_NAME}" STREQUAL Android))
|
|||
set(CMAKE_OBJC_EXTENSIONS OFF)
|
||||
set(CMAKE_OBJC_STANDARD 11)
|
||||
set(CMAKE_OBJC_FLAGS -fobjc-arc)
|
||||
set(CMAKE_OBJC_VISIBILITY_PRESET hidden)
|
||||
enable_language(OBJCXX)
|
||||
set(CMAKE_OBJCXX_EXTENSIONS OFF)
|
||||
set(CMAKE_OBJCXX_STANDARD 20)
|
||||
set(CMAKE_OBJCXX_STANDARD 17)
|
||||
set(CMAKE_OBJCXX_FLAGS -fobjc-arc)
|
||||
set(CMAKE_OBJCXX_VISIBILITY_PRESET hidden)
|
||||
endif()
|
||||
|
||||
message(STATUS "Using compiler ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}")
|
||||
|
||||
option(COVERAGE_REPORT "Configure for coverage report" OFF)
|
||||
|
||||
option(UNITY_DISABLE "Disable unity build" OFF)
|
||||
if (NOT UNITY_DISABLE AND NOT DEFINED ENV{UNITY_DISABLE})
|
||||
set(CMAKE_UNITY_BUILD ON)
|
||||
|
@ -73,36 +60,32 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${OMIM_ROOT}/cmake")
|
|||
include(OmimHelpers)
|
||||
include(OmimTesting)
|
||||
|
||||
set(PLATFORM_DESKTOP TRUE)
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
set(PLATFORM_LINUX TRUE)
|
||||
elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||
set(PLATFORM_MAC TRUE)
|
||||
elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
set(PLATFORM_WIN TRUE)
|
||||
elseif (CMAKE_SYSTEM_NAME STREQUAL "Android")
|
||||
set(PLATFORM_ANDROID TRUE)
|
||||
set(PLATFORM_DESKTOP FALSE)
|
||||
elseif (CMAKE_SYSTEM_NAME STREQUAL "iOS")
|
||||
set(PLATFORM_IPHONE TRUE)
|
||||
set(PLATFORM_DESKTOP FALSE)
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported platform: ${CMAKE_SYSTEM_NAME}")
|
||||
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
set(LINUX_DETECTED TRUE)
|
||||
endif()
|
||||
|
||||
if(${PLATFORM_MAC})
|
||||
set(XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES)
|
||||
|
||||
# Metal language support
|
||||
list(APPEND CMAKE_MODULE_PATH ${OMIM_ROOT}/3party/CMake-MetalShaderSupport/cmake)
|
||||
include(CheckLanguage)
|
||||
include(MetalShaderSupport)
|
||||
check_language(Metal)
|
||||
if(CMAKE_Metal_COMPILER)
|
||||
enable_language(Metal)
|
||||
if (CMAKE_SYSTEM_NAME MATCHES "Android")
|
||||
set(ANDROID_DETECTED TRUE)
|
||||
if ((${OS} MATCHES "mac"))
|
||||
set(DARWIN TRUE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
omim_set_platform_var(PLATFORM_IPHONE "iphone-.*")
|
||||
omim_set_platform_var(PLATFORM_ANDROID "android-.*" ${ANDROID_DETECTED})
|
||||
omim_set_platform_var(PLATFORM_MAC "macx-.*" ${APPLE})
|
||||
omim_set_platform_var(PLATFORM_WIN "win32-.*" ${WIN32})
|
||||
omim_set_platform_var(PLATFORM_LINUX "linux-.*" ${LINUX_DETECTED})
|
||||
|
||||
if (PLATFORM_LINUX OR PLATFORM_MAC OR PLATFORM_WIN)
|
||||
set(PLATFORM_DESKTOP TRUE)
|
||||
else()
|
||||
set(PLATFORM_DESKTOP FALSE)
|
||||
endif()
|
||||
|
||||
# End of setting the target platform
|
||||
|
||||
# Sanitizer
|
||||
if (PLATFORM_DESKTOP)
|
||||
# https://clang.llvm.org/docs/UsersManual.html#controlling-code-generation
|
||||
|
@ -121,31 +104,14 @@ if (NOT CMAKE_BUILD_TYPE)
|
|||
endif()
|
||||
|
||||
# Global compile options for all configurations.
|
||||
if (MSVC)
|
||||
add_compile_options(/utf-8)
|
||||
add_link_options(/INCREMENTAL:NO)
|
||||
else()
|
||||
add_compile_options(-ffast-math)
|
||||
endif()
|
||||
|
||||
if (PLATFORM_WIN)
|
||||
add_definitions(
|
||||
-DWIN32_LEAN_AND_MEAN
|
||||
-DNOMINMAX
|
||||
)
|
||||
endif()
|
||||
add_compile_options(-ffast-math)
|
||||
|
||||
# Built-in CMake configurations: Debug, Release, RelWithDebInfo, MinSizeRel
|
||||
if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
|
||||
add_definitions(-DDEBUG)
|
||||
if (NOT MSVC)
|
||||
add_compile_options(-fno-omit-frame-pointer)
|
||||
endif()
|
||||
add_definitions(-DDEBUG -fno-omit-frame-pointer)
|
||||
elseif (${CMAKE_BUILD_TYPE} MATCHES "Rel")
|
||||
add_definitions(-DRELEASE)
|
||||
if (NOT MSVC)
|
||||
add_compile_options(-Ofast) # Also enables -ffast-math
|
||||
endif()
|
||||
add_compile_options(-Ofast)
|
||||
else()
|
||||
message(FATAL_ERROR "Unknown build type: " ${CMAKE_BUILD_TYPE})
|
||||
endif()
|
||||
|
@ -162,21 +128,15 @@ if (BUILD_DESIGNER)
|
|||
add_definitions(-DBUILD_DESIGNER)
|
||||
endif()
|
||||
|
||||
option(BUILD_STANDALONE "Build standalone application" OFF)
|
||||
if (BUILD_STANDALONE)
|
||||
message(STATUS "Standalone building is enabled")
|
||||
add_definitions(-DBUILD_STANDALONE)
|
||||
endif()
|
||||
|
||||
option(USE_ASAN "Enable Address Sanitizer" OFF)
|
||||
option(USE_TSAN "Enable Thread Sanitizer" OFF)
|
||||
option(USE_LIBFUZZER "Enable LibFuzzer" OFF)
|
||||
option(PYBINDINGS "Create makefiles for building python bindings" OFF)
|
||||
option(SKIP_QT_GUI "Skip building of Qt GUI" OFF)
|
||||
# TODO: Fix mapshot, it doesn't work without our old FreeType hack.
|
||||
option(BUILD_MAPSHOT "Build mapshot tool" OFF)
|
||||
option(USE_PCH "Use precompiled headers" OFF)
|
||||
option(NJOBS "Number of parallel processes" OFF)
|
||||
option(ENABLE_VULKAN_DIAGNOSTICS "Enable Vulkan diagnostics" OFF)
|
||||
option(ENABLE_TRACE "Enable Tracing" OFF)
|
||||
|
||||
if (NJOBS)
|
||||
message(STATUS "Number of parallel processes: ${NJOBS}")
|
||||
|
@ -186,9 +146,9 @@ if (NJOBS)
|
|||
set(CMAKE_JOB_POOL_PRECOMPILE_HEADER custom)
|
||||
endif()
|
||||
|
||||
# GCC 10.0 is required to support <charconv> header inclusion in base/string_utils.hpp
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10.0)
|
||||
message(FATAL_ERROR "Minimum supported g++ version is 10.0, yours is ${CMAKE_CXX_COMPILER_VERSION}")
|
||||
# GCC 8.1 is required to support <charconv> header inclusion in base/string_utils.hpp, otherwise 7.0 is sufficient
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.1)
|
||||
message(FATAL_ERROR "Minimum supported g++ version is 8.1 yours is ${CMAKE_CXX_COMPILER_VERSION}")
|
||||
endif()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
|
@ -228,16 +188,6 @@ if (USE_HEAPPROF)
|
|||
message(STATUS "Heap Profiler is enabled")
|
||||
endif()
|
||||
|
||||
if (ENABLE_VULKAN_DIAGNOSTICS)
|
||||
message(WARNING "Vulkan diagnostics are enabled. Be aware of performance impact!")
|
||||
add_definitions(-DENABLE_VULKAN_DIAGNOSTICS)
|
||||
endif()
|
||||
|
||||
if (ENABLE_TRACE)
|
||||
message(STATUS "Tracing is enabled")
|
||||
add_definitions(-DENABLE_TRACE)
|
||||
endif()
|
||||
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
# Set environment variables
|
||||
|
@ -262,9 +212,6 @@ if (NOT SKIP_TESTS)
|
|||
enable_testing()
|
||||
# Enables ctest -T memcheck with valgrind
|
||||
include(CTest)
|
||||
if (COVERAGE_REPORT)
|
||||
include(OmimCoverage)
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
if (NOT PYTHON_VERSION)
|
||||
|
@ -278,6 +225,16 @@ find_package(Threads REQUIRED)
|
|||
|
||||
# Scripts
|
||||
|
||||
if (NOT CMAKE_HOST_WIN32)
|
||||
execute_process(
|
||||
COMMAND "${OMIM_ROOT}/tools/unix/check_cert.sh"
|
||||
RESULT_VARIABLE CheckCertResult
|
||||
)
|
||||
if (CheckCertResult)
|
||||
message(FATAL_ERROR "Certificate check failed")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (NOT PLATFORM_IPHONE AND NOT PLATFORM_ANDROID)
|
||||
list(APPEND qt_components Core Network)
|
||||
if (NOT SKIP_QT_GUI OR NOT SKIP_TESTS OR PYBINDINGS)
|
||||
|
@ -288,13 +245,11 @@ if (NOT PLATFORM_IPHONE AND NOT PLATFORM_ANDROID)
|
|||
endif()
|
||||
# PATHS are hard-coded hints where to look for qt6 in addition to other places.
|
||||
find_package(Qt6 COMPONENTS REQUIRED ${qt_components} PATHS $ENV{QT_PATH} /opt/homebrew/opt/qt@6 /usr/local/opt/qt@6 /usr/lib/x86_64-linux-gnu/qt6)
|
||||
endif()
|
||||
|
||||
set(MINIMUM_REQUIRED_QT_VERSION 6.4.0)
|
||||
if (Qt6Widgets_VERSION VERSION_LESS ${MINIMUM_REQUIRED_QT_VERSION})
|
||||
message(FATAL_ERROR "Unsupported Qt version: ${Qt6Widgets_VERSION}, the minimum required is ${MINIMUM_REQUIRED_QT_VERSION}")
|
||||
else()
|
||||
message(STATUS "Found Qt version: ${Qt6Widgets_VERSION}")
|
||||
endif()
|
||||
find_library(LIBZ NAMES z)
|
||||
if (LIBZ STREQUAL "LIBZ-NOTFOUND")
|
||||
message(FATAL_ERROR "Failed to find libz library.")
|
||||
endif()
|
||||
|
||||
# To allow #include "base/file_name.hpp" in all sources.
|
||||
|
@ -332,35 +287,27 @@ if (USE_PCH)
|
|||
endif()
|
||||
|
||||
# Should be on the root level, not in 3party, so tests can get these dependencies.
|
||||
if (PLATFORM_LINUX OR PLATFORM_WIN)
|
||||
# Should go before 3party as harfbuzz is using them.
|
||||
if (LINUX_DETECTED)
|
||||
find_package(ICU COMPONENTS uc i18n data REQUIRED)
|
||||
find_package(Freetype REQUIRED)
|
||||
find_package(harfbuzz REQUIRED)
|
||||
endif()
|
||||
|
||||
if (WITH_SYSTEM_PROVIDED_3PARTY)
|
||||
set(GFLAGS_USE_TARGET_NAMESPACE ON)
|
||||
find_package(gflags REQUIRED)
|
||||
|
||||
find_package(expat CONFIG REQUIRED)
|
||||
find_package(jansson CONFIG REQUIRED)
|
||||
find_package(pugixml REQUIRED)
|
||||
find_package(utf8cpp REQUIRED)
|
||||
endif()
|
||||
|
||||
find_package(ZLIB REQUIRED)
|
||||
|
||||
# Include 3party dependencies.
|
||||
add_subdirectory(3party)
|
||||
|
||||
# Not needed for the usual build process, but it fixes QtCreator editor,
|
||||
# that doesn't see gflags/gflags.h in binary dir (gflags has tricky cmake configuration).
|
||||
if (PLATFORM_DESKTOP AND NOT WITH_SYSTEM_PROVIDED_3PARTY)
|
||||
if (PLATFORM_DESKTOP)
|
||||
include_directories("${PROJECT_BINARY_DIR}/3party/gflags/include")
|
||||
endif()
|
||||
|
||||
# Used in qt/ and shaders/
|
||||
find_package(Python3 REQUIRED COMPONENTS Interpreter)
|
||||
find_package(Python3 COMPONENTS Interpreter)
|
||||
if (Python3_Interpreter_FOUND)
|
||||
message(STATUS "Found python to use in qt/, shaders/ and 3party/: ${Python3_EXECUTABLE}")
|
||||
else()
|
||||
message(FATAL_ERROR "Could not find python3 to use in qt/, shaders/ and 3party/.")
|
||||
endif()
|
||||
|
||||
add_subdirectory(base)
|
||||
add_subdirectory(coding)
|
||||
|
@ -386,6 +333,10 @@ add_subdirectory(traffic)
|
|||
add_subdirectory(transit)
|
||||
|
||||
if (PLATFORM_DESKTOP)
|
||||
if (BUILD_MAPSHOT)
|
||||
add_subdirectory(mapshot)
|
||||
add_subdirectory(software_renderer)
|
||||
endif()
|
||||
omim_add_tool_subdirectory(feature_list)
|
||||
add_subdirectory(generator)
|
||||
add_subdirectory(openlr)
|
||||
|
@ -397,7 +348,6 @@ if (PLATFORM_DESKTOP)
|
|||
add_subdirectory(qt)
|
||||
omim_add_tool_subdirectory(skin_generator)
|
||||
endif()
|
||||
add_subdirectory(dev_sandbox)
|
||||
endif()
|
||||
|
||||
omim_add_test_subdirectory(qt_tstfrm)
|
||||
|
|
94
CONTRIBUTORS
|
@ -1,72 +1,11 @@
|
|||
This file contains a list of people who have contributed to this project.
|
||||
Its not neccesarily comprehensive.
|
||||
Feel free to add yourself here along with your first contribution!
|
||||
This file contains a list of people who have contributed to the
|
||||
public version of MAPS.ME and Organic Maps.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
Organic Maps (formerly OMaps) contributors:
|
||||
(in alphabetic order)
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
Alexander Borsuk <me@alex.bio>
|
||||
Alexey Krasilnikov
|
||||
Andrew Shkrob
|
||||
Anton Makouski
|
||||
Arnaud Vergnet
|
||||
Arthur-GYT
|
||||
Atemu
|
||||
Caspar Nuël <casparnuel@yandex.com>
|
||||
cyber-toad
|
||||
David Martinez
|
||||
dbf
|
||||
Dzmitry Strekha
|
||||
Dzmitry Yarmolenka
|
||||
Fabian Wüthrich
|
||||
Ferenc Géczi
|
||||
Filip Czaplicki
|
||||
FinixFighter
|
||||
fparri
|
||||
Francesco Gazzetta
|
||||
gallegonovato
|
||||
Gonzalo Pesquero
|
||||
Harry Bond <me@hbond.xyz>
|
||||
Jaime Marquinez Ferrandiz
|
||||
Jean-Baptiste Charron
|
||||
Jenny Em
|
||||
Joan Montané
|
||||
Karina Kordon
|
||||
Kavi Khalique
|
||||
Kiryl Kaveryn
|
||||
Kiryl Razhdzestvenski
|
||||
Konstantin Pastbin
|
||||
Loïc Hernaut
|
||||
Lukas Hamm
|
||||
Lukas Kronberger
|
||||
Luna Rose
|
||||
map-per
|
||||
Markku Huotari
|
||||
Mateusz Konieczny
|
||||
Matheus Gomes
|
||||
MbTy1
|
||||
Meenbeese
|
||||
Metehan Özyürek
|
||||
Michał Brzozowski
|
||||
Nishant Bhandari <nishantbhandari0019@gmail.com>
|
||||
Ognjen Blagojevic
|
||||
Osyotr
|
||||
renderexpert
|
||||
Roman Kuznetsov
|
||||
Roman Tsisyk <roman@tsisyk.com>
|
||||
Rudo Kemper
|
||||
Sebastiao Sousa <sebastiao.sousa@tecnico.ulisboa.pt>
|
||||
Sergiy Kozyr
|
||||
Tobias G. <tobi.goergens@gmail.com>
|
||||
Veniamin Gvozdikov <g.veniamin@googlemail.com>
|
||||
Viktor Govako <viktor.govako@gmail.com>
|
||||
Will Bradley
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
MAPS.ME at Mail.Ru Group (prior to the Organic Maps (OMaps) fork in 2020/2021):
|
||||
--------------------------------------------------------------------------------
|
||||
Original MAPS.ME (MapsWithMe) design and implementation:
|
||||
Yury Melnichek <yury@melnichek.com>
|
||||
Alexander Borsuk <me@alex.bio>
|
||||
Viktor Govako <viktor.govako@gmail.com>
|
||||
Siarhei Rachytski <siarhei.rachytski@gmail.com>
|
||||
|
||||
Code contributions:
|
||||
Dmitry Yunitski
|
||||
|
@ -96,6 +35,10 @@ Code contributions:
|
|||
Alex Gontmakher <gsasha@gmail.com>
|
||||
Dima Korolev <dmitry.korolev@gmail.com>
|
||||
Max Grigorev <forwidur@gmail.com>
|
||||
Roman Tsisyk <roman@tsisyk.com>
|
||||
Caspar Nuël <casparnuel@yandex.com>
|
||||
Konstantin Pastbin
|
||||
Nishant Bhandari <nishantbhandari0019@gmail.com>
|
||||
|
||||
Porting to Tizen platform:
|
||||
Sergey Pisarchik
|
||||
|
@ -119,6 +62,11 @@ Strings and translations:
|
|||
Vasily Korotkevich
|
||||
Mark N. Kuramochi
|
||||
Lidia Vasiljeva
|
||||
Karina Kordon
|
||||
Konstantin Pastbin
|
||||
Metehan Özyürek
|
||||
Joan Montané
|
||||
Luna Rose
|
||||
|
||||
Project management:
|
||||
Alexander Matveenko
|
||||
|
@ -138,13 +86,3 @@ Special thanks to:
|
|||
Yuri Gurski
|
||||
Dmitry Matveev
|
||||
Anna Yakovleva
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
MAPS.ME (originally MapsWithMe) design and implementation at MapsWithMe GmbH
|
||||
(from 2010 till the acquisition by Mail.ru Group in 2014):
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
Yury Melnichek <yury@melnichek.com>
|
||||
Alexander Borsuk <me@alex.bio>
|
||||
Viktor Govako <viktor.govako@gmail.com>
|
||||
Siarhei Rachytski <siarhei.rachytski@gmail.com>
|
||||
|
|
9
LEGAL
|
@ -1,9 +0,0 @@
|
|||
Certain project resources, including but not limited to domain names, trademarks, hosting accounts, payment accounts, and others, are overseen and managed by Organic Maps OÜ. The governance of these digital assets is subject to policies established by Organic Maps OÜ, in compliance with applicable statutory laws.
|
||||
|
||||
Organic Maps OÜ is a legal entity established on 2021-05-01 under the laws of the Republic of Estonia and the European Union, with registration number 16225385. The primary purpose of the entity is to shield the project's members from personal liability and to ensure the legal protection of the project's assets. Official up-to-date information about the entity can be found in the Estonian Business Register:
|
||||
|
||||
https://ariregister.rik.ee/eng/company/16225385/Organic-Maps-O%C3%9C
|
||||
|
||||
Organic Maps OÜ does not require contributors to transfer copyright ownership and does not retain any copyright over the code contributed to the repository. See the NOTICE file and docs/DCO.md for additional information.
|
||||
|
||||
For any legal inquiries, feel free to contact legal@organicmaps.app.
|
2
NOTICE
|
@ -1,5 +1,5 @@
|
|||
Copyright 2020 My.com B.V. (Mail.Ru Group)
|
||||
Copyright 2024 Organic Maps Contributors
|
||||
Copyright 2021 Organic Maps Contributors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
|
119
README.md
|
@ -1,17 +1,31 @@
|
|||
<div align="center">
|
||||
<img src="qt/res/logo.png" height="100"/>
|
||||
</div>
|
||||
<h1 align="center"">Organic Maps</h1>
|
||||
# Organic Maps
|
||||
|
||||
[Organic Maps](https://organicmaps.app) is a free Android & iOS offline maps app for travellers, tourists, drivers, hikers, and cyclists.
|
||||
It uses crowd-sourced [OpenStreetMap](https://www.openstreetmap.org) data and is developed with love by the creators of **MapsWithMe** (later renamed to **Maps.Me**) and by our community.
|
||||
<a name="install"/>
|
||||
|
||||
[Organic Maps](https://organicmaps.app) is a free Android & iOS offline maps app for travelers, tourists, drivers, hikers, and cyclists.
|
||||
It uses crowd-sourced [OpenStreetMap](https://www.openstreetmap.org) data and is developed with love by creators of **MapsWithMe** app (later renamed to **Maps.Me**) and by our community.
|
||||
No ads, no tracking, no data collection, no crapware. Your [donations](https://organicmaps.app/donate/) and positive reviews motivate and inspire us, thanks ❤️!
|
||||
|
||||
[<img src="docs/badges/apple-appstore.png" alt="App Store" width="160">](https://apps.apple.com/app/organic-maps/id1567437057)
|
||||
[<img src="docs/badges/google-play.png" alt="Google Play" width="160">](https://play.google.com/store/apps/details?id=app.organicmaps)
|
||||
[<img src="docs/badges/huawei-appgallery.png" alt="AppGallery" width="160">](https://appgallery.huawei.com/#/app/C104325611)
|
||||
[<img src="docs/badges/obtainium.png" alt="Obtainium" width="160">](https://github.com/organicmaps/organicmaps/wiki/Installing-Organic-Maps-from-GitHub-using-Obtainium)
|
||||
[<img src="docs/badges/fdroid.png" alt="F-Droid" width="160">](https://f-droid.org/en/packages/app.organicmaps/)
|
||||
<p float="left">
|
||||
<a href="https://apps.apple.com/app/organic-maps/id1567437057">
|
||||
<img alt="Download on the App Store" src="docs/badges/apple-appstore.png" width="180">
|
||||
</a>
|
||||
<a href="https://play.google.com/store/apps/details?id=app.organicmaps">
|
||||
<img alt="Get it on Google Play" src="docs/badges/google-play.png" width="180">
|
||||
</a>
|
||||
<a href="https://appgallery.huawei.com/#/app/C104325611">
|
||||
<img alt="Explore it on AppGallery" src="docs/badges/huawei-appgallery.png" width="180">
|
||||
</a>
|
||||
<a href="https://f-droid.org/en/packages/app.organicmaps/">
|
||||
<img alt="Get it on F-Droid" src="docs/badges/fdroid.png" width="180">
|
||||
</a>
|
||||
<a href='https://flathub.org/apps/details/app.organicmaps.desktop'>
|
||||
<img alt="Download on Flathub" src="docs/badges/flathub.png" width="180"/>
|
||||
</a>
|
||||
<a href="https://repology.org/project/organicmaps/versions">
|
||||
<img src="https://repology.org/badge/vertical-allrepos/organicmaps.svg" width="180" alt="Packaging status">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p float="left">
|
||||
<img src="android/app/src/fdroid/play/listings/en-US/graphics/phone-screenshots/1.jpg" width="400" />
|
||||
|
@ -22,14 +36,14 @@ No ads, no tracking, no data collection, no crapware. Your [donations](https://o
|
|||
|
||||
## Features
|
||||
|
||||
Organic Maps is the ultimate companion app for travellers, tourists, hikers, and cyclists:
|
||||
Organic Maps is the ultimate companion app for travelers, tourists, hikers, and cyclists:
|
||||
|
||||
- Detailed offline maps with places that don't exist on other maps, thanks to [OpenStreetMap](https://openstreetmap.org)
|
||||
- Detailed offline maps with places that don't exist on other maps, thanks to [OpenStreetMap](https://osm.org)
|
||||
- Cycling routes, hiking trails, and walking paths
|
||||
- Contour lines, elevation profiles, peaks, and slopes
|
||||
- Turn-by-turn walking, cycling, and car navigation with voice guidance
|
||||
- Fast offline search on the map
|
||||
- Bookmarks and tracks import and export in KML, KMZ & GPX formats
|
||||
- Bookmarks and tracks export and import in KML, KMZ, GPX formats
|
||||
- Dark Mode to protect your eyes
|
||||
- Countries and regions don't take a lot of space
|
||||
- Free and open-source
|
||||
|
@ -42,7 +56,7 @@ Organic Maps is pure and organic, made with love:
|
|||
- Saves your battery
|
||||
- No unexpected mobile data charges
|
||||
|
||||
Organic Maps is free from trackers and other bad stuff:
|
||||
Organic Maps app is free from trackers and other bad stuff:
|
||||
|
||||
- No ads
|
||||
- No tracking
|
||||
|
@ -55,7 +69,7 @@ Organic Maps is free from trackers and other bad stuff:
|
|||
- No crapware
|
||||
- ~~No pesticides~~ Purely organic!
|
||||
|
||||
The Android application is verified by the <a href="https://reports.exodus-privacy.eu.org/en/reports/app.organicmaps/latest/">Exodus Privacy Project:
|
||||
The Android application is verified by <a href="https://reports.exodus-privacy.eu.org/en/reports/app.organicmaps/latest/">Exodus Privacy Project:
|
||||
|
||||
<img src="docs/privacy/exodus.png" width="400">
|
||||
</a>
|
||||
|
@ -78,64 +92,21 @@ At Organic Maps, we believe that privacy is a fundamental human right:
|
|||
|
||||
- Organic Maps is an indie community-driven open-source project
|
||||
- We protect your privacy from Big Tech's prying eyes
|
||||
- Stay safe no matter where you are
|
||||
- Stay safe no matter wherever you are
|
||||
|
||||
Reject surveillance - embrace your freedom.
|
||||
|
||||
[**Give Organic Maps a try!**](#install)
|
||||
|
||||
## Who is paying for the development?
|
||||
## Who is paying for the free app?
|
||||
|
||||
The app is free for everyone, so we rely on donations. Please donate at [organicmaps.app/donate](https://organicmaps.app/donate) to support us!
|
||||
The app is free for everyone. Please [donate](https://organicmaps.app/donate) to support us!
|
||||
|
||||
Beloved institutional sponsors below have provided targeted grants to cover some infrastructure costs and fund development of new selected features:
|
||||
### Our sponsors
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="https://nlnet.nl/"><img src="docs/sponsors/nlnet.svg" alt="The NLnet Foundation" width="200px"></a>
|
||||
</td>
|
||||
<td>
|
||||
<a href="https://github.com/organicmaps/organicmaps/milestone/7">The Search & Fonts improvement project</a> has been <a href="https://nlnet.nl/project/OrganicMaps/">funded</a> through NGI0 Entrust Fund. <a href="https://nlnet.nl/entrust/">NGI0 Entrust Fund</a> is established by the <a href="https://nlnet.nl/">NLnet Foundation</a> with financial support from the European Commission's <a href="https://www.ngi.eu/">Next Generation Internet programme</a>, under the aegis of DG Communications Networks, Content and Technology under grant agreement No 101069594.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="https://summerofcode.withgoogle.com/"><img src="docs/sponsors/gsoc.svg" alt="Google Summer of Code" width="200px"></a>
|
||||
</td>
|
||||
<td>
|
||||
<a href="https://summerofcode.withgoogle.com/">Google</a> backed 5 student's projects in the Google Summer of Code program during <a href="https://summerofcode.withgoogle.com/programs/2022/organizations/organic-maps">2022</a> and <a href="https://summerofcode.withgoogle.com/programs/2023/organizations/organic-maps">2023</a> programs. Noteworthy projects included Android Auto and Wikipedia Dump Extractor.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="https://www.mythic-beasts.com/"><img src="docs/sponsors/mythic-beasts.png" alt="Mythic Beasts" width="200px"></a>
|
||||
</td>
|
||||
<td>
|
||||
<a href="https://www.mythic-beasts.com/">Mythic Beasts</a> ISP <a href="https://www.mythic-beasts.com/blog/2021/10/06/improving-the-world-bit-by-expensive-bit/">provides us</a> two virtual servers with 400 TB/month of free bandwidth to host and serve maps downloads and updates.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="https://44plus.vn"><img src="docs/sponsors/44plus.svg" alt="44+ Technologies" width="200px"></a>
|
||||
</td>
|
||||
<td>
|
||||
<a href="https://44plus.vn">44+ Technologies</a> is <a href="https://44plus.vn/organicmaps">providing us </a>with a free dedicated server worth around $12,000/year to serve maps across Vietnam & Southeast Asia.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="https://futo.org"><img src="docs/sponsors/futo.svg" alt="FUTO" width="200px"></a>
|
||||
</td>
|
||||
<td>
|
||||
<a href="https://futo.org">FUTO</a> has <a href="https://www.youtube.com/watch?v=fJJclgBHrEw">awarded $1000 micro-grant</a> to Organic Maps in February 2023.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
The majority of all expenses have been funded by founders of the project since its inception. The project is far from achieving any sort of financial sustainability. The current level of voluntary donations falls significantly short of covering efforts needed to sustain the app. Any new developments of features are beyond the scope of possibility due to the absence of the necessary financial resources.
|
||||
|
||||
Please consider [donating](https://organicmaps.app/donate) if you want to see this open-source project thriving, not dying. There are [other ways how to support the project](#contributing). No coding skills required.
|
||||
[Mythic Beasts](https://www.mythic-beasts.com/) ISP [provides us](https://www.mythic-beasts.com/blog/2021/10/06/improving-the-world-bit-by-expensive-bit/)
|
||||
two virtual servers with 400 TB/month of free bandwidth to help our users with
|
||||
maps downloads and updates.
|
||||
|
||||
## Copyrights
|
||||
|
||||
|
@ -143,13 +114,11 @@ Licensed under the Apache License, Version 2.0. See
|
|||
[LICENSE](https://github.com/organicmaps/organicmaps/blob/master/LICENSE),
|
||||
[NOTICE](https://github.com/organicmaps/organicmaps/blob/master/NOTICE)
|
||||
and [data/copyright.html](http://htmlpreview.github.io/?https://github.com/organicmaps/organicmaps/blob/master/data/copyright.html)
|
||||
for more information.
|
||||
files for more information.
|
||||
|
||||
## Governance
|
||||
|
||||
See [docs/GOVERNANCE.md](docs/GOVERNANCE.md).
|
||||
|
||||
<a name="contributing">
|
||||
See [GOVERNANCE](docs/GOVERNANCE.md).
|
||||
|
||||
## Contributing
|
||||
|
||||
|
@ -165,20 +134,20 @@ Please join our beta program, suggest your features, and report bugs:
|
|||
|
||||
## Feedback
|
||||
|
||||
- **Rate us on the [App Store](https://apps.apple.com/app/organic-maps/id1567437057)
|
||||
- **Rate us on [App Store](https://apps.apple.com/app/organic-maps/id1567437057)
|
||||
and [Google Play](https://play.google.com/store/apps/details?id=app.organicmaps)**.
|
||||
- **Star us on Forgejo**.
|
||||
- Report bugs or issues to [the issue tracker](https://git.omaps.dev/organicmaps/organicmaps/issues).
|
||||
- **Star us on GitHub**.
|
||||
- Report bugs or issues to [the issue tracker](https://github.com/organicmaps/organicmaps/issues).
|
||||
- [Discuss](https://github.com/organicmaps/organicmaps/discussions/categories/ideas) ideas or propose feature requests.
|
||||
- Subscribe to our [Telegram Channel](https://t.me/OrganicMapsApp) or to the [[matrix] space](https://matrix.to/#/#organicmaps:matrix.org) for updates.
|
||||
- Join our [Telegram Group](https://t.me/OrganicMaps) to discuss with other users.
|
||||
- Присоединяйтесь к нашей [русскоязычной группе в Telegram](https://t.me/OrganicMapsRu) для обратной связи и помощи.
|
||||
- Diğer kullanıcılarla tartışmak için [Telegram Grubumuza](https://t.me/OrganicMapsTR) katılın.
|
||||
- Rejoignez notre groupe [Telegram](https://t.me/OrganicMapsFR) pour obtenir de l'aide.
|
||||
- Contact us by [email](mailto:hello@organicmaps.app).
|
||||
- Follow our updates in
|
||||
[Mastodon](https://fosstodon.org/@organicmaps),
|
||||
[Facebook](https://facebook.com/OrganicMaps),
|
||||
[X (Twitter)](https://x.com/OrganicMapsApp),
|
||||
[Twitter](https://twitter.com/OrganicMapsApp),
|
||||
[Instagram](https://instagram.com/organicmaps.app/).
|
||||
- Güncellemelerimizi [Instagram](https://instagram.com/organicmapstr/) üzerinden takip edin.
|
||||
|
||||
|
|
3
android/.gitignore
vendored
|
@ -21,6 +21,3 @@ local.properties
|
|||
.project
|
||||
lint.xml
|
||||
.gradletasknamecache
|
||||
|
||||
# Generated by Eclipse and JDTLS
|
||||
.settings/
|
||||
|
|
8
android/.idea/icon.svg
generated
|
@ -1,8 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
<svg version="1.1" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape">
|
||||
<g inkscape:groupmode="layer" inkscape:label="Layer 1">
|
||||
<rect fill="#006c35" fill-opacity="1.0" x="0" y="0" width="1024" height="1024"/>
|
||||
<path fill="#ffffff" d="m861.3562052 256.9139426c18.220574 48.4374573-79.2585233 166.2022835-172.1806378 196.4226995-168.0803471-58.2153969-173.5457836 39.5504743-311.1096159 132.4296677 162.6149552 112.4329497 332.9737882 24.8856325 329.7844002-85.7673036-127.9956457 73.3254376-208.1650824 81.3238121-254.1719349 79.1032962 154.8710218-30.6636026 322.0404219-125.7633124 357.0667834-165.7616685 0.032202 1.7749817 0.049863 3.5523114 0.049863 5.33456 0 191.0905993-295.1650572 474.6148576-295.1650572 474.6148576s-154.5086464-147.95159-239.9499331-302.4701423c-11.943516-0.1614425-83.8230022 25.9633002-110.3310391-9.051445-29.6082623-39.1049397 80.1693081-170.2028122 175.3699196-209.3102117 170.3563508 77.3261904 263.7351577-123.0971499 317.0292402-134.2068293-158.9688193-94.2135154-316.1183714-55.5493358-333.8847017 84.4353407 88.3675802-50.2172465 196.7775505-78.65765 246.8822227-76.4346744-140.7606999 28.7623957-301.9981102 132.8752019-350.2809443 172.4255642 0-159.041983 132.1505407-287.9677052 295.1650569-287.9677052 96.4018995 0 182.0095151 45.0859887 235.8744518 114.8252613 0.00335 0 96.1884344-31.2834041 109.851981 11.3787329zm-33.7059144 14.218972c-12.6607646-17.2289278-56.7341326 2.8936807-56.7341326 2.8936807 6.1678152 10.3446685 11.7002555 21.0960758 16.5352245 32.2084942 4.8995467 11.2622344 9.0867303 22.8954305 12.5044868 34.8382086 0 0 45.0041042-46.3863227 27.6944213-69.9403835zm-629.5734431 294.3797539c13.6858848 18.6189721 61.3258973-3.1309266 61.3258973-3.1309266-6.6716772-11.1802827-12.6484216-22.8033047-17.8755617-34.8139472-5.2966478-12.1727565-9.8213865-24.7454316-13.5171072-37.6545218 0 0-48.6427553 50.1397674-29.9332284 75.5993956z"/>
|
||||
</g>
|
||||
</svg>
|
Before Width: | Height: | Size: 2 KiB |
1
android/app/.gitignore
vendored
|
@ -12,7 +12,6 @@
|
|||
/firebase-app-distribution.json
|
||||
/firebase-test-lab.json
|
||||
/huawei-appgallery.json
|
||||
/agconnect-services.json
|
||||
/src/main/res/xml/network_security_config.xml
|
||||
|
||||
# ignore flags symlinks
|
||||
|
|
|
@ -4,37 +4,60 @@ buildscript {
|
|||
mavenCentral()
|
||||
}
|
||||
//
|
||||
// The magic below is needed to disable Google Firebase Services during the build time.
|
||||
// Unfortunately, the only way to disable Gradle plugins is to add these hardcore switches to buildscript().
|
||||
// The magic below is needed to disable Google Mobile Services (a.k.a GMS) and
|
||||
// Google Firebase Services during the build time. Unfortunately, the only way
|
||||
// to disable Gradle plugins is to add these hardcore switches to buildscript().
|
||||
//
|
||||
|
||||
// Detect flavors from the task name.
|
||||
def taskName = getGradle().getStartParameter().getTaskRequests().toString().toLowerCase()
|
||||
def isFdroid = taskName.contains('fdroid')
|
||||
def isBeta = taskName.contains('beta')
|
||||
def isDebug = taskName.contains('debug')
|
||||
def isSyncWithFiles = taskName.contains('rundefaulttasksexecutionrequest') // used by Android Studio
|
||||
|
||||
//
|
||||
// Please add symlinks to google/java/app/organicmaps/location for each new gms-enabled flavor below:
|
||||
// ```
|
||||
// mkdir -p src/$flavor/java/app/organicmaps/
|
||||
// ln -sf ../../../../google/java/app/organicmaps/location src/$flavor/java/app/organicmaps/
|
||||
// ls -la src/$flavor/java/app/organicmaps/location/GoogleFusedLocationProvider.java
|
||||
// ```
|
||||
ext.googleMobileServicesEnabled = taskName.contains('google') || taskName.contains('huawei') || taskName.contains('web')
|
||||
|
||||
// Firebase Crashlytics compile-time feature flag: -Pfirebase=true|false
|
||||
def googleFirebaseServicesFlag = findProperty('firebase')
|
||||
// Enable Firebase for all beta flavors except fdroid only if google-services.json exists.
|
||||
def googleFirebaseServicesDefault = isBeta && !isFdroid && file("$projectDir/google-services.json").exists()
|
||||
ext.googleFirebaseServicesEnabled = googleFirebaseServicesFlag != null ?
|
||||
googleFirebaseServicesFlag == '' || googleFirebaseServicesFlag.toBoolean() :
|
||||
ext.googleFirebaseServicesEnabled = googleFirebaseServicesFlag ? googleFirebaseServicesFlag.toBoolean() :
|
||||
googleFirebaseServicesDefault
|
||||
|
||||
// Android Auto compile-time feature flag: -Pandroidauto=true|false
|
||||
def androidAutoFlag = findProperty('androidauto')
|
||||
// Enable Android Auto by default for all debug and beta flavors except fdroid.
|
||||
def androidAutoDefault = isSyncWithFiles || ((isDebug || isBeta) && !isFdroid)
|
||||
ext.androidAutoEnabled = androidAutoFlag ? androidAutoFlag.toBoolean() : androidAutoDefault
|
||||
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:8.7.3'
|
||||
classpath 'com.android.tools.build:gradle:8.1.1'
|
||||
|
||||
if (googleMobileServicesEnabled) {
|
||||
println('Building with Google Mobile Services')
|
||||
classpath 'com.google.gms:google-services:4.3.15'
|
||||
} else {
|
||||
println('Building without Google Services')
|
||||
}
|
||||
|
||||
if (googleFirebaseServicesEnabled) {
|
||||
println('Building with Google Firebase Services')
|
||||
classpath 'com.google.gms:google-services:4.4.2'
|
||||
classpath 'com.google.firebase:firebase-crashlytics-gradle:3.0.2'
|
||||
classpath 'com.google.firebase:firebase-appdistribution-gradle:5.0.0'
|
||||
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.9'
|
||||
classpath 'com.google.firebase:firebase-appdistribution-gradle:4.0.0'
|
||||
} else {
|
||||
println('Building without Google Firebase Services')
|
||||
}
|
||||
|
||||
classpath('com.github.triplet.gradle:play-publisher:3.10.1')
|
||||
classpath('ru.cian:huawei-publish-gradle-plugin:1.4.2')
|
||||
classpath('com.github.triplet.gradle:play-publisher:3.8.4')
|
||||
classpath('ru.cian:huawei-publish-gradle-plugin:1.4.0')
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,14 +68,66 @@ repositories {
|
|||
}
|
||||
|
||||
apply plugin: 'com.android.application'
|
||||
if (googleFirebaseServicesEnabled) {
|
||||
apply from: 'secure.properties'
|
||||
if (googleMobileServicesEnabled) {
|
||||
apply plugin: 'com.google.gms.google-services'
|
||||
}
|
||||
if (googleFirebaseServicesEnabled) {
|
||||
apply plugin: 'com.google.firebase.crashlytics'
|
||||
apply plugin: 'com.google.firebase.appdistribution'
|
||||
}
|
||||
apply plugin: 'com.github.triplet.play'
|
||||
apply plugin: 'ru.cian.huawei-publish-gradle-plugin'
|
||||
|
||||
dependencies {
|
||||
// Google Mobile Services
|
||||
if (googleMobileServicesEnabled) {
|
||||
implementation 'com.google.android.gms:play-services-location:21.0.1'
|
||||
}
|
||||
|
||||
// Google Firebase Services
|
||||
if (googleFirebaseServicesEnabled) {
|
||||
// Import the BoM for the Firebase platform
|
||||
implementation platform('com.google.firebase:firebase-bom:32.2.3')
|
||||
// Add the dependencies for the Crashlytics and Analytics libraries
|
||||
// When using the BoM, you don't specify versions in Firebase library dependencies
|
||||
implementation 'com.google.firebase:firebase-crashlytics'
|
||||
implementation 'com.google.firebase:firebase-crashlytics-ndk'
|
||||
}
|
||||
|
||||
if (androidAutoEnabled) {
|
||||
println('Building with Android Auto')
|
||||
implementation 'androidx.car.app:app:1.4.0-beta02'
|
||||
// Fix for app/organicmaps/util/FileUploadWorker.java:14: error: cannot access ListenableFuture
|
||||
// https://github.com/organicmaps/organicmaps/issues/6106
|
||||
implementation 'com.google.guava:guava:32.1.2-android'
|
||||
} else {
|
||||
println('Building without Android Auto')
|
||||
}
|
||||
|
||||
// This line is added as a workaround for duplicate classes error caused by some outdated dependency:
|
||||
// > A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
|
||||
// We don't use Kotlin, but some dependencies are actively using it.
|
||||
// See https://stackoverflow.com/a/75719642
|
||||
implementation(platform('org.jetbrains.kotlin:kotlin-bom:1.9.10'))
|
||||
implementation 'androidx.annotation:annotation:1.7.0'
|
||||
implementation 'androidx.appcompat:appcompat:1.6.1'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||
implementation 'androidx.fragment:fragment:1.6.1'
|
||||
implementation 'androidx.preference:preference:1.2.1'
|
||||
implementation 'androidx.recyclerview:recyclerview:1.3.1'
|
||||
implementation 'androidx.work:work-runtime:2.8.1'
|
||||
implementation 'androidx.lifecycle:lifecycle-process:2.6.2'
|
||||
implementation 'com.google.android.material:material:1.9.0'
|
||||
implementation 'com.github.devnullorthrow:MPAndroidChart:3.2.0-alpha'
|
||||
implementation 'net.jcip:jcip-annotations:1.0'
|
||||
|
||||
// Test Dependencies
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
testImplementation 'org.mockito:mockito-core:5.5.0'
|
||||
testImplementation 'org.mockito:mockito-inline:5.2.0'
|
||||
}
|
||||
|
||||
def run(cmd) {
|
||||
def stdout = new ByteArrayOutputStream()
|
||||
exec {
|
||||
|
@ -83,24 +158,17 @@ def osName = System.properties['os.name'].toLowerCase()
|
|||
project.ext.appId = 'app.organicmaps'
|
||||
project.ext.appName = 'Organic Maps'
|
||||
|
||||
// I have Java 21 installed, but this doesn't work on MacOS.
|
||||
//java {
|
||||
// toolchain {
|
||||
// languageVersion.set(JavaLanguageVersion.of(17))
|
||||
// }
|
||||
//}
|
||||
|
||||
android {
|
||||
namespace 'app.organicmaps'
|
||||
|
||||
buildFeatures {
|
||||
dataBinding = true
|
||||
buildConfig = true
|
||||
}
|
||||
// All properties are read from gradle.properties file
|
||||
compileSdk propCompileSdkVersion.toInteger()
|
||||
compileSdkVersion propCompileSdkVersion.toInteger()
|
||||
buildToolsVersion propBuildToolsVersion
|
||||
|
||||
ndkVersion '27.2.12479018'
|
||||
ndkVersion '26.0.10792818'
|
||||
|
||||
defaultConfig {
|
||||
// Default package name is taken from the manifest and should be app.organicmaps
|
||||
|
@ -109,14 +177,17 @@ android {
|
|||
versionName = ver.V2
|
||||
println('Version: ' + versionName)
|
||||
println('VersionCode: ' + versionCode)
|
||||
minSdk propMinSdkVersion.toInteger()
|
||||
targetSdk propTargetSdkVersion.toInteger()
|
||||
minSdkVersion propMinSdkVersion.toInteger()
|
||||
targetSdkVersion propTargetSdkVersion.toInteger()
|
||||
applicationId project.ext.appId
|
||||
buildConfigField 'String', 'SUPPORT_MAIL', '"android@organicmaps.app"'
|
||||
// Should be customized in flavors.
|
||||
buildConfigField 'String', 'REVIEW_URL', '""'
|
||||
resourceConfigurations += [project.ext.supportedLocalizations]
|
||||
|
||||
multiDexEnabled true
|
||||
multiDexKeepFile file('multidex-config.txt')
|
||||
|
||||
externalNativeBuild {
|
||||
def pchFlag = 'OFF'
|
||||
if (project.hasProperty('pch')) pchFlag = 'ON'
|
||||
|
@ -124,25 +195,14 @@ android {
|
|||
def njobs = ''
|
||||
if (project.hasProperty('njobs')) njobs = project.getProperty('njobs')
|
||||
|
||||
def enableVulkanDiagnostics = 'OFF'
|
||||
if (project.hasProperty('enableVulkanDiagnostics')) {
|
||||
enableVulkanDiagnostics = project.getProperty('enableVulkanDiagnostics')
|
||||
}
|
||||
|
||||
def enableTrace = 'OFF'
|
||||
if (project.hasProperty('enableTrace')) {
|
||||
enableTrace = project.getProperty('enableTrace')
|
||||
}
|
||||
|
||||
cmake {
|
||||
cppFlags '-fexceptions', '-frtti'
|
||||
// There is no sense to enable sections without gcc's --gc-sections flag.
|
||||
cFlags '-fno-function-sections', '-fno-data-sections',
|
||||
'-Wno-extern-c-compat'
|
||||
arguments '-DANDROID_TOOLCHAIN=clang', '-DANDROID_STL=c++_static',
|
||||
"-DOS=$osName", '-DSKIP_TESTS=ON', '-DSKIP_TOOLS=ON', "-DUSE_PCH=$pchFlag",
|
||||
"-DNJOBS=$njobs", "-DENABLE_VULKAN_DIAGNOSTICS=$enableVulkanDiagnostics",
|
||||
"-DENABLE_TRACE=$enableTrace"
|
||||
"-DOS=$osName", '-DSKIP_TESTS=ON', "-DUSE_PCH=$pchFlag",
|
||||
"-DNJOBS=$njobs"
|
||||
targets 'organicmaps'
|
||||
}
|
||||
}
|
||||
|
@ -168,10 +228,14 @@ android {
|
|||
// For the emulator, chromebooks and some Intel Atom devices.
|
||||
abiFilters.add('x86_64')
|
||||
}
|
||||
println('Building for ' + abiFilters + ' archs.')
|
||||
println("Building for " + abiFilters + " archs.")
|
||||
}
|
||||
|
||||
setProperty('archivesBaseName', appName.replaceAll('\\s','') + '-' + defaultConfig.versionCode)
|
||||
setProperty("archivesBaseName", appName.replaceAll("\\s","") + "-" + defaultConfig.versionCode)
|
||||
|
||||
if (!androidAutoEnabled) {
|
||||
sourceSets.main.java.excludes += '**/organicmaps/car'
|
||||
}
|
||||
}
|
||||
|
||||
flavorDimensions += 'default'
|
||||
|
@ -181,27 +245,26 @@ android {
|
|||
final int HUAWEI_VERSION_CODE_BASE = 01_00_00_00_00
|
||||
|
||||
google {
|
||||
dimension 'default'
|
||||
dimension "default"
|
||||
versionName = android.defaultConfig.versionName + '-Google'
|
||||
buildConfigField 'String', 'SUPPORT_MAIL', '"googleplay@organicmaps.app"'
|
||||
buildConfigField 'String', 'REVIEW_URL', '"market://details?id=app.organicmaps"'
|
||||
}
|
||||
|
||||
web {
|
||||
dimension 'default'
|
||||
applicationIdSuffix '.web'
|
||||
dimension "default"
|
||||
versionName = android.defaultConfig.versionName + '-Web'
|
||||
buildConfigField 'String', 'SUPPORT_MAIL', '"apk@organicmaps.app"'
|
||||
}
|
||||
|
||||
fdroid {
|
||||
dimension 'default'
|
||||
dimension "default"
|
||||
versionName = android.defaultConfig.versionName + '-FDroid'
|
||||
buildConfigField 'String', 'SUPPORT_MAIL', '"fdroid@organicmaps.app"'
|
||||
}
|
||||
|
||||
huawei {
|
||||
dimension 'default'
|
||||
dimension "default"
|
||||
versionName = android.defaultConfig.versionName + '-Huawei'
|
||||
versionCode = HUAWEI_VERSION_CODE_BASE + android.defaultConfig.versionCode
|
||||
buildConfigField 'String', 'SUPPORT_MAIL', '"huawei@organicmaps.app"'
|
||||
|
@ -217,7 +280,7 @@ android {
|
|||
|
||||
splits.abi {
|
||||
boolean enabled = project.hasProperty('splitApk')
|
||||
println ('Create separate apks: ' + enabled)
|
||||
println ("Create separate apks: " + enabled)
|
||||
enable enabled
|
||||
reset()
|
||||
include 'x86', 'armeabi-v7a', 'arm64-v8a', 'x86_64'
|
||||
|
@ -234,6 +297,8 @@ android {
|
|||
disable 'CustomSplashScreen'
|
||||
// https://github.com/organicmaps/organicmaps/issues/3610
|
||||
disable 'InsecureBaseConfiguration'
|
||||
// https://github.com/organicmaps/organicmaps/issues/3608
|
||||
disable 'UnusedResources'
|
||||
abortOnError true
|
||||
}
|
||||
|
||||
|
@ -241,16 +306,11 @@ android {
|
|||
android.applicationVariants.all { variant ->
|
||||
def task = variant.name.capitalize()
|
||||
project.task(type: Exec, "run${task}", dependsOn: "install${task}") {
|
||||
commandLine android.getAdbExe(), 'shell', 'am', 'start', '-n', "$applicationId/app.organicmaps.DownloadResourcesActivity", '-a', 'android.intent.action.MAIN', '-c', 'android.intent.category.LAUNCHER'
|
||||
commandLine android.getAdbExe(), 'shell', 'am', 'start', '-n', "${applicationId}/app.organicmaps.SplashActivity"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def securityPropertiesFileExists = file('secure.properties').exists()
|
||||
if (securityPropertiesFileExists) {
|
||||
apply from: 'secure.properties'
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
debug {
|
||||
storeFile file('debug.keystore')
|
||||
|
@ -260,15 +320,10 @@ android {
|
|||
}
|
||||
|
||||
release {
|
||||
if (securityPropertiesFileExists) {
|
||||
println('The release signing keys are available')
|
||||
storeFile file(spropStoreFile)
|
||||
storePassword spropStorePassword
|
||||
keyAlias spropKeyAlias
|
||||
keyPassword spropKeyPassword
|
||||
} else {
|
||||
println('The release signing keys are unavailable')
|
||||
}
|
||||
storeFile file(spropStoreFile)
|
||||
storePassword spropStorePassword
|
||||
keyAlias spropKeyAlias
|
||||
keyPassword spropKeyPassword
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -279,7 +334,8 @@ android {
|
|||
jniDebuggable true // Enable jni debug build
|
||||
zipAlignEnabled true
|
||||
signingConfig signingConfigs.debug
|
||||
resValue 'string', 'app_name', 'Debug Organic Maps'
|
||||
resValue 'string', 'app_id', android.defaultConfig.applicationId + applicationIdSuffix
|
||||
resValue 'string', 'app_name', project.ext.appName + ' ' + '(Debug)'
|
||||
// Do not generate separate debug symbols for debug apps, because we don't distribute them.
|
||||
ndk.debugSymbolLevel = 'none'
|
||||
|
||||
|
@ -298,7 +354,8 @@ android {
|
|||
shrinkResources true
|
||||
// Includes the default ProGuard rules files that are packaged with the Android Gradle plugin.
|
||||
// To learn more, go to the documentation section about R8 configuration files.
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-mwm.txt'
|
||||
resValue 'string', 'app_id', android.defaultConfig.applicationId
|
||||
resValue 'string', 'app_name', project.ext.appName
|
||||
// Full size symbols are too big for Google, 217mb aab vs 95mb.
|
||||
ndk.debugSymbolLevel = 'symbol_table'
|
||||
|
@ -318,9 +375,10 @@ android {
|
|||
shrinkResources true
|
||||
// Includes the default ProGuard rules files that are packaged with the Android Gradle plugin.
|
||||
// To learn more, go to the documentation section about R8 configuration files.
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-mwm.txt'
|
||||
matchingFallbacks = ['debug', 'release']
|
||||
resValue 'string', 'app_name', 'Beta Organic Maps'
|
||||
resValue 'string', 'app_id', android.defaultConfig.applicationId + applicationIdSuffix
|
||||
resValue 'string', 'app_name', project.ext.appName + ' ' + '(Beta)'
|
||||
// Full size symbols are too big for Google, 217mb aab vs 95mb.
|
||||
ndk.debugSymbolLevel = 'symbol_table'
|
||||
|
||||
|
@ -332,7 +390,7 @@ android {
|
|||
// A new beta release is created for each commit.
|
||||
// Use the last commit message for the release notes.
|
||||
releaseNotes = getCommitMessage()
|
||||
groups = 'qa' // Notify only selected people.
|
||||
groups = "qa" // Notify only selected people.
|
||||
serviceCredentialsFile = "$projectDir/firebase-app-distribution.json"
|
||||
}
|
||||
}
|
||||
|
@ -341,9 +399,9 @@ android {
|
|||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
version '3.22.1+'
|
||||
buildStagingDirectory './nativeOutputs'
|
||||
path '../../CMakeLists.txt'
|
||||
version "3.22.1+"
|
||||
buildStagingDirectory "./nativeOutputs"
|
||||
path "../../CMakeLists.txt"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -351,87 +409,38 @@ android {
|
|||
// TODO: Load all minor files via separate call to ReadAsString which can correctly handle compressed files in zip containers.
|
||||
androidResources {
|
||||
ignoreAssetsPattern '!.svn:!.git:!.DS_Store:!*.scc:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~'
|
||||
noCompress = ['txt', 'bin', 'html', 'png', 'json', 'mwm', 'ttf', 'sdf', 'ui', 'config', 'csv', 'spv', 'obj']
|
||||
noCompress 'txt', 'bin', 'html', 'png', 'json', 'mwm', 'ttf', 'sdf', 'ui', 'config', 'csv', 'spv', 'obj'
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
coreLibraryDesugaringEnabled true
|
||||
|
||||
sourceCompatibility JavaVersion.VERSION_17
|
||||
targetCompatibility JavaVersion.VERSION_17
|
||||
sourceCompatibility JavaVersion.VERSION_11
|
||||
targetCompatibility JavaVersion.VERSION_11
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.4'
|
||||
|
||||
// Google Play Location Services
|
||||
//
|
||||
// Please add symlinks to google/java/app/organicmaps/location for each new gms-enabled flavor below:
|
||||
// ```
|
||||
// mkdir -p src/$flavor/java/app/organicmaps/
|
||||
// ln -sf ../../../../google/java/app/organicmaps/location src/$flavor/java/app/organicmaps/
|
||||
// ls -la src/$flavor/java/app/organicmaps/location/GoogleFusedLocationProvider.java
|
||||
// ```
|
||||
//
|
||||
webImplementation 'com.google.android.gms:play-services-location:21.3.0'
|
||||
googleImplementation 'com.google.android.gms:play-services-location:21.3.0'
|
||||
huaweiImplementation 'com.google.android.gms:play-services-location:21.3.0'
|
||||
// This is the microG project's re-implementation which is permissible on
|
||||
// F-droid because it's Apache-2.0.
|
||||
fdroidImplementation 'org.microg.gms:play-services-location:0.3.6.244735'
|
||||
|
||||
// Google Firebase Services
|
||||
if (googleFirebaseServicesEnabled) {
|
||||
// Import the BoM for the Firebase platform
|
||||
implementation platform('com.google.firebase:firebase-bom:33.5.1')
|
||||
// Add the dependencies for the Crashlytics and Analytics libraries
|
||||
// When using the BoM, you don't specify versions in Firebase library dependencies
|
||||
implementation 'com.google.firebase:firebase-crashlytics'
|
||||
implementation 'com.google.firebase:firebase-crashlytics-ndk'
|
||||
packagingOptions.jniLibs {
|
||||
excludes += [
|
||||
'lib/**/libVkLayer_khronos_validation.so',
|
||||
'lib/**/libVkLayer_core_validation.so',
|
||||
'lib/**/libVkLayer_threading.so',
|
||||
'lib/**/libVkLayer_image.so',
|
||||
'lib/**/libVkLayer_parameter_validation.so',
|
||||
'lib/**/libVkLayer_object_tracker.so',
|
||||
'lib/**/libVkLayer_swapchain.so',
|
||||
'lib/**/libVkLayer_unique_objects.so',
|
||||
]
|
||||
}
|
||||
|
||||
// This line is added as a workaround for duplicate classes error caused by some outdated dependency:
|
||||
// > A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
|
||||
// We don't use Kotlin, but some dependencies are actively using it.
|
||||
// See https://stackoverflow.com/a/75719642
|
||||
implementation 'androidx.core:core:1.15.0'
|
||||
implementation(platform('org.jetbrains.kotlin:kotlin-bom:2.1.10'))
|
||||
implementation 'androidx.annotation:annotation:1.9.1'
|
||||
implementation 'androidx.appcompat:appcompat:1.7.0'
|
||||
implementation 'androidx.car.app:app:1.7.0-rc01'
|
||||
implementation 'androidx.car.app:app-projected:1.7.0-rc01'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.2.0'
|
||||
implementation 'androidx.fragment:fragment:1.8.5'
|
||||
implementation 'androidx.preference:preference:1.2.1'
|
||||
implementation 'androidx.recyclerview:recyclerview:1.3.2'
|
||||
implementation 'androidx.work:work-runtime:2.10.0'
|
||||
implementation 'androidx.lifecycle:lifecycle-process:2.8.7'
|
||||
implementation 'com.google.android.material:material:1.12.0'
|
||||
// Fix for app/organicmaps/util/FileUploadWorker.java:14: error: cannot access ListenableFuture
|
||||
// https://github.com/organicmaps/organicmaps/issues/6106
|
||||
implementation 'com.google.guava:guava:33.3.0-android'
|
||||
implementation 'com.github.devnullorthrow:MPAndroidChart:3.2.0-alpha'
|
||||
implementation 'net.jcip:jcip-annotations:1.0'
|
||||
|
||||
// Test Dependencies
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
testImplementation 'org.mockito:mockito-core:5.15.2'
|
||||
testImplementation 'org.mockito:mockito-inline:5.2.0'
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.compilerArgs << '-Xlint:unchecked' << '-Xlint:deprecation'
|
||||
}
|
||||
|
||||
android.applicationVariants.all { variant ->
|
||||
def authorityValue = variant.applicationId + ".provider"
|
||||
android.buildTypes.all { buildType ->
|
||||
def suffix = applicationIdSuffix != null ? applicationIdSuffix : ""
|
||||
def authorityValue = android.defaultConfig.applicationId + suffix + ".provider"
|
||||
def authority = "\"" + authorityValue + "\""
|
||||
variant.buildConfigField 'String', 'FILE_PROVIDER_AUTHORITY', authority
|
||||
def flavor = variant.getMergedFlavor()
|
||||
flavor.manifestPlaceholders += [FILE_PROVIDER_PLACEHOLDER : authorityValue]
|
||||
variant.resValue 'string', 'app_id', variant.applicationId
|
||||
buildConfigField 'String', 'FILE_PROVIDER_AUTHORITY', authority
|
||||
manifestPlaceholders += [FILE_PROVIDER_PLACEHOLDER : authorityValue]
|
||||
manifestPlaceholders += [ANDROID_AUTO_ENABLED : androidAutoEnabled]
|
||||
}
|
||||
|
||||
task prepareGoogleReleaseListing {
|
||||
|
@ -442,7 +451,7 @@ task prepareGoogleReleaseListing {
|
|||
final sourceDir = new File("${projectDir}/src/$sourceFlavor/play/listings")
|
||||
final targetDir = new File("${projectDir}/src/$targetFlavor/play/listings")
|
||||
final sourceFiles = fileTree(dir: sourceDir,
|
||||
include: '**/*.txt', exclude: "**/*-${targetFlavor}.txt")
|
||||
include: "**/*.txt", exclude: "**/*-${targetFlavor}.txt")
|
||||
sourceFiles.each { File sourceFile ->
|
||||
final locale = sourceFile.parentFile.getName()
|
||||
final targetLocaleDir = new File(targetDir, locale)
|
||||
|
@ -450,7 +459,7 @@ task prepareGoogleReleaseListing {
|
|||
targetLocaleDir.mkdirs()
|
||||
final targetFile = new File(targetLocaleDir, sourceFile.getName())
|
||||
// Override Google-specific values by using ${name}-google.txt files.
|
||||
final overrideFile = new File(sourceFile.getPath().replace('.txt', "-${targetFlavor}.txt"))
|
||||
final overrideFile = new File(sourceFile.getPath().replace(".txt", "-${targetFlavor}.txt"))
|
||||
targetFile.text = overrideFile.exists() ? overrideFile.text : sourceFile.text
|
||||
}
|
||||
copy {
|
||||
|
@ -462,10 +471,11 @@ task prepareGoogleReleaseListing {
|
|||
|
||||
play {
|
||||
enabled.set(false)
|
||||
track.set('production')
|
||||
track.set("production")
|
||||
userFraction.set(Double.valueOf(0.10)) // 10%
|
||||
defaultToAppBundles.set(true)
|
||||
releaseStatus.set(ReleaseStatus.IN_PROGRESS)
|
||||
serviceAccountCredentials.set(file('google-play.json'))
|
||||
serviceAccountCredentials.set(file("google-play.json"))
|
||||
}
|
||||
|
||||
huaweiPublish {
|
||||
|
@ -474,7 +484,7 @@ huaweiPublish {
|
|||
credentialsPath = "$projectDir/huawei-appgallery.json"
|
||||
buildFormat = 'aab'
|
||||
deployType = 'draft' // confirm manually
|
||||
def releaseDescriptions = []
|
||||
releaseNotes = []
|
||||
def localeOverride = [
|
||||
'am' : 'am-ET',
|
||||
'gu': 'gu_IN',
|
||||
|
@ -492,9 +502,8 @@ huaweiPublish {
|
|||
def path = file.getPath()
|
||||
def locale = file.parentFile.getName()
|
||||
locale = localeOverride.get(locale, locale)
|
||||
releaseDescriptions.add(new ru.cian.huawei.publish.ReleaseNote(locale, path))
|
||||
releaseNotes.add(new ru.cian.huawei.publish.ReleaseNote(locale, path))
|
||||
}
|
||||
releaseNotes = new ru.cian.huawei.publish.ReleaseNotesExtension(releaseDescriptions, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
app/organicmaps/api/ParsedRoutingData.class
|
||||
app/organicmaps/api/ParsedSearchRequest.class
|
||||
app/organicmaps/api/ParsingResult.class
|
||||
app/organicmaps/api/RoutePoint.class
|
||||
app/organicmaps/bookmarks/data/Bookmark.class
|
||||
app/organicmaps/bookmarks/data/BookmarkCategory.class
|
||||
app/organicmaps/bookmarks/data/BookmarkInfo.class
|
||||
app/organicmaps/bookmarks/data/BookmarkManager.class
|
||||
app/organicmaps/bookmarks/data/BookmarkSharingResult.class
|
||||
app/organicmaps/bookmarks/data/DistanceAndAzimut.class
|
||||
app/organicmaps/bookmarks/data/ElevationInfo.class
|
||||
app/organicmaps/bookmarks/data/ElevationInfo$Point.class
|
||||
app/organicmaps/bookmarks/data/FeatureId.class
|
||||
app/organicmaps/bookmarks/data/MapObject.class
|
||||
app/organicmaps/bookmarks/data/SortedBlock.class
|
||||
app/organicmaps/downloader/ChunkTask.class
|
||||
app/organicmaps/downloader/CountryItem.class
|
||||
app/organicmaps/downloader/MapManager$StorageCallbackData.class
|
||||
app/organicmaps/downloader/UpdateInfo.class
|
||||
app/organicmaps/editor/data/FeatureCategory.class
|
||||
app/organicmaps/editor/data/HoursMinutes.class
|
||||
app/organicmaps/editor/data/Language.class
|
||||
app/organicmaps/editor/data/LocalizedName.class
|
||||
app/organicmaps/editor/data/LocalizedStreet.class
|
||||
app/organicmaps/editor/data/NamesDataSource.class
|
||||
app/organicmaps/editor/data/Timespan.class
|
||||
app/organicmaps/editor/data/Timetable.class
|
||||
app/organicmaps/location/PlatformSocket.class
|
||||
app/organicmaps/routing/RoutePointInfo.class
|
||||
app/organicmaps/routing/RoutingInfo.class
|
||||
app/organicmaps/routing/SingleLaneInfo.class
|
||||
app/organicmaps/routing/TransitStepInfo.class
|
||||
app/organicmaps/search/NativeMapSearchListener$Result.class
|
||||
app/organicmaps/search/Popularity.class
|
||||
app/organicmaps/search/PopularityProvider.class
|
||||
app/organicmaps/search/SearchResult.class
|
||||
app/organicmaps/search/SearchResult$Description.class
|
||||
app/organicmaps/util/BatteryState.class
|
||||
app/organicmaps/util/DateUtils.class
|
||||
app/organicmaps/util/HttpBackgroundUploader.class
|
||||
app/organicmaps/util/HttpClient$Params.class
|
||||
app/organicmaps/util/HttpClient.class
|
||||
app/organicmaps/util/HttpPayload.class
|
||||
app/organicmaps/util/HttpUploader$Result.class
|
||||
app/organicmaps/util/HttpUploader.class
|
||||
app/organicmaps/util/KeyValue.class
|
||||
app/organicmaps/util/Language.class
|
||||
app/organicmaps/util/log/Logger.class
|
||||
app/organicmaps/util/log/LogsManager.class
|
||||
app/organicmaps/util/NetworkPolicy.class
|
||||
app/organicmaps/util/SecureStorage.class
|
||||
app/organicmaps/util/SharedPropertiesUtils.class
|
||||
app/organicmaps/util/Utils.class
|
||||
app/organicmaps/widget/placepage/PlacePageData.class
|
27
android/app/proguard-mwm.txt
Normal file
|
@ -0,0 +1,27 @@
|
|||
# obfuscate supportV7 menu subclasses. it fixes bug with some Samsung and other devices ROMS based on android 4.2.2.
|
||||
# more details here : https://code.google.com/p/android/issues/detail?id=78377
|
||||
# For some reason, this line disables optimizations and avoids crashes due to missing @Keep attributes.
|
||||
# Looks like R8 keeps EVERYTHING except that unused support lib :)
|
||||
# TODO: Remove this line after properly marking all JNI-called classes and methods with @Keep.
|
||||
# Also remove everything else what is not needed.
|
||||
-keep class !android.support.v7.internal.view.menu.**,** {*;}
|
||||
|
||||
# Enabling shrinking causes
|
||||
# Execution failed for task ':minifyFdroidReleaseWithR8'.
|
||||
# > com.android.tools.r8.CompilationFailedException: Compilation failed to complete
|
||||
# Optimizing leads to crashes like
|
||||
# No pending exception expected: java.lang.ClassNotFoundException: Didn't find class "app.organicmaps.util.HttpClient"
|
||||
# It requires to manually mark all methods and classes called from NDK.
|
||||
-dontoptimize
|
||||
|
||||
-dontwarn com.google.android.material.**
|
||||
-keep class com.google.android.material.** { *; }
|
||||
|
||||
-dontwarn androidx.**
|
||||
-keep class androidx.** { *; }
|
||||
-keep interface androidx.** { *; }
|
||||
|
||||
-dontwarn javax.lang.model.element.Modifier
|
||||
|
||||
# For Guava used by Android Auto
|
||||
-dontwarn java.lang.reflect.AnnotatedType
|
30
android/app/proguard-rules.pro
vendored
|
@ -1,30 +0,0 @@
|
|||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
|
||||
# For Guava used by Android Auto
|
||||
-dontwarn java.lang.reflect.AnnotatedType
|
||||
|
||||
# Disable obfuscation since it is open-source app.
|
||||
-dontobfuscate
|
||||
# R8 crypts the source line numbers in all log messages.
|
||||
# https://github.com/organicmaps/organicmaps/issues/6559#issuecomment-1812039926
|
||||
-dontoptimize
|
|
@ -0,0 +1,28 @@
|
|||
package app.organicmaps;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest
|
||||
{
|
||||
@Test
|
||||
public void useAppContext()
|
||||
{
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
assertEquals("app.organicmaps", appContext.getPackageName());
|
||||
}
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<application android:gwpAsanMode="always" />
|
||||
</manifest>
|
Before Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 7.1 KiB |
Before Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 4.8 KiB |
Before Width: | Height: | Size: 5.5 KiB |
Before Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 8.6 KiB |