Browse Source

initial commit

master
Martin Dørum 3 years ago
commit
be6367a931
3 changed files with 88 additions and 0 deletions
  1. 4
    0
      .gitignore
  2. 76
    0
      Makefile
  3. 8
    0
      README.md

+ 4
- 0
.gitignore View File

@@ -0,0 +1,4 @@
/include
/libs
/depot_tools
/webrtc-checkout

+ 76
- 0
Makefile View File

@@ -0,0 +1,76 @@
WEBRTC_DIR ?= .
WEBRTC_VERSION ?= m79
WEBRTC_OUT ?= Release
WEBRTC_GN_ARGS ?= \
is_debug=false \
use_sysroot=false \
rtc_include_tests=false \
is_clang=false \
treat_warnings_as_errors=false \
$(WEBRTC_GN_ARGS_EXTRA)
WEBRTC_TARGETS ?= default $(WEBRTC_TARGETS_EXTRA)
WEBRTC_LIBS ?= libwebrtc.a $(WEBRTC_LIBS_EXTRA)
WEBRTC_INCLUDES = \
api audio base common_audio common_video logging media modules p2p pc \
rtc_base rtc_tools video common_types.h \
$(WEBRTC_INCLUDES_EXTRA)

SETPATH = PATH=$(WEBRTC_DIR)/depot_tools:"$$PATH"
RTC_STAMP_DEPOT = $(WEBRTC_DIR)/depot_tools/.stamp
RTC_STAMP_REPO = $(WEBRTC_DIR)/webrtc-checkout/.stamp
RTC_STAMP_VERSION = $(WEBRTC_DIR)/webrtc-checkout/.stamps/stamp-$(WEBRTC_VERSION)
RTC_STAMP_COMPILE = $(WEBRTC_DIR)/webrtc-checkout/src/out/$(WEBRTC_OUT)/.stamp
RTC_STAMP_INCLUDES = include/webrtc/.stamp

all: include/webrtc/.stamp $(patsubst %,libs/%,$(WEBRTC_LIBS))

# Get depot_tools, which contains all the tools required to work with Google software
$(RTC_STAMP_DEPOT):
rm -rf $(WEBRTC_DIR)/depot_tools
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git $(WEBRTC_DIR)/depot_tools
touch $@

# Fetch the WebRTC project itself
$(RTC_STAMP_REPO): $(RTC_STAMP_DEPOT)
rm -rf $(WEBRTC_DIR)/webrtc-checkout && mkdir $(WEBRTC_DIR)/webrtc-checkout
#
# Fetch webrtc, thit will take time...
cd $(WEBRTC_DIR)/webrtc-checkout && $(SETPATH) fetch --nohooks --no-history webrtc
touch $@

# Check out the correct WebRTC branch/commit
$(RTC_STAMP_VERSION): $(RTC_STAMP_REPO)
rm -rf $(WEBRTC_DIR)/webrtc-checkout/.stamps && mkdir $(WEBRTC_DIR)/webrtc-checkout/.stamps
cd $(WEBRTC_DIR)/webrtc-checkout/src && git checkout branch-heads/$(WEBRTC_VERSION)
#
# Sync webrtc, this will take time...
cd $(WEBRTC_DIR)/webrtc-checkout/src && $(SETPATH) gclient sync -D --nohooks
touch $@

# Compile
$(RTC_STAMP_COMPILE):
cd $(WEBRTC_DIR)/webrtc-checkout/src && $(SETPATH) gn gen out/$(WEBRTC_OUT) --args='$(WEBRTC_GN_ARGS)'
cd $(WEBRTC_DIR)/webrtc-checkout/src && $(SETPATH) ninja -C out/$(WEBRTC_OUT) $(WEBRTC_TARGETS)
touch $@

# Includes
$(RTC_STAMP_INCLUDES): $(RTC_STAMP_VERSION)
rm -rf include/webrtc && mkdir -p include/webrtc
rsync -m --recursive --include='*/' --include='*.h' --exclude='*' \
$(patsubst %,$(WEBRTC_DIR)/webrtc-checkout/src/%,$(WEBRTC_INCLUDES)) \
include/webrtc
touch $@

# Libraries
libs/%.a: $(WEBRTC_DIR)/webrtc-checkout/src/out/$(WEBRTC_OUT)/obj/%.a
@mkdir -p $(@D)
cp $< $@

.PHONY: clean
clean:
rm -rf $(WEBRTC_DIR)/depot_tools $(WEBRTC_DIR)/webrtc-checkout
rm -rf include libs

.PHONY: gn-clean
gn-clean:
cd $(WEBRTC_DIR)/webrtc-checkout/src && $(SETPATH) gn clean out/$(WEBRTC_OUT)

+ 8
- 0
README.md View File

@@ -0,0 +1,8 @@
# libwebrtc.mk

This repo tries to make it a bit easier to create new WebRTC projects.
It's intended to be used as a git submodule, and is an easy way to download
and compile WebRTC in a way which can be embedded in a parent project.

The WebRTC library will be compiled from source, and both the checkout process
and the compile itself can take quite a while. Be patient.

Loading…
Cancel
Save