Windows support
This commit is contained in:
parent
ecabf885f3
commit
e8ef207ec9
@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
* Added `scan` builtin, which computes prefix sum of passed values when provided with addition operator
|
* Added `scan` builtin, which computes prefix sum of passed values when provided with addition operator
|
||||||
* Added [rtmidi](https://github.com/thestk/rtmidi/) dependency which should provide multiplatform MIDI support
|
* Added [rtmidi](https://github.com/thestk/rtmidi/) dependency which should provide multiplatform MIDI support
|
||||||
|
* Support for Windows (with only basic REPL)
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
3
Makefile
3
Makefile
@ -8,11 +8,12 @@ all: bin/musique
|
|||||||
include scripts/debug.mk
|
include scripts/debug.mk
|
||||||
include scripts/release.mk
|
include scripts/release.mk
|
||||||
include scripts/test.mk
|
include scripts/test.mk
|
||||||
|
include scripts/windows.mk
|
||||||
|
|
||||||
# http://www.music.mcgill.ca/~gary/rtmidi/#compiling
|
# http://www.music.mcgill.ca/~gary/rtmidi/#compiling
|
||||||
bin/rtmidi.o: lib/rtmidi/RtMidi.cpp lib/rtmidi/RtMidi.h
|
bin/rtmidi.o: lib/rtmidi/RtMidi.cpp lib/rtmidi/RtMidi.h
|
||||||
@echo "CXX $@"
|
@echo "CXX $@"
|
||||||
@$(CXX) $< -c -O2 -o $@ -D__WINDOWS_MM__
|
@$(CXX) $< -c -O2 -o $@ $(CPPFLAGS)
|
||||||
|
|
||||||
doc: Doxyfile musique/*.cc musique/*.hh
|
doc: Doxyfile musique/*.cc musique/*.hh
|
||||||
doxygen
|
doxygen
|
||||||
|
28
README.md
28
README.md
@ -21,9 +21,8 @@ $ sudo apt install -y build-essential libasound2-dev
|
|||||||
|
|
||||||
## Budowanie interpretera
|
## Budowanie interpretera
|
||||||
|
|
||||||
```console
|
- Aby wybudować wersję Linux+ALSA: `make`
|
||||||
$ make bin/musique
|
- Aby wybudować wersję Windows: `make os=windows`
|
||||||
```
|
|
||||||
|
|
||||||
Żeby zainstalować interpreter języka Musique w systemie, należy dodatkowo wykonać polecenie:
|
Żeby zainstalować interpreter języka Musique w systemie, należy dodatkowo wykonać polecenie:
|
||||||
|
|
||||||
@ -38,6 +37,7 @@ $ make bin/musique
|
|||||||
- `make` - Buduje interpreter `bin/musique` (tryb release)
|
- `make` - Buduje interpreter `bin/musique` (tryb release)
|
||||||
- `make debug` - Buduje interpreter `bin/debug/musique` (tryb debug)
|
- `make debug` - Buduje interpreter `bin/debug/musique` (tryb debug)
|
||||||
- `make clean` - Usuwa reprodukowalne elementy projektu (automatycznie stworzone pliki binarne czy raporty)
|
- `make clean` - Usuwa reprodukowalne elementy projektu (automatycznie stworzone pliki binarne czy raporty)
|
||||||
|
|
||||||
### Dokumentacja
|
### Dokumentacja
|
||||||
|
|
||||||
- `make doc` - Tworzy `doc/build/html/` zawierający dokumentację projektu
|
- `make doc` - Tworzy `doc/build/html/` zawierający dokumentację projektu
|
||||||
@ -45,28 +45,6 @@ $ make bin/musique
|
|||||||
### Testowanie
|
### Testowanie
|
||||||
|
|
||||||
- `make test` - Uruchom wszystkie dostępne testy automatyczne
|
- `make test` - Uruchom wszystkie dostępne testy automatyczne
|
||||||
- `scripts/test.py test examples` - Uruchamia testy zachowań przykładów
|
|
||||||
- `scripts/test.py record examples` - Nagrywa testy zachowań przykładów
|
|
||||||
|
|
||||||
### Debugowanie
|
|
||||||
|
|
||||||
- `scripts/log-function-calls.sh` - Tworzy listę wywołań funkcji używając GDB
|
|
||||||
|
|
||||||
## Budowa projektu
|
|
||||||
|
|
||||||
```
|
|
||||||
.
|
|
||||||
├── bin Miejsce produkcji plików wykonywalnych
|
|
||||||
├── doc Dokumentacja języka, interpretera
|
|
||||||
│ └── build Miejsce produkcji dokumentacji
|
|
||||||
├── editor Pluginy do edytorów dodające wsparcie dla języka
|
|
||||||
├── lib Zewnętrzne zależności projektu
|
|
||||||
│ ├── expected
|
|
||||||
│ └── ut
|
|
||||||
└── include Główny katalog z plikami nagłówkowymi
|
|
||||||
├── scripts Skrypty wspierające budowanie i tworzenie
|
|
||||||
└── src Główny katalog z plikami źródłowymi
|
|
||||||
```
|
|
||||||
|
|
||||||
## Kolorowanie składni
|
## Kolorowanie składni
|
||||||
|
|
||||||
|
13
config.mk
13
config.mk
@ -2,12 +2,21 @@ MAKEFLAGS="-j $(grep -c ^processor /proc/cpuinfo)"
|
|||||||
|
|
||||||
CXXFLAGS:=$(CXXFLAGS) -std=c++20 -Wall -Wextra -Werror=switch -Werror=return-type -Werror=unused-result -Wno-maybe-uninitialized
|
CXXFLAGS:=$(CXXFLAGS) -std=c++20 -Wall -Wextra -Werror=switch -Werror=return-type -Werror=unused-result -Wno-maybe-uninitialized
|
||||||
CPPFLAGS:=$(CPPFLAGS) -Ilib/expected/ -I. -Ilib/bestline/ -Ilib/rtmidi/
|
CPPFLAGS:=$(CPPFLAGS) -Ilib/expected/ -I. -Ilib/bestline/ -Ilib/rtmidi/
|
||||||
|
LDFLAGS=-flto
|
||||||
|
LDLIBS= -lpthread -static-libgcc -static-libstdc++
|
||||||
|
|
||||||
RELEASE_FLAGS=-O2
|
RELEASE_FLAGS=-O2
|
||||||
DEBUG_FLAGS=-O0 -ggdb -fsanitize=undefined -DDebug
|
DEBUG_FLAGS=-O0 -ggdb -fsanitize=undefined -DDebug
|
||||||
|
|
||||||
|
ifeq ($(os),windows)
|
||||||
CC=i686-w64-mingw32-gcc
|
CC=i686-w64-mingw32-gcc
|
||||||
CXX=i686-w64-mingw32-g++
|
CXX=i686-w64-mingw32-g++
|
||||||
|
CPPFLAGS:=$(CPPFLAGS) -D__WINDOWS_MM__
|
||||||
|
LDLIBS:=-lwinmm $(LDLIBS)
|
||||||
|
else
|
||||||
|
CC=gcc
|
||||||
|
CXX=g++
|
||||||
|
CPPFLAGS:=$(CPPFLAGS) -D __LINUX_ALSA__
|
||||||
|
LDLIBS:=-lasound $(LDLIBS)
|
||||||
|
endif
|
||||||
|
|
||||||
LDFLAGS=-flto
|
|
||||||
LDLIBS=-lwinmm -lpthread -static-libgcc -static-libstdc++
|
|
||||||
|
@ -16,6 +16,16 @@
|
|||||||
#include <musique/try.hh>
|
#include <musique/try.hh>
|
||||||
#include <musique/unicode.hh>
|
#include <musique/unicode.hh>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
extern "C" {
|
||||||
|
#include <io.h>
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
extern "C" {
|
||||||
|
#include <bestline.h>
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
static bool ast_only_mode = false;
|
static bool ast_only_mode = false;
|
||||||
@ -190,12 +200,27 @@ struct Runner
|
|||||||
/// some of the strings are only views into source
|
/// some of the strings are only views into source
|
||||||
std::vector<std::string> eternal_sources;
|
std::vector<std::string> eternal_sources;
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
void completion(char const* buf, bestlineCompletions *lc)
|
||||||
|
{
|
||||||
|
std::string_view in{buf};
|
||||||
|
|
||||||
|
for (auto scope = Runner::the->interpreter.env.get(); scope != nullptr; scope = scope->parent.get()) {
|
||||||
|
for (auto const& [name, _] : scope->variables) {
|
||||||
|
if (name.starts_with(in)) {
|
||||||
|
bestlineAddCompletion(lc, name.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool is_tty()
|
bool is_tty()
|
||||||
{
|
{
|
||||||
#ifdef __linux__
|
#ifdef _WIN32
|
||||||
return isatty(STDOUT_FILENO);
|
return _isatty(STDOUT_FILENO);
|
||||||
#else
|
#else
|
||||||
return true;
|
return isatty(STDOUT_FILENO);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,13 +331,29 @@ static std::optional<Error> Main(std::span<char const*> args)
|
|||||||
if (runnables.empty() || enable_repl) {
|
if (runnables.empty() || enable_repl) {
|
||||||
repl_line_number = 1;
|
repl_line_number = 1;
|
||||||
enable_repl = true;
|
enable_repl = true;
|
||||||
|
#ifndef _WIN32
|
||||||
|
bestlineSetCompletionCallback(completion);
|
||||||
|
#else
|
||||||
|
std::vector<std::string> repl_source_lines;
|
||||||
|
#endif
|
||||||
for (;;) {
|
for (;;) {
|
||||||
std::string_view raw;
|
#ifndef _WIN32
|
||||||
if (auto s = new std::string{}; std::getline(std::cin, *s)) {
|
char const* input_buffer = bestlineWithHistory("> ", "musique");
|
||||||
raw = *s;
|
if (input_buffer == nullptr) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
std::cout << "> " << std::flush;
|
||||||
|
char const* input_buffer;
|
||||||
|
if (std::string s{}; std::getline(std::cin, s)) {
|
||||||
|
repl_source_lines.push_back(std::move(s));
|
||||||
|
input_buffer = repl_source_lines.back().c_str();
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
// Raw input line used for execution in language
|
||||||
|
std::string_view raw = input_buffer;
|
||||||
|
|
||||||
// Used to recognize REPL commands
|
// Used to recognize REPL commands
|
||||||
std::string_view command = raw;
|
std::string_view command = raw;
|
||||||
@ -320,6 +361,11 @@ static std::optional<Error> Main(std::span<char const*> args)
|
|||||||
|
|
||||||
if (command.empty()) {
|
if (command.empty()) {
|
||||||
// Line is empty so there is no need to execute it or parse it
|
// Line is empty so there is no need to execute it or parse it
|
||||||
|
#ifndef _WIN32
|
||||||
|
free(const_cast<char*>(input_buffer));
|
||||||
|
#else
|
||||||
|
repl_source_lines.pop_back();
|
||||||
|
#endif
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,13 +16,14 @@ fi
|
|||||||
|
|
||||||
mkdir -p "$Target"
|
mkdir -p "$Target"
|
||||||
|
|
||||||
if ! [ -f bin/musique ]; then
|
make clean && make bin/musique
|
||||||
make bin/musique
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Copy bin/musique, examples, license and documentation"
|
|
||||||
|
|
||||||
cp bin/musique "$Target"/
|
cp bin/musique "$Target"/
|
||||||
|
|
||||||
|
make clean && make bin/musique os=windows
|
||||||
|
cp bin/musique.exe "$Target"/
|
||||||
|
|
||||||
|
echo "Copy examples, license and documentation"
|
||||||
|
|
||||||
cp LICENSE "$Target"/LICENSE
|
cp LICENSE "$Target"/LICENSE
|
||||||
cp CHANGELOG.md "$Target/CHANGELOG.md"
|
cp CHANGELOG.md "$Target/CHANGELOG.md"
|
||||||
cp -r examples "$Target"/examples
|
cp -r examples "$Target"/examples
|
||||||
|
@ -1,9 +1,15 @@
|
|||||||
|
ifneq ($(os),windows)
|
||||||
Release_Obj=$(addprefix bin/,$(Obj))
|
Release_Obj=$(addprefix bin/,$(Obj))
|
||||||
|
|
||||||
|
bin/bestline.o: lib/bestline/bestline.c lib/bestline/bestline.h
|
||||||
|
@echo "CC $@"
|
||||||
|
@$(CC) $< -c -O3 -o $@
|
||||||
|
|
||||||
bin/%.o: musique/%.cc
|
bin/%.o: musique/%.cc
|
||||||
@echo "CXX $@"
|
@echo "CXX $@"
|
||||||
@$(CXX) $(CXXFLAGS) $(RELEASE_FLAGS) $(CPPFLAGS) -o $@ $< -c
|
@$(CXX) $(CXXFLAGS) $(RELEASE_FLAGS) $(CPPFLAGS) -o $@ $< -c
|
||||||
|
|
||||||
bin/musique: $(Release_Obj) bin/main.o bin/rtmidi.o
|
bin/musique: $(Release_Obj) bin/main.o bin/rtmidi.o bin/bestline.o
|
||||||
@echo "CXX $@"
|
@echo "CXX $@"
|
||||||
@$(CXX) $(CXXFLAGS) $(RELEASE_FLAGS) $(CPPFLAGS) -o $@ $(Release_Obj) bin/rtmidi.o $(LDFLAGS) $(LDLIBS)
|
@$(CXX) $(CXXFLAGS) $(RELEASE_FLAGS) $(CPPFLAGS) -o $@ $(Release_Obj) bin/rtmidi.o bin/bestline.o $(LDFLAGS) $(LDLIBS)
|
||||||
|
endif
|
||||||
|
11
scripts/windows.mk
Normal file
11
scripts/windows.mk
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
ifeq ($(os),windows)
|
||||||
|
Release_Obj=$(addprefix bin/,$(Obj))
|
||||||
|
|
||||||
|
bin/%.o: musique/%.cc
|
||||||
|
@echo "CXX $@"
|
||||||
|
@$(CXX) $(CXXFLAGS) $(RELEASE_FLAGS) $(CPPFLAGS) -o $@ $< -c
|
||||||
|
|
||||||
|
bin/musique: $(Release_Obj) bin/main.o bin/rtmidi.o
|
||||||
|
@echo "CXX $@"
|
||||||
|
@$(CXX) $(CXXFLAGS) $(RELEASE_FLAGS) $(CPPFLAGS) -o $@ $(Release_Obj) bin/rtmidi.o $(LDFLAGS) $(LDLIBS)
|
||||||
|
endif
|
Loading…
Reference in New Issue
Block a user