Change the conanfile
Signed-off-by: Nikolai Rodionov <allanger@badhouseplants.net>
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -88,3 +88,5 @@ compile_commands.json
|
||||
|
||||
*_qmlcache.qrc
|
||||
|
||||
# Conan build dir
|
||||
build/
|
||||
|
||||
33
conanfile.py
33
conanfile.py
@@ -1,34 +1,24 @@
|
||||
import os
|
||||
from conan import ConanFile
|
||||
from conan.tools.meson import MesonToolchain, Meson
|
||||
from conan.tools.layout import basic_layout
|
||||
from conan.tools.files import copy
|
||||
from conan.tools.gnu import PkgConfigDeps
|
||||
|
||||
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"
|
||||
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/*"
|
||||
|
||||
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):
|
||||
basic_layout(self)
|
||||
self.folders.build = "build"
|
||||
self.folders.generators = "build/scripts"
|
||||
|
||||
def generate(self):
|
||||
deps = PkgConfigDeps(self)
|
||||
deps.generate()
|
||||
tc = MesonToolchain(self)
|
||||
tc.generate()
|
||||
|
||||
@@ -40,6 +30,3 @@ class daw_expConan(ConanFile):
|
||||
def package(self):
|
||||
meson = Meson(self)
|
||||
meson.install()
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.libs = ["daw-exp"]
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
project('daw-exp ', 'cpp')
|
||||
qt6 = import('qt6')
|
||||
|
||||
qt_dep = dependency('qt6', modules: ['Core', 'Widgets'])
|
||||
exe = executable('myapp', 'src/main.cpp',
|
||||
dependencies: [qt_dep],
|
||||
jack_dep = dependency('jack', required : true)
|
||||
|
||||
executable('daw-project', 'src/main.cpp',
|
||||
dependencies: [qt_dep, jack_dep],
|
||||
install: true)
|
||||
|
||||
66
src/main.cpp
66
src/main.cpp
@@ -1,9 +1,61 @@
|
||||
#include <QApplication>
|
||||
#include <QLabel>
|
||||
// src/main.cpp
|
||||
#include <jack/jack.h>
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
#include <atomic>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
QApplication app(argc, argv);
|
||||
QLabel label("Hello from Qt + Meson + Conan!");
|
||||
label.show();
|
||||
return app.exec();
|
||||
static std::atomic<jack_client_t*> g_client{nullptr};
|
||||
static float g_phase = 0.0f;
|
||||
static const float kFreq = 440.0f;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -1,26 +1,14 @@
|
||||
import os
|
||||
from conan import ConanFile
|
||||
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"
|
||||
generators = "PkgConfigDeps", "MesonToolchain"
|
||||
|
||||
def requirements(self):
|
||||
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):
|
||||
if can_run(self):
|
||||
cmd = os.path.join(self.cpp.build.bindir, "example")
|
||||
self.run(cmd, env="conanrun")
|
||||
self.run("daw-project", env="conanrun")
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
project('Testdaw-exp', 'cpp')
|
||||
daw-exp = dependency('daw-exp', version : '>=0.1')
|
||||
executable('example', 'src/example.cpp', dependencies: daw-exp)
|
||||
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user