From 0b90feed793c19999f527b69295caadcce8e39df Mon Sep 17 00:00:00 2001 From: dijunkun Date: Fri, 17 Nov 2023 00:38:13 -0800 Subject: [PATCH] Support generate makefile --- README.md | 12 ++- .../screen_capture/linux/x11_session_impl.cpp | 2 +- .../remote_desk/thirdparty/ffmpeg/xmake.lua | 6 +- application/remote_desk/xmake.lua | 25 ++++-- src/common/common.cpp | 0 src/log/log.cpp | 0 src/ringbuffer/ringbuffer.cpp | 0 xmake.lua | 84 ++++++++++--------- 8 files changed, 76 insertions(+), 53 deletions(-) create mode 100644 src/common/common.cpp create mode 100644 src/log/log.cpp create mode 100644 src/ringbuffer/ringbuffer.cpp diff --git a/README.md b/README.md index 1f97af4..1469c4a 100644 --- a/README.md +++ b/README.md @@ -14,4 +14,14 @@ sudo apt-get install libxcb-randr0-dev libxcb-xtest0-dev libxcb-xinerama0-dev li sudo apt-get install libavcodec-dev libavformat-dev libavutil-dev libavfilter-dev libavdevice-dev -sudo apt remove libssl-dev libglib2.0-dev \ No newline at end of file +sudo apt remove libssl-dev libglib2.0-dev + +install: + @echo hello world + install -D build/linux/x86_64/release/remote_desk -t /usr/bin + install -D config/config.ini -t /usr/bin + install -D build/linux/x86_64/release/libprojectx.so -t /usr/lib + install -D thirdparty/nvcodec/Lib/x64/libnvidia-encode.so.1 -t /usr/lib + install -D thirdparty/nvcodec/Lib/x64/libnvidia-encode.so -t /usr/lib + install -D thirdparty/nvcodec/Lib/x64/libnvcuvid.so.1 -t /usr/lib + install -D thirdparty/nvcodec/Lib/x64/libnvcuvid.so -t /usr/lib \ No newline at end of file diff --git a/application/remote_desk/screen_capture/linux/x11_session_impl.cpp b/application/remote_desk/screen_capture/linux/x11_session_impl.cpp index d773e25..54aa7e9 100644 --- a/application/remote_desk/screen_capture/linux/x11_session_impl.cpp +++ b/application/remote_desk/screen_capture/linux/x11_session_impl.cpp @@ -20,7 +20,7 @@ X11SessionImpl::~X11SessionImpl() { void X11SessionImpl::Release() { delete this; } -int X11SessionImpl::Initialize() {} +int X11SessionImpl::Initialize() { return 0; } void X11SessionImpl::RegisterObserver(x11_session_observer *observer) { observer_ = observer; diff --git a/application/remote_desk/thirdparty/ffmpeg/xmake.lua b/application/remote_desk/thirdparty/ffmpeg/xmake.lua index b0edb9e..3e90c88 100644 --- a/application/remote_desk/thirdparty/ffmpeg/xmake.lua +++ b/application/remote_desk/thirdparty/ffmpeg/xmake.lua @@ -28,7 +28,7 @@ package("ffmpeg") add_versions("git:5.0.1", "n5.0.1") add_versions("git:4.0.2", "n4.0.2") - add_configs("gpl", {description = "Enable GPL code", default = true, type = "boolean"}) + add_configs("gpl", {description = "Enable GPL code", default = false, type = "boolean"}) add_configs("ffprobe", {description = "Enable ffprobe program.", default = false, type = "boolean"}) add_configs("ffmpeg", {description = "Enable ffmpeg program.", default = true, type = "boolean"}) add_configs("ffplay", {description = "Enable ffplay program.", default = false, type = "boolean"}) @@ -42,14 +42,14 @@ package("ffmpeg") add_configs("vdpau", {description = "Enable vdpau library.", default = false, type = "boolean"}) add_configs("hardcoded-tables", {description = "Enable hardcoded tables.", default = true, type = "boolean"}) add_configs("asm", {description = "Enable asm", default = false, type = "boolean"}) - add_configs("libx264", {description = "Enable libx264", default = true, type = "boolean"}) + add_configs("libopenh264", {description = "Enable libopenh264", default = true, type = "boolean"}) end add_links("avfilter", "avdevice", "avformat", "avcodec", "swscale", "swresample", "avutil") if is_plat("macosx") then add_frameworks("CoreFoundation", "Foundation", "CoreVideo", "CoreMedia", "AudioToolbox", "VideoToolbox", "Security") elseif is_plat("linux") then - add_syslinks("pthread") + add_syslinks("pthread", "openh264") end if is_plat("linux", "macosx") then diff --git a/application/remote_desk/xmake.lua b/application/remote_desk/xmake.lua index c063a70..e5c977e 100644 --- a/application/remote_desk/xmake.lua +++ b/application/remote_desk/xmake.lua @@ -68,13 +68,20 @@ target("remote_desk") "-lxcb-shm", "-lXext", "-lX11", "-lXv", "-ldl", "-lpthread", {force = true}) end + after_install(function (target) + os.cp("$(projectdir)/thirdparty/nvcodec/Lib/x64/*.so", "$(projectdir)/out/bin") + os.cp("$(projectdir)/thirdparty/nvcodec/Lib/x64/*.so.1", "$(projectdir)/out/bin") + os.cp("$(projectdir)/out/lib/*.so", "$(projectdir)/out/bin") + os.rm("$(projectdir)/out/include") + os.rm("$(projectdir)/out/lib") + end) -target("linux_capture") - set_kind("binary") - add_packages("sdl2", "imgui", "ffmpeg", "openh264") - add_files("remote_desk_gui/linux_capture.cpp") - add_ldflags("-lavformat", "-lavdevice", "-lavfilter", "-lavcodec", - "-lswscale", "-lavutil", "-lswresample", - "-lasound", "-lxcb-shape", "-lxcb-xfixes", "-lsndio", "-lxcb", - "-lxcb-shm", "-lXext", "-lX11", "-lXv", "-lpthread", "-lSDL2", "-lopenh264", - "-ldl" ,{force = true}) \ No newline at end of file +-- target("linux_capture") +-- set_kind("binary") +-- add_packages("sdl2", "imgui", "ffmpeg", "openh264") +-- add_files("remote_desk_gui/linux_capture.cpp") +-- add_ldflags("-lavformat", "-lavdevice", "-lavfilter", "-lavcodec", +-- "-lswscale", "-lavutil", "-lswresample", +-- "-lasound", "-lxcb-shape", "-lxcb-xfixes", "-lsndio", "-lxcb", +-- "-lxcb-shm", "-lXext", "-lX11", "-lXv", "-lpthread", "-lSDL2", "-lopenh264", +-- "-ldl" ,{force = true}) \ No newline at end of file diff --git a/src/common/common.cpp b/src/common/common.cpp new file mode 100644 index 0000000..e69de29 diff --git a/src/log/log.cpp b/src/log/log.cpp new file mode 100644 index 0000000..e69de29 diff --git a/src/ringbuffer/ringbuffer.cpp b/src/ringbuffer/ringbuffer.cpp new file mode 100644 index 0000000..e69de29 diff --git a/xmake.lua b/xmake.lua index ee5c90a..065b4d4 100644 --- a/xmake.lua +++ b/xmake.lua @@ -5,6 +5,7 @@ set_license("LGPL-3.0") add_rules("mode.release", "mode.debug") set_languages("c++17") +set_installdir("$(projectdir)/out") option("server_only") set_showmenu(true) @@ -20,7 +21,7 @@ if is_os("windows") then add_links("windowsapp", "User32", "Strmiids", "Mfuuid", "Secur32", "Bcrypt") add_requires("cuda") elseif is_os("linux") then - set_config("cflags", "-fPIC") + add_cxflags("-fPIC") add_syslinks("pthread") elseif is_os("macosx") then add_ldflags("-ld_classic", {force = true}) @@ -39,7 +40,7 @@ else add_packages("vcpkg::libnice") add_requires("openh264 2.1.1", {configs = {shared = false}}) elseif is_os("linux") then - add_requires("ffmpeg 5.1.2") + add_requires("ffmpeg 5.1.2", {system = false}) add_requires("glib", {system = true}) add_requires("vcpkg::libnice 0.1.21") add_requires("openh264 2.1.1", {configs = {shared = false}}) @@ -51,16 +52,17 @@ else end includes("application/remote_desk") - includes("application/signal_server") + -- includes("application/signal_server") target("log") - set_kind("headeronly") + set_kind("static") add_packages("spdlog") - add_headerfiles("src/log/log.h") + add_files("src/log/log.cpp") add_includedirs("src/log", {public = true}) target("common") - set_kind("headeronly") + set_kind("static") + add_files("src/common/common.cpp") add_includedirs("src/common", {public = true}) target("inih") @@ -69,7 +71,8 @@ else add_includedirs("src/inih", {public = true}) target("ringbuffer") - set_kind("headeronly") + set_kind("static") + add_files("src/ringbuffer/ringbuffer.cpp") add_includedirs("src/ringbuffer", {public = true}) target("thread") @@ -219,45 +222,48 @@ else set_kind("shared") add_deps("log") add_deps("pc") + add_installfiles("src/interface/*.h", {prefixdir = "include"}) add_files("src/rtc/*.cpp") add_packages("asio", "nlohmann_json", "cuda") add_includedirs("src/rtc", "src/pc", "src/interface") add_rules("utils.symbols.export_all", {export_classes = true}) - -- set_policy("build.merge_archive", true) - -- set_targetdir("$(projectdir)/libdrtc/lib") + -- after_install(function (target) + -- os.rm("$(projectdir)/out/lib/*.a") + -- os.rm("$(projectdir)/out/include/log.h") + -- end) - target("host") - set_kind("binary") - add_deps("projectx") - add_files("tests/peerconnection/host.cpp") - add_includedirs("src/interface") + -- target("host") + -- set_kind("binary") + -- add_deps("projectx") + -- add_files("tests/peerconnection/host.cpp") + -- add_includedirs("src/interface") - target("guest") - set_kind("binary") - add_deps("projectx") - add_files("tests/peerconnection/guest.cpp") - add_includedirs("src/interface") + -- target("guest") + -- set_kind("binary") + -- add_deps("projectx") + -- add_files("tests/peerconnection/guest.cpp") + -- add_includedirs("src/interface") - target("nicetest") - set_kind("binary") - add_files("tests/peerconnection/nice.cpp") - add_includedirs("E:/SourceCode/vcpkg/installed/x64-windows-static/include/glib-2.0") - add_includedirs("E:/SourceCode/vcpkg/installed/x64-windows-static/lib/glib-2.0/include") - add_linkdirs("E:/SourceCode/vcpkg/installed/x64-windows-static/lib") - add_links("nice", "glib-2.0", "gio-2.0", "gmodule-2.0", "gobject-2.0", "gthread-2.0", - "pcre2-8", "pcre2-16", "pcre2-32", "pcre2-posix", - "zlib", "ffi", "libcrypto", "libssl", "intl", "iconv", "charset", "bz2", - "Shell32", "Advapi32", "Dnsapi", "Shlwapi", "Iphlpapi") + -- target("nicetest") + -- set_kind("binary") + -- add_files("tests/peerconnection/nice.cpp") + -- add_includedirs("E:/SourceCode/vcpkg/installed/x64-windows-static/include/glib-2.0") + -- add_includedirs("E:/SourceCode/vcpkg/installed/x64-windows-static/lib/glib-2.0/include") + -- add_linkdirs("E:/SourceCode/vcpkg/installed/x64-windows-static/lib") + -- add_links("nice", "glib-2.0", "gio-2.0", "gmodule-2.0", "gobject-2.0", "gthread-2.0", + -- "pcre2-8", "pcre2-16", "pcre2-32", "pcre2-posix", + -- "zlib", "ffi", "libcrypto", "libssl", "intl", "iconv", "charset", "bz2", + -- "Shell32", "Advapi32", "Dnsapi", "Shlwapi", "Iphlpapi") - target("fec_client") - set_kind("binary") - add_packages("openfec") - add_files("tests/fec/simple_client.cpp") - add_includedirs("tests/fec") + -- target("fec_client") + -- set_kind("binary") + -- add_packages("openfec") + -- add_files("tests/fec/simple_client.cpp") + -- add_includedirs("tests/fec") - target("fec_server") - set_kind("binary") - add_packages("openfec") - add_files("tests/fec/simple_server.cpp") - add_includedirs("tests/fec") + -- target("fec_server") + -- set_kind("binary") + -- add_packages("openfec") + -- add_files("tests/fec/simple_server.cpp") + -- add_includedirs("tests/fec") end \ No newline at end of file