mirror of
https://github.com/luau-lang/luau.git
synced 2025-01-09 12:59:10 +00:00
Refactor CLI structure to match the include/src split that our other projects have. (#1573)
Some checks failed
benchmark / callgrind (map[branch:main name:luau-lang/benchmark-data], ubuntu-22.04) (push) Has been cancelled
build / macos (push) Has been cancelled
build / macos-arm (push) Has been cancelled
build / ubuntu (push) Has been cancelled
build / windows (Win32) (push) Has been cancelled
build / windows (x64) (push) Has been cancelled
build / coverage (push) Has been cancelled
build / web (push) Has been cancelled
release / macos (push) Has been cancelled
release / ubuntu (push) Has been cancelled
release / windows (push) Has been cancelled
release / web (push) Has been cancelled
Some checks failed
benchmark / callgrind (map[branch:main name:luau-lang/benchmark-data], ubuntu-22.04) (push) Has been cancelled
build / macos (push) Has been cancelled
build / macos-arm (push) Has been cancelled
build / ubuntu (push) Has been cancelled
build / windows (Win32) (push) Has been cancelled
build / windows (x64) (push) Has been cancelled
build / coverage (push) Has been cancelled
build / web (push) Has been cancelled
release / macos (push) Has been cancelled
release / ubuntu (push) Has been cancelled
release / windows (push) Has been cancelled
release / web (push) Has been cancelled
This PR refactors the CLI folder to use the same project split between include and src directories that we have for all the other artifacts in luau. It also includes the require-by-string implementation we already have as a feature of `Luau.CLI.lib`. Both of these changes are targeted at making it easier for embedding projects to setup an effective equivalent to the standalone `luau` executable with whatever runtime libraries they need attached and without having to unnecessarily duplicate code from luau itself.
This commit is contained in:
parent
7ab3482003
commit
8f94786ceb
24 changed files with 64 additions and 66 deletions
|
@ -7,9 +7,9 @@
|
|||
#include "Luau/TypeAttach.h"
|
||||
#include "Luau/Transpiler.h"
|
||||
|
||||
#include "FileUtils.h"
|
||||
#include "Flags.h"
|
||||
#include "Require.h"
|
||||
#include "Luau/FileUtils.h"
|
||||
#include "Luau/Flags.h"
|
||||
#include "Luau/Require.h"
|
||||
|
||||
#include <condition_variable>
|
||||
#include <functional>
|
|
@ -8,7 +8,7 @@
|
|||
#include "Luau/ParseOptions.h"
|
||||
#include "Luau/ToString.h"
|
||||
|
||||
#include "FileUtils.h"
|
||||
#include "Luau/FileUtils.h"
|
||||
|
||||
static void displayHelp(const char* argv0)
|
||||
{
|
|
@ -7,8 +7,8 @@
|
|||
#include "Luau/BytecodeBuilder.h"
|
||||
#include "Luau/Parser.h"
|
||||
#include "Luau/BytecodeSummary.h"
|
||||
#include "FileUtils.h"
|
||||
#include "Flags.h"
|
||||
#include "Luau/FileUtils.h"
|
||||
#include "Luau/Flags.h"
|
||||
|
||||
#include <memory>
|
||||
|
|
@ -8,8 +8,8 @@
|
|||
#include "Luau/Parser.h"
|
||||
#include "Luau/TimeTrace.h"
|
||||
|
||||
#include "FileUtils.h"
|
||||
#include "Flags.h"
|
||||
#include "Luau/FileUtils.h"
|
||||
#include "Luau/Flags.h"
|
||||
|
||||
#include <memory>
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
||||
#include "Coverage.h"
|
||||
#include "Luau/Coverage.h"
|
||||
|
||||
#include "lua.h"
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
||||
#include "FileUtils.h"
|
||||
#include "Luau/FileUtils.h"
|
||||
|
||||
#include "Luau/Common.h"
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
#include "Luau/Parser.h"
|
||||
#include "Luau/Transpiler.h"
|
||||
|
||||
#include "FileUtils.h"
|
||||
#include "Luau/FileUtils.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <stdio.h>
|
|
@ -1,5 +1,5 @@
|
|||
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
||||
#include "Repl.h"
|
||||
#include "Luau/Repl.h"
|
||||
|
||||
#include "Luau/Common.h"
|
||||
#include "lua.h"
|
||||
|
@ -10,11 +10,11 @@
|
|||
#include "Luau/Parser.h"
|
||||
#include "Luau/TimeTrace.h"
|
||||
|
||||
#include "Coverage.h"
|
||||
#include "FileUtils.h"
|
||||
#include "Flags.h"
|
||||
#include "Profiler.h"
|
||||
#include "Require.h"
|
||||
#include "Luau/Coverage.h"
|
||||
#include "Luau/FileUtils.h"
|
||||
#include "Luau/Flags.h"
|
||||
#include "Luau/Profiler.h"
|
||||
#include "Luau/Require.h"
|
||||
|
||||
#include "isocline.h"
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
||||
#include "Repl.h"
|
||||
#include "Luau/Repl.h"
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
|
@ -1,7 +1,7 @@
|
|||
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
||||
#include "Require.h"
|
||||
#include "Luau/Require.h"
|
||||
|
||||
#include "FileUtils.h"
|
||||
#include "Luau/FileUtils.h"
|
||||
#include "Luau/Common.h"
|
||||
#include "Luau/Config.h"
|
||||
|
|
@ -68,7 +68,8 @@ include(Sources.cmake)
|
|||
target_include_directories(Luau.Common INTERFACE Common/include)
|
||||
|
||||
target_compile_features(Luau.CLI.lib PUBLIC cxx_std_17)
|
||||
target_link_libraries(Luau.CLI.lib PRIVATE Luau.Common)
|
||||
target_include_directories(Luau.CLI.lib PUBLIC CLI/include)
|
||||
target_link_libraries(Luau.CLI.lib PRIVATE Luau.Common Luau.Config)
|
||||
|
||||
target_compile_features(Luau.Ast PUBLIC cxx_std_17)
|
||||
target_include_directories(Luau.Ast PUBLIC Ast/include)
|
||||
|
|
20
Makefile
20
Makefile
|
@ -42,23 +42,23 @@ ISOCLINE_SOURCES=extern/isocline/src/isocline.c
|
|||
ISOCLINE_OBJECTS=$(ISOCLINE_SOURCES:%=$(BUILD)/%.o)
|
||||
ISOCLINE_TARGET=$(BUILD)/libisocline.a
|
||||
|
||||
TESTS_SOURCES=$(wildcard tests/*.cpp) CLI/FileUtils.cpp CLI/Flags.cpp CLI/Profiler.cpp CLI/Coverage.cpp CLI/Repl.cpp CLI/Require.cpp
|
||||
TESTS_SOURCES=$(wildcard tests/*.cpp) CLI/src/FileUtils.cpp CLI/src/Flags.cpp CLI/src/Profiler.cpp CLI/src/Coverage.cpp CLI/src/Repl.cpp CLI/src/Require.cpp
|
||||
TESTS_OBJECTS=$(TESTS_SOURCES:%=$(BUILD)/%.o)
|
||||
TESTS_TARGET=$(BUILD)/luau-tests
|
||||
|
||||
REPL_CLI_SOURCES=CLI/FileUtils.cpp CLI/Flags.cpp CLI/Profiler.cpp CLI/Coverage.cpp CLI/Repl.cpp CLI/ReplEntry.cpp CLI/Require.cpp
|
||||
REPL_CLI_SOURCES=CLI/src/FileUtils.cpp CLI/src/Flags.cpp CLI/src/Profiler.cpp CLI/src/Coverage.cpp CLI/src/Repl.cpp CLI/src/ReplEntry.cpp CLI/src/Require.cpp
|
||||
REPL_CLI_OBJECTS=$(REPL_CLI_SOURCES:%=$(BUILD)/%.o)
|
||||
REPL_CLI_TARGET=$(BUILD)/luau
|
||||
|
||||
ANALYZE_CLI_SOURCES=CLI/FileUtils.cpp CLI/Flags.cpp CLI/Require.cpp CLI/Analyze.cpp
|
||||
ANALYZE_CLI_SOURCES=CLI/src/FileUtils.cpp CLI/src/Flags.cpp CLI/src/Require.cpp CLI/src/Analyze.cpp
|
||||
ANALYZE_CLI_OBJECTS=$(ANALYZE_CLI_SOURCES:%=$(BUILD)/%.o)
|
||||
ANALYZE_CLI_TARGET=$(BUILD)/luau-analyze
|
||||
|
||||
COMPILE_CLI_SOURCES=CLI/FileUtils.cpp CLI/Flags.cpp CLI/Compile.cpp
|
||||
COMPILE_CLI_SOURCES=CLI/src/FileUtils.cpp CLI/src/Flags.cpp CLI/src/Compile.cpp
|
||||
COMPILE_CLI_OBJECTS=$(COMPILE_CLI_SOURCES:%=$(BUILD)/%.o)
|
||||
COMPILE_CLI_TARGET=$(BUILD)/luau-compile
|
||||
|
||||
BYTECODE_CLI_SOURCES=CLI/FileUtils.cpp CLI/Flags.cpp CLI/Bytecode.cpp
|
||||
BYTECODE_CLI_SOURCES=CLI/src/FileUtils.cpp CLI/src/Flags.cpp CLI/src/Bytecode.cpp
|
||||
BYTECODE_CLI_OBJECTS=$(BYTECODE_CLI_SOURCES:%=$(BUILD)/%.o)
|
||||
BYTECODE_CLI_TARGET=$(BUILD)/luau-bytecode
|
||||
|
||||
|
@ -149,11 +149,11 @@ $(EQSAT_OBJECTS): CXXFLAGS+=-std=c++17 -ICommon/include -IEqSat/include
|
|||
$(CODEGEN_OBJECTS): CXXFLAGS+=-std=c++17 -ICommon/include -ICodeGen/include -IVM/include -IVM/src # Code generation needs VM internals
|
||||
$(VM_OBJECTS): CXXFLAGS+=-std=c++11 -ICommon/include -IVM/include
|
||||
$(ISOCLINE_OBJECTS): CXXFLAGS+=-Wno-unused-function -Iextern/isocline/include
|
||||
$(TESTS_OBJECTS): CXXFLAGS+=-std=c++17 -ICommon/include -IAst/include -ICompiler/include -IConfig/include -IAnalysis/include -IEqSat/include -ICodeGen/include -IVM/include -ICLI -Iextern -DDOCTEST_CONFIG_DOUBLE_STRINGIFY
|
||||
$(REPL_CLI_OBJECTS): CXXFLAGS+=-std=c++17 -ICommon/include -IAst/include -ICompiler/include -IVM/include -ICodeGen/include -Iextern -Iextern/isocline/include
|
||||
$(ANALYZE_CLI_OBJECTS): CXXFLAGS+=-std=c++17 -ICommon/include -IAst/include -IAnalysis/include -IEqSat/include -IConfig/include -Iextern
|
||||
$(COMPILE_CLI_OBJECTS): CXXFLAGS+=-std=c++17 -ICommon/include -IAst/include -ICompiler/include -IVM/include -ICodeGen/include
|
||||
$(BYTECODE_CLI_OBJECTS): CXXFLAGS+=-std=c++17 -ICommon/include -IAst/include -ICompiler/include -IVM/include -ICodeGen/include
|
||||
$(TESTS_OBJECTS): CXXFLAGS+=-std=c++17 -ICommon/include -IAst/include -ICompiler/include -IConfig/include -IAnalysis/include -IEqSat/include -ICodeGen/include -IVM/include -ICLI/include -Iextern -DDOCTEST_CONFIG_DOUBLE_STRINGIFY
|
||||
$(REPL_CLI_OBJECTS): CXXFLAGS+=-std=c++17 -ICommon/include -IAst/include -ICompiler/include -IVM/include -ICodeGen/include -Iextern -Iextern/isocline/include -ICLI/include
|
||||
$(ANALYZE_CLI_OBJECTS): CXXFLAGS+=-std=c++17 -ICommon/include -IAst/include -IAnalysis/include -IEqSat/include -IConfig/include -Iextern -ICLI/include
|
||||
$(COMPILE_CLI_OBJECTS): CXXFLAGS+=-std=c++17 -ICommon/include -IAst/include -ICompiler/include -IVM/include -ICodeGen/include -ICLI/include
|
||||
$(BYTECODE_CLI_OBJECTS): CXXFLAGS+=-std=c++17 -ICommon/include -IAst/include -ICompiler/include -IVM/include -ICodeGen/include -ICLI/include
|
||||
$(FUZZ_OBJECTS): CXXFLAGS+=-std=c++17 -ICommon/include -IAst/include -ICompiler/include -IAnalysis/include -IEqSat/include -IVM/include -ICodeGen/include -IConfig/include
|
||||
|
||||
$(TESTS_TARGET): LDFLAGS+=-lpthread
|
||||
|
|
|
@ -389,36 +389,39 @@ target_sources(isocline PRIVATE
|
|||
|
||||
# Common sources shared between all CLI apps
|
||||
target_sources(Luau.CLI.lib PRIVATE
|
||||
CLI/FileUtils.cpp
|
||||
CLI/Flags.cpp
|
||||
CLI/Flags.h
|
||||
CLI/FileUtils.h
|
||||
CLI/include/Luau/FileUtils.h
|
||||
CLI/include/Luau/Flags.h
|
||||
CLI/include/Luau/Require.h
|
||||
|
||||
CLI/src/FileUtils.cpp
|
||||
CLI/src/Flags.cpp
|
||||
CLI/src/Require.cpp
|
||||
)
|
||||
|
||||
if(TARGET Luau.Repl.CLI)
|
||||
# Luau.Repl.CLI Sources
|
||||
target_sources(Luau.Repl.CLI PRIVATE
|
||||
CLI/Coverage.h
|
||||
CLI/Coverage.cpp
|
||||
CLI/Profiler.h
|
||||
CLI/Profiler.cpp
|
||||
CLI/Repl.cpp
|
||||
CLI/ReplEntry.cpp
|
||||
CLI/Require.cpp)
|
||||
CLI/include/Luau/Coverage.h
|
||||
CLI/include/Luau/Profiler.h
|
||||
|
||||
CLI/src/Coverage.cpp
|
||||
CLI/src/Profiler.cpp
|
||||
CLI/src/Repl.cpp
|
||||
CLI/src/ReplEntry.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
if(TARGET Luau.Analyze.CLI)
|
||||
# Luau.Analyze.CLI Sources
|
||||
target_sources(Luau.Analyze.CLI PRIVATE
|
||||
CLI/Analyze.cpp
|
||||
CLI/Require.cpp
|
||||
CLI/src/Analyze.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
if(TARGET Luau.Ast.CLI)
|
||||
# Luau.Ast.CLI Sources
|
||||
target_sources(Luau.Ast.CLI PRIVATE
|
||||
CLI/Ast.cpp
|
||||
CLI/src/Ast.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
|
@ -543,12 +546,12 @@ endif()
|
|||
if(TARGET Luau.CLI.Test)
|
||||
# Luau.CLI.Test Sources
|
||||
target_sources(Luau.CLI.Test PRIVATE
|
||||
CLI/Coverage.h
|
||||
CLI/Coverage.cpp
|
||||
CLI/Profiler.h
|
||||
CLI/Profiler.cpp
|
||||
CLI/Repl.cpp
|
||||
CLI/Require.cpp
|
||||
CLI/include/Luau/Coverage.h
|
||||
CLI/include/Luau/Profiler.h
|
||||
|
||||
CLI/src/Coverage.cpp
|
||||
CLI/src/Profiler.cpp
|
||||
CLI/src/Repl.cpp
|
||||
|
||||
tests/RegisterCallbacks.h
|
||||
tests/RegisterCallbacks.cpp
|
||||
|
@ -560,24 +563,24 @@ endif()
|
|||
if(TARGET Luau.Web)
|
||||
# Luau.Web Sources
|
||||
target_sources(Luau.Web PRIVATE
|
||||
CLI/Web.cpp)
|
||||
CLI/src/Web.cpp)
|
||||
endif()
|
||||
|
||||
if(TARGET Luau.Reduce.CLI)
|
||||
# Luau.Reduce.CLI Sources
|
||||
target_sources(Luau.Reduce.CLI PRIVATE
|
||||
CLI/Reduce.cpp
|
||||
CLI/src/Reduce.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
if(TARGET Luau.Compile.CLI)
|
||||
# Luau.Compile.CLI Sources
|
||||
target_sources(Luau.Compile.CLI PRIVATE
|
||||
CLI/Compile.cpp)
|
||||
CLI/src/Compile.cpp)
|
||||
endif()
|
||||
|
||||
if(TARGET Luau.Bytecode.CLI)
|
||||
# Luau.Bytecode.CLI Sources
|
||||
target_sources(Luau.Bytecode.CLI PRIVATE
|
||||
CLI/Bytecode.cpp)
|
||||
CLI/src/Bytecode.cpp)
|
||||
endif()
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "lua.h"
|
||||
#include "lualib.h"
|
||||
|
||||
#include "Repl.h"
|
||||
#include "Luau/Repl.h"
|
||||
#include "ScopedFlags.h"
|
||||
|
||||
#include "doctest.h"
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
#include "lua.h"
|
||||
#include "lualib.h"
|
||||
|
||||
#include "Repl.h"
|
||||
#include "FileUtils.h"
|
||||
#include "Luau/Repl.h"
|
||||
#include "Luau/FileUtils.h"
|
||||
|
||||
#include "doctest.h"
|
||||
|
||||
|
@ -116,7 +116,7 @@ public:
|
|||
for (int i = 0; i < 20; ++i)
|
||||
{
|
||||
bool engineTestDir = isDirectory(luauDirAbs + "/Client/Luau/tests");
|
||||
bool luauTestDir = isDirectory(luauDirAbs + "/luau/tests/require");
|
||||
bool luauTestDir = isDirectory(luauDirAbs + "/tests/require");
|
||||
|
||||
if (engineTestDir || luauTestDir)
|
||||
{
|
||||
|
@ -125,12 +125,6 @@ public:
|
|||
luauDirRel += "/Client/Luau";
|
||||
luauDirAbs += "/Client/Luau";
|
||||
}
|
||||
else
|
||||
{
|
||||
luauDirRel += "/luau";
|
||||
luauDirAbs += "/luau";
|
||||
}
|
||||
|
||||
|
||||
if (type == PathType::Relative)
|
||||
return luauDirRel;
|
||||
|
|
Loading…
Reference in a new issue