diff --git a/.github/workflows/deploy_linux.yml b/.github/workflows/deploy_linux.yml new file mode 100644 index 0000000..063a14f --- /dev/null +++ b/.github/workflows/deploy_linux.yml @@ -0,0 +1,57 @@ +name: Deploy to Linux + +on: + pull_request: + types: [closed] + branches: + - main # Only trigger for PRs merged into main + +jobs: + linux_x86_64: + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install LLVM's C++ Standard Library + run: sudo apt-get install libc++-20-dev libc++abi-20-dev + + - name: Installing pipx + run: sudo apt install pipx + + - name: Installing Prerequisites for Linux + run: | + sudo apt-get update + sudo apt install software-properties-common -y + sudo add-apt-repository ppa:deadsnakes/ppa + + - name: Installing Conan + run: pipx install "conan>=2.18.1" + + - name: Setting up Conan Profiles + run: conan config install -sf profiles/x86_64/linux/ -tf profiles https://github.com/engine3d-dev/conan-config.git + + - name: Adding Conan remote dependencies + run: | + conan remote add engine3d-conan https://libhal.jfrog.io/artifactory/api/conan/engine3d-conan + conan remote add libhal-trunk https://libhal.jfrog.io/artifactory/api/conan/trunk-conan + + - name: Creating Release build for audio-cpp + shell: pwsh + run: conan create . -b missing -s build_type=Release -pr linux_x86_64 -c tools.system.package_manager:sudo=True -c tools.system.package_manager:mode=install + + - name: Creating Debug build for audio-cpp + shell: pwsh + run: conan create . -b missing -s build_type=Debug -pr linux_x86_64 -c tools.system.package_manager:sudo=True -c tools.system.package_manager:mode=install + + - name: Creating MinSizeRel build for audio-cpp + shell: pwsh + run: conan create . -b missing -s build_type=MinSizeRel -pr linux_x86_64 -c tools.system.package_manager:sudo=True -c tools.system.package_manager:mode=install + + - name: Login to JFrog + run: conan remote login -p ${{ secrets.JFROG_USER_TOKEN_ID }} engine3d-conan ${{ secrets.JFROG_USERNAME }} + + - name: Uploading audio-cpp to JFrog remote repositories + shell: pwsh + run: conan upload audio-cpp/2.0 --r=engine3d-conan --confirm + diff --git a/.github/workflows/deploy_mac.yml b/.github/workflows/deploy_mac.yml new file mode 100644 index 0000000..06d1555 --- /dev/null +++ b/.github/workflows/deploy_mac.yml @@ -0,0 +1,64 @@ +name: Deploy to MacOS + +on: + pull_request: + types: [closed] + branches: + - main # Only trigger for PRs merged into main + +jobs: + macos_armv8: + if: github.event.pull_request.merged == true + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + + - name: Install Homebrew + run: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + + - name: Install LLVM + run: | + brew install python pipx llvm@17 + + - name: Pipx installing conan + run: | + pipx install "conan>=2.18.2" + pipx upgrade conan + + - name: Installing clang-tidy + run: sudo ln -s $(brew --prefix llvm)/bin/clang-tidy /usr/local/bin/ + + - name: Install Rosetta + run: /usr/sbin/softwareupdate --install-rosetta --agree-to-license + + - name: Setting up Conan profile + run: conan config install -sf profiles/armv8/mac/ -tf profiles https://github.com/engine3d-dev/conan-config.git + + - name: Installing Atlas repositories + run: | + conan remote add engine3d-conan https://libhal.jfrog.io/artifactory/api/conan/engine3d-conan + conan remote add libhal-trunk https://libhal.jfrog.io/artifactory/api/conan/trunk-conan + + - name: Creating Release build for audio-cpp + shell: pwsh + run: conan create . -b missing -s build_type=Release -pr mac_armv8 + + - name: Creating Debug build for audio-cpp + shell: pwsh + run: conan create . -b missing -s build_type=Debug -pr mac_armv8 + + - name: Creating MinSizeRel build for audio-cpp + shell: pwsh + run: conan create . -b missing -s build_type=MinSizeRel -pr mac_armv8 + + - name: Login to JFrog + shell: pwsh + env: + PASSWORD: ${{ secrets.JFROG_ID }} + JFROG_USER: ${{ secrets.JFROG_USER_TOKEN_ID }} + run: conan remote login -p ${{ secrets.JFROG_USER_TOKEN_ID }} engine3d-conan ${{ secrets.JFROG_USERNAME }} + + - name: Deploy audio-cpp to JFrog remote repositories + shell: pwsh + run: | + conan upload audio-cpp/2.0 --r=engine3d-conan --confirm diff --git a/.github/workflows/deploy_windows.yml b/.github/workflows/deploy_windows.yml new file mode 100644 index 0000000..110db72 --- /dev/null +++ b/.github/workflows/deploy_windows.yml @@ -0,0 +1,62 @@ +name: Deploy to Windows + +on: + pull_request: + types: [closed] + branches: + - main # Only trigger for PRs merged into main + +jobs: + windows_x86_64: + if: github.event.pull_request.merged == true + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + + - name: Installing Choco + shell: pwsh + run: Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) + + - name: Install tooling with Choco + shell: pwsh + run: | + choco install cmake.install --version=3.31.6 + cmake --version + choco install llvm --version=20.1.4 + clang++ --version + choco install git make mingw + + - name: Pip installing conan + shell: pwsh + run: pip install conan + + - name: Setting up conan profiles + shell: pwsh + run: conan config install -sf profiles/x86_64/Windows/ -tf profiles https://github.com/engine3d-dev/conan-config.git + + - name: Setting up remote repositories + shell: pwsh + run: | + conan remote add engine3d-conan https://libhal.jfrog.io/artifactory/api/conan/engine3d-conan + conan remote add libhal-trunk https://libhal.jfrog.io/artifactory/api/conan/trunk-conan + + - name: Creating Release build for audio-cpp + shell: pwsh + run: conan create . -b missing -s build_type=Release -pr windows_x86_64 + + - name: Creating Debug build for audio-cpp + shell: pwsh + run: conan create . -b missing -s build_type=Debug -pr windows_x86_64 + + - name: Creating MinSizeRel build for audio-cpp + shell: pwsh + run: conan create . -b missing -s build_type=MinSizeRel -pr windows_x86_64 + + - name: Login to JFrog + shell: pwsh + run: conan remote login -p ${{ secrets.JFROG_USER_TOKEN_ID }} engine3d-conan ${{ secrets.JFROG_USERNAME }} + + - name: Deploy audio-cpp to JFrog remote repositories + shell: pwsh + run: | + conan upload audio-cpp/2.0 --r=engine3d-conan --confirm diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 6e1c60a..e08b920 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -1,4 +1,4 @@ -name: Linux Build Tests +name: Linux Platform Build on: [pull_request] @@ -9,23 +9,38 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Install LLVM - run: wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && sudo ./llvm.sh - - name: Install LLVM's C++ Standard Library - run: sudo apt install libc++-17-dev libc++abi-17-dev + run: sudo apt-get install libc++-20-dev libc++abi-20-dev - name: Installing pipx run: sudo apt install pipx + - name: Installing Prerequisites for Linux + run: | + sudo apt-get update + sudo apt install software-properties-common -y + sudo add-apt-repository ppa:deadsnakes/ppa + - name: Installing Conan - run: pipx install "conan>=2.10.1" + run: pipx install "conan>=2.18.1" - name: Setting up Conan Profiles run: conan config install -sf profiles/x86_64/linux/ -tf profiles https://github.com/engine3d-dev/conan-config.git - - name: Installing project dependencies - run: conan remote add engine3d-conan https://libhal.jfrog.io/artifactory/api/conan/engine3d-conan + - name: Adding Conan remote dependencies + run: | + conan remote add engine3d-conan https://libhal.jfrog.io/artifactory/api/conan/engine3d-conan + conan remote add libhal-trunk https://libhal.jfrog.io/artifactory/api/conan/trunk-conan + + - name: Creating Release build for audio-cpp + shell: pwsh + run: conan create . -b missing -s build_type=Release -pr linux_x86_64 -c tools.system.package_manager:sudo=True -c tools.system.package_manager:mode=install + + - name: Creating Debug build for audio-cpp + shell: pwsh + run: conan create . -b missing -s build_type=Debug -pr linux_x86_64 -c tools.system.package_manager:sudo=True -c tools.system.package_manager:mode=install + + - name: Creating MinSizeRel build for audio-cpp + shell: pwsh + run: conan create . -b missing -s build_type=MinSizeRel -pr linux_x86_64 -c tools.system.package_manager:sudo=True -c tools.system.package_manager:mode=install - - name: Building audio-cpp - run: conan build . -b missing -c tools.system.package_manager:sudo=True -c tools.system.package_manager:mode=install diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml index 82ef2b8..92e839d 100644 --- a/.github/workflows/mac.yml +++ b/.github/workflows/mac.yml @@ -29,7 +29,23 @@ jobs: run: conan config install -sf profiles/armv8/mac/ -tf profiles https://github.com/engine3d-dev/conan-config.git - name: Installing Atlas repositories - run: conan remote add engine3d-conan https://libhal.jfrog.io/artifactory/api/conan/engine3d-conan - - - name: Building audio-cpp - run: conan build . -b missing + run: | + conan remote add engine3d-conan https://libhal.jfrog.io/artifactory/api/conan/engine3d-conan + conan remote add libhal-trunk https://libhal.jfrog.io/artifactory/api/conan/trunk-conan + + # - name: Building audio-cpp + # run: | + # conan create . -b missing -s build_type=Release -pr mac_armv8 + # conan create . -b missing -s build_type=Debug -pr mac_armv8 + # conan create . -b missing -s build_type=MinSizeRel -pr mac_armv8 + - name: Creating Release build for audio-cpp + shell: pwsh + run: conan create . -b missing -s build_type=Release -pr mac_armv8 + + - name: Creating Debug build for audio-cpp + shell: pwsh + run: conan create . -b missing -s build_type=Debug -pr mac_armv8 + + - name: Creating MinSizeRel build for audio-cpp + shell: pwsh + run: conan create . -b missing -s build_type=MinSizeRel -pr mac_armv8 \ No newline at end of file diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 6de26c7..e91fe8c 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -32,8 +32,24 @@ jobs: - name: Setting up packages shell: pwsh - run: conan remote add engine3d-conan https://libhal.jfrog.io/artifactory/api/conan/engine3d-conan + run: | + conan remote add engine3d-conan https://libhal.jfrog.io/artifactory/api/conan/engine3d-conan + conan remote add libhal-trunk https://libhal.jfrog.io/artifactory/api/conan/trunk-conan + + # - name: Building audio-cpp + # shell: pwsh + # run: | + # conan create . -b missing -s build_type=Release -pr windows_x86_64 + # conan create . -b missing -s build_type=Debug -pr windows_x86_64 + # conan create . -b missing -s build_type=MinSizeRel -pr windows_x86_64 + - name: Creating Release build for audio-cpp + shell: pwsh + run: conan create . -b missing -s build_type=Release -pr windows_x86_64 + + - name: Creating Debug build for audio-cpp + shell: pwsh + run: conan create . -b missing -s build_type=Debug -pr windows_x86_64 - - name: Building audio-cpp + - name: Creating MinSizeRel build for audio-cpp shell: pwsh - run: conan build . -b missing + run: conan create . -b missing -s build_type=MinSizeRel -pr windows_x86_64 \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index f80c8b8..8aff406 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,15 +1,21 @@ -cmake_minimum_required(VERSION 3.25) -project(audio-cpp LANGUAGES C CXX) +cmake_minimum_required(VERSION 4.0) -build_library( - DIRECTORIES src +# Generate compile commands for anyone using our libraries. +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +set(CMAKE_COLOR_DIAGNOSTICS ON) - ENABLE_TESTS ON +project(audio-cpp LANGUAGES CXX) +static_library( + ENABLE_TESTS ON + UNIT_TEST_SOURCES tests/main.test.cpp tests/basic_audio.test.cpp + LOCAL_PACKAGES + audio-cpp + PACKAGES miniaudio @@ -17,6 +23,36 @@ build_library( miniaudio::miniaudio ) -generate_compile_commands() +target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_23) + +target_sources(${PROJECT_NAME} PUBLIC + FILE_SET CXX_MODULES + TYPE CXX_MODULES + FILES + audio-cpp/audio.cppm + audio-cpp/sound.cppm +) + +install( + TARGETS ${PROJECT_NAME} + EXPORT audio-cpp_targets + FILE_SET CXX_MODULES DESTINATION "." + LIBRARY DESTINATION "lib" + ARCHIVE DESTINATION "lib" + CXX_MODULES_BMI DESTINATION "bmi" +) + +install( + EXPORT audio-cpp_targets + FILE "audio-cpp-config.cmake" + DESTINATION "lib/cmake" + CXX_MODULES_DIRECTORY "cxx-modules" +) -target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_LIST_DIR}) +# Always run this custom target by making it depend on ALL +add_custom_target(copy_compile_commands ALL + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${CMAKE_BINARY_DIR}/compile_commands.json + ${CMAKE_SOURCE_DIR}/compile_commands.json + DEPENDS ${CMAKE_BINARY_DIR}/compile_commands.json +) \ No newline at end of file diff --git a/audio-cpp/audio.cppm b/audio-cpp/audio.cppm new file mode 100644 index 0000000..68e6f62 --- /dev/null +++ b/audio-cpp/audio.cppm @@ -0,0 +1,9 @@ +module; + +export module audio; + +export import :sound; + + +export namespace audio::inline v1 { +}; \ No newline at end of file diff --git a/audio-cpp/audio_reader.hpp b/audio-cpp/audio_reader.hpp deleted file mode 100644 index 158d630..0000000 --- a/audio-cpp/audio_reader.hpp +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -#include -#include -#include - -namespace audio { - /** - * @note Audio Reader takes in any type of audio file. - * @note Using this API allows you to control how you read in that data. - * @note Such as ReadInt, ReadAs, ReadFloat, ReadString, etc. - * - */ - class audio_reader { - public: - audio_reader(const std::string& p_filename); - - bool is_valid() const { return m_is_audio_stream_valid; } - - //! @note We are reading data from a specified audio file - //! @param p_Filename is the location of the audiofile we are reading - //! from. - //! @note Basically should allow us to read in those files and play - //! them. - static std::span read(const std::string& p_filename); - - template - T ReadAs() {} - - private: - bool m_is_audio_stream_valid = false; - }; -}; \ No newline at end of file diff --git a/audio-cpp/decoder.h b/audio-cpp/decoder.h deleted file mode 100644 index 90b76c4..0000000 --- a/audio-cpp/decoder.h +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once -#include - -namespace audio { - /** - * @name decoder - * @note Custom decoder for decoding audio data. - */ - class decoder { - public: - //! @note users should not be able to create a non-init decoder - decoder() = delete; - - /** - * @param format defines the sample format - */ - decoder(uint32_t format, uint32_t channels, uint32_t sample_rate); - - /** - * @param device_config is to set the device_config for the decoder - */ - decoder(uint32_t device_config); - // private: - }; -}; diff --git a/audio-cpp/drivers/audio_context.hpp b/audio-cpp/drivers/audio_context.hpp deleted file mode 100644 index 8a1b606..0000000 --- a/audio-cpp/drivers/audio_context.hpp +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -namespace audio { - /** - * @brief Low-level audio context for setting up miniaudio - */ - class audio_context { - public: - audio_context() = default; - }; -}; \ No newline at end of file diff --git a/audio-cpp/drivers/audio_device.hpp b/audio-cpp/drivers/audio_device.hpp deleted file mode 100644 index e9f4fae..0000000 --- a/audio-cpp/drivers/audio_device.hpp +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once -#include - -namespace audio { - class device_enumeration { - public: - device_enumeration() { - ma_context test_context; - if (ma_context_init(nullptr, 0, nullptr, &test_context) != - MA_SUCCESS) { - } - } - }; -}; \ No newline at end of file diff --git a/audio-cpp/sound.cppm b/audio-cpp/sound.cppm new file mode 100644 index 0000000..2dceac1 --- /dev/null +++ b/audio-cpp/sound.cppm @@ -0,0 +1,78 @@ +module; + +#include +#include + +export module audio:sound; + +export namespace audio::inline v1 { + void data_callback(ma_device* p_device, + /*NOLINT*/void* p_output, + /*NOLINT*/ const void* p_input, + ma_uint32 p_frame_count) { + ma_decoder* decoder = (ma_decoder*)p_device->pUserData; + if (decoder == nullptr) { + return; + } + + ma_decoder_read_pcm_frames(decoder, p_output, p_frame_count, NULL); + + (void)p_input; + } + + /** + * @note Sound abstraction around the miniaudio API + * + */ + class sound { + public: + sound(const std::string& p_filename) { + ma_decoder_init_file(p_filename.c_str(), nullptr, &m_decoder); + + m_audio_device_config = ma_device_config_init(ma_device_type_playback); + + m_audio_device_config.playback.format = m_decoder.outputFormat; + m_audio_device_config.playback.channels = m_decoder.outputChannels; + m_audio_device_config.sampleRate = m_decoder.outputSampleRate; + m_audio_device_config.dataCallback = data_callback; + m_audio_device_config.pUserData = &m_decoder; + + auto res = ma_device_init( + nullptr, &m_audio_device_config, &m_audio_device_handler); + if (res != MA_SUCCESS) { + cleanup(); + return; + } + } + + ~sound() { + cleanup(); + } + + void on_play() { + auto res = ma_device_start(&m_audio_device_handler); + if (res != MA_SUCCESS) { + cleanup(); + } + } + + void on_stop() { + auto res = ma_device_stop(&m_audio_device_handler); + + if (res != MA_SUCCESS) { + cleanup(); + } + } + + private: + void cleanup() { + ma_device_uninit(&m_audio_device_handler); + ma_decoder_uninit(&m_decoder); + } + + private: + ma_decoder m_decoder; + ma_device m_audio_device_handler; + ma_device_config m_audio_device_config; + }; +}; diff --git a/audio-cpp/sound.hpp b/audio-cpp/sound.hpp deleted file mode 100644 index 2fdaab2..0000000 --- a/audio-cpp/sound.hpp +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once -#include -#include - -namespace audio { - /** - * @note Sound abstraction around the miniaudio API - * - */ - class sound { - public: - sound(const std::string& p_filename); - ~sound(); - - void on_play(); - void on_stop(); - - private: - void cleanup(); - - private: - ma_decoder m_decoder; - ma_device m_audio_device_handler; - ma_device_config m_audio_device_config; - }; -}; diff --git a/audio-cpp/utilities.hpp b/audio-cpp/utilities.hpp deleted file mode 100644 index 85abce3..0000000 --- a/audio-cpp/utilities.hpp +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once -#include -#include - -namespace audio { - void stream_write(std::span>& p_Buffer); -}; \ No newline at end of file diff --git a/conanfile.py b/conanfile.py index 82fd141..72826e5 100644 --- a/conanfile.py +++ b/conanfile.py @@ -1,111 +1,58 @@ from conan import ConanFile -from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps -from conan.tools.scm import Git +from conan.tools.cmake import CMake, cmake_layout, CMakeToolchain, CMakeDeps from conan.tools.files import copy -import os -import glob -import hashlib -# from conan.tools.files import find_files +from pathlib import Path -class AudioRecipe(ConanFile): + +required_conan_version = ">=2.2.0" + + +class AudioCppRecipe(ConanFile): name = "audio-cpp" - version = "1.0" - package_type = "library" + version = "2.0" license = "Apache-2.0" - homepage = "https://github.com/engine3d-dev/engine3d-audio" - - # Binary configuration - settings = "os", "compiler", "build_type", "arch" + url = "https://github.com/engine3d-dev/audio-cpp" + homepage = "https://github.com/engine3d-dev/audio-cpp" + settings = "compiler", "build_type", "os", "arch" options = {"shared": [True, False], "fPIC": [True, False]} default_options = {"shared": False, "fPIC": True} - exports_sources = "CMakeLists.txt", "src/CMakeLists.txt" + exports_sources = "audio-cpp/*", "tests/*", "CMakeLists.txt", "LICENSE" def build_requirements(self): - self.tool_requires("make/4.4.1") - self.tool_requires("cmake/3.27.1") + self.tool_requires("cmake/[^4.0.0]") + self.tool_requires("ninja/[^1.3.0]") + self.test_requires("boost-ext-ut/2.3.1") self.tool_requires("engine3d-cmake-utils/4.0") - self.requires("boost-ext-ut/2.1.0") - + def requirements(self): - self.requires("miniaudio/1.0") - - # This is how exporting the sources work - def export_sources(self): - copy(self,"CMakeLists.txt", self.recipe_folder, self.export_sources_folder) - copy(self,"*.hpp", self.recipe_folder, self.export_sources_folder) - copy(self,"*.h", self.recipe_folder, self.export_sources_folder) - copy(self,"*.cpp", self.recipe_folder, self.export_sources_folder) + self.requires("miniaudio/2.0") def layout(self): cmake_layout(self) - - def generate(self): - deps = CMakeDeps(self) - deps.generate() + def generate(self): tc = CMakeToolchain(self) + tc.generator = "Ninja" tc.generate() - - def file_changed(self, filepath, previous_hash=None): - """ - Checks if a file has changed by comparing its current hash with a previous hash. - - Args: - filepath (str): The path to the file. - previous_hash (str, optional): The previous hash of the file. Defaults to None. - - Returns: - tuple: (True, current_hash) if the file has changed or is new, (False, current_hash) otherwise. - Returns (None, None) if the file does not exist. - """ - if not os.path.exists(filepath): - return None, None - try: - with open(filepath, 'rb') as f: - file_content = f.read() - current_hash = hashlib.md5(file_content).hexdigest() - - if previous_hash is None: # First time checking the file - return True, current_hash - - return current_hash != previous_hash, current_hash - - except Exception as e: - print(f"Error checking file {filepath}: {e}") - return None, None + deps = CMakeDeps(self) + deps.generate() def build(self): - # Directory to the files tests get generated - gcda_tests_dir = os.path.join(self.build_folder, "CMakeFiles/unit_test.dir/tests") - tests_dir = os.path.join(self.source_folder, "tests"); - tests_files = os.path.join(tests_dir, "*.test.cpp") - - gcda_files = os.path.join(gcda_tests_dir, "*.gcda") - - if os.path.exists(gcda_tests_dir): - for file in glob.glob(gcda_files): - os.remove(file) - cmake = CMake(self) - cmake.verbose = True cmake.configure() cmake.build() - - + def package(self): - copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) - copy(self, pattern="*.h", src=os.path.join(self.source_folder, "audio-cpp"), dst=os.path.join(self.package_folder, "audio-cpp")) - copy(self, pattern="*.hpp", src=os.path.join(self.source_folder, "audio-cpp"), dst=os.path.join(self.package_folder, "audio-cpp")) - copy(self, pattern="*.a", src=self.build_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False) - copy(self, pattern="*.so", src=self.build_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False) - copy(self, pattern="*.lib", src=self.build_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False) - copy(self, pattern="*.dll", src=self.build_folder, dst=os.path.join(self.package_folder, "bin"), keep_path=False) - copy(self, pattern="*.dylib", src=self.build_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False) cmake = CMake(self) cmake.install() + copy(self, "LICENSE", + dst=Path(self.package_folder) / "licenses", + src=self.source_folder) + def package_info(self): - self.cpp_info.set_property("cmake_target_name", "audio-cpp::audio-cpp") - self.cpp_info.libs = ["audio-cpp"] - self.cpp_info.includedirs = ['./', './audio-cpp'] + # DISABLE Conan's config file generation + self.cpp_info.set_property("cmake_find_mode", "none") + # Tell CMake to include this directory in its search path + self.cpp_info.builddirs.append("lib/cmake") diff --git a/demo/CMakeLists.txt b/demo/CMakeLists.txt index ec9b7a3..0640162 100644 --- a/demo/CMakeLists.txt +++ b/demo/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.28) project(demo CXX) build_application( @@ -10,6 +10,6 @@ build_application( miniaudio LINK_PACKAGES - audio-cpp::audio-cpp + audio-cpp miniaudio::miniaudio -) +) \ No newline at end of file diff --git a/demo/application.cpp b/demo/application.cpp index dcc50ad..cfe8b66 100644 --- a/demo/application.cpp +++ b/demo/application.cpp @@ -1,5 +1,5 @@ #include -#include +import audio; using namespace std; int diff --git a/demo/conanfile.py b/demo/conanfile.py index db81597..1cea638 100644 --- a/demo/conanfile.py +++ b/demo/conanfile.py @@ -6,18 +6,19 @@ class Demo(ConanFile): version = "1.0" settings = "os", "compiler", "build_type", "arch" generators = "CMakeDeps", "CMakeToolchain" - export_source = "CMakeLists.txt", "application.cpp" + export_source = "CMakeLists.txt", "audio-cpp/*" # Putting all of your build-related dependencies here def build_requirements(self): - self.tool_requires("make/4.4.1") - self.tool_requires("cmake/3.27.1") - self.tool_requires("engine3d-cmake-utils/3.0") + self.tool_requires("ninja/1.13.2") + self.tool_requires("cmake/4.2.1") + self.tool_requires("cmake-modules-toolchain/1.0.3") + self.tool_requires("engine3d-cmake-utils/4.0") # Putting all of your packages here def requirements(self): - self.requires("miniaudio/1.0") - self.requires("audio-cpp/1.0") + self.requires("audio-cpp/2.0") + self.requires("miniaudio/2.0") def build(self): cmake = CMake(self) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt deleted file mode 100644 index 4469584..0000000 --- a/src/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ - -set(AUDIO_INCLUDE_DIRS ../audio-cpp) -set(AUDIO_SRC_DIRS audio-cpp) - -set( - all_src - ${AUDIO_SRC_DIRS}/utilities.cpp - ${AUDIO_SRC_DIRS}/sound.cpp -) - -add_library(${PROJECT_NAME} ${all_headers} ${all_src}) diff --git a/src/audio-cpp/decoder.cpp b/src/audio-cpp/decoder.cpp deleted file mode 100644 index 35bc38d..0000000 --- a/src/audio-cpp/decoder.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include