Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convenient way of generating Lua files for every tl file? #31

Closed
pdesaulniers opened this issue Jan 29, 2020 · 9 comments
Closed

Convenient way of generating Lua files for every tl file? #31

pdesaulniers opened this issue Jan 29, 2020 · 9 comments

Comments

@pdesaulniers
Copy link
Member

pdesaulniers commented Jan 29, 2020

Right now, it seems like I need to manually call tl gen <filename> for every tl file in my project.

While I can write a script to automate this, I suppose it would be nice if there was a built-in way of generating Lua files for multiple tl modules at once.

For instance, in TypeScript, we can specify the input files inside tsconfig.json and run tsc to compile the whole project.

@hishamhm
Copy link
Member

hishamhm commented Feb 4, 2020

I guess we can call this one fixed by #42, since you can run tl gen *.tl now!

@pdesaulniers
Copy link
Member Author

pdesaulniers commented Feb 5, 2020

Yes, that works. However, I would prefer if there was some way to specify the input files inside tlconfig.lua. That way, users would not have to rely on a shell-specific script or command to build the project.

For instance, the syntax for globs is shell dependent, especially when we get to patterns like **/*.tl. My build.sh script would not work in cmd.exe :(

I'd be happy if tlconfig supported something akin to the "include" and "exclude" properties in tsconfig.json. This would allow using globs for input files in a platform independent manner.

For the time being, though, I suppose a simple files array would be good enough.

@hishamhm
Copy link
Member

hishamhm commented Feb 5, 2020

For the time being, though, I suppose a simple files array would be good enough.

Yeah, that should be an easy add. Anything involving globs would take some extra dependency to do the directory traversal.

@pdesaulniers
Copy link
Member Author

pdesaulniers commented Feb 7, 2020

It seems like lua-path supports globs:

local path = require("path")

local src = "./game/*.lua"

path.each(src, "f", function(full_path)
	print(full_path)
end, {
	recurse = true; -- include subdirs
})

This library could also be used for building paths in #47.

Otherwise, there is also lpath:

local fs = require("path.fs")

-- find all .lua files in directory "game"
local src = "game/*/*.lua"

local files = fs.glob(src)

for _, v in ipairs(files) do
	-- do something
end

Are you aware of a better library for this?

@hishamhm
Copy link
Member

Are you aware of a better library for this?

Not really! At first glance it doesn't look like either of them supports the zsh/typescript ** notation for recursive descent, but I don't know if that's a must-have either (maybe some toggle in the libraries make them expand all subdirs in globs? or maybe contacting the module authors about it would be a good idea?).

In any case, I have no immediate preference, it's up to you to pick the library if you're interested in adding the feature!

@pdesaulniers pdesaulniers added good first issue Good for newcomers and removed good first issue Good for newcomers labels Jun 12, 2020
@euclidianAce
Copy link
Member

@hishamhm So I'm working on a pr for this and was wondering if we should change the --include option to mimic tsconfigs. My thought process is that if you want to include extra paths, you should do that in the shell with LUA_PATH and LUA_CPATH. Otherwise I'd probably call it --input or something. Any thoughts?

@pdesaulniers
Copy link
Member Author

pdesaulniers commented Jun 19, 2020

@euclidianAce I added the --include flag for text editor support. If this variable is set inside tlconfig.lua, then the language server inside the editor can use the proper module search path automatically. For this use case, I'm not sure if people want to mess around with LUA_PATH and LUA_CPATH manually (especially not in GUI editors)

With that said, maybe it would be better to rename the current --include flag to something else, so that --include and --exclude may be used for this feature.

@hishamhm
Copy link
Member

hishamhm commented Jun 21, 2020

I kinda like the fact that -I (uppercase i) and -l (lowercase l) have vaguely similar meanings as they do for gcc. Don't mind if the long form --include becomes --include-dir or something.

@pdesaulniers
Copy link
Member Author

Fixed by #177.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants