From 42a41f7d61226895108b77c9fbba89d58110769e Mon Sep 17 00:00:00 2001 From: Jiaxun Yang Date: Fri, 6 Sep 2024 16:54:53 +0100 Subject: [PATCH] meson test Signed-off-by: Jiaxun Yang --- .github/workflows/build.yml | 28 ++++++++++------------ meson.build | 47 +++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 16 deletions(-) create mode 100644 meson.build diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e2d056c7..95a9dfda 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,13 +14,15 @@ jobs: - uses: ilammy/msvc-dev-cmd@v1 + - name: Install Meson + run: | + pip install meson + #don't use run-cmake for windows because only one build should add warnings to pull request - name: Build Debug run: | - mkdir debug - cd debug - cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Debug .. - nmake + meson setup debug --buildtype=debug --backend=vs + meson compile -C debug - name: Upload ryzenadj debug uses: actions/upload-artifact@v2 @@ -32,10 +34,8 @@ jobs: - name: Build Release run: | - mkdir build - cd build - cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release .. - nmake + meson setup build --buildtype=release --backend=vs + meson compile -C build - name: Prepair Release Folder run: | @@ -102,16 +102,12 @@ jobs: - name: Install Dependencies run: | sudo apt-get update - sudo apt-get install libpci-dev - - - name: run-cmake #with support for inline error reporting - uses: lukka/run-cmake@v3.3 + sudo apt-get install -y libpci-dev meson ninja-build - - name: Test make like readme + - name: Meson Build run: | - mkdir build && cd build - cmake DCMAKE_BUILD_TYPE=Release .. - make + meson setup build --buildtype=release + meson compile -C build # - name: Test Scripts # shell: bash diff --git a/meson.build b/meson.build new file mode 100644 index 00000000..5174eacc --- /dev/null +++ b/meson.build @@ -0,0 +1,47 @@ +project('ryzenadj', 'c', 'cpp', + default_options : ['cpp_std=c++11', 'c_visibilty=hidden', 'cpp_visibilty=hidden'] +) + +add_project_arguments('-D_LIBRYZENADJ_INTERNAL', language : ['c', 'cpp']) + +# Include directories +inc_dirs = include_directories('.') # Adjust this if your include path is different + +# Source directories +lib_srcs = files( + 'lib/nb_smu_ops.c', + 'lib/api.c', + 'lib/cpuid.c' +) + +# OS-specific settings +if host_machine.system() == 'windows' + lib_srcs += files('lib/osdep_win32.cpp') + cxx = meson.get_compiler('cpp') + os_deps = declare_dependency(link_with: cxx.find_library('WinRing0x64', dirs: ['win32'])) +elif host_machine.system() == 'linux' + lib_srcs += files('lib/osdep_linux.c') + os_deps = dependency('libpci', required : true) +else + error('Unsupported OS') +endif + +cli_srcs = files( + 'argparse.c', + 'main.c', +) +cli_inc_dirs = include_directories('lib') + +# Define executable +executable('ryzenadj', [lib_srcs, cli_srcs], + include_directories: cli_inc_dirs, + dependencies: os_deps, + install: true) + +# Define library +libryzenadj = library('libryzenadj', lib_srcs, + dependencies: os_deps, + install: true) +install_headers('lib/ryzenadj.h', subdir : 'ryzenadj') +pkg = import('pkgconfig') +pkg.generate(libryzenadj)