Userland: Move Shell code to be in a library directory

This change ensures that users can use LibShell easily understand this
library now, because we have an actual library directory.

In addition to that, we move the test scripts to Tests/LibShell, to
match the usual pattern of putting test-related files in the Tests/
directory.
This commit is contained in:
Liav A. 2024-07-26 18:09:10 +03:00 committed by Tim Schumacher
parent c8a068496a
commit d46be35f3f
54 changed files with 55 additions and 52 deletions

View file

@ -502,6 +502,7 @@ if (BUILD_LAGOM)
Regex
RIFF
SoftGPU
Shell
SQL
Syntax
TextCodec

View file

@ -5,7 +5,7 @@
*/
#include <AK/StringView.h>
#include <Shell/Shell.h>
#include <LibShell/Shell.h>
#include <stddef.h>
#include <stdint.h>

View file

@ -5,8 +5,8 @@
*/
#include <AK/StringView.h>
#include <Shell/PosixParser.h>
#include <Shell/Shell.h>
#include <LibShell/PosixParser.h>
#include <LibShell/Shell.h>
#include <stddef.h>
#include <stdint.h>

View file

@ -10,7 +10,7 @@ if [ "$#" -eq "0" ]; then
git ls-files -- \
'*.sh' \
':!:Ports' \
':!:Userland/Shell/Tests' \
':!:Tests/LibShell' \
':!:Base/home/anon/Tests' \
':!:Base/root/generate_manpages.sh' \
':!:Base/usr/share/shell' \

View file

@ -19,6 +19,7 @@ add_subdirectory(LibMarkdown)
add_subdirectory(LibPDF)
add_subdirectory(LibRegex)
add_subdirectory(LibSemVer)
add_subdirectory(LibShell)
add_subdirectory(LibSQL)
add_subdirectory(LibTest)
add_subdirectory(LibTextCodec)

View file

@ -0,0 +1,7 @@
if (NOT ENABLE_FUZZERS)
install(DIRECTORY Tests/ DESTINATION usr/Tests/Shell
PATTERN "Tests/*"
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
GROUP_EXECUTE GROUP_READ
WORLD_EXECUTE WORLD_READ)
endif()

View file

