Browse Source

Customize bazel BUILD files for android and linux

TODO: Implement and test iOS BUILD file
Andy Hochhaus 2 years ago
parent
commit
57db2dc3ad
8 changed files with 67 additions and 14 deletions
  1. 27 4
      README.md
  2. 8 0
      android.BUILD
  3. 5 0
      android.WORKSPACE
  4. 10 9
      builder/builder.go
  5. 11 0
      ios.BUILD
  6. 1 1
      webrtc.WORKSPACE
  7. 0 0
      linux.BUILD
  8. 5 0
      linux.WORKSPACE

+ 27 - 4
README.md

@@ -8,11 +8,12 @@ bazel linux, iOS or android project.
 
 ## Bazel Usage
 
-First, install Bazel. Then add the following to your `WORKSPACE` file:
+First, install Bazel. Then for a C++ project on linux add the following to your
+`WORKSPACE` file:
 
 ```python
 http_archive(
-    name = "com_github_socialworkout_webrtc",
+    name = "com_github_socialworkout_webrtc_linux",
     sha256 = "2a4e2ec331599c5d8bcd128b69876f92e3e6e108a9b45dfdc12f14e21ea08130",
     url = "https://github.com/socialworkout/webrtc/releases/download/58-0/webrtc-58-0-linux.tar.gz",
 )
@@ -26,7 +27,7 @@ Next, add `deps` to the webrtc package from the appropriate `cc_library()` or
 cc_library(
     ...
     copts = ["-fno-rtti"],
-    deps = [ "@com_github_socialworkout_webrtc//:rtc" ],
+    deps = [ "@com_github_socialworkout_webrtc_linux//:rtc" ],
     ...
 )
 
@@ -35,7 +36,29 @@ cc_library(
 cc_binary(
     ...
     copts = ["-fno-rtti"],
-    deps = [ "@com_github_socialworkout_webrtc//:rtc" ],
+    deps = [ "@com_github_socialworkout_webrtc_linux//:rtc" ],
+    ...
+)
+```
+
+For a Java android project add the following to your `WORKSPACE` file:
+
+```python
+http_archive(
+    name = "com_github_socialworkout_webrtc_android",
+    sha256 = "2e96428e7bda02d621bc6ef0a607db5a219a3b7e3282881ee82be6f3462eb6c0",
+    url = "https://github.com/socialworkout/webrtc/releases/download/58-0/webrtc-58-0-android.tar.gz",
+)
+```
+
+Next, add `deps` to the webrtc package from the appropriate `android_binary` in
+your `BUILD` files:
+
+
+```python
+android_binary(
+    ...
+    deps = [ "@com_github_socialworkout_webrtc_android//:rtc" ],
     ...
 )
 ```

+ 8 - 0
android.BUILD

@@ -0,0 +1,8 @@
+# Copyright (c) 2017 Latham Labs, Inc
+# All Rights Reserved.
+# Author: Andy Hochhaus <andy@socialworkout.com>
+
+aar_import(
+    name = "rtc",
+    aar = "libwebrtc.aar",
+)

+ 5 - 0
android.WORKSPACE

@@ -0,0 +1,5 @@
+# Copyright (c) 2017 Latham Labs, Inc
+# All Rights Reserved.
+# Author: Andy Hochhaus <andy@socialworkout.com>
+
+workspace(name = "com_github_socialworkout_webrtc_android")

+ 10 - 9
builder/builder.go

@@ -292,12 +292,13 @@ func build() {
 
 	case "darwin":
 		// build framework for use both on device and in the simulator
-		execOrDie("rm", "-rf", "../tmp", "out_ios_libs")
-		execOrDie("mkdir", "../tmp")
-		execOrDie("python", "./tools-webrtc/ios/build_ios_libs.py", "-r",
-			fmt.Sprintf("%d", *ver))
-		execOrDie("cp", "-r", "out_ios_libs/WebRTC.framework", "../tmp/")
-		tarPackage("ios-arm64-arm-x64")
+		// TODO(ahochhaus): Which iOS target should we use? Do we need both?
+		// execOrDie("rm", "-rf", "../tmp", "out_ios_libs")
+		// execOrDie("mkdir", "../tmp")
+		// execOrDie("python", "./tools-webrtc/ios/build_ios_libs.py", "-r",
+		// 	fmt.Sprintf("%d", *ver))
+		// execOrDie("cp", "-r", "out_ios_libs/WebRTC.framework", "../tmp/")
+		// tarPackage("ios-arm64-arm-x64")
 
 		// build framework for use on device and through app strore
 		execOrDie("rm", "-rf", "../tmp", "out_ios_libs")
@@ -305,7 +306,7 @@ func build() {
 		execOrDie("python", "./tools-webrtc/ios/build_ios_libs.py", "-r",
 			fmt.Sprintf("%d", *ver), "--arch", "arm64", "arm")
 		execOrDie("cp", "-r", "out_ios_libs/WebRTC.framework", "../tmp/")
-		tarPackage("ios-arm64-arm")
+		tarPackage("ios")
 
 		// TODO(ahochhaus): Build darwin static libraries once webrtc adds native
 		// support.
@@ -323,8 +324,8 @@ func build() {
 
 func tarPackage(archLabel string) {
 	chOrDie("../tmp")
-	execOrDie("cp", filepath.Join(clientDir, "webrtc.BUILD"), "BUILD")
-	execOrDie("cp", filepath.Join(clientDir, "webrtc.WORKSPACE"), "WORKSPACE")
+	execOrDie("cp", filepath.Join(clientDir, archLabel+".BUILD"), "BUILD")
+	execOrDie("cp", filepath.Join(clientDir, archLabel+".WORKSPACE"), "WORKSPACE")
 	archive := fmt.Sprintf("%s/release/webrtc-%s-%s.tar.gz", *buildDir,
 		buildLabel, archLabel)
 	execOrDie("tar", "-czf", archive, ".")

+ 11 - 0
ios.BUILD

@@ -0,0 +1,11 @@
+# Copyright (c) 2017 Latham Labs, Inc
+# All Rights Reserved.
+# Author: Andy Hochhaus <andy@socialworkout.com>
+
+# TODO(ahochhaus): Determine how to import "WebRTC.framework" in bazel.
+# https://bazel.build/versions/master/docs/be/objective-c.html
+
+aar_import(
+    name = "rtc",
+    aar = "WebRTC.framework",
+)

+ 1 - 1
webrtc.WORKSPACE

@@ -2,4 +2,4 @@
 # All Rights Reserved.
 # Author: Andy Hochhaus <andy@socialworkout.com>
 
-workspace(name = "com_github_socialworkout_webrtc")
+workspace(name = "com_github_socialworkout_webrtc_ios")

webrtc.BUILD → linux.BUILD


+ 5 - 0
linux.WORKSPACE

@@ -0,0 +1,5 @@
+# Copyright (c) 2017 Latham Labs, Inc
+# All Rights Reserved.
+# Author: Andy Hochhaus <andy@socialworkout.com>
+
+workspace(name = "com_github_socialworkout_webrtc_linux")