diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..80d24ac --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "lib/midi"] + path = lib/midi + url = git@engi.evolpe.it:pi/midi.git diff --git a/Makefile b/Makefile index 5685dc3..b18b820 100644 --- a/Makefile +++ b/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 diff --git a/README.md b/README.md index fafe112..7806d7d 100644 --- a/README.md +++ b/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) diff --git a/lib/midi b/lib/midi new file mode 160000 index 0000000..fb7d285 --- /dev/null +++ b/lib/midi @@ -0,0 +1 @@ +Subproject commit fb7d28563bf731b0a689ce9902dfad0ec9e63b19 diff --git a/src/main.cc b/src/main.cc index f14941d..93a49e1 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1,9 +1,11 @@ -#include -#include - #include -#include #include +#include +#include + +#include +#define MIDI_ENABLE_ALSA_SUPPORT +#include namespace fs = std::filesystem; @@ -23,12 +25,12 @@ void usage() "usage: musique [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 Main(std::span 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;