2020-10-23 黑科技

https://www.jianshu.com/p/596b4463eacd

黑科技之Beyond Compare在Mac OS系统下永久试用


https://depthlove.github.io/2019/10/18/webrtc-development-5-run-mac-project/

在 WebRTC 开发(四)源码下载与更新 一文中,我们获取到了可以在 iOS,macOS 平台运行的 WebRTC 源码。其中,在执行命令 fetch --nohooks webrtc_ios 时,我们可以明确看到代码支持的平台 ios, mac

1

2

3

4

5

6

7

8

9

10

11

12

13

suntongmiandeMacBook-Pro:webrtc suntongmian$fetch--nohooks webrtc_ios

Running: gclient root

WARNING: Your metrics.cfg file was invalidornonexistent. Anewone will be created.

Running: gclient config--spec 'solutions = [

  {

    "url": "https://webrtc.googlesource.com/src.git",

"managed":False,

    "name": "src",

    "deps_file": "DEPS",

    "custom_deps": {},

  },

]

target_os = ["ios", "mac"]

以前,我的精力一直放在 iOS 平台的项目开发上,现在主要投入 Mac 平台的项目开发,所以,对 Mac 项目的关注度更大一些。下面的编译也以 Mac 为切入点。

WebRTC 的编译可以使用 ninja,也可以使用 Xcode。本文采用 Xcode 来编译 WebRTC 的 Mac 工程。

编译 WebRTC 的 Mac 工程

命令

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

cd/Users/suntongmian/Documents/workplace

ls

cdwebrtc

ls

cdsrc

ls

lsexamples

lsexamples/objc

lsexamples/objc/AppRTCMobile

gngenout/mac--ide=xcode

# 查看 ~/.bashrc 文件中是否配置有工具 depot_tools 的路径

cat~/.bashrc

export PATH=$PATH:/Users/suntongmian/Documents/workplace/webrtc/depot_tools

# 启动 gn 工具

source ~/.bashrc

gngenout/mac--ide=xcode

lsout/mac

# 启动 Xcode 工程

open-a Xcode.appout/mac/all.xcworkspace

命令执行过程

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

Last login: Fri Oct1820:59:20on ttys000

The default interactive shell is now zsh.

To update your accounttouse zsh, please run `chsh -s /bin/zsh`.

For more details, please visit https://support.apple.com/kb/HT208050.

suntongmiandeMacBook-Pro:~ suntongmian$

suntongmiandeMacBook-Pro:~ suntongmian$

suntongmiandeMacBook-Pro:~ suntongmian$

suntongmiandeMacBook-Pro:~ suntongmian$ cd /Users/suntongmian/Documents/workplace

suntongmiandeMacBook-Pro:workplace suntongmian$

suntongmiandeMacBook-Pro:workplace suntongmian$

suntongmiandeMacBook-Pro:workplace suntongmian$ ls

webrtc

suntongmiandeMacBook-Pro:workplace suntongmian$

suntongmiandeMacBook-Pro:workplace suntongmian$

suntongmiandeMacBook-Pro:workplace suntongmian$ cd webrtc/

suntongmiandeMacBook-Pro:webrtc suntongmian$

suntongmiandeMacBook-Pro:webrtc suntongmian$ ls

depot_tools src

suntongmiandeMacBook-Pro:webrtc suntongmian$

suntongmiandeMacBook-Pro:webrtc suntongmian$

suntongmiandeMacBook-Pro:webrtc suntongmian$ cd src/

suntongmiandeMacBook-Pro:src suntongmian$

suntongmiandeMacBook-Pro:src suntongmian$ ls

AUTHORSREADME.chromiumbuildtoolsiospresubmit_test.pystyle-guide.mdwebrtc

BUILD.gnREADME.mdcalllicense_template.txtpresubmit_test_mocks.pysystem_wrapperswebrtc.gni

CODE_OF_CONDUCT.mdWATCHLISTSchromiumloggingpylintrctalkwhitespace.txt

DEPSabseil-in-webrtc.mdcodereview.settingsmediaresourcestest

ENG_REVIEW_OWNERS api common_audio modules rtc_base testing

LICENSE audio common_types.h native-api.md rtc_tools third_party

OWNERS base common_video out sdk tools

PATENTS build data p2p stats tools_webrtc

PRESUBMIT.pybuild_overridesexamplespcstyle-guidevideo

suntongmiandeMacBook-Pro:src suntongmian$

suntongmiandeMacBook-Pro:src suntongmian$

