Skip to content

Commit c596f8d

Browse files
janicduplessisFacebook Github Bot 8
authored and
Facebook Github Bot 8
committed
Allow building UIExplorer with Buck
Summary:This adds a BUCK file to UIExplorer to allow building it with buck. It is based on the one in the movies app but I removed the extra deps that were not needed in both files. Also add build version number and target sdk version in the Android manifest so Buck can use it since it was only specified in the gradle build and caused the app to run on a super old target sdk. bestander mkonicek Would it be simple to also build the ndk part with Buck? Right now it is built with gradle and packaged after. I suppose it is already being done internally at facebook. The BUCK files for building the cpp code are already there but I couldn't figure out what was missing to make it work :( That is pretty much the only missing part to have first class support for building RN apps with Buck in OSS. We could eventually include BUCK files with the generated project. **Test plan (required)** Build and run UIExplorer and Movies examples using Buck. Edited: ``` ./gradlew ReactAndroid:packageReactNdkLibsForBuck Closes facebook#6399 Reviewed By: mkonicek Differential Revision: D3042355 Pulled By: bestander fb-gh-sync-id: 74760c7ba12d35b1853d2e3706c2ba130f9eef1c fbshipit-source-id: 74760c7ba12d35b1853d2e3706c2ba130f9eef1c
1 parent c3824f4 commit c596f8d

File tree

8 files changed

+84
-21
lines changed

8 files changed

+84
-21
lines changed

.buckconfig

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77

88
[alias]
99
movies = //Examples/Movies/android/app:app
10+
uiexplorer = //Examples/UIExplorer/android/app:app

Examples/Movies/README.md

+15
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,21 @@ Open the Movies app in your emulator.
3535

3636
See [Running on Device](https://facebook.github.io/react-native/docs/running-on-device-android.html) in case you want to use a physical device.
3737

38+
### Running with Buck
39+
40+
Follow the same setup as running with gradle.
41+
42+
Install Buck from [here](https://buckbuild.com/setup/install.html).
43+
44+
Run the following commands from the react-native folder:
45+
46+
./gradlew :ReactAndroid:packageReactNdkLibsForBuck
47+
buck fetch movies
48+
buck install -r movies
49+
./packager/packager.sh
50+
51+
_Note: The native libs are still built using gradle. Full build with buck is coming soon(tm)._
52+
3853
## Built from source
3954

4055
Building the app on both iOS and Android means building the React Native framework from source. This way you're running the latest native and JS code the way you see it in your clone of the github repo.

Examples/Movies/android/app/BUCK

+4-16
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,17 @@ android_library(
1313
name = 'movies-lib',
1414
srcs = glob(['src/main/java/**/*.java']),
1515
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'),
16+
':res',
17+
react_native_dep('third-party/java/jsr-305:jsr-305'),
1918
react_native_target('java/com/facebook/react/modules/core:core'),
2019
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'),
20+
react_native_target('java/com/facebook/react:react'),
21+
react_native_target('jni/prebuilt:android-jsc'),
2922
# .so files are prebuilt by Gradle with `./gradlew :ReactAndroid:packageReactNdkLibsForBuck`
3023
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',
3524
],
3625
)
3726

38-
3927
android_resource(
4028
name = 'res',
4129
res = 'src/main/res',

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

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="com.facebook.react.movies">
2+
package="com.facebook.react.movies"
3+
android:versionCode="1"
4+
android:versionName="1.0">
35

46
<uses-permission android:name="android.permission.INTERNET" />
57
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
68
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
79

10+
<uses-sdk
11+
android:minSdkVersion="16"
12+
android:targetSdkVersion="22" />
13+
814
<application
915
android:allowBackup="true"
1016
android:label="@string/app_name"

Examples/UIExplorer/README.md

+15
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,21 @@ Open the UIExplorer app in your emulator.
3535

3636
See [Running on Device](https://facebook.github.io/react-native/docs/running-on-device-android.html) in case you want to use a physical device.
3737

38+
### Running with Buck
39+
40+
Follow the same setup as running with gradle.
41+
42+
Install Buck from [here](https://buckbuild.com/setup/install.html).
43+
44+
Run the following commands from the react-native folder:
45+
46+
./gradlew :ReactAndroid:packageReactNdkLibsForBuck
47+
buck fetch uiexplorer
48+
buck install -r uiexplorer
49+
./packager/packager.sh
50+
51+
_Note: The native libs are still built using gradle. Full build with buck is coming soon(tm)._
52+
3853
## Built from source
3954

4055
Building the app on both iOS and Android means building the React Native framework from source. This way you're running the latest native and JS code the way you see it in your clone of the github repo.

Examples/UIExplorer/android/app/BUCK

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
':uiexplorer-lib',
9+
],
10+
)
11+
12+
android_library(
13+
name = 'uiexplorer-lib',
14+
srcs = glob(['src/main/java/**/*.java']),
15+
deps = [
16+
':res',
17+
react_native_dep('third-party/java/jsr-305:jsr-305'),
18+
react_native_target('java/com/facebook/react/modules/core:core'),
19+
react_native_target('java/com/facebook/react/shell:shell'),
20+
react_native_target('java/com/facebook/react:react'),
21+
react_native_target('jni/prebuilt:android-jsc'),
22+
# .so files are prebuilt by Gradle with `./gradlew :ReactAndroid:packageReactNdkLibsForBuck`
23+
react_native_target('jni/prebuilt:reactnative-libs'),
24+
],
25+
)
26+
27+
android_resource(
28+
name = 'res',
29+
res = 'src/main/res',
30+
package = 'com.facebook.react.uiapp',
31+
)

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

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
package="com.facebook.react.uiapp" >
2+
<manifest
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
package="com.facebook.react.uiapp"
5+
android:versionCode="1"
6+
android:versionName="1.0">
47

58
<uses-permission android:name="android.permission.INTERNET" />
69
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
710
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
811
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
912
<uses-permission android:name="android.permission.VIBRATE"/>
1013

14+
<uses-sdk
15+
android:minSdkVersion="16"
16+
android:targetSdkVersion="22" />
17+
1118
<application
1219
android:allowBackup="true"
1320
android:icon="@drawable/launcher_icon"

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ prebuilt_jar(
3838

3939
genrule(
4040
name = 'classes-unpacker-cmd',
41-
cmd = '$(exe :aar-unpacker) $(location :appcompat-binary-aar) "classes.jar" $OUT',
41+
cmd = '$(exe :aar-unpacker) $(location :appcompat-binary-aar) classes.jar $OUT',
4242
out = 'classes.jar',
4343
)
4444

4545
genrule(
4646
name = 'res-unpacker-cmd',
47-
cmd = '$(exe :aar-unpacker) $(location :appcompat-binary-aar) "res/" $OUT',
47+
cmd = '$(exe :aar-unpacker) $(location :appcompat-binary-aar) res/ $OUT',
4848
out = 'res',
4949
visibility = ['//ReactAndroid/...',],
5050
)

0 commit comments

Comments
 (0)