Compare commits
No commits in common. "d351b49148988f62c76e0c91a596a540bb204075" and "2d61896824c0b8a81dee4ea8f6ead6d6d47bd5a1" have entirely different histories.
d351b49148
...
2d61896824
@ -7,14 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
|
||||
- `CTRL-C` handler that turns notes that are playing off
|
||||
|
||||
### Changed
|
||||
|
||||
- Moved from `bestline` to `replxx` Readline implementation due to lack of Windows support from bestline
|
||||
|
||||
## [0.4.0]
|
||||
|
||||
### Added
|
||||
|
@ -13,7 +13,7 @@ VERSION := $(MAJOR).$(MINOR).$(PATCH)-dev+$(COMMIT)
|
||||
|
||||
CXXFLAGS:=$(CXXFLAGS) -std=c++20 -Wall -Wextra -Werror=switch -Werror=return-type -Werror=unused-result -ggdb
|
||||
CPPFLAGS:=$(CPPFLAGS) -DMusique_Version='"$(VERSION)"' \
|
||||
-Ilib/expected/ -I. -Ilib/bestline/ -Ilib/rtmidi/ -Ilib/link/include -Ilib/asio/include/ -Ilib/replxx/include -DREPLXX_STATIC
|
||||
-Ilib/expected/ -I. -Ilib/bestline/ -Ilib/rtmidi/ -Ilib/link/include -Ilib/asio/include/ -Ilib/replxx/include
|
||||
LDFLAGS=-flto
|
||||
LDLIBS= -lpthread
|
||||
|
||||
|
@ -62,11 +62,4 @@ concept Three_Way_Comparable = requires (T const& lhs, T const& rhs) {
|
||||
{ lhs <=> rhs };
|
||||
};
|
||||
|
||||
template<typename Needle, typename ...Heystack>
|
||||
requires (std::equality_comparable_with<Needle const&, Heystack const&> && ...)
|
||||
constexpr bool one_of(Needle const& needle, Heystack const& ...heystack)
|
||||
{
|
||||
return ((needle == heystack) || ...);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -14,11 +14,9 @@
|
||||
#include <musique/lexer/lines.hh>
|
||||
#include <musique/midi/midi.hh>
|
||||
#include <musique/parser/parser.hh>
|
||||
#include <musique/platform.hh>
|
||||
#include <musique/pretty.hh>
|
||||
#include <musique/try.hh>
|
||||
#include <musique/unicode.hh>
|
||||
#include <musique/user_directory.hh>
|
||||
#include <musique/value/block.hh>
|
||||
|
||||
#include <replxx.hxx>
|
||||
@ -227,7 +225,6 @@ struct Runner
|
||||
}
|
||||
} catch (KeyboardInterrupt const&) {
|
||||
interpreter.turn_off_all_active_notes();
|
||||
interpreter.starter.stop();
|
||||
std::cout << std::endl;
|
||||
}
|
||||
return {};
|
||||
@ -253,9 +250,8 @@ void completion(char const* buf, bestlineCompletions *lc)
|
||||
}
|
||||
#endif
|
||||
|
||||
static bool is_tty()
|
||||
bool is_tty()
|
||||
{
|
||||
// Can't use if constexpr since _isatty is not defined on non-windows platforms
|
||||
#ifdef _WIN32
|
||||
return _isatty(STDOUT_FILENO);
|
||||
#else
|
||||
@ -361,16 +357,6 @@ static Result<bool> handle_repl_session_commands(std::string_view input, Runner
|
||||
return false;
|
||||
}
|
||||
|
||||
static Runner *runner;
|
||||
|
||||
void sigint_handler(int sig)
|
||||
{
|
||||
if (sig == SIGINT) {
|
||||
runner->interpreter.issue_interrupt();
|
||||
}
|
||||
std::signal(SIGINT, sigint_handler);
|
||||
}
|
||||
|
||||
/// Fancy main that supports Result forwarding on error (Try macro)
|
||||
static std::optional<Error> Main(std::span<char const*> args)
|
||||
{
|
||||
@ -445,9 +431,8 @@ static std::optional<Error> Main(std::span<char const*> args)
|
||||
std::exit(1);
|
||||
}
|
||||
|
||||
Runner runner;
|
||||
::runner = &runner;
|
||||
std::signal(SIGINT, sigint_handler);
|
||||
static Runner runner;
|
||||
std::signal(SIGINT, [](int sig) { if (sig == SIGINT) runner.interpreter.issue_interrupt(); });
|
||||
|
||||
for (auto const& [type, argument] : runnables) {
|
||||
if (type == Run::Argument) {
|
||||
@ -488,11 +473,13 @@ static std::optional<Error> Main(std::span<char const*> args)
|
||||
|
||||
replxx::Replxx repl;
|
||||
|
||||
auto const history_path = (user_directory::data_home() / "history").string();
|
||||
{
|
||||
std::ifstream history(".musique_history");
|
||||
repl.history_load(history);
|
||||
}
|
||||
|
||||
repl.set_max_history_size(2048);
|
||||
repl.set_max_hint_rows(3);
|
||||
repl.history_load(history_path);
|
||||
|
||||
for (;;) {
|
||||
char const* input = nullptr;
|
||||
@ -514,7 +501,6 @@ static std::optional<Error> Main(std::span<char const*> args)
|
||||
}
|
||||
|
||||
repl.history_add(std::string(command));
|
||||
repl.history_save(history_path);
|
||||
|
||||
if (command.starts_with(':')) {
|
||||
command.remove_prefix(1);
|
||||
|
@ -1,24 +0,0 @@
|
||||
#ifndef MUSIQUE_PLATFORM_HH
|
||||
#define MUSIQUE_PLATFORM_HH
|
||||
|
||||
namespace platform
|
||||
{
|
||||
enum class Operating_System
|
||||
{
|
||||
MacOS,
|
||||
Unix,
|
||||
Windows,
|
||||
};
|
||||
|
||||
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
|
||||
static constexpr Operating_System os = Operating_System::Windows;
|
||||
#elif defined(__APPLE__)
|
||||
static constexpr Operating_System os = Operating_System::MacOS;
|
||||
#elif defined(__linux__) || defined(__unix__)
|
||||
static constexpr Operating_System os = Operating_System::Unix;
|
||||
#else
|
||||
#error "Unknown platform"
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // MUSIQUE_PLATFORM_HH
|
@ -1,92 +0,0 @@
|
||||
#include <musique/user_directory.hh>
|
||||
#include <musique/errors.hh>
|
||||
#include <musique/platform.hh>
|
||||
|
||||
static std::filesystem::path home()
|
||||
{
|
||||
if constexpr (platform::os == platform::Operating_System::Windows) {
|
||||
if (auto home = std::getenv("USERPROFILE")) return home;
|
||||
|
||||
if (auto drive = std::getenv("HOMEDRIVE")) {
|
||||
if (auto path = std::getenv("HOMEPATH")) {
|
||||
return std::string(drive) + path;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (auto home = std::getenv("HOME")) {
|
||||
return home;
|
||||
}
|
||||
}
|
||||
|
||||
unreachable();
|
||||
}
|
||||
|
||||
std::filesystem::path user_directory::data_home()
|
||||
{
|
||||
std::filesystem::path path;
|
||||
|
||||
static_assert(one_of(platform::os,
|
||||
platform::Operating_System::Unix,
|
||||
platform::Operating_System::Windows,
|
||||
platform::Operating_System::MacOS
|
||||
));
|
||||
|
||||
if constexpr (platform::os == platform::Operating_System::Unix) {
|
||||
if (auto data = std::getenv("XDG_DATA_HOME")) {
|
||||
path = data;
|
||||
} else {
|
||||
path = home() / ".local" / "share";
|
||||
}
|
||||
}
|
||||
|
||||
if constexpr (platform::os == platform::Operating_System::Windows) {
|
||||
if (auto data = std::getenv("LOCALAPPDATA")) {
|
||||
path = data;
|
||||
} else {
|
||||
path = home() / "AppData" / "Local";
|
||||
}
|
||||
}
|
||||
|
||||
if constexpr (platform::os == platform::Operating_System::MacOS) {
|
||||
path = home() / "Library";
|
||||
}
|
||||
|
||||
path /= "musique";
|
||||
std::filesystem::create_directories(path);
|
||||
return path;
|
||||
}
|
||||
|
||||
std::filesystem::path user_directory::config_home()
|
||||
{
|
||||
std::filesystem::path path;
|
||||
|
||||
static_assert(one_of(platform::os,
|
||||
platform::Operating_System::Unix,
|
||||
platform::Operating_System::Windows,
|
||||
platform::Operating_System::MacOS
|
||||
));
|
||||
|
||||
if constexpr (platform::os == platform::Operating_System::Unix) {
|
||||
if (auto data = std::getenv("XDG_CONFIG_HOME")) {
|
||||
path = data;
|
||||
} else {
|
||||
path = home() / ".config";
|
||||
}
|
||||
}
|
||||
|
||||
if constexpr (platform::os == platform::Operating_System::Windows) {
|
||||
if (auto data = std::getenv("LOCALAPPDATA")) {
|
||||
path = data;
|
||||
} else {
|
||||
path = home() / "AppData" / "Local";
|
||||
}
|
||||
}
|
||||
|
||||
if constexpr (platform::os == platform::Operating_System::MacOS) {
|
||||
path = home() / "Library" / "Preferences";
|
||||
}
|
||||
|
||||
path /= "musique";
|
||||
std::filesystem::create_directories(path);
|
||||
return path;
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
#ifndef MUSIQUE_USER_DIRECTORY_HH
|
||||
#define MUSIQUE_USER_DIRECTORY_HH
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
namespace user_directory
|
||||
{
|
||||
/// Returns system-specific user directory for data; same as XDG_DATA_HOME
|
||||
std::filesystem::path data_home();
|
||||
|
||||
/// Returns system-specific user directory for config; same as XDG_CONFIG_HOME
|
||||
std::filesystem::path config_home();
|
||||
}
|
||||
|
||||
#endif // MUSIQUE_USER_DIRECTORY_HH
|
@ -1,15 +1,15 @@
|
||||
Release_Obj=$(addprefix bin/$(os)/,$(Obj))
|
||||
|
||||
# bin/$(os)/libreplxx.a:
|
||||
# @CXX=$(CXX) os=$(os) scripts/build_replxx.sh
|
||||
bin/$(os)/libreplxx.a:
|
||||
@CXX=$(CXX) os=$(os) scripts/build_replxx.sh
|
||||
|
||||
bin/$(os)/%.o: musique/%.cc
|
||||
@echo "CXX $@"
|
||||
@$(CXX) $(CXXFLAGS) $(RELEASE_FLAGS) $(CPPFLAGS) -o $@ $< -c
|
||||
|
||||
bin/$(os)/$(Target): $(Release_Obj) bin/$(os)/main.o bin/$(os)/rtmidi.o
|
||||
bin/$(os)/$(Target): $(Release_Obj) bin/$(os)/main.o bin/$(os)/rtmidi.o bin/$(os)/libreplxx.a
|
||||
@echo "CXX $@"
|
||||
@$(CXX) $(CXXFLAGS) $(RELEASE_FLAGS) $(CPPFLAGS) -o $@ $(shell CXX=$(CXX) os=$(os) scripts/build_replxx.sh) $(Release_Obj) bin/$(os)/rtmidi.o $(LDFLAGS) $(LDLIBS)
|
||||
@$(CXX) $(CXXFLAGS) $(RELEASE_FLAGS) $(CPPFLAGS) -o $@ $(Release_Obj) bin/$(os)/rtmidi.o -Lbin/$(os)/ $(LDFLAGS) $(LDLIBS) -lreplxx
|
||||
|
||||
Debug_Obj=$(addprefix bin/$(os)/debug/,$(Obj))
|
||||
|
||||
|
@ -8,13 +8,13 @@ mkdir -p "bin/${os}/replxx"
|
||||
|
||||
objects=""
|
||||
|
||||
find lib/replxx/src/ -name '*.cxx' -o -name '*.cpp' | while read -r src
|
||||
echo "Building libreplxx library archive"
|
||||
|
||||
ar rcs "bin/${os}/libreplxx.a" $(find lib/replxx/src/ -name '*.cxx' -o -name '*.cpp' | while read -r src
|
||||
do
|
||||
dst="${src##"$prefix"}"
|
||||
dst="bin/${os}/replxx/${dst%%.*}.o"
|
||||
if [ ! -f "$dst" ]; then
|
||||
"${CXX}" -Ilib/replxx/src/ -Ilib/replxx/include/ -c -o "$dst" "$src" -std=c++20 -O3 -DREPLXX_STATIC
|
||||
fi
|
||||
"${CXX}" -Ilib/replxx/src/ -Ilib/replxx/include/ -c -o "$dst" "$src" -std=c++20 -O3 -DREPLXX_STATIC
|
||||
echo "${dst}"
|
||||
done
|
||||
done)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user