Added Midi dependency
This commit is contained in:
parent
f28cb10669
commit
8853451cb5
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
[submodule "lib/midi"]
|
||||
path = lib/midi
|
||||
url = git@engi.evolpe.it:pi/midi.git
|
9
Makefile
9
Makefile
@ -1,9 +1,12 @@
|
||||
MAKEFLAGS="-j $(grep -c ^processor /proc/cpuinfo)"
|
||||
CXXFLAGS:=$(CXXFLAGS) -std=c++20 -Wall -Wextra -Werror=switch -Werror=return-type -Werror=unused-result
|
||||
CPPFLAGS:=$(CPPFLAGS) -Ilib/expected/ -Ilib/ut/ -Isrc/
|
||||
CPPFLAGS:=$(CPPFLAGS) -Ilib/expected/ -Ilib/ut/ -Ilib/midi/include -Isrc/
|
||||
RELEASE_FLAGS=-O3
|
||||
DEBUG_FLAGS=-O0 -ggdb
|
||||
|
||||
LDFLAGS=-L./lib/midi/
|
||||
LDLIBS=-lmidi-alsa -lasound
|
||||
|
||||
Obj= \
|
||||
environment.o \
|
||||
errors.o \
|
||||
@ -29,8 +32,8 @@ debug: bin/debug/musique
|
||||
bin/%.o: src/%.cc src/*.hh
|
||||
g++ $(CXXFLAGS) $(RELEASE_FLAGS) $(CPPFLAGS) -o $@ $< -c
|
||||
|
||||
bin/musique: $(Release_Obj) bin/main.o src/*.hh
|
||||
g++ $(CXXFLAGS) $(RELEASE_FLAGS) $(CPPFLAGS) -o $@ $(Release_Obj) bin/main.o
|
||||
bin/musique: $(Release_Obj) bin/main.o src/*.hh lib/midi/libmidi-alsa.a
|
||||
g++ $(CXXFLAGS) $(RELEASE_FLAGS) $(CPPFLAGS) -o $@ $(Release_Obj) bin/main.o $(LDFLAGS) $(LDLIBS)
|
||||
|
||||
bin/debug/musique: $(Debug_Obj) bin/debug/main.o src/*.hh
|
||||
g++ $(CXXFLAGS) $(DEBUG_FLAGS) $(CPPFLAGS) -o $@ $(Debug_Obj) bin/debug/main.o
|
||||
|
16
README.md
16
README.md
@ -5,6 +5,22 @@ Interpreter języka Musique. Możliwy do wykorzystywania jako:
|
||||
- biblioteka interpretera języka dołączana do innego projektu (podobnie jak Lua);
|
||||
- REPL działający w systemie GNU/Linux + ALSA wykonujący język Musique.
|
||||
|
||||
## Budowanie interpretera
|
||||
|
||||
Jeśli nie posiadasz zależności `lib/midi` to:
|
||||
|
||||
```console
|
||||
$ git submodule init
|
||||
$ git submodule update
|
||||
$ (cd lib/midi; make)
|
||||
```
|
||||
|
||||
A następnie zbuduj interpreter:
|
||||
|
||||
```console
|
||||
$ make bin/musique
|
||||
```
|
||||
|
||||
## Dostępne komendy
|
||||
|
||||
- `make` - Buduje interpreter `bin/musique` (tryb release)
|
||||
|
1
lib/midi
Submodule
1
lib/midi
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit fb7d28563bf731b0a689ce9902dfad0ec9e63b19
|
25
src/main.cc
25
src/main.cc
@ -1,9 +1,11 @@
|
||||
#include <iostream>
|
||||
#include <musique.hh>
|
||||
|
||||
#include <filesystem>
|
||||
#include <span>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <span>
|
||||
|
||||
#include <musique.hh>
|
||||
#define MIDI_ENABLE_ALSA_SUPPORT
|
||||
#include <midi.hh>
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
@ -23,12 +25,12 @@ void usage()
|
||||
"usage: musique <options> [filename]\n"
|
||||
" where filename is path to file with Musique code that will be executed\n"
|
||||
" where options are:\n"
|
||||
" -c CODE\n"
|
||||
" --run CODE\n"
|
||||
" -c,--run CODE\n"
|
||||
" executes given code\n"
|
||||
"\n"
|
||||
" --ast\n"
|
||||
" prints ast for given code\n";
|
||||
" prints ast for given code\n"
|
||||
" -l,--list\n"
|
||||
" lists all available MIDI ports and quit\n";
|
||||
std::exit(1);
|
||||
}
|
||||
|
||||
@ -65,6 +67,13 @@ static Result<void> Main(std::span<char const*> args)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (arg == "-l" || arg == "--list") {
|
||||
midi::ALSA alsa("musique");
|
||||
alsa.init_sequencer();
|
||||
alsa.list_ports(std::cout);
|
||||
return {};
|
||||
}
|
||||
|
||||
if (arg == "-c" || arg == "--run") {
|
||||
if (args.empty()) {
|
||||
std::cerr << "musique: error: option " << arg << " requires an argument" << std::endl;
|
||||
|
Loading…
Reference in New Issue
Block a user