Skip to content

Commit 670655b

Browse files
authored
Merge pull request #91 from jhen0409/add-tvos-target
Add tvOS build target
2 parents cf61bb6 + 655ccd2 commit 670655b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+7416
-1801
lines changed

examples/SimpleExample/.babelrc

Lines changed: 0 additions & 3 deletions
This file was deleted.

examples/SimpleExample/.flowconfig

Lines changed: 43 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,50 +5,71 @@
55
; Ignore "BUCK" generated dirs
66
<PROJECT_ROOT>/\.buckd/
77

8-
; Ignore unexpected extra "@providesModule"
9-
.*/node_modules/.*/node_modules/fbjs/.*
8+
; Ignore polyfills
9+
node_modules/react-native/Libraries/polyfills/.*
1010

11-
; Ignore duplicate module providers
12-
; For RN Apps installed via npm, "Libraries" folder is inside
13-
; "node_modules/react-native" but in the source repo it is in the root
14-
.*/Libraries/react-native/React.js
11+
; These should not be required directly
12+
; require from fbjs/lib instead: require('fbjs/lib/warning')
13+
node_modules/warning/.*
1514

16-
; Ignore polyfills
17-
.*/Libraries/polyfills/.*
15+
; Flow doesn't support platforms
16+
.*/Libraries/Utilities/LoadingView.js
1817

19-
; Ignore metro
20-
.*/node_modules/metro/.*
18+
[untyped]
19+
.*/node_modules/@react-native-community/cli/.*/.*
2120

2221
[include]
2322

2423
[libs]
2524
node_modules/react-native/Libraries/react-native/react-native-interface.js
2625
node_modules/react-native/flow/
27-
node_modules/react-native/flow-github/
2826

2927
[options]
3028
emoji=true
3129

32-
module.system=haste
33-
34-
munge_underscores=true
35-
36-
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
30+
esproposal.optional_chaining=enable
31+
esproposal.nullish_coalescing=enable
3732

3833
module.file_ext=.js
39-
module.file_ext=.jsx
4034
module.file_ext=.json
41-
module.file_ext=.native.js
35+
module.file_ext=.ios.js
36+
37+
munge_underscores=true
38+
39+
module.name_mapper='^react-native$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/react-native/react-native-implementation'
40+
module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/node_modules/react-native/\1'
41+
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/Image/RelativeImageStub'
4242

4343
suppress_type=$FlowIssue
4444
suppress_type=$FlowFixMe
4545
suppress_type=$FlowFixMeProps
4646
suppress_type=$FlowFixMeState
4747

48-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
49-
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
50-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
48+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)
49+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+
5150
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
5251

52+
[lints]
53+
sketchy-null-number=warn
54+
sketchy-null-mixed=warn
55+
sketchy-number=warn
56+
untyped-type-import=warn
57+
nonstrict-import=warn
58+
deprecated-type=warn
59+
unsafe-getters-setters=warn
60+
inexact-spread=warn
61+
unnecessary-invariant=warn
62+
signature-verification-failure=warn
63+
deprecated-utility=error
64+
65+
[strict]
66+
deprecated-type
67+
nonstrict-import
68+
sketchy-null
69+
unclear-type
70+
unsafe-getters-setters
71+
untyped-import
72+
untyped-type-import
73+
5374
[version]
54-
^0.67.0
75+
^0.105.0

examples/SimpleExample/.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ DerivedData
2020
*.hmap
2121
*.ipa
2222
*.xcuserstate
23-
project.xcworkspace
2423

2524
# Android/IntelliJ
2625
#
@@ -40,6 +39,7 @@ yarn-error.log
4039
buck-out/
4140
\.buckd/
4241
*.keystore
42+
!debug.keystore
4343

4444
# fastlane
4545
#
@@ -54,3 +54,6 @@ buck-out/
5454

