Change the conanfile

Signed-off-by: Nikolai Rodionov <allanger@badhouseplants.net>
This commit is contained in:
2025-11-16 20:55:28 +01:00
parent 4aa1a38ba3
commit f6586bef83
8 changed files with 81 additions and 63 deletions

2
.gitignore vendored
View File

@@ -88,3 +88,5 @@ compile_commands.json
*_qmlcache.qrc *_qmlcache.qrc
# Conan build dir
build/

View File

@@ -1,3 +1,5 @@
# daw-project # daw-project
Think about the name
## Build

View File

@@ -1,34 +1,24 @@
import os
from conan import ConanFile from conan import ConanFile
from conan.tools.meson import MesonToolchain, Meson from conan.tools.meson import MesonToolchain, Meson
from conan.tools.layout import basic_layout from conan.tools.gnu import PkgConfigDeps
from conan.tools.files import copy
class daw_expConan(ConanFile):
name = "daw-exp"
version = "1.0"
package_type = "library"
# Binary configuration class daw_projectConan(ConanFile):
name = "daw-project"
version = "0.0.1"
package_type = "application"
settings = "os", "compiler", "build_type", "arch" settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False], "fPIC": [True, False]}
default_options = {"shared": False, "fPIC": True}
# Sources are located in the same place as this recipe, copy them to the recipe
exports_sources = "meson.build", "src/*" exports_sources = "meson.build", "src/*"
def config_options(self):
if self.settings.os == "Windows":
self.options.rm_safe("fPIC")
def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")
def layout(self): def layout(self):
basic_layout(self) self.folders.build = "build"
self.folders.generators = "build/scripts"
def generate(self): def generate(self):
deps = PkgConfigDeps(self)
deps.generate()
tc = MesonToolchain(self) tc = MesonToolchain(self)
tc.generate() tc.generate()
@@ -40,6 +30,3 @@ class daw_expConan(ConanFile):
def package(self): def package(self):
meson = Meson(self) meson = Meson(self)
meson.install() meson.install()
def package_info(self):
self.cpp_info.libs = ["daw-exp"]

View File

@@ -1,6 +1,8 @@
project('daw-exp ', 'cpp') project('daw-exp ', 'cpp')
qt6 = import('qt6')
qt_dep = dependency('qt6', modules: ['Core', 'Widgets']) qt_dep = dependency('qt6', modules: ['Core', 'Widgets'])
exe = executable('myapp', 'src/main.cpp', jack_dep = dependency('jack', required : true)
dependencies: [qt_dep],
executable('daw-project', 'src/main.cpp',
dependencies: [qt_dep, jack_dep],
install: true) install: true)

View File

@@ -1,9 +1,61 @@
#include <QApplication> // src/main.cpp
#include <QLabel> #include <jack/jack.h>
#include <cmath>
#include <iostream>
#include <atomic>
int main(int argc, char *argv[]) { static std::atomic<jack_client_t*> g_client{nullptr};
QApplication app(argc, argv); static float g_phase = 0.0f;
QLabel label("Hello from Qt + Meson + Conan!"); static const float kFreq = 440.0f;
label.show();
return app.exec(); int process(jack_nframes_t nframes, void* arg) {
jack_port_t* port = static_cast<jack_port_t*>(arg);
float* out = (float*)jack_port_get_buffer(port, nframes);
jack_client_t* client = g_client.load();
if (!client) return 0;
jack_nframes_t sr = jack_get_sample_rate(client);
for (jack_nframes_t i = 0; i < nframes; ++i) {
out[i] = std::sinf(g_phase);
g_phase += 2.0f * static_cast<float>(M_PI) * kFreq / static_cast<float>(sr);
if (g_phase > 2.0f * static_cast<float>(M_PI)) g_phase -= 2.0f * static_cast<float>(M_PI);
}
return 0;
}
int main() {
jack_status_t status;
jack_client_t* client = jack_client_open("cpp_jack_player", JackNullOption, &status);
if (!client) {
std::cerr << "Failed to open JACK client (status=" << status << ")\n";
return 1;
}
g_client.store(client);
jack_port_t* outport = jack_port_register(client, "output", JACK_DEFAULT_AUDIO_TYPE,
JackPortIsOutput, 0);
if (!outport) {
std::cerr << "Failed to register output port\n";
jack_client_close(client);
return 1;
}
if (jack_set_process_callback(client, process, outport) != 0) {
std::cerr << "Failed to set process callback\n";
jack_client_close(client);
return 1;
}
if (jack_activate(client) != 0) {
std::cerr << "Failed to activate JACK client\n";
jack_client_close(client);
return 1;
}
std::cout << "Client active. Connect " << jack_get_client_name(client)
<< ":output to system:playback (e.g. with qjackctl). Press Enter to quit.\n";
std::cin.get();
jack_client_close(client);
return 0;
} }

View File

@@ -1,26 +1,14 @@
import os import os
from conan import ConanFile from conan import ConanFile
from conan.tools.build import can_run from conan.tools.build import can_run
from conan.tools.meson import MesonToolchain, Meson
from conan.tools.layout import basic_layout
class daw_expTestConan(ConanFile): class daw_projectTestConan(ConanFile):
settings = "os", "compiler", "build_type", "arch" settings = "os", "compiler", "build_type", "arch"
generators = "PkgConfigDeps", "MesonToolchain"
def requirements(self): def requirements(self):
self.requires(self.tested_reference_str) self.requires(self.tested_reference_str)
def build(self):
meson = Meson(self)
meson.configure()
meson.build()
def layout(self):
basic_layout(self)
def test(self): def test(self):
if can_run(self): if can_run(self):
cmd = os.path.join(self.cpp.build.bindir, "example") self.run("daw-project", env="conanrun")
self.run(cmd, env="conanrun")

View File

@@ -1,3 +0,0 @@
project('Testdaw-exp', 'cpp')
daw-exp = dependency('daw-exp', version : '>=0.1')
executable('example', 'src/example.cpp', dependencies: daw-exp)

View File

@@ -1,12 +0,0 @@
#include "daw-exp.h"
#include <vector>
#include <string>
int main() {
daw_exp();
std::vector<std::string> vec;
vec.push_back("test_package");
daw_exp_print_vector(vec);
}