Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[build] Use a submodule for mapbox-gl-js rather than an npm dependency #7513

Merged
merged 1 commit into from
Dec 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@
[submodule "platform/ios/uitest/OHHTTPStubs"]
path = platform/ios/uitest/OHHTTPStubs
url = https://github.com/AliSoftware/OHHTTPStubs.git
[submodule "mapbox-gl-js"]
path = mapbox-gl-js
url = git://github.com/mapbox/mapbox-gl-js.git
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ if(NOT EXISTS ".mason/mason.cmake")
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
endif()

if(NOT EXISTS "mapbox-gl-js/package.json")
execute_process(
COMMAND git submodule update --init mapbox-gl-js
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we try using externalproject_add with the GIT_SUBMODULES setting instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't able to get this to work. It looks to me like the GIT_SUBMODULES option is for initializing submodules of the external project, rather than using a submodule as the method to obtain the external project itself.

Copy link
Contributor

@tmpsantos tmpsantos Dec 23, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been playing with externalproject_add for a while on the CMake build I'm maintaining for building Mapbox GL Native 100% offline and for Qt + Windows. On the build file for predownloading all of our dependencies I'm doing something like:

include(ExternalProject)

# Macro for cloning and downloading our header-only dependencies
macro(add_dep package tag git)
    externalproject_add(${package}
        URL https://github.com/${git}/archive/${tag}.zip
        CONFIGURE_COMMAND ""
        BUILD_COMMAND ""
        INSTALL_COMMAND ""
    )

    add_dependencies(mbgl-core ${package})

    externalproject_get_property(${package} SOURCE_DIR)

    target_include_directories(mbgl-core PRIVATE ${SOURCE_DIR}/include)
    target_include_directories(qmapboxgl PRIVATE ${SOURCE_DIR}/include)

    set(${package}_SOURCE_DIR ${SOURCE_DIR})
endmacro()

Two things: It is a lot faster to get the tarball rather then cloning the repo and CMake will try to configure + build + install, but you can override it.

endif()

include(.mason/mason.cmake)

option(WITH_CXX11ABI "Use cxx11abi mason packages" OFF)
Expand Down
2 changes: 1 addition & 1 deletion cmake/shaders.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function(add_shader VAR name)
set(shader_build_cmd ${NodeJS_EXECUTABLE} ${CMAKE_SOURCE_DIR}/scripts/build-shaders.js)
set(shader_file_prefix ${CMAKE_SOURCE_DIR}/node_modules/mapbox-gl/shaders)
set(shader_file_prefix ${CMAKE_SOURCE_DIR}/mapbox-gl-js/shaders)
set(shader_source_prefix ${MBGL_GENERATED}/include/mbgl/shader)

add_custom_command(
Expand Down
1 change: 1 addition & 0 deletions mapbox-gl-js
Submodule mapbox-gl-js added at ef5582
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"ejs": "^2.4.1",
"express": "^4.11.1",
"lodash": "^4.16.4",
"mapbox-gl": "mapbox/mapbox-gl-js#ef5582dd3bc5c15a3112e875ed66494dab8e9d0b",
"mapbox-gl-style-spec": "mapbox/mapbox-gl-style-spec#49e8b407bdbbe6f7c92dbcb56d3d51f425fc2653",
"mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#da53a81453068f4c2b440f9077d6bd5e7e14ff3d",
"mkdirp": "^0.5.1",
Expand Down