Skip to content

Commit

Permalink
Squashed Rust impl
Browse files Browse the repository at this point in the history
  • Loading branch information
nyurik committed Jul 25, 2024
1 parent 1dafc39 commit 50205f2
Show file tree
Hide file tree
Showing 20 changed files with 265 additions and 518 deletions.
1 change: 0 additions & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ cc_library(
":mbgl-core-generated-private-artifacts",
":mbgl-core-generated-public-artifacts",
"//vendor:boost",
"//vendor:csscolorparser",
"//vendor:earcut.hpp",
"//vendor:eternal",
"//vendor:mapbox-base",
Expand Down
23 changes: 18 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1333,7 +1333,6 @@ target_include_directories(
)

include(${PROJECT_SOURCE_DIR}/vendor/boost.cmake)
include(${PROJECT_SOURCE_DIR}/vendor/csscolorparser.cmake)
include(${PROJECT_SOURCE_DIR}/vendor/earcut.hpp.cmake)
include(${PROJECT_SOURCE_DIR}/vendor/eternal.cmake)
include(${PROJECT_SOURCE_DIR}/vendor/mapbox-base.cmake)
Expand All @@ -1355,6 +1354,19 @@ set_target_properties(
INTERFACE_MAPBOX_LICENSE ${PROJECT_SOURCE_DIR}/vendor/unordered_dense/LICENSE
)

include(FetchContent)
FetchContent_Declare(
Corrosion
GIT_REPOSITORY https://github.com/corrosion-rs/corrosion.git
GIT_TAG v0.5
)
FetchContent_MakeAvailable(Corrosion)

corrosion_import_crate(MANIFEST_PATH rustutils/Cargo.toml)

# rustutils_headers is a set of .h headers generated from rustutils crate
corrosion_add_cxxbridge(rustutils_headers CRATE rustutils FILES lib.rs)

target_link_libraries(
mbgl-core
PRIVATE
Expand All @@ -1365,7 +1377,6 @@ target_link_libraries(
Mapbox::Base::cheap-ruler-cpp
mbgl-compiler-options
mbgl-vendor-boost
mbgl-vendor-csscolorparser
mbgl-vendor-earcut.hpp
mbgl-vendor-eternal
mbgl-vendor-parsedate
Expand All @@ -1374,6 +1385,7 @@ target_link_libraries(
mbgl-vendor-unique_resource
mbgl-vendor-vector-tile
mbgl-vendor-wagyu
rustutils_headers
PUBLIC
Mapbox::Base
Mapbox::Base::Extras::expected-lite
Expand All @@ -1383,11 +1395,13 @@ target_link_libraries(
Mapbox::Base::variant
TracyClient
unordered_dense
rustutils
)

export(TARGETS
rustutils_headers
mbgl-core

rustutils
mapbox-base
mapbox-base-cheap-ruler-cpp
mapbox-base-extras-expected-lite
Expand All @@ -1403,7 +1417,6 @@ export(TARGETS
mapbox-base-variant
mbgl-compiler-options
mbgl-vendor-boost
mbgl-vendor-csscolorparser
mbgl-vendor-earcut.hpp
mbgl-vendor-eternal
mbgl-vendor-parsedate
Expand Down Expand Up @@ -1437,7 +1450,7 @@ if(MLN_WITH_CORE_ONLY)
return()
endif()

include(${PROJECT_SOURCE_DIR}/scripts/license.cmake)
#include(${PROJECT_SOURCE_DIR}/scripts/license.cmake)

if(MLN_WITH_QT)
include(${PROJECT_SOURCE_DIR}/platform/qt/qt.cmake)
Expand Down
29 changes: 0 additions & 29 deletions LICENSES.core.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,34 +178,6 @@ DEALINGS IN THE SOFTWARE.

---

### [csscolorparser](https://github.com/mapbox/css-color-parser-cpp) by Dean McNamee and Konstantin Käfer

```
(c) Dean McNamee <[email protected]>, 2012.
(c) Konstantin Käfer <[email protected]>, 2014.
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.
```

---

### [earcut.hpp](https://github.com/mapbox/earcut.hpp) by Mapbox

```
Expand Down Expand Up @@ -633,4 +605,3 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
```

---

4 changes: 4 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,9 @@ RUN chmod +x /usr/local/bin/startup.sh
# This allows users to `docker run` without specifying -u and -g
USER $USERNAME

ENV RUSTUP_HOME=/home/$USERNAME/.cache/.rustup \
CARGO_HOME=/home/$USERNAME/.cache/.cargo \
PATH=/home/$USERNAME/.cache/.cargo/bin:$PATH

ENTRYPOINT ["/usr/local/bin/startup.sh"]
CMD ["bash"]
15 changes: 15 additions & 0 deletions docker/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,19 @@ if [ ! -d /app/.github ] || [ ! -d /home/user/.cache ]; then
exit 1
fi


if [ ! -f "$CARGO_HOME/env" ]; then
echo "Downloading and installing Rust..."
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal
fi
. "$CARGO_HOME/env"



if ! command -v cxxbridge > /dev/null; then
echo "Installing cxxbridge..."
cargo install cxxbridge-cmd
fi


exec "$@"
29 changes: 0 additions & 29 deletions platform/android/LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -456,34 +456,6 @@ DEALINGS IN THE SOFTWARE.

---

### [csscolorparser](https://github.com/mapbox/css-color-parser-cpp) by Dean McNamee and Konstantin Käfer

```
(c) Dean McNamee <[email protected]>, 2012.
(c) Konstantin Käfer <[email protected]>, 2014.
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.
```

---

### [earcut.hpp](https://github.com/mapbox/earcut.hpp) by Mapbox

```
Expand Down Expand Up @@ -942,4 +914,3 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
```

---

1 change: 0 additions & 1 deletion platform/android/android.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ include(${PROJECT_SOURCE_DIR}/vendor/icu.cmake)
include(${PROJECT_SOURCE_DIR}/vendor/sqlite.cmake)

# cmake-format: off
target_compile_options(mbgl-vendor-csscolorparser PRIVATE $<$<CONFIG:Release>:-Oz> $<$<CONFIG:Release>:-Qunused-arguments> $<$<CONFIG:Release>:-flto>)
target_compile_options(mbgl-vendor-icu PRIVATE $<$<CONFIG:Release>:-Oz> $<$<CONFIG:Release>:-Qunused-arguments> $<$<CONFIG:Release>:-flto>)
target_compile_options(mbgl-vendor-parsedate PRIVATE $<$<CONFIG:Release>:-Oz> $<$<CONFIG:Release>:-Qunused-arguments> $<$<CONFIG:Release>:-flto>)
target_compile_options(mbgl-vendor-sqlite PRIVATE $<$<CONFIG:Release>:-Oz> $<$<CONFIG:Release>:-Qunused-arguments> $<$<CONFIG:Release>:-flto>)
Expand Down
30 changes: 1 addition & 29 deletions platform/ios/LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -1026,34 +1026,6 @@ DEALINGS IN THE SOFTWARE.

---

### [csscolorparser](https://github.com/mapbox/css-color-parser-cpp) by Dean McNamee and Konstantin Käfer

```
(c) Dean McNamee <[email protected]>, 2012.
(c) Konstantin Käfer <[email protected]>, 2014.
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.
```

---

### [earcut.hpp](https://github.com/mapbox/earcut.hpp) by Mapbox

```
Expand Down Expand Up @@ -1687,4 +1659,4 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```
```
3 changes: 3 additions & 0 deletions platform/linux/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ cd maplibre-native
# Install build tools
apt install build-essential clang cmake ccache ninja-build pkg-config

# Install rust toolchain (default options should be sufficient)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# Install system dependencies
apt install libcurl4-openssl-dev libglfw3-dev libuv1-dev libpng-dev libicu-dev libjpeg-turbo8-dev libwebp-dev xvfb
```
Expand Down
2 changes: 0 additions & 2 deletions platform/qt/qt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ target_link_libraries(
PUBLIC
$<BUILD_INTERFACE:mbgl-vendor-parsedate>
$<BUILD_INTERFACE:mbgl-vendor-nunicode>
$<BUILD_INTERFACE:mbgl-vendor-csscolorparser>
$<$<NOT:$<OR:$<PLATFORM_ID:Windows>,$<PLATFORM_ID:Emscripten>>>:z>
$<IF:$<BOOL:${MLN_QT_WITH_INTERNAL_SQLITE}>,$<BUILD_INTERFACE:mbgl-vendor-sqlite>,Qt${QT_VERSION_MAJOR}::Sql>
PRIVATE
Expand All @@ -162,7 +161,6 @@ if(MLN_QT_HAS_PARENT)
set(MLN_QT_VENDOR_LIBRARIES
mbgl-vendor-parsedate
mbgl-vendor-nunicode
mbgl-vendor-csscolorparser
$<$<BOOL:${MLN_QT_WITH_INTERNAL_SQLITE}>:$<BUILD_INTERFACE:mbgl-vendor-sqlite>>
$<$<AND:$<PLATFORM_ID:Linux>,$<BOOL:${MLN_QT_WITH_INTERNAL_ICU}>>:$<BUILD_INTERFACE:mbgl-vendor-icu>>
PARENT_SCOPE
Expand Down
1 change: 1 addition & 0 deletions rustutils/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
Loading

0 comments on commit 50205f2

Please sign in to comment.