Compiling with mingw

This commit is contained in:
Robert Bendun 2022-10-08 17:18:55 +02:00
parent 32f2183136
commit ecabf885f3
5 changed files with 18 additions and 31 deletions

View File

@ -9,14 +9,10 @@ include scripts/debug.mk
include scripts/release.mk
include scripts/test.mk
bin/bestline.o: lib/bestline/bestline.c lib/bestline/bestline.h
@echo "CC $@"
@$(CC) $< -c -O3 -o $@
# http://www.music.mcgill.ca/~gary/rtmidi/#compiling
bin/rtmidi.o: lib/rtmidi/RtMidi.cpp lib/rtmidi/RtMidi.h
@echo "CXX $@"
@$(CXX) $< -c -O2 -o $@ -D__LINUX_ALSA__
@$(CXX) $< -c -O2 -o $@ -D__WINDOWS_MM__
doc: Doxyfile musique/*.cc musique/*.hh
doxygen

View File

@ -6,7 +6,8 @@ CPPFLAGS:=$(CPPFLAGS) -Ilib/expected/ -I. -Ilib/bestline/ -Ilib/rtmidi/
RELEASE_FLAGS=-O2
DEBUG_FLAGS=-O0 -ggdb -fsanitize=undefined -DDebug
CXX=g++
CC=i686-w64-mingw32-gcc
CXX=i686-w64-mingw32-g++
LDFLAGS=-flto
LDLIBS=-lasound -lpthread -static-libgcc -static-libstdc++
LDLIBS=-lwinmm -lpthread -static-libgcc -static-libstdc++

View File

@ -20,6 +20,7 @@ using i64 = std::int64_t;
using usize = std::size_t;
using isize = std::ptrdiff_t;
using uint = unsigned int;
/// Combine several lambdas into one for visiting std::variant
template<typename ...Lambdas>

View File

@ -16,10 +16,6 @@
#include <musique/try.hh>
#include <musique/unicode.hh>
extern "C" {
#include <bestline.h>
}
namespace fs = std::filesystem;
static bool ast_only_mode = false;
@ -194,23 +190,19 @@ struct Runner
/// some of the strings are only views into source
std::vector<std::string> eternal_sources;
void completion(char const* buf, bestlineCompletions *lc)
bool is_tty()
{
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());
}
}
}
#ifdef __linux__
return isatty(STDOUT_FILENO);
#else
return true;
#endif
}
/// Fancy main that supports Result forwarding on error (Try macro)
static std::optional<Error> Main(std::span<char const*> args)
{
if (isatty(STDOUT_FILENO) && getenv("NO_COLOR") == nullptr) {
if (is_tty() && getenv("NO_COLOR") == nullptr) {
pretty::terminal_mode();
}
@ -314,23 +306,20 @@ static std::optional<Error> Main(std::span<char const*> args)
if (runnables.empty() || enable_repl) {
repl_line_number = 1;
enable_repl = true;
bestlineSetCompletionCallback(completion);
for (;;) {
char *input_buffer = bestlineWithHistory("> ", "musique");
if (input_buffer == nullptr) {
std::string_view raw;
if (auto s = new std::string{}; std::getline(std::cin, *s)) {
raw = *s;
} else {
break;
}
// Raw input line used for execution in language
std::string_view raw = input_buffer;
// Used to recognize REPL commands
std::string_view command = raw;
trim(command);
if (command.empty()) {
// Line is empty so there is no need to execute it or parse it
free(input_buffer);
continue;
}

View File

@ -4,6 +4,6 @@ bin/%.o: musique/%.cc
@echo "CXX $@"
@$(CXX) $(CXXFLAGS) $(RELEASE_FLAGS) $(CPPFLAGS) -o $@ $< -c
bin/musique: $(Release_Obj) bin/main.o bin/bestline.o bin/rtmidi.o
bin/musique: $(Release_Obj) bin/main.o bin/rtmidi.o
@echo "CXX $@"
@$(CXX) $(CXXFLAGS) $(RELEASE_FLAGS) $(CPPFLAGS) -o $@ $(Release_Obj) bin/bestline.o bin/rtmidi.o $(LDFLAGS) $(LDLIBS)
@$(CXX) $(CXXFLAGS) $(RELEASE_FLAGS) $(CPPFLAGS) -o $@ $(Release_Obj) bin/rtmidi.o $(LDFLAGS) $(LDLIBS)