Skip to content

Commit 5112a63

Browse files
bestanderfacebook-github-bot-7
authored and
facebook-github-bot-7
committedFeb 26, 2016
Added ability to run Movies app with BUCK
Reviewed By: mkonicek Differential Revision: D2874873 fb-gh-sync-id: 9feface8d9a18742e68206dbafb804de25f53ed8 shipit-source-id: 9feface8d9a18742e68206dbafb804de25f53ed8
1 parent 9d3d9df commit 5112a63

File tree

20 files changed

+158
-49
lines changed

20 files changed

+158
-49
lines changed
 

‎.buckconfig

+3
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44

55
[maven_repositories]
66
central = https://repo1.maven.org/maven2
7+
8+
[alias]
9+
movies = //Examples/Movies/android/app:app

‎.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ project.xcworkspace
2929
# Buck
3030
.buckd
3131
buck-out
32+
/ReactAndroid/src/main/jni/prebuilt/lib/armeabi-v7a/
33+
/ReactAndroid/src/main/jni/prebuilt/lib/x86/
3234

3335
# Android
3436
.idea

‎Examples/Movies/android/app/BUCK

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
include_defs('//ReactAndroid/DEFS')
2+
3+
android_binary(
4+
name = 'app',
5+
manifest = 'src/main/AndroidManifest.xml',
6+
keystore = '//keystores:debug',
7+
deps = [
8+
':movies-lib',
9+
],
10+
)
11+
12+
android_library(
13+
name = 'movies-lib',
14+
srcs = glob(['src/main/java/**/*.java']),
15+
deps = [
16+
react_native_target('java/com/facebook/csslayout:csslayout'),
17+
react_native_target('java/com/facebook/react:react'),
18+
react_native_target('java/com/facebook/react/devsupport:devsupport'),
19+
react_native_target('java/com/facebook/react/modules/core:core'),
20+
react_native_target('java/com/facebook/react/shell:shell'),
21+
react_native_target('java/com/facebook/react/touch:touch'),
22+
react_native_target('java/com/facebook/react/uimanager:uimanager'),
23+
react_native_target('java/com/facebook/react/uimanager/annotations:annotations'),
24+
react_native_target('java/com/facebook/react/views/image:image'),
25+
react_native_target('java/com/facebook/react/views/recyclerview:recyclerview'),
26+
react_native_target('java/com/facebook/react/views/scroll:scroll'),
27+
react_native_target('java/com/facebook/react/views/text:text'),
28+
react_native_target('java/com/facebook/react/views/view:view'),
29+
# .so files are prebuilt by Gradle with `./gradlew :ReactAndroid:packageReactNdkLibsForBuck`
30+
react_native_target('jni/prebuilt:reactnative-libs'),
31+
react_native_target('jni/prebuilt:android-jsc'),
32+
react_native_dep('libraries/soloader/java/com/facebook/soloader:soloader'),
33+
react_native_dep('third-party/java/jsr-305:jsr-305'),
34+
':res',
35+
],
36+
)
37+
38+
39+
android_resource(
40+
name = 'res',
41+
res = 'src/main/res',
42+
package = 'com.facebook.react.movies',
43+
)

‎Examples/Movies/android/app/src/main/AndroidManifest.xml

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
<uses-permission android:name="android.permission.INTERNET" />
55
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
6+
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
67

78
<application
89
android:allowBackup="true"

‎Examples/UIExplorer/android/app/src/main/AndroidManifest.xml

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<uses-permission android:name="android.permission.INTERNET" />
66
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
77
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
8+
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
89

910
<application
1011
android:allowBackup="true"

‎Examples/UIExplorer/android/app/src/main/java/UIExplorerActivity.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
import com.facebook.react.ReactActivity;
1818
import com.facebook.react.ReactPackage;
1919
import com.facebook.react.shell.MainReactPackage;
20+
import com.facebook.react.uiapp.R;
2021

2122
import java.util.Arrays;
2223
import java.util.List;
23-
2424
import javax.annotation.Nullable;
2525

