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

Improve tvOS build; builds for correct platform, including dependencies. #2778

Closed
wants to merge 12 commits into from
Closed
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
2 changes: 1 addition & 1 deletion .mason
Submodule .mason updated 1 files
+59 −5 mason.sh
35 changes: 35 additions & 0 deletions AppleTV-README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# AppleTV

A first run at getting MapboxGL running on AppleTV.

# Discussion

[This discussion on GitHub](https://github.com/mapbox/mapbox-gl-native/pull/2340) is useful for context.

# Building

To build MapboxGL on a Mac you have to install a few dependencies:

* [xcpretty](https://github.com/supermarin/xcpretty); can be installed with ```sudo gem install xcpretty```.
* [appledoc](https://github.com/tomaz/appledoc); can be installed from homebrew with ```brew install appledoc```. Except it doesn't appear to be in homebrew at the moment, so clone, archive, and copy executable into path.

# Status

* Code that doesn't work on tvOS is disabled using preprocessor conditionals for references that don't compile on tvOS.
* A lot of this related to simplications on the tv. For instance, location doesn't have the concept of speed or heading, because it's a tv.
* asset_request_fs.cpp uses the *nix stat struct to set the modified time on (I assume) asset requests. tvOS doesn't appear to have a mtimespec on this struct, so on tvOS modified is always set to 0. I'm not sure what the implications of this are.
* Build scripts have had tvOS conditions added everywhere I could locate; that part appears to be ok, although the structure may not be optimal.
* Mason has been updated to build tvOS targets; everything builds find without source changes except libuv.
* libuv uses fork and execvp, which are not available on tvOS. Forks of mason and libuv have been made to work around this using preprocessor conditions that just use the error condition, instead of trying to fork.
* I believe iOS would always fail to fork, so this should result in the same thing. libuv being used seems to be old; this fork extends the latest version.
* For some reason I had to add a v to a path in the mason script.sh that didn't seem like it should have been necessary.

# Building

```
make tvpackage
```

Find output in **./build/tvos/pkg/static/**

Or ```make tvpackage sim``` if you only want to build for the simulator, for some reason.
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ xosx: ; $(RUN) HOST=osx HOST_VERSION=x86_64 Xcode/osxapp
run-osx: osx ; @"build/osx-x86_64/$(BUILDTYPE)/Mapbox GL.app/Contents/MacOS/Mapbox GL"
run-xosx: xosx ; @"gyp/build/$(BUILDTYPE)/Mapbox GL.app/Contents/MacOS/Mapbox GL"

.PHONY: Xcode/osx Xcode/ios
.PHONY: Xcode/osx Xcode/ios Xcode/tvos
Xcode/ios: ; $(RUN) HOST=ios Xcode/__project__
Xcode/tvos: ; $(RUN) HOST=tvos Xcode/__project__
Xcode/osx: ; $(RUN) HOST=osx HOST_VERSION=x86_64 Xcode/__project__

.PHONY: xproj iproj
Expand All @@ -48,10 +49,15 @@ isim: ; $(RUN) HOST=ios Xcode/iosapp
ibench: export XCODEBUILD_ARGS += -sdk iphoneos ARCHS="arm64"
ibench: ; $(RUN) HOST=ios Xcode/ios-bench

.PHONY: ipackage ipackage-strip ipackage-sim itest
.PHONY: ipackage ipackage-strip ipackage-sim tvpackage itest
ipackage: Xcode/ios ; @JOBS=$(JOBS) ./scripts/ios/package.sh
ipackage-strip: Xcode/ios ; @JOBS=$(JOBS) ./scripts/ios/package.sh strip
ipackage-sim: Xcode/ios ; @JOBS=$(JOBS) ./scripts/ios/package.sh sim

tvpackage: Xcode/tvos ; JOBS=$(JOBS) ./scripts/tvos/package.sh
tvpackage-strip: Xcode/tvos ; JOBS=$(JOBS) ./scripts/tvos/package.sh strip
tvpackage-sim: Xcode/tvos ; JOBS=$(JOBS) ./scripts/tvos/package.sh sim

itest: ipackage-sim ; ./scripts/ios/test.sh
endif

Expand Down
17 changes: 17 additions & 0 deletions gyp/common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,23 @@
},
},
}],
['host == "tvos"', {
'xcode_settings': {
'SDKROOT': 'appletvos',
'SUPPORTED_PLATFORMS': 'appletvsimulator appletvos',
'IPHONEOS_DEPLOYMENT_TARGET': '9.0',
'TARGETED_DEVICE_FAMILY': '1',
'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0',
'CODE_SIGN_IDENTITY': 'iPhone Developer',
},
'configurations': {
'Release': {
'xcode_settings': {
'ARCHS': [ "arm64", "x86_64" ],
},
},
},
}],
],
}],
],
Expand Down
1 change: 0 additions & 1 deletion gyp/platform-ios.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
],
'ldflags': [
'-framework CoreLocation',
'-framework CoreTelephony',
'-framework GLKit',
'-framework ImageIO',
'-framework MobileCoreServices',
Expand Down
115 changes: 115 additions & 0 deletions gyp/platform-tvos.gypi
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
{
'targets': [
{ 'target_name': 'platform-tvos',
'product_name': 'mbgl-platform-tvos',
'type': 'static_library',
'standalone_static_library': 1,
'hard_dependency': 1,
'dependencies': [
'version',
],

'sources': [
'../platform/darwin/log_nslog.mm',
'../platform/darwin/string_nsstring.mm',
'../platform/darwin/application_root.mm',
'../platform/darwin/asset_root.mm',
'../platform/darwin/image.mm',
'../platform/darwin/nsthread.mm',
'../platform/darwin/reachability.m',
'../include/mbgl/ios/Mapbox.h',
'../platform/ios/MGLMapboxEvents.h',
'../platform/ios/MGLMapboxEvents.m',
'../include/mbgl/ios/MGLMapCamera.h',
'../platform/ios/MGLMapCamera.mm',
'../include/mbgl/ios/MGLMapView.h',
'../include/mbgl/ios/MGLMapView+IBAdditions.h',
'../platform/ios/MGLMapView.mm',
'../platform/ios/MGLFileCache.h',
'../platform/ios/MGLFileCache.mm',
'../include/mbgl/ios/MGLAccountManager.h',
'../platform/ios/MGLAccountManager_Private.h',
'../platform/ios/MGLAccountManager.m',
'../include/mbgl/ios/MGLAnnotation.h',
'../include/mbgl/ios/MGLUserLocation.h',
'../platform/ios/MGLUserLocation_Private.h',
'../platform/ios/MGLUserLocation.m',
'../platform/ios/MGLUserLocationAnnotationView.h',
'../platform/ios/MGLUserLocationAnnotationView.m',
'../include/mbgl/ios/MGLTypes.h',
'../platform/ios/MGLTypes.m',
'../include/mbgl/ios/MGLGeometry.h',
'../platform/ios/MGLGeometry.m',
'../include/mbgl/ios/MGLMultiPoint.h',
'../platform/ios/MGLMultiPoint_Private.h',
'../platform/ios/MGLMultiPoint.mm',
'../include/mbgl/ios/MGLOverlay.h',
'../include/mbgl/ios/MGLPointAnnotation.h',
'../platform/ios/MGLPointAnnotation.m',
'../include/mbgl/ios/MGLPolyline.h',
'../platform/ios/MGLPolyline.m',
'../include/mbgl/ios/MGLPolygon.h',
'../platform/ios/MGLPolygon.m',
'../include/mbgl/ios/MGLShape.h',
'../platform/ios/MGLShape.m',
'../include/mbgl/ios/MGLAnnotationImage.h',
'../platform/ios/MGLAnnotationImage.m',
'../platform/ios/NSBundle+MGLAdditions.h',
'../platform/ios/NSBundle+MGLAdditions.m',
'../platform/ios/NSException+MGLAdditions.h',
'../platform/ios/NSProcessInfo+MGLAdditions.h',
'../platform/ios/NSProcessInfo+MGLAdditions.m',
'../platform/ios/NSString+MGLAdditions.h',
'../platform/ios/NSString+MGLAdditions.m',
'../platform/ios/vendor/SMCalloutView/SMCalloutView.h',
'../platform/ios/vendor/SMCalloutView/SMCalloutView.m',
'../platform/ios/resources/',
],

'variables': {
'cflags_cc': [
'<@(libuv_cflags)',
'<@(boost_cflags)',
],
'libraries': [
'<@(libuv_static_libs)',
],
'ldflags': [
'-framework CoreLocation',
'-framework GLKit',
'-framework ImageIO',
'-framework MobileCoreServices',
'-framework QuartzCore',
'-framework SystemConfiguration',
'-ObjC',
],
},

'include_dirs': [
'../include',
],

'xcode_settings': {
'OTHER_CPLUSPLUSFLAGS': [ '<@(cflags_cc)' ],
'CLANG_ENABLE_OBJC_ARC': 'YES',
'CLANG_ENABLE_MODULES': 'YES',
},

'link_settings': {
'libraries': [ '<@(libraries)' ],
'xcode_settings': {
'OTHER_LDFLAGS': [ '<@(ldflags)' ],
},
},

'direct_dependent_settings': {
'include_dirs': [
'../include',
],
'mac_bundle_resources': [
'<!@(find ./platform/ios/resources -type f \! -name "README")',
],
},
},
],
}
6 changes: 6 additions & 0 deletions gyp/tvos.gyp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
'includes': [
'../tvos/app/mapboxgl-app.gypi',
'../tvos/benchmark/benchmark-tvos.gypi',
],
}
2 changes: 1 addition & 1 deletion include/mbgl/ios/MGLUserLocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ NS_ASSUME_NONNULL_BEGIN
/** The heading of the user location. (read-only)
*
* This property is `nil` if the user location tracking mode is not `MGLUserTrackingModeFollowWithHeading`. */
#if !__TVOS_9_0
#if !TARGET_OS_TV
@property (nonatomic, readonly, nullable) CLHeading *heading;
#endif

Expand Down
3 changes: 2 additions & 1 deletion mbgl.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
['headless_lib == "glx" and host == "linux"', { 'includes': [ './gyp/headless-glx.gypi' ] } ],
['platform_lib == "osx" and host == "osx"', { 'includes': [ './gyp/platform-osx.gypi' ] } ],
['platform_lib == "ios" and host == "ios"', { 'includes': [ './gyp/platform-ios.gypi' ] } ],
['platform_lib == "tvos" and host == "tvos"', { 'includes': [ './gyp/platform-tvos.gypi' ] } ],
['platform_lib == "linux"', { 'includes': [ './gyp/platform-linux.gypi' ] } ],
['platform_lib == "android" and host == "android"', { 'includes': [ './gyp/platform-android.gypi' ] } ],
['http_lib == "curl"', { 'includes': [ './gyp/http-curl.gypi' ] } ],
['http_lib == "nsurl" and (host == "osx" or host == "ios")', { 'includes': [ './gyp/http-nsurl.gypi' ] } ],
['http_lib == "nsurl" and (host == "osx" or host == "ios" or host == "tvos")', { 'includes': [ './gyp/http-nsurl.gypi' ] } ],
['http_lib == "android" and host == "android"', { 'includes': [ './gyp/http-android.gypi' ] } ],
['asset_lib == "fs"', { 'includes': [ './gyp/asset-fs.gypi' ] } ],
['asset_lib == "zip"', { 'includes': [ './gyp/asset-zip.gypi' ] } ],
Expand Down
4 changes: 4 additions & 0 deletions platform/default/asset_request_fs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,14 @@ void AssetRequest::fileStated(uv_fs_t *req) {
uv_fs_close(req->loop, req, self->fd, fileClosed);
} else {
self->response = std::make_unique<Response>();
#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
#ifdef __APPLE__
self->response->modified = stat->st_mtimespec.tv_sec;
#else
self->response->modified = stat->st_mtime;
#endif
#else
self->response->modified = stat->st_mtim.tv_sec;
#endif
self->response->etag = util::toString(stat->st_ino);
const auto size = (unsigned int)(stat->st_size);
Expand Down
Loading