suntongmiandeMacBook-Pro:src suntongmian$

suntongmiandeMacBook-Pro:src suntongmian$ ls examples/

BUILD.gnaarprojectandroidnativeapiobjcnativeapistunproberunityplugin

DEPS androidapp androidtests peerconnection stunserver

OWNERS androidjunit objc relayserver turnserver

suntongmiandeMacBook-Pro:src suntongmian$

suntongmiandeMacBook-Pro:src suntongmian$

suntongmiandeMacBook-Pro:src suntongmian$ ls examples/objc

AppRTCMobileIcon-120.pngIcon-180.pngIcon.pngREADME

suntongmiandeMacBook-Pro:src suntongmian$

suntongmiandeMacBook-Pro:src suntongmian$

suntongmiandeMacBook-Pro:src suntongmian$ ls examples/objc/AppRTCMobile/

ARDAppClient+Internal.hARDExternalSampleCapturer.hARDSettingsModel+Private.hARDStatsBuilder.mRTCIceServer+JSON.m

ARDAppClient.hARDExternalSampleCapturer.mARDSettingsModel.hARDTURNClient+Internal.hRTCSessionDescription+JSON.h

ARDAppClient.mARDJoinResponse+Internal.hARDSettingsModel.mARDTURNClient.hRTCSessionDescription+JSON.m

ARDAppEngineClient.hARDJoinResponse.hARDSettingsStore.hARDTURNClient.mcommon

ARDAppEngineClient.mARDJoinResponse.mARDSettingsStore.mARDWebSocketChannel.hios

ARDBitrateTracker.hARDMessageResponse+Internal.hARDSignalingChannel.hARDWebSocketChannel.mmac

ARDBitrateTracker.mARDMessageResponse.hARDSignalingMessage.hRTCIceCandidate+JSON.htests

ARDCaptureController.hARDMessageResponse.mARDSignalingMessage.mRTCIceCandidate+JSON.mthird_party

ARDCaptureController.mARDRoomServerClient.hARDStatsBuilder.hRTCIceServer+JSON.h

suntongmiandeMacBook-Pro:src suntongmian$

suntongmiandeMacBook-Pro:src suntongmian$

suntongmiandeMacBook-Pro:src suntongmian$

suntongmiandeMacBook-Pro:src suntongmian$

suntongmiandeMacBook-Pro:src suntongmian$ gn gen out/mac --ide=xcode

-bash: gn: command not found

suntongmiandeMacBook-Pro:src suntongmian$

suntongmiandeMacBook-Pro:src suntongmian$

suntongmiandeMacBook-Pro:src suntongmian$ cat ~/.bashrc

export PATH=$PATH:/Users/suntongmian/Documents/workplace/webrtc/depot_tools

suntongmiandeMacBook-Pro:src suntongmian$

suntongmiandeMacBook-Pro:src suntongmian$

suntongmiandeMacBook-Pro:src suntongmian$ source ~/.bashrc

suntongmiandeMacBook-Pro:src suntongmian$

suntongmiandeMacBook-Pro:src suntongmian$

suntongmiandeMacBook-Pro:src suntongmian$ gn gen out/mac --ide=xcode

Generating Xcode projects took200ms

Done. Made1056targets from206filesin2007ms

suntongmiandeMacBook-Pro:src suntongmian$

suntongmiandeMacBook-Pro:src suntongmian$

suntongmiandeMacBook-Pro:src suntongmian$

suntongmiandeMacBook-Pro:src suntongmian$ ls out/mac/

AppRTCMobile.appgenmacroproducts.xcodeproj

WebRTC.frameworkgenmoduleprotoc

all.xcworkspace genperf pyproto

args.gn genstring re2c

build.ninja genversion toolchain.ninja

build.ninja.d low_bandwidth_audio_perf_test.runtime_deps yasm

gen obj

suntongmiandeMacBook-Pro:src suntongmian$

suntongmiandeMacBook-Pro:src suntongmian$

suntongmiandeMacBook-Pro:src suntongmian$

suntongmiandeMacBook-Pro:src suntongmian$open-aXcode.app out/mac/all.xcworkspace

suntongmiandeMacBook-Pro:src suntongmian$

suntongmiandeMacBook-Pro:src suntongmian$

在 Xcode 中执行 target 的编译和运行

选择 target “AppRTCMobile”,执行 Run 操作,运行成功后就可以看到弹出的 Mac 端应用界面。

参考文献

[1] https://webrtc.org/native-code/ios/

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。