From 766be2624ca345ff91f8a01c6af9ed62b19d6044 Mon Sep 17 00:00:00 2001 From: Gustavo Ramos Rehermann Date: Wed, 26 Jun 2024 17:41:11 -0300 Subject: [PATCH 1/2] Add compile_commands.json CMake script, and Lapce runners (#302) * Add Lapce runner to run CMake This is necessary to generate the compile_commands.json file which clangd uses to be able to load libaries like gtkmm. * Move compile_commands generation script into separate file * Add more Lapce run settings * Set execute bit on gen_compile_commands.sh * Move Lapce run files to .lapce --- .gitignore | 3 +++ .lapce/gen_compile_commands.sh | 7 +++++++ .lapce/run.toml | 24 ++++++++++++++++++++++++ compile_commands.json | 1 + 4 files changed, 35 insertions(+) create mode 100755 .lapce/gen_compile_commands.sh create mode 100644 .lapce/run.toml create mode 120000 compile_commands.json diff --git a/.gitignore b/.gitignore index e47837d..b28524f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,9 @@ ## ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore +# Build directory contents +build/* + # User-specific files *.rsuser *.suo diff --git a/.lapce/gen_compile_commands.sh b/.lapce/gen_compile_commands.sh new file mode 100755 index 0000000..e9e7e9b --- /dev/null +++ b/.lapce/gen_compile_commands.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Use this script to create the compile_commands.json file. +# This is necessary for clangd completion. + +cmake . -B build \ + -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_EXPORT_COMPILE_COMMANDS=True \ No newline at end of file diff --git a/.lapce/run.toml b/.lapce/run.toml new file mode 100644 index 0000000..a309b78 --- /dev/null +++ b/.lapce/run.toml @@ -0,0 +1,24 @@ +# The run config is used for both run mode and debug mode + +[[configs]] +name = "cmake-debug" +program = "sh" +args = [".lapce/gen_compile_commands.sh"] + +[configs.env] +CC = "/usr/bin/clang" +CXX = "/usr/bin/clang++" + +[[configs]] +name = "cmake" +program = "cmake" +args = ["--build", "build"] + +[configs.env] +CC = "/usr/bin/clang" +CXX = "/usr/bin/clang++" + +[[configs]] +name = "run" +type = "lldb" +program = "build/abaddon" diff --git a/compile_commands.json b/compile_commands.json new file mode 120000 index 0000000..25eb4b2 --- /dev/null +++ b/compile_commands.json @@ -0,0 +1 @@ +build/compile_commands.json \ No newline at end of file From de7edc4658db4936afd37ed49df82d1746521b0f Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Sun, 30 Jun 2024 16:35:24 -0400 Subject: [PATCH 2/2] please build number fuck off --- src/startup.cpp | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/startup.cpp b/src/startup.cpp index f2ed5ce..50b8744 100644 --- a/src/startup.cpp +++ b/src/startup.cpp @@ -32,22 +32,11 @@ std::optional> ParseCookie(const Glib::ustri } std::optional GetJavascriptFileFromAppPage(const Glib::ustring &contents) { - auto regex = Glib::Regex::create(R"(/assets/\w+\.?\w{20}\.js)"); - std::vector matches; + auto regex = Glib::Regex::create(R"(/assets/sentry.*?\.js)"); - // regex->match_all doesnt work for some reason - int start_position = 0; Glib::MatchInfo match; - while (regex->match(contents, start_position, match)) { - const auto str = match.fetch(0); - matches.push_back(str); - int foo; - match.fetch_pos(0, start_position, foo); - start_position += str.size(); - } - - if (matches.size() >= 8) { - return matches[matches.size() - 8]; + if (regex->match(contents, match)) { + return match.fetch(0); } return {}; @@ -67,7 +56,7 @@ std::optional GetBuildNumberFromJSURL(const Glib::ustring &url, const auto res = req.execute(); if (res.error) return {}; - auto regex = Glib::Regex::create(R"(Build Number: "\).concat\("(\d+))"); + auto regex = Glib::Regex::create(R"(buildNumber",\(.="(\d+))"); Glib::MatchInfo match; Glib::ustring string = res.text; if (regex->match(string, match)) { @@ -130,6 +119,9 @@ void DiscordStartupDialog::RunAsync() { auto js_url = GetJavascriptFileFromAppPage(app_page); if (js_url.has_value()) { m_build_number = GetBuildNumberFromJSURL(*js_url, *opt_cookie); + if (m_build_number.has_value()) { + spdlog::get("discord")->debug("Found build number: {}", *m_build_number); + } } } m_dispatcher.emit();