Skip to content

Commit

Permalink
fix compilation when libssh2 not found
Browse files Browse the repository at this point in the history
  • Loading branch information
Yaraslaut committed Nov 25, 2023
1 parent 9c3073d commit ea3fb43
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 60 deletions.
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,4 @@
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
92 changes: 46 additions & 46 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -7,66 +7,66 @@ BUILDDIR = release

configure: configure-stamp
configure-stamp:
mkdir -p ${BUILDDIR}
cd "${BUILDDIR}" && \
CPM_SOURCE_CACHE="$(shell pwd)/_3rdparty" cmake .. \
-DCMAKE_BUILD_TYPE="RelWithDebInfo" \
-DCMAKE_INSTALL_PREFIX="/usr" \
-DCMAKE_CXX_FLAGS="-DNDEBUG=1" \
\
-DCONTOUR_EXAMPLES=OFF \
\
-DCRISPY_TESTING=ON \
-DLIBTERMINAL_TESTING=ON \
-DLIBUNICODE_TESTING=ON
touch $@
mkdir -p ${BUILDDIR}
cd "${BUILDDIR}" && \
CPM_SOURCE_CACHE="$(shell pwd)/_3rdparty" cmake .. \
-DCMAKE_BUILD_TYPE="RelWithDebInfo" \
-DCMAKE_INSTALL_PREFIX="/usr" \
-DCMAKE_CXX_FLAGS="-DNDEBUG=1" \
\
-DCONTOUR_EXAMPLES=OFF \
\
-DCRISPY_TESTING=ON \
-DLIBTERMINAL_TESTING=ON \
-DLIBUNICODE_TESTING=ON
touch $@

build: build-stamp
build-stamp: configure-stamp
dh_testdir
$(MAKE) -C ${BUILDDIR} -j3
${BUILDDIR}/src/crispy/crispy_test
${BUILDDIR}/src/vtbackend/vtbackend_test
touch $@
dh_testdir
$(MAKE) -C ${BUILDDIR} -j3
${BUILDDIR}/src/crispy/crispy_test
${BUILDDIR}/src/vtbackend/vtbackend_test
touch $@

install: install-stamp
install-stamp:
dh_testdir
dh_testroot
dh_prep
dh_installdirs
$(MAKE) -C ${BUILDDIR} install DESTDIR=$(CURDIR)/debian/tmp
touch $@
dh_testdir
dh_testroot
dh_prep
dh_installdirs
$(MAKE) -C ${BUILDDIR} install DESTDIR=$(CURDIR)/debian/tmp
touch $@

binary-indep: build install
binary-arch: build install
dh_testdir
dh_testroot
dh_installchangelogs
dh_install
dh_installman
dh_link
dh_strip
dh_compress
dh_fixperms
dh_installdeb
dh_makeshlibs
dh_shlibdeps
dh_installdeb
dh_gencontrol
dh_md5sums
dh_builddeb
dh_testdir
dh_testroot
dh_installchangelogs
dh_install
dh_installman
dh_link
dh_strip
dh_compress
dh_fixperms
dh_installdeb
dh_makeshlibs
dh_shlibdeps
dh_installdeb
dh_gencontrol
dh_md5sums
dh_builddeb

binary: binary-arch binary-indep

clean:
rm -rf ${BUILDDIR}
dh_testdir
dh_testroot
dh_clean
#dh_auto_clean
rm -rf ${BUILDDIR}
dh_testdir
dh_testroot
dh_clean
#dh_auto_clean

%:
dh $@
dh $@

.PHONY: configure build binary-indep binary-arch binary install clean
4 changes: 4 additions & 0 deletions src/contour/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1403,6 +1403,7 @@ namespace
loginShell.erase(loginShell.begin());
terminalProfile.shell.arguments = loginShell;
}
#if defined(VTPTY_LIBSSH2)
if (auto const sshNode = profile["ssh"]; sshNode && sshNode.IsMap())
{
usedKeys.emplace(fmt::format("{}.{}.ssh", parentPath, profileName));
Expand Down Expand Up @@ -1442,6 +1443,7 @@ namespace
else if (auto const p = Process::homeDirectory() / ".ssh" / "known_hosts"; fs::exists(p))
ssh.knownHostsFile = p;
}
#endif

tryLoadChildRelative(usedKeys, profile, basePath, "maximized", terminalProfile.maximized, logger);
tryLoadChildRelative(usedKeys, profile, basePath, "fullscreen", terminalProfile.fullscreen, logger);
Expand Down Expand Up @@ -1537,7 +1539,9 @@ namespace
terminalProfile.shell.env["COLORTERM"] = "truecolor";

// This is currently duplicated. Environment vars belong to each parent struct, not just shell.
#if defined(VTPTY_LIBSSH2)
terminalProfile.ssh.env = terminalProfile.shell.env;
#endif
// }}}

