Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Script to build-from-scratch from upstream webrtc #32

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

infinity0
Copy link

See the first few lines of build-gnu-linux.sh for a broad description of what it does. (Forms part of a solution for #23).

We avoid depot_tools, to reduce the resource burden on whoever wants to build this project. Currently we pull in the latest upstream versions 49.xxx of both webrtc and chromium, and apply some patches specific to these versions. These will need to be maintained as the upstream repos are updated, but this shouldn't be too hard. The upstream build process by default currently builds vpx, boringssl, protobuf_lite, etc. Later I will play with trying to avoid that, and instead link against system libraries. (It already links against some, like jpeg and srtp.) Later also I will try to persuade upstream to expose a more finalised public API version of libjingle_peerconnection_internal.

The script takes about 20 minutes to run on my machine. It should be adaptable to FreeBSD-based systems such as a certain other popular OS, but I don't have a system to test that on.

I didn't update README yet, because I wanted to check that you're fine with the general approach here. There's some untidy bits like automatically patching the .pc files, better suggestions welcome.

Note that we can't just remove the cgo CXXFLAGS, the build fails when we do
that. It seems that cgo sets a std *different* from what the system default
compiler does when compiling plain C++ code. :/
On Debian we built libwebrtc-magic using the same settings as chromium-browser
which links against certain system libs instead of bundled libs.
@keroserene
Copy link
Owner

This is awesome! Thanks for doing this.

Ran into a couple issues at first, but then made it work 👍
Also took about 20 minutes to build (archlinux).

  • The first time, after fetching & patching, it failed at setup_links.py because I forgot that these scripts require python 2.7. Using a virtualenv fixes this. It may be worth checking the python version earlier in the script, and stopping / notifying the user if their environment isn't set up correctly to save time.
  • Also need to make sure to export JAVA_HOME to wherever java-7-openjdk is.
  • Then I had to install libsrtp as a system library, because I hadn't done that yet.
  • Lastly when trying to run the chat demo, it couldn't find libboringssl. Fixed with export LD_LIBRARY_PATH=lib

Totally great that you've managed to skip the depot_tools shenanigans.
Really like your approach so far!

@keroserene
Copy link
Owner

Also, we have two choices to get this to work with Travis CI...

  • Run your script during the travis build (an OSX version will also be needed) However, this will extend the travis build time from ~1-2 minutes to 20+ minutes.
  • Keep the pre-built archive & includes in the repo, if only for quicker testing on travis.

Having a cleaner repo is nice, though a very long test setup is less nice. Choices!

@arlolra
Copy link
Collaborator

arlolra commented Feb 5, 2016

Choices!

  • Have a second repo that builds the dependencies and have go-webrtc depend on that?

@infinity0
Copy link
Author

Nice to hear it works on Arch! I wasn't aware you had to set JAVA_HOME - I don't have it set over here in Debian; what's the error if you don't set it? When I get some time I'll try to figure out the minimal list of dependencies, instead of just saying apt-get build-dep chromium.

I like @arlolra's idea with the second repo, if it's possible to configure travis like that. (I'm new to travis, and haven't seen the build config options.)

@amozoss
Copy link

amozoss commented May 4, 2016

Error when JAVA_HOME isn't set

Updating projects from gyp files...
Traceback (most recent call last):
File "", line 1, in
AssertionError: Point $JAVA_HOME or the java_home gyp variable to a directory containing include/jni.h!
gyp: Call to 'python -c "import os; dir=os.getenv('JAVA_HOME', '/usr/lib/jvm/java-7-openjdk-amd64'); assert os.path.exists(os.path.join(dir, 'include/jni.h')), 'Point $JAVA_HOME or the java_home gyp variable to a directory containing include/jni.h!'; print dir"' returned exit status 1 while in talk/libjingle.gyp.
Traceback (most recent call last):
File "", line 1, in
AssertionError: Point $JAVA_HOME or the java_home gyp variable to a directory containing include/jni.h!
gyp: Call to 'python -c "import os; dir=os.getenv('JAVA_HOME', '/usr/lib/jvm/java-7-openjdk-amd64'); assert os.path.exists(os.path.join(dir, 'include/jni.h')), 'Point $JAVA_HOME or the java_home gyp variable to a directory containing include/jni.h!'; print dir"' returned exit status 1 while in webrtc/webrtc_examples.gyp.
Traceback (most recent call last):
File "", line 1, in
AssertionError: Point $JAVA_HOME or the java_home gyp variable to a directory containing include/jni.h!
gyp: Call to 'python -c "import os; dir=os.getenv('JAVA_HOME', '/usr/lib/jvm/java-7-openjdk-amd64'); assert os.path.exists(os.path.join(dir, 'include/jni.h')), 'Point $JAVA_HOME or the java_home gyp variable to a directory containing include/jni.h!'; print dir"' returned exit status 1 while in talk/libjingle_tests.gyp.

@amozoss
Copy link

amozoss commented May 9, 2016

Here is a more specific list of dependencies. It should be fairly close.
apt-get install libsrtp-dev libxslt-dev yasm libxml2-dev libffi-dev libglib2.0-dev libatk1.0-dev libgtk2.0-dev libxtst-dev libxss-dev libpci-dev libdbus-1-dev libgnome-keyring-dev libnss3-dev libpulse-dev libcups2-dev libexif-dev libjpeg-dev libasound2-dev libudev-dev ninja-build

@cstrahan
Copy link

Hey, this is pretty neat. This does make me wonder, though: has the person that provided e.g. lib/libwebrtc-darwin-amd64-magic.a made their notes/scripts public? (I guess that's @arlolra and @keroserene, judging by the git history)

I'm tempted to write bindings for Haskell (but first, I'd like to package WebRTC for NixOS), and I'd like to avoid experiencing the pain of building WebRTC if at all possible 😅.

@arlolra
Copy link
Collaborator

arlolra commented Jan 3, 2017

@cstrahan see #51

@cantstopthesignal
Copy link
Contributor

cantstopthesignal commented Jan 7, 2017 via email

@eighthave eighthave mentioned this pull request Nov 22, 2018
@eighthave
Copy link
Contributor

Since this stuff was fresh in my brain, I rebased this on top of my #90 pull request:
https://github.com/eighthave/go-webrtc/tree/build-from-scratch

And threw it in a gitlab-ci job running in Debian/testing:
https://gitlab.com/eighthave/go-webrtc/-/jobs/124653582

@eighthave
Copy link
Contributor

This is perhaps more interesting, it is running only the go build on various Debian and Ubuntu versions:
https://gitlab.com/eighthave/go-webrtc/pipelines/37678401

Seems the pkg-config libs also needs an update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants