Skip to content

Commit

Permalink
Improve update_from_qtc.sh script
Browse files Browse the repository at this point in the history
  • Loading branch information
hluk committed Mar 3, 2021
1 parent bbe5e16 commit b6a6f3a
Show file tree
Hide file tree
Showing 3 changed files with 160 additions and 26 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,15 @@ Python Bindings

To install Python bindings for FakeVim see "python/README.md" file.

Update from Upstream
--------------------

The source code should be regularly updated from the Qt Creator.

To fetch Qt Creator source code:

git clone "https://codereview.qt-project.org/qt-creator/qt-creator" /path/to/qt-creator

To update FakeVim source code, run:

utils/update_from_qtc.sh /path/to/qt-creator
103 changes: 103 additions & 0 deletions utils/patches/add-patches-for-upstream.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
From 7d2323e1d13d0e53832d65038e926266bc9d9af3 Mon Sep 17 00:00:00 2001
From: Lukas Holecek <hluk@email.cz>
Date: Wed, 3 Mar 2021 08:52:06 +0100
Subject: [PATCH] Add patches for upstream

---
fakevim/fakevimactions.h | 14 +++++++++-----
fakevim/fakevimhandler.h | 12 +++++++++---
2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/fakevim/fakevimactions.h b/fakevim/fakevimactions.h
index 69131c7..c93cc6b 100644
--- a/fakevim/fakevimactions.h
+++ b/fakevim/fakevimactions.h
@@ -25,8 +25,12 @@

#pragma once

-#ifndef FAKEVIM_STANDALONE
-# include <utils/aspects.h>
+#define FAKEVIM_STANDALONE
+
+#ifdef FAKEVIM_STANDALONE
+# include "private/fakevim_export.h"
+#else
+# include <utils/savedaction.h>
#endif

#include <QCoreApplication>
@@ -39,7 +43,7 @@ namespace FakeVim {
namespace Internal {

#ifdef FAKEVIM_STANDALONE
-class FvBaseAspect
+class FAKEVIM_EXPORT FvBaseAspect
{
public:
FvBaseAspect();
@@ -95,7 +99,7 @@ using FvStringAspect = Utils::StringAspect;

#endif

-class FakeVimSettings final : public FvAspectContainer
+class FAKEVIM_EXPORT FakeVimSettings final : public FvAspectContainer
{
Q_DECLARE_TR_FUNCTIONS(FakeVim)

@@ -166,7 +170,7 @@ class FakeVimSettings final : public FvAspectContainer
QHash<FvBaseAspect *, QString> m_aspectToName;
};

-FakeVimSettings *fakeVimSettings();
+FAKEVIM_EXPORT FakeVimSettings *fakeVimSettings();

} // namespace Internal
} // namespace FakeVim
diff --git a/fakevim/fakevimhandler.h b/fakevim/fakevimhandler.h
index 9ba321f..33a63f7 100644
--- a/fakevim/fakevimhandler.h
+++ b/fakevim/fakevimhandler.h
@@ -25,6 +25,12 @@

#pragma once

+#define FAKEVIM_STANDALONE
+
+#ifdef FAKEVIM_STANDALONE
+# include "private/fakevim_export.h"
+#endif
+
#include <QObject>
#include <QTextEdit>

@@ -45,7 +51,7 @@ enum RangeMode
RangeBlockAndTailMode // Ctrl-v for D and X
};

-struct Range
+struct FAKEVIM_EXPORT Range
{
Range() = default;
Range(int b, int e, RangeMode m = RangeCharMode);
@@ -57,7 +63,7 @@ struct Range
RangeMode rangemode = RangeCharMode;
};

-struct ExCommand
+struct FAKEVIM_EXPORT ExCommand
{
ExCommand() = default;
ExCommand(const QString &cmd, const QString &args = QString(),
@@ -102,7 +108,7 @@ class Signal
std::vector<Callable> m_callables;
};

-class FakeVimHandler : public QObject
+class FAKEVIM_EXPORT FakeVimHandler : public QObject
{
Q_OBJECT

--
2.29.2

71 changes: 45 additions & 26 deletions utils/update_from_qtc.sh
Original file line number Diff line number Diff line change
@@ -1,39 +1,58 @@
#!/bin/bash
files_to_update=(
fakevimactions.cpp
fakevimactions.h
fakevimhandler.cpp
fakevimhandler.h
fakevimtr.h

utils/hostosinfo.h
utils/layoutbuilder.cpp
utils/layoutbuilder.h
utils/optional.h
utils/qtcassert.cpp
utils/qtcassert.h
utils/utils_global.h

3rdparty/optional/optional.hpp
)

qtc_home=$1
qtc_fakevim_home=$qtc_home/src/plugins/fakevim/
qtc_utils_home=$qtc_home/src/libs/utils/

script_dir=$(dirname "$(readlink -f "$0")")
base_dir=$script_dir/..

die() {
echo "$1" 1>&2
exit 1
}

up() {
local src=$1
local dst=$2
rsync "$src" "$dst" || exit
}

set -e

[ -n "$qtc_home" ] ||
die "Usage: $0 PATH_TO_QT_CREATOR"

[ -d "$qtc_fakevim_home" ] ||
die "Cannot find FakeVim plugin in \"$qtc_fakevim_home\"!"

( cd fakevim
up {"$qtc_fakevim_home",}fakevimactions.cpp
up {"$qtc_fakevim_home",}fakevimactions.h
up {"$qtc_fakevim_home",}fakevimhandler.cpp
up {"$qtc_fakevim_home",}fakevimhandler.h
up {"$qtc_fakevim_home",}fakevimtr.h
)

#( cd fakevim/utils
#up {"$qtc_utils_home",}hostosinfo.h
#up {"$qtc_utils_home",}qtcassert.cpp
#up {"$qtc_utils_home",}qtcassert.h
#up {"$qtc_utils_home",}utils_global.h
#)

echo "--- Fetching latest development code for Qt Creator"
cd "$qtc_home"
git fetch origin master
git checkout origin/master
commit=$(git rev-parse --short HEAD)

echo "--- Updating source files"
cd "$base_dir/fakevim"
for file in "${files_to_update[@]}"; do
echo "-- $file"
if [[ "$file" == fakevim* ]]; then
dir=plugins/fakevim
else
dir=libs
fi
rsync --mkpath -- "$qtc_home/src/$dir/$file" "$file"
git add -- "$file"
done

echo "--- Patching source files and creating commit"
git commit -m "Update from Qt Creator (commit $commit)"
git apply -- "$script_dir/patches/add-patches-for-upstream.patch"
git add -- "${files_to_update[@]}"
git commit --amend --no-edit --allow-empty

0 comments on commit b6a6f3a

Please sign in to comment.