strValue = fmt::format("{}", terminalProfile.terminalId);
Expand Down
7 changes: 6 additions & 1 deletion src/contour/ContourGuiApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,10 @@ void ContourGuiApp::onExit(TerminalSession& session)
{
if (auto const* localProcess = dynamic_cast<vtpty::Process const*>(&session.terminal().device()))
_exitStatus = localProcess->checkStatus();
#if defined(VTPTY_LIBSSH2)
else if (auto const* sshSession = dynamic_cast<vtpty::SshSession const*>(&session.terminal().device()))
_exitStatus = sshSession->exitStatus();
#endif
}

QUrl ContourGuiApp::resolveResource(std::string_view path)
Expand Down Expand Up @@ -418,6 +420,7 @@ int ContourGuiApp::terminalGuiAction()

if (_exitStatus.has_value())
{
#if defined(VTPTY_LIBSSH2)
if (holds_alternative<SshSession::ExitStatus>(*_exitStatus))
{
auto const sshExitStatus = get<SshSession::ExitStatus>(*_exitStatus);
Expand All @@ -426,7 +429,9 @@ int ContourGuiApp::terminalGuiAction()
else if (holds_alternative<SshSession::SignalExit>(sshExitStatus))
rv = EXIT_FAILURE;
}
else if (holds_alternative<Process::ExitStatus>(*_exitStatus))
else
#endif
if (holds_alternative<Process::ExitStatus>(*_exitStatus))
{
auto const processExitStatus = get<Process::ExitStatus>(*_exitStatus);
if (holds_alternative<Process::NormalExit>(processExitStatus))
Expand Down
2 changes: 2 additions & 0 deletions src/contour/TerminalSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,7 @@ void TerminalSession::onClosed()
else
sessionLog()("Process terminated after {} seconds.", diff.count());
}
#if defined(VTPTY_LIBSSH2)
else if (auto* sshSession = dynamic_cast<vtpty::SshSession*>(&_terminal.device()))
{
auto const exitStatus = sshSession->exitStatus();
Expand All @@ -594,6 +595,7 @@ void TerminalSession::onClosed()
else
sessionLog()("Process terminated after {} seconds.", diff.count());
}
#endif
else
sessionLog()("Process terminated after {} seconds.", diff.count());

Expand Down
7 changes: 5 additions & 2 deletions src/contour/TerminalSessionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
#include <contour/TerminalSessionManager.h>

#include <vtpty/Process.h>
#include <vtpty/SshSession.h>
#if defined(VTPTY_LIBSSH2)
#include <vtpty/SshSession.h>
#endif

#include <QtQml/QQmlEngine>

Expand All @@ -26,9 +28,10 @@ std::unique_ptr<vtpty::Pty> TerminalSessionManager::createPty()
{
auto const& profile = _app.config().profile(_app.profileName());

#if defined(VTPTY_LIBSSH2)
if (!profile->ssh.hostname.empty())
return make_unique<vtpty::SshSession>(profile->ssh);

#endif
return make_unique<vtpty::Process>(profile->shell, vtpty::createPty(profile->terminalSize, nullopt));
}

Expand Down
3 changes: 3 additions & 0 deletions src/contour/display/OpenGLRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@ namespace contour::display
{

class OpenGLRenderer final:
public QObject,
public vtrasterizer::RenderTarget,
public vtrasterizer::atlas::AtlasBackend,
public QOpenGLExtraFunctions
{
Q_OBJECT

using ImageSize = vtbackend::ImageSize;

using AtlasTextureScreenshot = vtrasterizer::AtlasTextureScreenshot;
Expand Down
6 changes: 3 additions & 3 deletions src/contour/shell-integration/shell-integration.fish
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
# switch "$PWD"
# case "$HOME/work"*
# contour set profile to work
# case "$HOME/projects"*
# case "$HOME/projects"*
# contour set profile to main
# case '*'
# case '*'
# contour set profile to mobile
# end
# end


function precmd_hook_contour -d "Shell Integration hook to be invoked before each prompt" -e fish_prompt
function precmd_hook_contour -d "Shell Integration hook to be invoked before each prompt" -e fish_prompt
# Disable text reflow for the command prompt (and below).
printf '\e[?2028l'

Expand Down
12 changes: 6 additions & 6 deletions src/vtbackend/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ target_include_directories(vtbackend PUBLIC
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/include>
)

target_link_libraries(vtbackend PUBLIC
target_link_libraries(vtbackend PUBLIC
Microsoft.GSL::GSL
Threads::Threads
crispy::core
Threads::Threads
crispy::core
fmt::fmt-header-only
range-v3::range-v3
range-v3::range-v3
unicode::unicode
vtparser
vtpty
vtparser
vtpty
)

if(LIBTERMINAL_LOG_TRACE)
Expand Down
1 change: 1 addition & 0 deletions src/vtpty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ else()
endif()
endif()
if(_include_SshSession_module)
add_compile_definitions(VTPTY_LIBSSH2)
list(APPEND vtpty_SOURCES SshSession.cpp)
list(APPEND vtpty_HEADERS SshSession.h)
endif()
Expand Down
Loading

0 comments on commit ea3fb43

Please sign in to comment.