2626
public class UIExplorerActivity extends ReactActivity {

‎ReactAndroid/build.gradle

+5
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,11 @@ task packageReactNdkLibs(dependsOn: buildReactNdkLib, type: Copy) {
204204
into "$buildDir/react-ndk/exported"
205205
}
206206

207+
task packageReactNdkLibsForBuck(dependsOn: packageReactNdkLibs, type: Copy) {
208+
from "$buildDir/react-ndk/exported"
209+
into "src/main/jni/prebuilt/lib"
210+
}
211+
207212
android {
208213
compileSdkVersion 23
209214
buildToolsVersion "23.0.1"
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,10 @@
1-
# Unpack resources from the appcompat aar and merge their ids into the
2-
# generated com.facebook.react.R class.
3-
#
4-
# We do this for compatibility with Gradle: we build the open source
5-
# version React Native with both Buck and Gradle. See for example
6-
# ReactToolbarManager.java where we access the appcompat resources
7-
# via com.facebook.react.R.
8-
android_resource(
9-
name = 'res-for-react-native',
10-
res = ':res-unpacker-cmd',
11-
package = 'com.facebook.react',
12-
visibility = ['//ReactAndroid/...',],
13-
)
14-
15-
genrule(
16-
name = 'res-unpacker-cmd',
17-
cmd = '$(exe :res-unpacker) $(location :appcompat-binary-aar) $OUT',
18-
out = 'res',
19-
)
1+
include_defs('//ReactAndroid/DEFS')
202

21-
python_binary(
22-
name = 'res-unpacker',
23-
main = 'res-unpacker.py',
24-
)
25-
26-
remote_file(
27-
name = 'appcompat-binary-aar',
28-
url = 'mvn:com.android.support:appcompat-v7:aar:23.0.1',
29-
sha1 = '7d659f671541394a8bc2b9f909950aa2a5ec87ff',
3+
# used by ReactToolbarManager because of Gradle
4+
# TODO t10182713 will be replaced with res-for-appcompat when we stop using Gradle
5+
android_resource(
6+
name = 'res-for-react-native',
7+
res = react_native_dep('third-party/android/support/v7/appcompat-orig:res-unpacker-cmd'),
8+
package = 'com.facebook.react',
9+
visibility = ['//ReactAndroid/...',],
3010
)

‎ReactAndroid/src/main/java/com/facebook/react/views/switchview/BUCK

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ android_library(
99
react_native_target('java/com/facebook/csslayout:csslayout'),
1010
react_native_target('java/com/facebook/react/uimanager:uimanager'),
1111
react_native_target('java/com/facebook/react/uimanager/annotations:annotations'),
12-
react_native_dep('android_res/android/support/v7/appcompat-orig:res-for-react-native'),
1312
react_native_dep('third-party/android/support/v7/appcompat-orig:appcompat'),
1413
react_native_dep('third-party/java/jsr-305:jsr-305'),
1514
],

‎ReactAndroid/src/main/java/com/facebook/react/views/toolbar/DrawableWithIntrinsicSize.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
// Copyright 2004-present Facebook. All Rights Reserved.
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
8+
*/
29

310
package com.facebook.react.views.toolbar;
411

‎ReactAndroid/src/main/java/com/facebook/react/views/toolbar/ReactToolbar.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
// Copyright 2004-present Facebook. All Rights Reserved.
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
8+
*/
29

310
package com.facebook.react.views.toolbar;
411

Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
android_prebuilt_aar(
1+
include_defs('//ReactAndroid/DEFS')
2+
3+
android_library(
24
name = 'logging',
3-
aar = ':fbcore-binary-aar',
4-
visibility = ['//ReactAndroid/...'],
5+
exported_deps = [
6+
react_native_dep('libraries/fresco/fresco-react-native:fbcore'),
7+
],
8+
visibility = ['//ReactAndroid/...',],
59
)
610

7-
remote_file(
8-
name = 'fbcore-binary-aar',
9-
url = 'mvn:com.facebook.fresco:fbcore:aar:0.8.1',
10-
sha1 = 'cc46b3d564139bf63bb41534c7a723ee8119ae5f',
11-
)

‎ReactAndroid/src/main/third-party/android/support/v4/BUCK

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
android_prebuilt_aar(
22
name = 'lib-support-v4',
33
aar = ':lib-support-v4-binary-aar',
4-
visibility = ['//ReactAndroid/...',],
4+
visibility = ['PUBLIC',],
55
)
66

77
remote_file(

‎ReactAndroid/src/main/third-party/android/support/v7/appcompat-orig/BUCK

+53-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,59 @@
1-
android_prebuilt_aar(
2-
name = 'appcompat-23.1',
3-
aar = ':appcompat-binary-aar',
1+
include_defs('//ReactAndroid/DEFS')
2+
3+
# This is a bit messy and hopefully a temporary thing
4+
# The problem is that Gradle extracts appcompat resources into app namespace, com.facebook.react
5+
# While BUCK behaves properly and extracts them into android.support.v7.appcompat package.
6+
# We want to support both Gradle and BUCK builds so we hack a bit how BUCK extracts resources.
7+
# Besides that we still need JAVA classes from appcompat-v7.aar, that is why android_library
8+
# extracts classes.jar but the trick is that we can't take full appcompat.aar because resources
9+
# extracted from it by BUCK would conflict with resources we use under Gradelified package
10+
# All this mumbo jumbo will go away after t10182713
11+
12+
android_library(
13+
name = 'appcompat',
14+
deps = [
15+
':res-for-appcompat',
16+
],
17+
visibility = [
18+
'PUBLIC',
19+
],
20+
exported_deps = [
21+
':classes-for-react-native',
22+
],
23+
)
24+
25+
# still used by appcompat library internally, so we need both during the build
26+
android_resource(
27+
name = 'res-for-appcompat',
28+
res = ':res-unpacker-cmd',
29+
package = 'android.support.v7.appcompat',
30+
visibility = ['//ReactAndroid/...',],
31+
)
32+
33+
prebuilt_jar(
34+
name = 'classes-for-react-native',
35+
binary_jar = ':classes-unpacker-cmd',
436
visibility = ['//ReactAndroid/...',],
537
)
638

39+
genrule(
40+
name = 'classes-unpacker-cmd',
41+
cmd = '$(exe :aar-unpacker) $(location :appcompat-binary-aar) "classes.jar" $OUT',
42+
out = 'classes.jar',
43+
)
44+
45+
genrule(
46+
name = 'res-unpacker-cmd',
47+
cmd = '$(exe :aar-unpacker) $(location :appcompat-binary-aar) "res/" $OUT',
48+
out = 'res',
49+
visibility = ['//ReactAndroid/...',],
50+
)
51+
52+
python_binary(
53+
name = 'aar-unpacker',
54+
main = 'aar-unpacker.py',
55+
)
56+
757
remote_file(
858
name = 'appcompat-binary-aar',
959
url = 'mvn:com.android.support:appcompat-v7:aar:23.0.1',

‎ReactAndroid/src/main/android_res/android/support/v7/appcompat-orig/res-unpacker.py ‎ReactAndroid/src/main/third-party/android/support/v7/appcompat-orig/aar-unpacker.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import tempfile
66
import zipfile
77

8-
# Helper that unpacks the contents of the res folder of an .aar file
8+
# Helper that unpacks the contents of an .aar file
99
# into given destination.
1010

1111
@contextlib.contextmanager
@@ -16,5 +16,5 @@ def cleanup(path):
1616
if __name__ == '__main__':
1717
with zipfile.ZipFile(sys.argv[1], 'r') as z:
1818
with cleanup(tempfile.mkdtemp()) as temp_path:
19-
z.extractall(temp_path, filter(lambda n: n.startswith('res/'), z.namelist()))
20-
shutil.move(os.path.join(temp_path, 'res'), sys.argv[2])
19+
z.extractall(temp_path, filter(lambda n: n.startswith(sys.argv[2]), z.namelist()))
20+
shutil.move(os.path.join(temp_path, sys.argv[2]), sys.argv[3])

‎ReactAndroid/src/main/third-party/java/jsr-305/BUCK

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
prebuilt_jar(
22
name = 'jsr-305',
33
binary_jar = ':jsr305-binary-jar',
4-
visibility = ['//ReactAndroid/...',],
4+
visibility = ['PUBLIC'],
55
)
66

77
remote_file(

‎gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-2.9-bin.zip
6+
distributionUrl=https://services.gradle.org/distributions/gradle-2.11-all.zip

‎keystores/BUCK

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
keystore(
2+
name = 'debug',
3+
store = 'debug.keystore',
4+
properties = 'debug.keystore.properties',
5+
visibility = [
6+
'PUBLIC',
7+
],
8+
)

‎keystores/debug.keystore

2.2 KB
Binary file not shown.

‎keystores/debug.keystore.properties

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
key.store=debug.keystore
2+
key.alias=androiddebugkey
3+
key.store.password=android
4+
key.alias.password=android

0 commit comments

Comments
 (0)
Please sign in to comment.