5555
# Bundle artifact
5656
*.jsbundle
57+
58+
# CocoaPods
59+
/ios/Pods/
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
bracketSpacing: false,
3+
jsxBracketSameLine: true,
4+
singleQuote: true,
5+
trailingComma: 'all',
6+
};

examples/SimpleExample/App.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
View
77
} from 'react-native';
88
import { Thread } from 'react-native-threads';
9+
import './config';
910

1011
export default class App extends Component {
1112
state = { messages: [] }

examples/SimpleExample/README.md

Lines changed: 0 additions & 53 deletions
This file was deleted.

examples/SimpleExample/android/app/BUCK

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,13 @@
88
# - `buck install -r android/app` - compile, install and run application
99
#
1010

11+
load(":build_defs.bzl", "create_aar_targets", "create_jar_targets")
12+
1113
lib_deps = []
1214

13-
for jarfile in glob(['libs/*.jar']):
14-
name = 'jars__' + jarfile[jarfile.rindex('/') + 1: jarfile.rindex('.jar')]
15-
lib_deps.append(':' + name)
16-
prebuilt_jar(
17-
name = name,
18-
binary_jar = jarfile,
19-
)
15+
create_aar_targets(glob(["libs/*.aar"]))
2016

21-
for aarfile in glob(['libs/*.aar']):
22-
name = 'aars__' + aarfile[aarfile.rindex('/') + 1: aarfile.rindex('.aar')]
23-
lib_deps.append(':' + name)
24-
android_prebuilt_aar(
25-
name = name,
26-
aar = aarfile,
27-
)
17+
create_jar_targets(glob(["libs/*.jar"]))
2818

2919
android_library(
3020
name = "all-libs",

examples/SimpleExample/android/app/build.gradle

Lines changed: 66 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ import com.android.build.OutputFile
1818
* // the entry file for bundle generation
1919
* entryFile: "index.android.js",
2020
*
21+
* // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format
22+
* bundleCommand: "ram-bundle",
23+
*
2124
* // whether to bundle JS and assets in debug mode
2225
* bundleInDebug: false,
2326
*
@@ -73,7 +76,8 @@ import com.android.build.OutputFile
7376
*/
7477

7578
project.ext.react = [
76-
entryFile: "index.js"
79+
entryFile: "index.js",
80+
enableHermes: false, // clean and rebuild if changing
7781
]
7882

7983
apply from: "../../node_modules/react-native/react.gradle"
@@ -93,65 +97,99 @@ def enableSeparateBuildPerCPUArchitecture = false
9397
*/
9498
def enableProguardInReleaseBuilds = false
9599

100+
/**
101+
* The preferred build flavor of JavaScriptCore.
102+
*
103+
* For example, to use the international variant, you can use:
104+
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
105+
*
106+
* The international variant includes ICU i18n library and necessary data
107+
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
108+
* give correct results when using with locales other than en-US. Note that
109+
* this variant is about 6MiB larger per architecture than default.
110+
*/
111+
def jscFlavor = 'org.webkit:android-jsc:+'
112+
113+
/**
114+
* Whether to enable the Hermes VM.
115+
*
116+
* This should be set on project.ext.react and mirrored here. If it is not set
117+
* on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
118+
* and the benefits of using Hermes will therefore be sharply reduced.
119+
*/
120+
def enableHermes = project.ext.react.get("enableHermes", false);
121+
96122
android {
97-
compileSdkVersion 23
98-
buildToolsVersion "23.0.1"
123+
compileSdkVersion rootProject.ext.compileSdkVersion
124+
125+
compileOptions {
126+
sourceCompatibility JavaVersion.VERSION_1_8
127+
targetCompatibility JavaVersion.VERSION_1_8
128+
}
99129

100130
defaultConfig {
101131
applicationId "com.simpleexample"
102-
minSdkVersion 16
103-
targetSdkVersion 22
132+
minSdkVersion rootProject.ext.minSdkVersion
133+
targetSdkVersion rootProject.ext.targetSdkVersion
104134
versionCode 1
105135
versionName "1.0"
106-
ndk {
107-
abiFilters "armeabi-v7a", "x86"
108-
}
109-
}
110-
signingConfigs {
111-
release {
112-
if (project.hasProperty('SIMPLE_EXAMPLE_RELEASE_STORE_FILE')) {
113-
storeFile file(SIMPLE_EXAMPLE_RELEASE_STORE_FILE)
114-
storePassword SIMPLE_EXAMPLE_RELEASE_STORE_PASSWORD
115-
keyAlias SIMPLE_EXAMPLE_RELEASE_KEY_ALIAS
116-
keyPassword SIMPLE_EXAMPLE_RELEASE_KEY_PASSWORD
117-
}
118-
}
119136
}
120137
splits {
121138
abi {
122139
reset()
123140
enable enableSeparateBuildPerCPUArchitecture
124141
universalApk false // If true, also generate a universal APK
125-
include "armeabi-v7a", "x86"
142+
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
143+
}
144+
}
145+
signingConfigs {
146+
debug {
147+
storeFile file('debug.keystore')
148+
storePassword 'android'
149+
keyAlias 'androiddebugkey'
150+
keyPassword 'android'
126151
}
127152
}
128153
buildTypes {
154+
debug {
155+
signingConfig signingConfigs.debug
156+
}
129157
release {
158+
// Caution! In production, you need to generate your own keystore file.
159+
// see https://facebook.github.io/react-native/docs/signed-apk-android.
160+
signingConfig signingConfigs.debug
130161
minifyEnabled enableProguardInReleaseBuilds
131162
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
132-
signingConfig signingConfigs.release
133163
}
134164
}
135165
// applicationVariants are e.g. debug, release
136166
applicationVariants.all { variant ->
137167
variant.outputs.each { output ->
138168
// For each separate APK per architecture, set a unique version code as described here:
139-
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
140-
def versionCodes = ["armeabi-v7a":1, "x86":2]
169+
// https://developer.android.com/studio/build/configure-apk-splits.html
170+
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
141171
def abi = output.getFilter(OutputFile.ABI)
142172
if (abi != null) { // null for the universal-debug, universal-release variants
143173
output.versionCodeOverride =
144174
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
145175
}
176+
146177
}
147178
}
148179
}
149180

150181
dependencies {
151-
compile fileTree(dir: "libs", include: ["*.jar"])
152-
compile "com.android.support:appcompat-v7:23.0.1"
153-
compile "com.facebook.react:react-native:+" // From node_modules
154-
compile project(':react-native-threads')
182+
implementation fileTree(dir: "libs", include: ["*.jar"])
183+
implementation "com.facebook.react:react-native:+" // From node_modules
184+
implementation project(':react-native-threads')
185+
186+
if (enableHermes) {
187+
def hermesPath = "../../node_modules/hermes-engine/android/";
188+
debugImplementation files(hermesPath + "hermes-debug.aar")
189+
releaseImplementation files(hermesPath + "hermes-release.aar")
190+
} else {
191+
implementation jscFlavor
192+
}
155193
}
156194

157195
// Run this once to be able to run the application with BUCK
@@ -160,3 +198,5 @@ task copyDownloadableDepsToLibs(type: Copy) {
160198
from configurations.compile
161199
into 'libs'
162200
}
201+
202+
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"""Helper definitions to glob .aar and .jar targets"""
2+
3+
def create_aar_targets(aarfiles):
4+
for aarfile in aarfiles:
5+
name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")]
6+
lib_deps.append(":" + name)
7+
android_prebuilt_aar(
8+
name = name,
9+
aar = aarfile,
10+
)
11+
12+
def create_jar_targets(jarfiles):
13+
for jarfile in jarfiles:
14+
name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")]
15+
lib_deps.append(":" + name)
16+
prebuilt_jar(
17+
name = name,
18+
binary_jar = jarfile,
19+
)
2.2 KB
Binary file not shown.

0 commit comments

Comments
 (0)