Skip to content

Commit

Permalink
Make build and lfs optional
Browse files Browse the repository at this point in the history
  • Loading branch information
Frityet committed Dec 13, 2023
1 parent cecb87d commit e53c980
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions tl
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,12 @@ end
-- Build system (deprecated, use Cyan)
--------------------------------------------------------------------------------

local build = {}
do
local lfs = require("lfs")
-- local has_lfs, lfs = pcall(require, "lfs")
local has_lfs = false

local build
if has_lfs then
build = {}

local function str_split(str, delimiter)
local idx = 0
Expand Down Expand Up @@ -874,7 +877,9 @@ local function get_args_parser()
:argname("<modulename>")
:count("*")

build.arg_parser(parser)
if build then
build.arg_parser(parser)
end

parser:command("warnings", "List each kind of warning the compiler can produce.")

Expand All @@ -899,7 +904,9 @@ local function get_config(cmd)
local conf, err = loadfile(config_path)
if not conf then
if err:match("No such file or directory$") then
build.tlconfig_not_found(cmd)
if build then
build.tlconfig_not_found(cmd)
end
else
die("Error loading tlconfig.lua:\n" .. err)
end
Expand All @@ -920,7 +927,9 @@ local function get_config(cmd)
end
end

build.config_dir(cmd, config_path, config)
if build then
build.config_dir(cmd, config_path, config)
end

local errs, warnings = validate_config(config)

Expand Down Expand Up @@ -984,7 +993,9 @@ local function merge_config_and_args(tlconfig, args)
prepend_to_lua_paths(include)
end

build.merge_config(tlconfig, args)
if build then
build.merge_config(tlconfig, args)
end
end

local function get_output_filename(file_name)
Expand Down Expand Up @@ -1378,8 +1389,9 @@ end
--------------------------------------------------------------------------------
-- tl build
--------------------------------------------------------------------------------

commands["build"] = build.run
if build then
commands["build"] = build.run
end

--------------------------------------------------------------------------------
-- Main program
Expand Down Expand Up @@ -1410,6 +1422,8 @@ if not args["quiet"] then
end
end

build.run_build_script(tlconfig)
if build then
build.run_build_script(tlconfig)
end

commands[cmd](tlconfig, args)

0 comments on commit e53c980

Please sign in to comment.