Skip to content

Commit

Permalink
* build aarch64 and x86_64 for macos
Browse files Browse the repository at this point in the history
  • Loading branch information
vyloy committed Jan 30, 2024
1 parent 471d93c commit 4bc64d3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
39 changes: 20 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ ifeq ($(TARGET_OS), apple)
ifeq ($(TARGET_CPU), arm64)
RUST_TARGET?=aarch64-apple-darwin
else
RUST_TARGET?=$(TARGET_CPU)-apple-darwin
endif
ifndef RUST_TARGET
RUST_TARGET:=$(TARGET_CPU)-apple-darwin
endif
endif
DEF_WEBRTC_COND?=-DWEBRTC_MAC -DWEBRTC_POSIX
DEF_LDFLAGS?=-framework Cocoa
endif
Expand All @@ -85,9 +87,8 @@ export CGO_CXXFLAGS=-I$(PWD)/dep/_google-webrtc/src \
-I$(PWD)/dep/_google-webrtc/src/third_party/abseil-cpp \
-I$(PWD)/dep/_msquic/src/inc \
-std=c++17 $(DEF_WEBRTC_COND) -DQUIC_API_ENABLE_PREVIEW_FEATURES
export CGO_LDFLAGS= $(PWD)/dep/_google-webrtc/src/out/release-$(TARGET)/obj/libwebrtc.a \
$(PWD)/dep/_msquic/$(TARGET)/bin/Release/libmsquic.a \
-pthread $(DEF_LDFLAGS)
export CGO_LDFLAGS= $(DEF_LDFLAGS) \
-pthread
export CGO_ENABLED=1

.PHONY: all build docker_build_linux_arm64 fmt build_client docker_build_linux_arm64_client gofumpt build_server docker_build_linux_arm64_server golangci-lint check_webrtc_dependencies docker_release_linux_amd64 release clean docker_release_linux_amd64_client release_client compile_webrtc docker_release_linux_amd64_server release_server docker_create_image docker_build_linux_amd64 docker_release_linux_arm64 revive docker_build_linux_amd64_client docker_release_linux_arm64_client test docker_build_linux_amd64_server docker_release_linux_arm64_server set_safe_directories update_submodule build_web_server build_web_client release_web_server release_web_client check_npm front_release duplicate_dist_server clean_duplication_client clean_web clean_dist clean_duplication clean_duplication_server clean_duplication_client check_msquic_dependencies compile_msquic
Expand Down Expand Up @@ -223,12 +224,12 @@ release_server: $(SOURCES) Makefile compile_msquic compile_webrtc release_web_se
build_lib: $(SOURCES) Makefile compile_msquic compile_webrtc
mkdir -p release/$(RUST_TARGET)
cp $(PWD)/dep/_google-webrtc/src/out/release-$(TARGET)/obj/libwebrtc.a release/$(RUST_TARGET)/
cp $(PWD)/dep/_msquic/$(TARGET)/bin/Release/libmsquic.a release/$(RUST_TARGET)/
cp $(PWD)/dep/_msquic/out/$(TARGET)/bin/Release/libmsquic.a release/$(RUST_TARGET)/
go build $(DEBUG_OPTIONS) -buildmode=c-archive -o release/$(RUST_TARGET)/libcs.a ./lib/export
release_lib: $(SOURCES) Makefile compile_msquic compile_webrtc release_web_client release_web_server
mkdir -p release/$(RUST_TARGET)
cp $(PWD)/dep/_google-webrtc/src/out/release-$(TARGET)/obj/libwebrtc.a release/$(RUST_TARGET)/
cp $(PWD)/dep/_msquic/$(TARGET)/bin/Release/libmsquic.a release/$(RUST_TARGET)/
cp $(PWD)/dep/_msquic/out/$(TARGET)/bin/Release/libmsquic.a release/$(RUST_TARGET)/
go build $(RELEASE_OPTIONS) -buildmode=c-archive -o release/$(RUST_TARGET)/libcs.a ./lib/export

release_web_server: $(SOURCES_FRONT) Makefile check_npm front_release duplicate_dist_server
Expand Down Expand Up @@ -320,8 +321,8 @@ ifeq ($(TARGET_OS), mac)
compile_webrtc: check_webrtc_dependencies update_submodule
cd ./dep/_google-webrtc/src && gn gen out/release-$(TARGET) --args=" \
clang_use_chrome_plugins=false \
use_xcode_clang=true \
clang_base_path=\"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr\" \
use_xcode_clang=false \
clang_base_path=\"/opt/homebrew/opt/llvm\" \
enable_google_benchmarks=false \
enable_libaom=false \
is_component_build=false \
Expand All @@ -345,7 +346,7 @@ compile_webrtc: check_webrtc_dependencies update_submodule
treat_warnings_as_errors=false \
use_custom_libcxx=false \
use_gold=false \
use_lld=false \
use_lld=true \
use_rtti=true \
use_sysroot=false"
sed 's| [^ ]*gcc | $(CC) |g' ./dep/_google-webrtc/src/out/release-$(TARGET)/toolchain.ninja > ./dep/_google-webrtc/src/out/release-$(TARGET)/toolchain.ninja.tmp
Expand All @@ -365,19 +366,19 @@ check_msquic_dependencies:

ifeq ($(TARGET_OS), linux)
compile_msquic: check_msquic_dependencies update_submodule
mkdir -p ./dep/_msquic/$(TARGET)
cmake -B./dep/_msquic/$(TARGET) -S./dep/_msquic -DQUIC_BUILD_SHARED=OFF -DCMAKE_TARGET_ARCHITECTURE=$(TARGET_CPU)
make -C./dep/_msquic/$(TARGET) -j$(shell nproc)
@renameSymbols=$$(objdump -t ./dep/_msquic/$(TARGET)/bin/Release/libmsquic.a | awk -v RS= '/_YB80VJ/{next}1' | grep -E 'g +(F|O) ' | grep -Evi ' (ms){0,1}quic' | awk '{print " --redefine-sym " $$NF "=" $$NF "_YB80VJ"}') && \
$(TARGET)-objcopy $$renameSymbols ./dep/_msquic/$(TARGET)/bin/Release/libmsquic.a
mkdir -p ./dep/_msquic/out/$(TARGET)
cmake -B./dep/_msquic/out/$(TARGET) -S./dep/_msquic -DQUIC_BUILD_SHARED=OFF -DCMAKE_TARGET_ARCHITECTURE=$(TARGET_CPU)
make -C./dep/_msquic/out/$(TARGET) -j$(shell nproc)
@renameSymbols=$$(objdump -t ./dep/_msquic/out/$(TARGET)/bin/Release/libmsquic.a | awk -v RS= '/_YB80VJ/{next}1' | grep -E 'g +(F|O) ' | grep -Evi ' (ms){0,1}quic' | awk '{print " --redefine-sym " $$NF "=" $$NF "_YB80VJ"}') && \
$(TARGET)-objcopy $$renameSymbols ./dep/_msquic/out/$(TARGET)/bin/Release/libmsquic.a
endif
ifeq ($(TARGET_OS), mac)
compile_msquic: check_msquic_dependencies update_submodule
mkdir -p ./dep/_msquic/$(TARGET)
cmake -B./dep/_msquic/$(TARGET) -S./dep/_msquic -DQUIC_BUILD_SHARED=OFF -DCMAKE_TARGET_ARCHITECTURE=$(TARGET_CPU)
make -C./dep/_msquic/$(TARGET) -j$(shell sysctl -n hw.physicalcpu)
mkdir -p ./dep/_msquic/out/$(TARGET)
cmake -B./dep/_msquic/out/$(TARGET) -S./dep/_msquic -DQUIC_BUILD_SHARED=OFF -DCMAKE_TARGET_ARCHITECTURE=$(TARGET_CPU)
make -C./dep/_msquic/out/$(TARGET) -j$(shell sysctl -n hw.physicalcpu)
renameSymbols=$$(cat ./dep/patch/redefine-sym.mac) && \
$(OBJCOPY) $$renameSymbols ./dep/_msquic/$(TARGET)/bin/Release/libmsquic.a
$(OBJCOPY) $$renameSymbols ./dep/_msquic/out/$(TARGET)/bin/Release/libmsquic.a
endif

compile_p2p:
Expand Down
2 changes: 1 addition & 1 deletion client/peerproc.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ type opGetOfferSDP struct {
}

func (pt *peerProcessTask) init() (err error) {
cmd := exec.Command(os.Args[0], "p2p")
cmd := exec.Command(os.Args[0], "sub-p2p")
pt.stdin, err = cmd.StdinPipe()
if err != nil {
return
Expand Down

0 comments on commit 4bc64d3

Please sign in to comment.