switch to xmake (hopefully everything works)

This commit is contained in:
Mars 2024-09-03 00:02:09 -04:00
parent b1bbc19d62
commit dfabc25ef8
7 changed files with 86 additions and 128 deletions

View file

@ -1,6 +1,7 @@
# noinspection SpellCheckingInspection
Checks: >
*,
-ctad-maybe-unsupported,
-abseil-*,
-altera-*,
-bugprone-easily-swappable-parameters,

View file

@ -1,2 +1,4 @@
Diagnostics:
Suppress: -Wmissing-template-arg-list-after-template-kw
Suppress: >
-Wmissing-template-arg-list-after-template-kw,
-Wctad-maybe-unsupported

1
.gitignore vendored
View file

@ -4,6 +4,7 @@
.idea/
.vs/
.vscode/
.xmake/
bin/
build/

View file

@ -1,116 +0,0 @@
project(
'draconis++', 'cpp',
version: '0.1.0',
default_options: [
'cpp_std=c++20',
'default_library=static',
'warning_level=everything',
'buildtype=release'
]
)
cpp = meson.get_compiler('cpp')
if host_machine.system() == 'darwin'
add_languages('objcpp')
objcpp = meson.get_compiler('objcpp')
add_project_arguments(
objcpp.get_supported_arguments([
'-Wno-c++20-compat',
'-Wno-c++20-extensions',
'-Wno-c++98-compat',
'-Wno-c++98-compat-pedantic',
'-Wno-disabled-macro-expansion',
'-Wno-missing-prototypes',
'-Wno-padded',
'-Wno-pre-c++20-compat-pedantic',
'-Wno-switch-default',
'-Wunused-function',
'-fvisibility=hidden'
]),
language: 'objcpp'
)
endif
common_cpp_args = [
'-Wno-c++20-compat',
'-Wno-c++20-extensions',
'-Wno-c++98-compat',
'-Wno-c++98-compat-pedantic',
'-Wno-disabled-macro-expansion',
'-Wno-missing-prototypes',
'-Wno-padded',
'-Wno-pre-c++20-compat-pedantic',
'-Wno-switch-default',
'-Wunused-function',
'-fvisibility=hidden'
]
if host_machine.system() == 'windows'
common_cpp_args += ['-DCURL_STATICLIB']
endif
add_project_arguments(
cpp.get_supported_arguments(common_cpp_args),
language: 'cpp'
)
source_file_names = [
'src/main.cpp',
'src/config/config.cpp',
'src/config/weather.cpp'
]
if host_machine.system() == 'linux'
source_file_names += ['src/os/linux.cpp']
elif host_machine.system() == 'freebsd'
source_file_names += ['src/os/freebsd.cpp']
elif host_machine.system() == 'darwin'
source_file_names += [
'src/os/macos.cpp',
'src/os/macos/bridge.mm',
]
elif host_machine.system() == 'windows'
source_file_names += ['src/os/windows.cpp']
endif
sources = []
foreach file : source_file_names
sources += files(file)
endforeach
deps = [
dependency('fmt'),
dependency('libcurl'),
dependency('tomlplusplus'),
dependency('yyjson')
]
if host_machine.system() == 'darwin'
deps += dependency('Foundation')
deps += dependency('MediaPlayer')
deps += dependency('SystemConfiguration')
deps += dependency('iconv')
elif host_machine.system() == 'linux' or host_machine.system() == 'freebsd'
deps += dependency('sdbus-c++')
deps += dependency('x11')
endif
objc_args = []
link_args = []
if host_machine.system() == 'darwin'
objc_args += ['-fobjc-arc']
elif host_machine.system() == 'windows'
windows_sdk_lib_dir = 'C:/Program Files (x86)/Windows Kits/10/Lib/10.0.22621.0/um/x64'
link_args += ['-L' + windows_sdk_lib_dir, '-lwindowsapp', '-static']
endif
executable(
'draconis++',
sources,
objc_args: objc_args,
link_args: link_args,
dependencies: deps
)

View file

@ -1,6 +1,7 @@
#include <cstdlib>
#include <filesystem>
#include <fmt/core.h>
#include <stdexcept>
#include <string>
#include "config.h"
@ -27,17 +28,15 @@ inline fn GetConfigPath() -> std::string {
}
fn Config::getInstance() -> Config {
try {
fs::path configPath = GetConfigPath();
configPath /= "draconis++/config.toml";
const Result<Config> result = rfl::toml::load<Config>(configPath.string());
if (result)
return result.value();
fmt::println("Failed to load config file: {}", result.error().value().what());
} catch (const std::exception& e) { fmt::println("Error getting config path: {}", e.what()); }
return {};
if (!result) {
fmt::println(stderr, "Failed to load config file: {}", result.error()->what());
exit(1);
}
return result.value();
}

View file

@ -84,7 +84,8 @@ fn main() -> i32 {
const string nowPlaying = GetNowPlaying();
if (!nowPlaying.empty())
fmt::println("{}", nowPlaying);
else fmt::println("No song playing");
else
fmt::println("No song playing");
}
return 0;

70
xmake.lua Normal file
View file

@ -0,0 +1,70 @@
---@diagnostic disable: undefined-field, undefined-global
add_requires("fmt", "libcurl", "tomlplusplus", "yyjson")
if os.host() == "macosx" then
add_requires("Foundation", "MediaPlayer", "SystemConfiguration", "iconv")
elseif os.host() == "linux" or os.host() == "bsd" then
add_requires("sdbus-c++", "x11")
end
add_cxxflags(
"-Wno-c++20-compat",
"-Wno-c++20-extensions",
"-Wno-c++98-compat",
"-Wno-c++98-compat-pedantic",
"-Wno-disabled-macro-expansion",
"-Wno-missing-prototypes",
"-Wno-padded",
"-Wno-pre-c++20-compat-pedantic",
"-Wno-switch-default",
"-Wunused-function",
"-fvisibility=hidden"
)
if os.host() == "macosx" then
add_mxxflags(
"-Wno-c++20-compat",
"-Wno-c++20-extensions",
"-Wno-c++98-compat",
"-Wno-c++98-compat-pedantic",
"-Wno-disabled-macro-expansion",
"-Wno-missing-prototypes",
"-Wno-padded",
"-Wno-pre-c++20-compat-pedantic",
"-Wno-switch-default",
"-Wunused-function",
"-fvisibility=hidden",
"-fobjc-arc"
)
elseif os.host() == "windows" then
add_cxxflags("-DCURL_STATICLIB")
add_ldflags("-LC:/Program Files (x86)/Windows Kits/10/Lib/10.0.22621.0/um/x64", "-lwindowsapp", "static")
end
target("draconis++")
set_languages("c++20")
set_kind("binary")
add_rules("plugin.compile_commands.autoupdate", { outputdir = "." })
add_rules("mode.debug", "mode.release")
add_files("src/main.cpp", "src/config/config.cpp", "src/config/weather.cpp")
if os.host() == "bsd" then
add_files("src/os/freebsd.cpp")
elseif os.host() == "linux" then
add_files("src/os/linux.cpp")
elseif os.host() == "macosx" then
add_files("src/os/macos.cpp", "src/os/macos/bridge.mm")
elseif os.host() == "windows" then
add_files("src/os/windows.cpp")
end
add_packages("fmt", "libcurl", "tomlplusplus", "yyjson")
if os.host() == "macosx" then
add_packages("Foundation", "MediaPlayer", "SystemConfiguration", "iconv")
elseif os.host() == "linux" or os.host() == "bsd" then
add_packages("sdbus-c++", "x11")
end