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/release.mk
include scripts/test.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 # 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__LINUX_ALSA__ @$(CXX) $< -c -O2 -o $@ -D__WINDOWS_MM__
doc: Doxyfile musique/*.cc musique/*.hh doc: Doxyfile musique/*.cc musique/*.hh
doxygen doxygen

View File

@ -6,7 +6,8 @@ CPPFLAGS:=$(CPPFLAGS) -Ilib/expected/ -I. -Ilib/bestline/ -Ilib/rtmidi/
RELEASE_FLAGS=-O2 RELEASE_FLAGS=-O2
DEBUG_FLAGS=-O0 -ggdb -fsanitize=undefined -DDebug DEBUG_FLAGS=-O0 -ggdb -fsanitize=undefined -DDebug
CXX=g++ CC=i686-w64-mingw32-gcc
CXX=i686-w64-mingw32-g++
LDFLAGS=-flto 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 usize = std::size_t;
using isize = std::ptrdiff_t; using isize = std::ptrdiff_t;
using uint = unsigned int;
/// Combine several lambdas into one for visiting std::variant /// Combine several lambdas into one for visiting std::variant
template<typename ...Lambdas> template<typename ...Lambdas>

View File

@ -16,10 +16,6 @@
#include <musique/try.hh> #include <musique/try.hh>
#include <musique/unicode.hh> #include <musique/unicode.hh>
extern "C" {
#include <bestline.h>
}
namespace fs = std::filesystem; namespace fs = std::filesystem;
static bool ast_only_mode = false; static bool ast_only_mode = false;
@ -194,23 +190,19 @@ 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;
void completion(char const* buf, bestlineCompletions *lc) bool is_tty()
{ {
std::string_view in{buf}; #ifdef __linux__
return isatty(STDOUT_FILENO);
for (auto scope = Runner::the->interpreter.env.get(); scope != nullptr; scope = scope->parent.get()) { #else
for (auto const& [name, _] : scope->variables) { return true;
if (name.starts_with(in)) { #endif
bestlineAddCompletion(lc, name.c_str());
}
}
}
} }
/// Fancy main that supports Result forwarding on error (Try macro) /// Fancy main that supports Result forwarding on error (Try macro)
static std::optional<Error> Main(std::span<char const*> args) 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(); pretty::terminal_mode();
} }
@ -314,23 +306,20 @@ 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;
bestlineSetCompletionCallback(completion);
for (;;) { for (;;) {
char *input_buffer = bestlineWithHistory("> ", "musique"); std::string_view raw;
if (input_buffer == nullptr) { if (auto s = new std::string{}; std::getline(std::cin, *s)) {
raw = *s;
} else {
break; break;
} }
// 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;
trim(command); trim(command);
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
free(input_buffer);
continue; continue;
} }

View File

@ -4,6 +4,6 @@ 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/bestline.o bin/rtmidi.o bin/musique: $(Release_Obj) bin/main.o bin/rtmidi.o
@echo "CXX $@" @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)