diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 57df77c4..75208c38 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -156,17 +156,26 @@ jobs: strategy: fail-fast: false matrix: - name: - - ubuntu-20.04_x86_64 - - ubuntu-22.04_x86_64 - - android - name: Build sora-cpp-sdk for ${{ matrix.name }} - runs-on: ${{ matrix.name == 'ubuntu-22.04_x86_64' && 'ubuntu-22.04' || 'ubuntu-20.04' }} + platform: + - name: ubuntu-20.04_x86_64 + runs-on: ubuntu-20.04 + os: ubuntu + - name: ubuntu-22.04_x86_64 + runs-on: ubuntu-22.04 + os: ubuntu + - name: ubuntu-24.04_x86_64 + runs-on: ubuntu-24.04 + os: ubuntu + - name: android + runs-on: ubuntu-22.04 + os: android + name: Build sora-cpp-sdk for ${{ matrix.platform.name }} + runs-on: ${{ matrix.platform.runs-on }} env: TEST_SIGNALING_URL: ${{ secrets.TEST_SIGNALING_URL }} TEST_CHANNEL_ID_PREFIX: ${{ secrets.TEST_CHANNEL_ID_PREFIX }} TEST_SECRET_KEY: ${{ secrets.TEST_SECRET_KEY }} - TEST_MATRIX_NAME: ${{ matrix.name }} + TEST_MATRIX_NAME: ${{ matrix.platform.name }} steps: - uses: actions/checkout@v4 - name: Disk cleanup @@ -177,7 +186,10 @@ jobs: sudo du -h -d1 /usr/local/share sudo du -h -d1 /usr/local/lib sudo du -h -d1 /usr/share - docker rmi `docker images -q -a` + RMI=`docker images -q -a` + if [ -n "$RMI" ]; then + docker rmi $RMI + fi # 4.6G sudo rm -rf /usr/local/.ghcup # 1.7G @@ -185,19 +197,41 @@ jobs: # 1.4G sudo rm -rf /usr/share/dotnet df -h - - name: Install deps for ${{ matrix.name }} - if: matrix.name == 'ubuntu-20.04_x86_64' || matrix.name == 'ubuntu-22.04_x86_64' + # Ubuntu 24.04 だと libtinfo5 が見つからない問題があるので、その修正 + # ref: https://qiita.com/gengen16k/items/88cf3c18a40a94205fab + - name: Fix CUDA issues for Ubuntu 24.04 + if: matrix.platform.name == 'ubuntu-24.04_x86_64' + run: | + sudo tee /etc/apt/sources.list.d/jammy.list << EOF + deb http://archive.ubuntu.com/ubuntu/ jammy universe + EOF + + sudo tee /etc/apt/preferences.d/pin-jammy <> $GITHUB_OUTPUT echo "boost_name=${BOOST_PACKAGE_NAME}" >> $GITHUB_OUTPUT id: package_name @@ -229,33 +263,33 @@ jobs: uses: actions/upload-artifact@v4 with: name: ${{ steps.package_name.outputs.name }} - path: _package/${{ matrix.name }}/release/${{ steps.package_name.outputs.name }} + path: _package/${{ matrix.platform.name }}/release/${{ steps.package_name.outputs.name }} - name: Upload Boost Artifact uses: actions/upload-artifact@v4 with: name: ${{ steps.package_name.outputs.boost_name }} - path: _package/${{ matrix.name }}/release/${{ steps.package_name.outputs.boost_name }} + path: _package/${{ matrix.platform.name }}/release/${{ steps.package_name.outputs.boost_name }} - name: Upload Environment uses: actions/upload-artifact@v4 with: - name: ${{ matrix.name }}.env - path: _package/${{ matrix.name }}/release/sora.env + name: ${{ matrix.platform.name }}.env + path: _package/${{ matrix.platform.name }}/release/sora.env # Examples のビルド - name: Build Examples run: | cd examples - mkdir examples_${{ matrix.name }} + mkdir examples_${{ matrix.platform.name }} for app in sdl_sample sumomo messaging_recvonly_sample; do - python3 $app/${{ matrix.name }}/run.py --local-sora-cpp-sdk-dir .. - cp _build/${{ matrix.name }}/release/$app/$app examples_${{ matrix.name }} + python3 $app/${{ matrix.platform.name }}/run.py --local-sora-cpp-sdk-dir .. + cp _build/${{ matrix.platform.name }}/release/$app/$app examples_${{ matrix.platform.name }} done - if: matrix.name == 'ubuntu-20.04_x86_64' || matrix.name == 'ubuntu-22.04_x86_64' + if: matrix.platform.os == 'ubuntu' - name: Upload Examples Artifact uses: actions/upload-artifact@v4 with: - name: examples_${{ matrix.name }} - path: examples/examples_${{ matrix.name }} - if: matrix.name == 'ubuntu-20.04_x86_64' || matrix.name == 'ubuntu-22.04_x86_64' + name: examples_${{ matrix.platform.name }} + path: examples/examples_${{ matrix.platform.name }} + if: matrix.platform.os == 'ubuntu' create-release: name: Create Release @@ -282,6 +316,9 @@ jobs: - uses: ./.github/actions/download with: platform: ubuntu-22.04_x86_64 + - uses: ./.github/actions/download + with: + platform: ubuntu-24.04_x86_64 - uses: ./.github/actions/download with: platform: android diff --git a/CHANGES.md b/CHANGES.md index 1d009842..5a6e5ef3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -31,7 +31,7 @@ - @enm10k - [UPDATE] CLI11 を 2.4.2 にあげる - @enm10k -- [UPDATE] libwebrtc を m125.6422.2.1 にあげる +- [UPDATE] libwebrtc を m125.6422.2.5 にあげる - Android の test アプリがリンクできなくなったため、リンカーを Android NDK のものから libwebrtc のものに変更 - リンカーのバージョンの違いによる互換性の問題でエラーが発生していた - @melpon @enm10k @@ -47,6 +47,8 @@ - @melpon - [ADD] NVIDIA Video Codec SDK を H265 に対応する - @melpon +- [ADD] Ubuntu 24.04 に対応する + - @melpon ## 2024.6.1 (2024-04-16) diff --git a/CMakeLists.txt b/CMakeLists.txt index c8346228..21e76e52 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,6 +45,11 @@ elseif (SORA_TARGET STREQUAL "ubuntu-22.04_x86_64") set(SORA_TARGET_OS_VERSION "22.04") set(SORA_TARGET_ARCH "x86_64") set(SORA_TARGET_DEF "SORA_CPP_SDK_UBUNTU_2204") +elseif (SORA_TARGET STREQUAL "ubuntu-24.04_x86_64") + set(SORA_TARGET_OS "ubuntu") + set(SORA_TARGET_OS_VERSION "24.04") + set(SORA_TARGET_ARCH "x86_64") + set(SORA_TARGET_DEF "SORA_CPP_SDK_UBUNTU_2404") endif() list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) diff --git a/VERSION b/VERSION index ac0b2c2d..2a7e333f 100644 --- a/VERSION +++ b/VERSION @@ -1,5 +1,5 @@ SORA_CPP_SDK_VERSION=2024.7.0-canary.3 -WEBRTC_BUILD_VERSION=m125.6422.2.1 +WEBRTC_BUILD_VERSION=m125.6422.2.5 BOOST_VERSION=1.85.0 CMAKE_VERSION=3.28.1 CUDA_VERSION=11.8.0-1 diff --git a/examples/VERSION b/examples/VERSION index 2eb62b3d..355ac474 100644 --- a/examples/VERSION +++ b/examples/VERSION @@ -1,5 +1,5 @@ SORA_CPP_SDK_VERSION=2024.7.0-canary.3 -WEBRTC_BUILD_VERSION=m125.6422.2.1 +WEBRTC_BUILD_VERSION=m125.6422.2.5 BOOST_VERSION=1.85.0 CMAKE_VERSION=3.28.1 SDL2_VERSION=2.30.3 diff --git a/examples/messaging_recvonly_sample/ubuntu-24.04_x86_64/CMakeLists.txt b/examples/messaging_recvonly_sample/ubuntu-24.04_x86_64/CMakeLists.txt new file mode 100644 index 00000000..48fbba9f --- /dev/null +++ b/examples/messaging_recvonly_sample/ubuntu-24.04_x86_64/CMakeLists.txt @@ -0,0 +1,41 @@ +cmake_minimum_required(VERSION 3.23) + +# Only interpret if() arguments as variables or keywords when unquoted. +cmake_policy(SET CMP0054 NEW) +# MSVC runtime library flags are selected by an abstraction. +cmake_policy(SET CMP0091 NEW) + +set(WEBRTC_INCLUDE_DIR "" CACHE PATH "WebRTC のインクルードディレクトリ") +set(WEBRTC_LIBRARY_DIR "" CACHE PATH "WebRTC のライブラリディレクトリ") +set(WEBRTC_LIBRARY_NAME "webrtc" CACHE STRING "WebRTC のライブラリ名") +set(BOOST_ROOT "" CACHE PATH "Boost のルートディレクトリ") +set(SORA_DIR "" CACHE PATH "Sora のルートディレクトリ") +set(CLI11_DIR "" CACHE PATH "CLI11 のルートディレクトリ") + +project(sora-sdl-sample C CXX) + +list(APPEND CMAKE_PREFIX_PATH ${SORA_DIR}) +list(APPEND CMAKE_MODULE_PATH ${SORA_DIR}/share/cmake) + +set(Boost_USE_STATIC_LIBS ON) + +find_package(Boost REQUIRED COMPONENTS json filesystem) +find_package(WebRTC REQUIRED) +find_package(Sora REQUIRED) +find_package(Threads REQUIRED) +find_package(Libva REQUIRED) +find_package(Libdrm REQUIRED) + +add_executable(messaging_recvonly_sample) +set_target_properties(messaging_recvonly_sample PROPERTIES CXX_STANDARD 20 C_STANDARD 20) +set_target_properties(messaging_recvonly_sample PROPERTIES POSITION_INDEPENDENT_CODE ON) +target_sources(messaging_recvonly_sample PRIVATE ../src/messaging_recvonly_sample.cpp) + +target_compile_options(messaging_recvonly_sample + PRIVATE + "$<$:-nostdinc++>" + "$<$:-isystem${LIBCXX_INCLUDE_DIR}>" +) +target_include_directories(messaging_recvonly_sample PRIVATE ${CLI11_DIR}/include) +target_link_libraries(messaging_recvonly_sample PRIVATE Sora::sora) +target_compile_definitions(messaging_recvonly_sample PRIVATE CLI11_HAS_FILESYSTEM=0) diff --git a/examples/messaging_recvonly_sample/ubuntu-24.04_x86_64/run.py b/examples/messaging_recvonly_sample/ubuntu-24.04_x86_64/run.py new file mode 100644 index 00000000..a9b1f861 --- /dev/null +++ b/examples/messaging_recvonly_sample/ubuntu-24.04_x86_64/run.py @@ -0,0 +1,189 @@ +import argparse +import multiprocessing +import os +import sys +from typing import List, Optional + +PROJECT_DIR = os.path.abspath(os.path.dirname(__file__)) +BASE_DIR = os.path.join(PROJECT_DIR, "..", "..") +BUILDBASE_DIR = os.path.join(BASE_DIR, "..") +sys.path.insert(0, BUILDBASE_DIR) + + +from buildbase import ( # noqa: E402 + add_path, + add_sora_arguments, + add_webrtc_build_arguments, + build_sora, + build_webrtc, + cd, + cmake_path, + cmd, + get_sora_info, + get_webrtc_info, + install_cli11, + install_cmake, + install_llvm, + install_sora_and_deps, + install_webrtc, + mkdir_p, + read_version_file, +) + + +def install_deps( + source_dir, + build_dir, + install_dir, + debug, + local_webrtc_build_dir: Optional[str], + local_webrtc_build_args: List[str], + local_sora_cpp_sdk_dir: Optional[str], + local_sora_cpp_sdk_args: List[str], +): + with cd(BASE_DIR): + version = read_version_file("VERSION") + + # WebRTC + if local_webrtc_build_dir is None: + install_webrtc_args = { + "version": version["WEBRTC_BUILD_VERSION"], + "version_file": os.path.join(install_dir, "webrtc.version"), + "source_dir": source_dir, + "install_dir": install_dir, + "platform": "ubuntu-24.04_x86_64", + } + install_webrtc(**install_webrtc_args) + else: + build_webrtc_args = { + "platform": "ubuntu-24.04_x86_64", + "local_webrtc_build_dir": local_webrtc_build_dir, + "local_webrtc_build_args": local_webrtc_build_args, + "debug": debug, + } + build_webrtc(**build_webrtc_args) + + webrtc_info = get_webrtc_info( + "ubuntu-24.04_x86_64", local_webrtc_build_dir, install_dir, debug + ) + + if local_webrtc_build_dir is None: + webrtc_version = read_version_file(webrtc_info.version_file) + + # LLVM + tools_url = webrtc_version["WEBRTC_SRC_TOOLS_URL"] + tools_commit = webrtc_version["WEBRTC_SRC_TOOLS_COMMIT"] + libcxx_url = webrtc_version["WEBRTC_SRC_THIRD_PARTY_LIBCXX_SRC_URL"] + libcxx_commit = webrtc_version["WEBRTC_SRC_THIRD_PARTY_LIBCXX_SRC_COMMIT"] + buildtools_url = webrtc_version["WEBRTC_SRC_BUILDTOOLS_URL"] + buildtools_commit = webrtc_version["WEBRTC_SRC_BUILDTOOLS_COMMIT"] + install_llvm_args = { + "version": f"{tools_url}.{tools_commit}." + f"{libcxx_url}.{libcxx_commit}." + f"{buildtools_url}.{buildtools_commit}", + "version_file": os.path.join(install_dir, "llvm.version"), + "install_dir": install_dir, + "tools_url": tools_url, + "tools_commit": tools_commit, + "libcxx_url": libcxx_url, + "libcxx_commit": libcxx_commit, + "buildtools_url": buildtools_url, + "buildtools_commit": buildtools_commit, + } + install_llvm(**install_llvm_args) + + # Sora C++ SDK, Boost + if local_sora_cpp_sdk_dir is None: + install_sora_and_deps("ubuntu-24.04_x86_64", source_dir, install_dir) + else: + build_sora( + "ubuntu-24.04_x86_64", + local_sora_cpp_sdk_dir, + local_sora_cpp_sdk_args, + debug, + local_webrtc_build_dir, + ) + + # CMake + install_cmake_args = { + "version": version["CMAKE_VERSION"], + "version_file": os.path.join(install_dir, "cmake.version"), + "source_dir": source_dir, + "install_dir": install_dir, + "platform": "linux-x86_64", + "ext": "tar.gz", + } + install_cmake(**install_cmake_args) + add_path(os.path.join(install_dir, "cmake", "bin")) + + # CLI11 + install_cli11_args = { + "version": version["CLI11_VERSION"], + "version_file": os.path.join(install_dir, "cli11.version"), + "install_dir": install_dir, + } + install_cli11(**install_cli11_args) + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("--debug", action="store_true") + add_webrtc_build_arguments(parser) + add_sora_arguments(parser) + + args = parser.parse_args() + + configuration_dir = "debug" if args.debug else "release" + platform = "ubuntu-24.04_x86_64" + source_dir = os.path.join(BASE_DIR, "_source", platform, configuration_dir) + build_dir = os.path.join(BASE_DIR, "_build", platform, configuration_dir) + install_dir = os.path.join(BASE_DIR, "_install", platform, configuration_dir) + mkdir_p(source_dir) + mkdir_p(build_dir) + mkdir_p(install_dir) + + install_deps( + source_dir, + build_dir, + install_dir, + args.debug, + args.local_webrtc_build_dir, + args.local_webrtc_build_args, + args.local_sora_cpp_sdk_dir, + args.local_sora_cpp_sdk_args, + ) + + configuration = "Debug" if args.debug else "Release" + + sample_build_dir = os.path.join(build_dir, "messaging_recvonly_sample") + mkdir_p(sample_build_dir) + with cd(sample_build_dir): + webrtc_info = get_webrtc_info( + "ubuntu-24.04_x86_64", args.local_webrtc_build_dir, install_dir, args.debug + ) + sora_info = get_sora_info(platform, args.local_sora_cpp_sdk_dir, install_dir, args.debug) + + cmake_args = [] + cmake_args.append(f"-DCMAKE_BUILD_TYPE={configuration}") + cmake_args.append(f"-DBOOST_ROOT={cmake_path(sora_info.boost_install_dir)}") + cmake_args.append(f"-DWEBRTC_INCLUDE_DIR={cmake_path(webrtc_info.webrtc_include_dir)}") + cmake_args.append(f"-DWEBRTC_LIBRARY_DIR={cmake_path(webrtc_info.webrtc_library_dir)}") + cmake_args.append(f"-DSORA_DIR={cmake_path(sora_info.sora_install_dir)}") + cmake_args.append(f"-DCLI11_DIR={cmake_path(os.path.join(install_dir, 'cli11'))}") + + # クロスコンパイルの設定。 + # 本来は toolchain ファイルに書く内容 + cmake_args += [ + f"-DCMAKE_C_COMPILER={os.path.join(webrtc_info.clang_dir, 'bin', 'clang')}", + f"-DCMAKE_CXX_COMPILER={os.path.join(webrtc_info.clang_dir, 'bin', 'clang++')}", + f"-DLIBCXX_INCLUDE_DIR={cmake_path(os.path.join(webrtc_info.libcxx_dir, 'include'))}", + ] + + cmd(["cmake", os.path.join(PROJECT_DIR)] + cmake_args) + cmd( + ["cmake", "--build", ".", f"-j{multiprocessing.cpu_count()}", "--config", configuration] + ) + + +if __name__ == "__main__": + main() diff --git a/examples/sdl_sample/ubuntu-24.04_x86_64/CMakeLists.txt b/examples/sdl_sample/ubuntu-24.04_x86_64/CMakeLists.txt new file mode 100644 index 00000000..7d57c4a5 --- /dev/null +++ b/examples/sdl_sample/ubuntu-24.04_x86_64/CMakeLists.txt @@ -0,0 +1,43 @@ +cmake_minimum_required(VERSION 3.23) + +# Only interpret if() arguments as variables or keywords when unquoted. +cmake_policy(SET CMP0054 NEW) +# MSVC runtime library flags are selected by an abstraction. +cmake_policy(SET CMP0091 NEW) + +set(WEBRTC_INCLUDE_DIR "" CACHE PATH "WebRTC のインクルードディレクトリ") +set(WEBRTC_LIBRARY_DIR "" CACHE PATH "WebRTC のライブラリディレクトリ") +set(WEBRTC_LIBRARY_NAME "webrtc" CACHE STRING "WebRTC のライブラリ名") +set(BOOST_ROOT "" CACHE PATH "Boost のルートディレクトリ") +set(SORA_DIR "" CACHE PATH "Sora のルートディレクトリ") +set(SDL2_DIR "" CACHE PATH "SDL2 のルートディレクトリ") +set(CLI11_DIR "" CACHE PATH "CLI11 のルートディレクトリ") + +project(sora-sdl-sample C CXX) + +list(APPEND CMAKE_PREFIX_PATH ${SORA_DIR} ${SDL2_DIR}) +list(APPEND CMAKE_MODULE_PATH ${SORA_DIR}/share/cmake) + +set(Boost_USE_STATIC_LIBS ON) + +find_package(Boost REQUIRED COMPONENTS json filesystem) +find_package(WebRTC REQUIRED) +find_package(Sora REQUIRED) +find_package(SDL2 REQUIRED) +find_package(Threads REQUIRED) +find_package(Libva REQUIRED) +find_package(Libdrm REQUIRED) + +add_executable(sdl_sample) +set_target_properties(sdl_sample PROPERTIES CXX_STANDARD 20 C_STANDARD 20) +set_target_properties(sdl_sample PROPERTIES POSITION_INDEPENDENT_CODE ON) +target_sources(sdl_sample PRIVATE ../src/sdl_sample.cpp ../src/sdl_renderer.cpp) + +target_compile_options(sdl_sample + PRIVATE + "$<$:-nostdinc++>" + "$<$:-isystem${LIBCXX_INCLUDE_DIR}>" +) +target_include_directories(sdl_sample PRIVATE ${CLI11_DIR}/include) +target_link_libraries(sdl_sample PRIVATE Sora::sora SDL2::SDL2 SDL2::SDL2main) +target_compile_definitions(sdl_sample PRIVATE CLI11_HAS_FILESYSTEM=0) diff --git a/examples/sdl_sample/ubuntu-24.04_x86_64/run.py b/examples/sdl_sample/ubuntu-24.04_x86_64/run.py new file mode 100644 index 00000000..899e5e15 --- /dev/null +++ b/examples/sdl_sample/ubuntu-24.04_x86_64/run.py @@ -0,0 +1,207 @@ +import argparse +import multiprocessing +import os +import sys +from typing import List, Optional + +PROJECT_DIR = os.path.abspath(os.path.dirname(__file__)) +BASE_DIR = os.path.join(PROJECT_DIR, "..", "..") +BUILDBASE_DIR = os.path.join(BASE_DIR, "..") +sys.path.insert(0, BUILDBASE_DIR) + + +from buildbase import ( # noqa: E402 + add_path, + add_sora_arguments, + add_webrtc_build_arguments, + build_sora, + build_webrtc, + cd, + cmake_path, + cmd, + get_sora_info, + get_webrtc_info, + install_cli11, + install_cmake, + install_llvm, + install_sdl2, + install_sora_and_deps, + install_webrtc, + mkdir_p, + read_version_file, +) + + +def install_deps( + source_dir, + build_dir, + install_dir, + debug, + local_webrtc_build_dir: Optional[str], + local_webrtc_build_args: List[str], + local_sora_cpp_sdk_dir: Optional[str], + local_sora_cpp_sdk_args: List[str], +): + with cd(BASE_DIR): + version = read_version_file("VERSION") + + # WebRTC + if local_webrtc_build_dir is None: + install_webrtc_args = { + "version": version["WEBRTC_BUILD_VERSION"], + "version_file": os.path.join(install_dir, "webrtc.version"), + "source_dir": source_dir, + "install_dir": install_dir, + "platform": "ubuntu-24.04_x86_64", + } + install_webrtc(**install_webrtc_args) + else: + build_webrtc_args = { + "platform": "ubuntu-24.04_x86_64", + "local_webrtc_build_dir": local_webrtc_build_dir, + "local_webrtc_build_args": local_webrtc_build_args, + "debug": debug, + } + build_webrtc(**build_webrtc_args) + + webrtc_info = get_webrtc_info( + "ubuntu-24.04_x86_64", local_webrtc_build_dir, install_dir, debug + ) + + if local_webrtc_build_dir is None: + webrtc_version = read_version_file(webrtc_info.version_file) + + # LLVM + tools_url = webrtc_version["WEBRTC_SRC_TOOLS_URL"] + tools_commit = webrtc_version["WEBRTC_SRC_TOOLS_COMMIT"] + libcxx_url = webrtc_version["WEBRTC_SRC_THIRD_PARTY_LIBCXX_SRC_URL"] + libcxx_commit = webrtc_version["WEBRTC_SRC_THIRD_PARTY_LIBCXX_SRC_COMMIT"] + buildtools_url = webrtc_version["WEBRTC_SRC_BUILDTOOLS_URL"] + buildtools_commit = webrtc_version["WEBRTC_SRC_BUILDTOOLS_COMMIT"] + install_llvm_args = { + "version": f"{tools_url}.{tools_commit}." + f"{libcxx_url}.{libcxx_commit}." + f"{buildtools_url}.{buildtools_commit}", + "version_file": os.path.join(install_dir, "llvm.version"), + "install_dir": install_dir, + "tools_url": tools_url, + "tools_commit": tools_commit, + "libcxx_url": libcxx_url, + "libcxx_commit": libcxx_commit, + "buildtools_url": buildtools_url, + "buildtools_commit": buildtools_commit, + } + install_llvm(**install_llvm_args) + + # Sora C++ SDK, Boost + if local_sora_cpp_sdk_dir is None: + install_sora_and_deps("ubuntu-24.04_x86_64", source_dir, install_dir) + else: + build_sora( + "ubuntu-24.04_x86_64", + local_sora_cpp_sdk_dir, + local_sora_cpp_sdk_args, + debug, + local_webrtc_build_dir, + ) + + # CMake + install_cmake_args = { + "version": version["CMAKE_VERSION"], + "version_file": os.path.join(install_dir, "cmake.version"), + "source_dir": source_dir, + "install_dir": install_dir, + "platform": "linux-x86_64", + "ext": "tar.gz", + } + install_cmake(**install_cmake_args) + add_path(os.path.join(install_dir, "cmake", "bin")) + + # SDL2 + install_sdl2_args = { + "version": version["SDL2_VERSION"], + "version_file": os.path.join(install_dir, "sdl2.version"), + "source_dir": source_dir, + "build_dir": build_dir, + "install_dir": install_dir, + "debug": debug, + "platform": "linux", + "cmake_args": [ + f"-DCMAKE_C_COMPILER={os.path.join(webrtc_info.clang_dir, 'bin', 'clang')}", + f"-DCMAKE_CXX_COMPILER={os.path.join(webrtc_info.clang_dir, 'bin', 'clang++')}", + ], + } + install_sdl2(**install_sdl2_args) + + # CLI11 + install_cli11_args = { + "version": version["CLI11_VERSION"], + "version_file": os.path.join(install_dir, "cli11.version"), + "install_dir": install_dir, + } + install_cli11(**install_cli11_args) + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("--debug", action="store_true") + add_webrtc_build_arguments(parser) + add_sora_arguments(parser) + + args = parser.parse_args() + + configuration_dir = "debug" if args.debug else "release" + platform = "ubuntu-24.04_x86_64" + source_dir = os.path.join(BASE_DIR, "_source", platform, configuration_dir) + build_dir = os.path.join(BASE_DIR, "_build", platform, configuration_dir) + install_dir = os.path.join(BASE_DIR, "_install", platform, configuration_dir) + mkdir_p(source_dir) + mkdir_p(build_dir) + mkdir_p(install_dir) + + install_deps( + source_dir, + build_dir, + install_dir, + args.debug, + args.local_webrtc_build_dir, + args.local_webrtc_build_args, + args.local_sora_cpp_sdk_dir, + args.local_sora_cpp_sdk_args, + ) + + configuration = "Debug" if args.debug else "Release" + + sample_build_dir = os.path.join(build_dir, "sdl_sample") + mkdir_p(sample_build_dir) + with cd(sample_build_dir): + webrtc_info = get_webrtc_info( + "ubuntu-24.04_x86_64", args.local_webrtc_build_dir, install_dir, args.debug + ) + sora_info = get_sora_info(platform, args.local_sora_cpp_sdk_dir, install_dir, args.debug) + + cmake_args = [] + cmake_args.append(f"-DCMAKE_BUILD_TYPE={configuration}") + cmake_args.append(f"-DBOOST_ROOT={cmake_path(sora_info.boost_install_dir)}") + cmake_args.append(f"-DWEBRTC_INCLUDE_DIR={cmake_path(webrtc_info.webrtc_include_dir)}") + cmake_args.append(f"-DWEBRTC_LIBRARY_DIR={cmake_path(webrtc_info.webrtc_library_dir)}") + cmake_args.append(f"-DSORA_DIR={cmake_path(sora_info.sora_install_dir)}") + cmake_args.append(f"-DCLI11_DIR={cmake_path(os.path.join(install_dir, 'cli11'))}") + cmake_args.append(f"-DSDL2_DIR={cmake_path(os.path.join(install_dir, 'sdl2'))}") + + # クロスコンパイルの設定。 + # 本来は toolchain ファイルに書く内容 + cmake_args += [ + f"-DCMAKE_C_COMPILER={os.path.join(webrtc_info.clang_dir, 'bin', 'clang')}", + f"-DCMAKE_CXX_COMPILER={os.path.join(webrtc_info.clang_dir, 'bin', 'clang++')}", + f"-DLIBCXX_INCLUDE_DIR={cmake_path(os.path.join(webrtc_info.libcxx_dir, 'include'))}", + ] + + cmd(["cmake", os.path.join(PROJECT_DIR)] + cmake_args) + cmd( + ["cmake", "--build", ".", f"-j{multiprocessing.cpu_count()}", "--config", configuration] + ) + + +if __name__ == "__main__": + main() diff --git a/examples/sumomo/ubuntu-24.04_x86_64/CMakeLists.txt b/examples/sumomo/ubuntu-24.04_x86_64/CMakeLists.txt new file mode 100644 index 00000000..c41f6cbc --- /dev/null +++ b/examples/sumomo/ubuntu-24.04_x86_64/CMakeLists.txt @@ -0,0 +1,43 @@ +cmake_minimum_required(VERSION 3.23) + +# Only interpret if() arguments as variables or keywords when unquoted. +cmake_policy(SET CMP0054 NEW) +# MSVC runtime library flags are selected by an abstraction. +cmake_policy(SET CMP0091 NEW) + +set(WEBRTC_INCLUDE_DIR "" CACHE PATH "WebRTC のインクルードディレクトリ") +set(WEBRTC_LIBRARY_DIR "" CACHE PATH "WebRTC のライブラリディレクトリ") +set(WEBRTC_LIBRARY_NAME "webrtc" CACHE STRING "WebRTC のライブラリ名") +set(BOOST_ROOT "" CACHE PATH "Boost のルートディレクトリ") +set(SORA_DIR "" CACHE PATH "Sora のルートディレクトリ") +set(SDL2_DIR "" CACHE PATH "SDL2 のルートディレクトリ") +set(CLI11_DIR "" CACHE PATH "CLI11 のルートディレクトリ") + +project(sora-sdl-sample C CXX) + +list(APPEND CMAKE_PREFIX_PATH ${SORA_DIR} ${SDL2_DIR}) +list(APPEND CMAKE_MODULE_PATH ${SORA_DIR}/share/cmake) + +set(Boost_USE_STATIC_LIBS ON) + +find_package(Boost REQUIRED COMPONENTS json filesystem) +find_package(WebRTC REQUIRED) +find_package(Sora REQUIRED) +find_package(SDL2 REQUIRED) +find_package(Threads REQUIRED) +find_package(Libva REQUIRED) +find_package(Libdrm REQUIRED) + +add_executable(sumomo) +set_target_properties(sumomo PROPERTIES CXX_STANDARD 20 C_STANDARD 20) +set_target_properties(sumomo PROPERTIES POSITION_INDEPENDENT_CODE ON) +target_sources(sumomo PRIVATE ../src/sumomo.cpp ../src/sdl_renderer.cpp) + +target_compile_options(sumomo + PRIVATE + "$<$:-nostdinc++>" + "$<$:-isystem${LIBCXX_INCLUDE_DIR}>" +) +target_include_directories(sumomo PRIVATE ${CLI11_DIR}/include) +target_link_libraries(sumomo PRIVATE Sora::sora SDL2::SDL2 SDL2::SDL2main) +target_compile_definitions(sumomo PRIVATE CLI11_HAS_FILESYSTEM=0) diff --git a/examples/sumomo/ubuntu-24.04_x86_64/run.py b/examples/sumomo/ubuntu-24.04_x86_64/run.py new file mode 100644 index 00000000..993abd72 --- /dev/null +++ b/examples/sumomo/ubuntu-24.04_x86_64/run.py @@ -0,0 +1,207 @@ +import argparse +import multiprocessing +import os +import sys +from typing import List, Optional + +PROJECT_DIR = os.path.abspath(os.path.dirname(__file__)) +BASE_DIR = os.path.join(PROJECT_DIR, "..", "..") +BUILDBASE_DIR = os.path.join(BASE_DIR, "..") +sys.path.insert(0, BUILDBASE_DIR) + + +from buildbase import ( # noqa: E402 + add_path, + add_sora_arguments, + add_webrtc_build_arguments, + build_sora, + build_webrtc, + cd, + cmake_path, + cmd, + get_sora_info, + get_webrtc_info, + install_cli11, + install_cmake, + install_llvm, + install_sdl2, + install_sora_and_deps, + install_webrtc, + mkdir_p, + read_version_file, +) + + +def install_deps( + source_dir, + build_dir, + install_dir, + debug, + local_webrtc_build_dir: Optional[str], + local_webrtc_build_args: List[str], + local_sora_cpp_sdk_dir: Optional[str], + local_sora_cpp_sdk_args: List[str], +): + with cd(BASE_DIR): + version = read_version_file("VERSION") + + # WebRTC + if local_webrtc_build_dir is None: + install_webrtc_args = { + "version": version["WEBRTC_BUILD_VERSION"], + "version_file": os.path.join(install_dir, "webrtc.version"), + "source_dir": source_dir, + "install_dir": install_dir, + "platform": "ubuntu-24.04_x86_64", + } + install_webrtc(**install_webrtc_args) + else: + build_webrtc_args = { + "platform": "ubuntu-24.04_x86_64", + "local_webrtc_build_dir": local_webrtc_build_dir, + "local_webrtc_build_args": local_webrtc_build_args, + "debug": debug, + } + build_webrtc(**build_webrtc_args) + + webrtc_info = get_webrtc_info( + "ubuntu-24.04_x86_64", local_webrtc_build_dir, install_dir, debug + ) + + if local_webrtc_build_dir is None: + webrtc_version = read_version_file(webrtc_info.version_file) + + # LLVM + tools_url = webrtc_version["WEBRTC_SRC_TOOLS_URL"] + tools_commit = webrtc_version["WEBRTC_SRC_TOOLS_COMMIT"] + libcxx_url = webrtc_version["WEBRTC_SRC_THIRD_PARTY_LIBCXX_SRC_URL"] + libcxx_commit = webrtc_version["WEBRTC_SRC_THIRD_PARTY_LIBCXX_SRC_COMMIT"] + buildtools_url = webrtc_version["WEBRTC_SRC_BUILDTOOLS_URL"] + buildtools_commit = webrtc_version["WEBRTC_SRC_BUILDTOOLS_COMMIT"] + install_llvm_args = { + "version": f"{tools_url}.{tools_commit}." + f"{libcxx_url}.{libcxx_commit}." + f"{buildtools_url}.{buildtools_commit}", + "version_file": os.path.join(install_dir, "llvm.version"), + "install_dir": install_dir, + "tools_url": tools_url, + "tools_commit": tools_commit, + "libcxx_url": libcxx_url, + "libcxx_commit": libcxx_commit, + "buildtools_url": buildtools_url, + "buildtools_commit": buildtools_commit, + } + install_llvm(**install_llvm_args) + + # Sora C++ SDK, Boost + if local_sora_cpp_sdk_dir is None: + install_sora_and_deps("ubuntu-24.04_x86_64", source_dir, install_dir) + else: + build_sora( + "ubuntu-24.04_x86_64", + local_sora_cpp_sdk_dir, + local_sora_cpp_sdk_args, + debug, + local_webrtc_build_dir, + ) + + # CMake + install_cmake_args = { + "version": version["CMAKE_VERSION"], + "version_file": os.path.join(install_dir, "cmake.version"), + "source_dir": source_dir, + "install_dir": install_dir, + "platform": "linux-x86_64", + "ext": "tar.gz", + } + install_cmake(**install_cmake_args) + add_path(os.path.join(install_dir, "cmake", "bin")) + + # SDL2 + install_sdl2_args = { + "version": version["SDL2_VERSION"], + "version_file": os.path.join(install_dir, "sdl2.version"), + "source_dir": source_dir, + "build_dir": build_dir, + "install_dir": install_dir, + "debug": debug, + "platform": "linux", + "cmake_args": [ + f"-DCMAKE_C_COMPILER={os.path.join(webrtc_info.clang_dir, 'bin', 'clang')}", + f"-DCMAKE_CXX_COMPILER={os.path.join(webrtc_info.clang_dir, 'bin', 'clang++')}", + ], + } + install_sdl2(**install_sdl2_args) + + # CLI11 + install_cli11_args = { + "version": version["CLI11_VERSION"], + "version_file": os.path.join(install_dir, "cli11.version"), + "install_dir": install_dir, + } + install_cli11(**install_cli11_args) + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("--debug", action="store_true") + add_webrtc_build_arguments(parser) + add_sora_arguments(parser) + + args = parser.parse_args() + + configuration_dir = "debug" if args.debug else "release" + platform = "ubuntu-24.04_x86_64" + source_dir = os.path.join(BASE_DIR, "_source", platform, configuration_dir) + build_dir = os.path.join(BASE_DIR, "_build", platform, configuration_dir) + install_dir = os.path.join(BASE_DIR, "_install", platform, configuration_dir) + mkdir_p(source_dir) + mkdir_p(build_dir) + mkdir_p(install_dir) + + install_deps( + source_dir, + build_dir, + install_dir, + args.debug, + args.local_webrtc_build_dir, + args.local_webrtc_build_args, + args.local_sora_cpp_sdk_dir, + args.local_sora_cpp_sdk_args, + ) + + configuration = "Debug" if args.debug else "Release" + + sample_build_dir = os.path.join(build_dir, "sumomo") + mkdir_p(sample_build_dir) + with cd(sample_build_dir): + webrtc_info = get_webrtc_info( + "ubuntu-24.04_x86_64", args.local_webrtc_build_dir, install_dir, args.debug + ) + sora_info = get_sora_info(platform, args.local_sora_cpp_sdk_dir, install_dir, args.debug) + + cmake_args = [] + cmake_args.append(f"-DCMAKE_BUILD_TYPE={configuration}") + cmake_args.append(f"-DBOOST_ROOT={cmake_path(sora_info.boost_install_dir)}") + cmake_args.append(f"-DWEBRTC_INCLUDE_DIR={cmake_path(webrtc_info.webrtc_include_dir)}") + cmake_args.append(f"-DWEBRTC_LIBRARY_DIR={cmake_path(webrtc_info.webrtc_library_dir)}") + cmake_args.append(f"-DSORA_DIR={cmake_path(sora_info.sora_install_dir)}") + cmake_args.append(f"-DCLI11_DIR={cmake_path(os.path.join(install_dir, 'cli11'))}") + cmake_args.append(f"-DSDL2_DIR={cmake_path(os.path.join(install_dir, 'sdl2'))}") + + # クロスコンパイルの設定。 + # 本来は toolchain ファイルに書く内容 + cmake_args += [ + f"-DCMAKE_C_COMPILER={os.path.join(webrtc_info.clang_dir, 'bin', 'clang')}", + f"-DCMAKE_CXX_COMPILER={os.path.join(webrtc_info.clang_dir, 'bin', 'clang++')}", + f"-DLIBCXX_INCLUDE_DIR={cmake_path(os.path.join(webrtc_info.libcxx_dir, 'include'))}", + ] + + cmd(["cmake", os.path.join(PROJECT_DIR)] + cmake_args) + cmd( + ["cmake", "--build", ".", f"-j{multiprocessing.cpu_count()}", "--config", configuration] + ) + + +if __name__ == "__main__": + main() diff --git a/run.py b/run.py index 0ceb8d1c..587d6fd8 100644 --- a/run.py +++ b/run.py @@ -72,7 +72,11 @@ def get_common_cmake_args( args.append(f"-DCMAKE_OBJCXX_COMPILER_TARGET={target}") args.append(f"-DCMAKE_SYSROOT={sysroot}") if platform.target.os == "ubuntu": - if platform.target.package_name in ("ubuntu-20.04_x86_64", "ubuntu-22.04_x86_64"): + if platform.target.package_name in ( + "ubuntu-20.04_x86_64", + "ubuntu-22.04_x86_64", + "ubuntu-24.04_x86_64", + ): args.append("-DCMAKE_C_COMPILER=clang-18") args.append("-DCMAKE_CXX_COMPILER=clang++-18") else: @@ -464,6 +468,7 @@ def install_deps( "macos_arm64", "ubuntu-20.04_x86_64", "ubuntu-22.04_x86_64", + "ubuntu-24.04_x86_64", "ios", "android", ] @@ -491,6 +496,8 @@ def main(): platform = Platform("ubuntu", "20.04", "x86_64") elif args.target == "ubuntu-22.04_x86_64": platform = Platform("ubuntu", "22.04", "x86_64") + elif args.target == "ubuntu-24.04_x86_64": + platform = Platform("ubuntu", "24.04", "x86_64") elif args.target == "ios": platform = Platform("ios", None, None) elif args.target == "android": @@ -557,7 +564,11 @@ def main(): if platform.target.os == "windows": cmake_args.append(f"-DCMAKE_SYSTEM_VERSION={WINDOWS_SDK_VERSION}") if platform.target.os == "ubuntu": - if platform.target.package_name in ("ubuntu-20.04_x86_64", "ubuntu-22.04_x86_64"): + if platform.target.package_name in ( + "ubuntu-20.04_x86_64", + "ubuntu-22.04_x86_64", + "ubuntu-24.04_x86_64", + ): cmake_args.append("-DCMAKE_C_COMPILER=clang-18") cmake_args.append("-DCMAKE_CXX_COMPILER=clang++-18") else: @@ -760,6 +771,7 @@ def main(): if platform.target.package_name in ( "ubuntu-20.04_x86_64", "ubuntu-22.04_x86_64", + "ubuntu-24.04_x86_64", ): cmake_args.append("-DCMAKE_C_COMPILER=clang-18") cmake_args.append("-DCMAKE_CXX_COMPILER=clang++-18")