@ -39,11 +39,11 @@
#include <LibMarkdown/Document.h>
#include <LibMarkdown/SyntaxHighlighter.h>
#include <LibSQL/AST/SyntaxHighlighter.h>
#include <LibShell/SyntaxHighlighter.h>
#include <LibURL/URL.h>
#include <LibWeb/CSS/SyntaxHighlighter/SyntaxHighlighter.h>
#include <LibWeb/HTML/SyntaxHighlighter/SyntaxHighlighter.h>
#include <LibWebView/OutOfProcessWebView.h>
#include <Shell/SyntaxHighlighter.h>
namespace TextEditor {

View file

@ -7,7 +7,7 @@
#include <AK/LexicalPath.h>
#include <LibMain/Main.h>
#include <Userland/Shell/Shell.h>
#include <LibShell/Shell.h>
#define ENUMERATE_UTILITIES(E, ALIAS) \
ALIAS(b2sum, checksum) \

View file

@ -37,13 +37,13 @@
#include <LibMarkdown/Document.h>
#include <LibMarkdown/SyntaxHighlighter.h>
#include <LibSQL/AST/SyntaxHighlighter.h>
#include <LibShell/SyntaxHighlighter.h>
#include <LibSyntax/Language.h>
#include <LibWeb/CSS/SyntaxHighlighter/SyntaxHighlighter.h>
#include <LibWeb/DOM/Text.h>
#include <LibWeb/HTML/HTMLHeadElement.h>
#include <LibWeb/HTML/SyntaxHighlighter/SyntaxHighlighter.h>
#include <LibWebView/OutOfProcessWebView.h>
#include <Shell/SyntaxHighlighter.h>
#include <fcntl.h>
namespace HackStudio {

View file

@ -50,6 +50,7 @@ add_subdirectory(LibRegex)
add_subdirectory(LibRIFF)
add_subdirectory(LibSanitizer)
add_subdirectory(LibSemVer)
add_subdirectory(LibShell)
add_subdirectory(LibSoftGPU)
add_subdirectory(LibSQL)
add_subdirectory(LibSymbolication)

View file

@ -7,7 +7,7 @@
#pragma once
#include <LibCodeComprehension/CodeComprehensionEngine.h>
#include <Shell/Shell.h>
#include <LibShell/Shell.h>
namespace CodeComprehension::Shell {

View file

@ -0,0 +1,20 @@
set(SOURCES
AST.cpp
Builtin.cpp
Formatter.cpp
ImmediateFunctions.cpp
Job.cpp
NodeVisitor.cpp
Parser.cpp
PosixLexer.cpp
PosixParser.cpp
Shell.cpp
)
serenity_lib(LibShell shell)
target_link_libraries(LibShell PRIVATE LibCore LibRegex LibLine LibFileSystem LibSyntax LibURL)
if (SERENITYOS)
target_sources(LibShell PRIVATE SyntaxHighlighter.cpp)
target_link_libraries(LibShell PRIVATE LibCodeComprehension)
endif()

View file

@ -5,7 +5,7 @@
*/
#include <AK/CharacterTypes.h>
#include <Shell/PosixLexer.h>
#include <LibShell/PosixLexer.h>
static bool is_operator(StringView text)
{

View file

@ -12,7 +12,7 @@
#include <AK/TemporaryChange.h>
#include <AK/Variant.h>
#include <AK/Vector.h>
#include <Shell/AST.h>
#include <LibShell/AST.h>
namespace Shell::Posix {

View file

@ -7,8 +7,8 @@
#include <AK/CharacterTypes.h>
#include <AK/Debug.h>
#include <AK/StringUtils.h>
#include <Shell/Parser.h>
#include <Shell/PosixParser.h>
#include <LibShell/Parser.h>
#include <LibShell/PosixParser.h>
#define TRY_OR_THROW_PARSE_ERROR_AT(expr, position) ({ \
/* Ignore -Wshadow to allow nesting the macro. */ \

View file

@ -6,8 +6,8 @@
#pragma once
#include <Shell/AST.h>
#include <Shell/PosixLexer.h>
#include <LibShell/AST.h>
#include <LibShell/PosixLexer.h>
namespace Shell::Posix {

View file

@ -30,8 +30,8 @@
#include <LibCore/Timer.h>
#include <LibFileSystem/FileSystem.h>
#include <LibLine/Editor.h>
#include <LibShell/PosixParser.h>
#include <LibURL/URL.h>
#include <Shell/PosixParser.h>
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>

View file

@ -9,10 +9,10 @@
#include <AK/TemporaryChange.h>
#include <LibGfx/Font/Font.h>
#include <LibGfx/Palette.h>
#include <LibShell/NodeVisitor.h>
#include <LibShell/Parser.h>
#include <LibShell/SyntaxHighlighter.h>
#include <LibSyntax/Document.h>
#include <Shell/NodeVisitor.h>
#include <Shell/Parser.h>
#include <Shell/SyntaxHighlighter.h>
namespace Shell {

View file

@ -4,38 +4,11 @@ serenity_component(
TARGETS Shell
)
set(SOURCES
AST.cpp
Builtin.cpp
Formatter.cpp
ImmediateFunctions.cpp
Job.cpp
NodeVisitor.cpp
Parser.cpp
PosixLexer.cpp
PosixParser.cpp
Shell.cpp
)
serenity_lib(LibShell shell)
target_link_libraries(LibShell PRIVATE LibCore LibFileSystem LibLine LibSyntax LibRegex LibURL)
if (SERENITYOS)
target_sources(LibShell PRIVATE SyntaxHighlighter.cpp)
target_link_libraries(LibShell PRIVATE LibCodeComprehension)
endif()
if (ENABLE_FUZZERS)
add_custom_target(Shell) # Stub target to placate serenity_component
else()
set(SOURCES main.cpp)
serenity_bin(Shell)
target_link_libraries(Shell PRIVATE LibCore LibFileSystem LibLine LibShell LibMain)
install(DIRECTORY Tests/ DESTINATION usr/Tests/Shell
PATTERN "Tests/*"
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
GROUP_EXECUTE GROUP_READ
WORLD_EXECUTE WORLD_READ)
target_link_libraries(Shell PRIVATE LibCore LibShell LibFileSystem LibLine LibMain)
endif()

View file

@ -4,7 +4,6 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "Shell.h"
#include <AK/LexicalPath.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/Event.h>
@ -12,6 +11,7 @@
#include <LibCore/System.h>
#include <LibFileSystem/FileSystem.h>
#include <LibMain/Main.h>
#include <LibShell/Shell.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>

View file

@ -22,11 +22,11 @@
#include "AvailablePortDatabase.h"
#include "MarkdownTableFinder.h"
#include <Shell/AST.h>
#include <Shell/Formatter.h>
#include <Shell/NodeVisitor.h>
#include <Shell/PosixParser.h>
#include <Shell/Shell.h>
#include <LibShell/AST.h>
#include <LibShell/Formatter.h>
#include <LibShell/NodeVisitor.h>
#include <LibShell/PosixParser.h>
#include <LibShell/Shell.h>
void AvailablePortDatabase::query_details_for_package(HashMap<String, InstalledPort> const& installed_ports_map, StringView package_name, bool verbose)
{