From 9acdd75d04f335313a6c491599b5c7559d6458c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Fri, 14 Dec 2018 15:53:13 +0100 Subject: [build] add a Buck build and BUCK file for Android --- .gitignore | 2 + circle.yml | 21 ++++ misc/buck/.buckconfig | 8 ++ misc/buck/mapbox-gl-native/Android.mk | 4 + misc/buck/mapbox-gl-native/Application.mk | 2 + misc/buck/mapbox-gl-native/BUCK | 198 ++++++++++++++++++++++++++++++ misc/buck/mapbox-gl-native/cmake | 1 + misc/buck/mapbox-gl-native/include | 1 + misc/buck/mapbox-gl-native/platform | 1 + misc/buck/mapbox-gl-native/src | 1 + misc/buck/mapbox-gl-native/vendor | 1 + 11 files changed, 240 insertions(+) create mode 100644 misc/buck/.buckconfig create mode 100644 misc/buck/mapbox-gl-native/Android.mk create mode 100644 misc/buck/mapbox-gl-native/Application.mk create mode 100644 misc/buck/mapbox-gl-native/BUCK create mode 120000 misc/buck/mapbox-gl-native/cmake create mode 120000 misc/buck/mapbox-gl-native/include create mode 120000 misc/buck/mapbox-gl-native/platform create mode 120000 misc/buck/mapbox-gl-native/src create mode 120000 misc/buck/mapbox-gl-native/vendor diff --git a/.gitignore b/.gitignore index 5fae2ae5eb..127cb1171b 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,8 @@ test/fixtures/api/assets.zip test/fixtures/storage/assets.zip /.circle-week /vendor/.cache +buck-out +.buckd # Visual Studio Code .vscode diff --git a/circle.yml b/circle.yml index 95bcc8dc78..b1cb4eed11 100644 --- a/circle.yml +++ b/circle.yml @@ -9,6 +9,7 @@ workflows: filters: branches: ignore: master + - android-debug-arm-v7-buck - android-arm-v7-template: name: android-debug-arm-v7 - android-arm-v7-template: @@ -650,6 +651,26 @@ jobs: if [[ $CIRCLE_BRANCH == master ]] || [[ $CIRCLE_BRANCH == release-* ]] || [[ $CIRCLE_TAG == android-v* ]]; then make run-android-upload-archives fi +# ------------------------------------------------------------------------------ + android-debug-arm-v7-buck: + docker: + - image: mbgl/android-ndk-r17c-buck:07c5ef2e71 + working_directory: /src + environment: + LIBSYSCONFCPUS: 2 + JOBS: 2 + BUILDTYPE: Debug + ANDROID_NDK: /android/sdk/ndk-bundle + steps: + - checkout + - run: + name: Checkout submodules + command: git submodule update --init + - run: + name: Build Android library + command: | + cd misc/buck + buck build mapbox-gl-native:android-core # ------------------------------------------------------------------------------ node-clang39-release: diff --git a/misc/buck/.buckconfig b/misc/buck/.buckconfig new file mode 100644 index 0000000000..48028a9adb --- /dev/null +++ b/misc/buck/.buckconfig @@ -0,0 +1,8 @@ +[ndk] +cpu_abis = armv7 +compiler = clang +app_platform = android-14 + +[project] +ignore = .git +allow_symlinks = allow diff --git a/misc/buck/mapbox-gl-native/Android.mk b/misc/buck/mapbox-gl-native/Android.mk new file mode 100644 index 0000000000..ba1e2dd708 --- /dev/null +++ b/misc/buck/mapbox-gl-native/Android.mk @@ -0,0 +1,4 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) +LOCAL_MODULE := android-core +include $(BUILD_SHARED_LIBRARY) diff --git a/misc/buck/mapbox-gl-native/Application.mk b/misc/buck/mapbox-gl-native/Application.mk new file mode 100644 index 0000000000..a11b28debc --- /dev/null +++ b/misc/buck/mapbox-gl-native/Application.mk @@ -0,0 +1,2 @@ +APP_ABI := armeabi-v7a +APP_PLATFORM := android-14 diff --git a/misc/buck/mapbox-gl-native/BUCK b/misc/buck/mapbox-gl-native/BUCK new file mode 100644 index 0000000000..199cd1b210 --- /dev/null +++ b/misc/buck/mapbox-gl-native/BUCK @@ -0,0 +1,198 @@ +# BUILD FILE SYNTAX: SKYLARK +import re + +mbgl_search_prefixes = [ + r'^include/', + r'^src/', + r'^platform/default/include/', + r'^platform/darwin/src/', + r'^platform/darwin/include/', + r'^platform/ios/src/', + r'^platform/linux/src/', + r'^platform/android/src/', + r'^platform/android/', + r'^platform/ios/vendor/mapbox-events-ios/vendor/TrustKit/Pinning/', + r'^platform/ios/vendor/mapbox-events-ios/vendor/TrustKit/Reporting/', + r'^platform/ios/vendor/mapbox-events-ios/vendor/TrustKit/', + r'^platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/Reachability/', + r'^platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/', + r'^platform/ios/vendor/SMCalloutView/', +] + +def mbgl_header_path(filename): + for prefix in mbgl_search_prefixes: + if re.search(prefix, filename): + return re.sub(prefix, '', filename) + return filename + +mbgl_is_header = re.compile(r'\.h(pp)?$') +mbgl_is_public = re.compile(r'^(include/|^[^/]+\.h(pp)?$)') + +def mbgl_load_file_list(filename, prefix = ''): + add_build_file_dep('//' + filename) + files = filter(len, [ re.sub(r'#.*|\n', '', file).strip() for file in open(filename) ]) + headers = [ file for file in files if mbgl_is_header.search(file) ] + + return dict( + public_headers = [ (mbgl_header_path(file), prefix + file) + for file in headers if mbgl_is_public.search(file) ], + private_headers = [ (mbgl_header_path(file), prefix + file) + for file in headers if not mbgl_is_public.search(file) ], + sources = [ prefix + file for file in files if not mbgl_is_header.search(file) ], + ) + +def mbgl_merge_file_lists(*argv): + merged = dict(public_headers = [], private_headers = [], sources = []) + for arg in argv: + merged['public_headers'] += arg['public_headers'] + merged['private_headers'] += arg['private_headers'] + merged['sources'] += arg['sources'] + return merged + +base_path = get_base_path() or '.'; + +mbgl = dict( + core = mbgl_merge_file_lists(mbgl_load_file_list(base_path + '/cmake/core-files.txt'), + mbgl_load_file_list(base_path + '/cmake/filesource-files.txt')), + android = mbgl_merge_file_lists(mbgl_load_file_list(base_path + '/platform/android/core-files.txt'), + mbgl_load_file_list(base_path + '/platform/android/filesource-files.txt')), + ios = mbgl_merge_file_lists(mbgl_load_file_list(base_path + '/platform/ios/core-files.txt'), + mbgl_load_file_list(base_path + '/platform/ios/sdk-files.txt')), + deps = [], +) + +def mbgl_vendor_library(name): + files = mbgl_load_file_list(base_path + '/vendor/' + name + '-files.txt', prefix = 'vendor/' + name + '/') + cxx_library( + name = "vendor-" + name, + header_namespace = "", + srcs = files['sources'], + headers = dict(files['private_headers']), + exported_headers = dict(files['public_headers']), + link_style = 'static', + compiler_flags = [ + "-Wno-tautological-unsigned-enum-zero-compare", + ], + ) + mbgl['deps'].append(':vendor-' + name) + +mbgl_vendor_library("icu") +mbgl_vendor_library("boost") +mbgl_vendor_library("cheap-ruler-cpp") +mbgl_vendor_library("earcut.hpp") +mbgl_vendor_library("expected") +mbgl_vendor_library("eternal") +mbgl_vendor_library("geojson.hpp") +mbgl_vendor_library("geojson-vt-cpp") +mbgl_vendor_library("geometry.hpp") +mbgl_vendor_library("jni.hpp") +mbgl_vendor_library("kdbush.hpp") +mbgl_vendor_library("sqlite") +mbgl_vendor_library("pixelmatch-cpp") +mbgl_vendor_library("polylabel") +mbgl_vendor_library("protozero") +mbgl_vendor_library("rapidjson") +mbgl_vendor_library("shelf-pack-cpp") +mbgl_vendor_library("supercluster.hpp") +mbgl_vendor_library("unique_resource") +mbgl_vendor_library("variant") +mbgl_vendor_library("vector-tile") +mbgl_vendor_library("wagyu") + +cxx_library( + name = "core", + + srcs = mbgl['core']['sources'], + platform_srcs = [ + ("android", mbgl['android']['sources'] + [ 'platform/android/src/main.cpp' ]) + ], + + header_namespace = "", + headers = dict(mbgl['core']['private_headers']), + exported_headers = dict(mbgl['core']['public_headers']), + platform_headers = [ + ("android", dict(mbgl['android']['private_headers'])) + ], + exported_platform_headers = [ + ("android", dict(mbgl['android']['public_headers'])), + ], + + compiler_flags = [ + "-std=c++14", + "-g", + "-Wall", + "-Wextra", + "-Werror", + "-Wno-unused-variable", + "-Wno-unused-parameter", + "-Wno-c++11-narrowing", + "-Wno-tautological-constant-compare", + "-fexceptions", + "-ftemplate-depth=1024", + "-frtti", + ], + + preprocessor_flags = [ + "-DMBGL_USE_GLES2=1", + "-DMBGL_VERSION_REV=\"standalone\"", + "-DRAPIDJSON_HAS_STDSTRING=1", + ], + exported_platform_linker_flags = [ + ("android", [ + "-lz", + "-lEGL", + "-lGLESv2", + "-landroid", + "-ljnigraphics", + "-llog", + "-fvisibility=hidden", + "-Wl,--icf=safe", + "-Wl,--version-script=" + base_path + "/platform/android/version-script" + ]), + ], + + visibility = ["PUBLIC"], + deps = mbgl['deps'], + soname = "libmapbox-gl.$(ext)", +) + +ndk_library( + name = "android-core", + deps = [ ":core" ], + flags = [ + "NDK_APPLICATION_MK=$(env PWD)/" + get_base_path() + "/Application.mk", + ], +) + +android_manifest( + name = 'android-manifest', + skeleton = 'platform/android/MapboxGLAndroidSDK/src/main/AndroidManifest.xml', +) + +android_library( + name = "android", + deps = [ ":android-core" ], + manifest = ":android-manifest", +) + +apple_library( + name = "ios-core", + deps = [ ":core" ], + headers = dict(mbgl['ios']['private_headers'] + [('Mapbox/Mapbox.h', 'platform/ios/src/Mapbox.h')]), + exported_headers = dict(mbgl['ios']['public_headers']), + srcs = mbgl['ios']['sources'], + lang_compiler_flags = { + "OBJCXX_CPP_OUTPUT": [ + "-std=c++14", + "-fmodules", + "-fobjc-arc", + ], + "OBJC_CPP_OUTPUT": [ + "-fmodules", + "-fobjc-arc", + ], + "CXX_CPP_OUTPUT": [ + "-std=c++14", + ] + }, +) diff --git a/misc/buck/mapbox-gl-native/cmake b/misc/buck/mapbox-gl-native/cmake new file mode 120000 index 0000000000..0881531144 --- /dev/null +++ b/misc/buck/mapbox-gl-native/cmake @@ -0,0 +1 @@ +../../../cmake \ No newline at end of file diff --git a/misc/buck/mapbox-gl-native/include b/misc/buck/mapbox-gl-native/include new file mode 120000 index 0000000000..8a5dba6c4b --- /dev/null +++ b/misc/buck/mapbox-gl-native/include @@ -0,0 +1 @@ +../../../include \ No newline at end of file diff --git a/misc/buck/mapbox-gl-native/platform b/misc/buck/mapbox-gl-native/platform new file mode 120000 index 0000000000..d99dc6bc34 --- /dev/null +++ b/misc/buck/mapbox-gl-native/platform @@ -0,0 +1 @@ +../../../platform \ No newline at end of file diff --git a/misc/buck/mapbox-gl-native/src b/misc/buck/mapbox-gl-native/src new file mode 120000 index 0000000000..dabb0e15a9 --- /dev/null +++ b/misc/buck/mapbox-gl-native/src @@ -0,0 +1 @@ +../../../src \ No newline at end of file diff --git a/misc/buck/mapbox-gl-native/vendor b/misc/buck/mapbox-gl-native/vendor new file mode 120000 index 0000000000..c73e2c9ac0 --- /dev/null +++ b/misc/buck/mapbox-gl-native/vendor @@ -0,0 +1 @@ +../../../vendor \ No newline at end of file -- cgit v1.2.1