-
Notifications
You must be signed in to change notification settings - Fork 112
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
tl: add build options #177
tl: add build options #177
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! I left some minor reviews from a quick reading of the PR but haven't gotten around to running it yet
@pdesaulniers Could you take a look at this PR? :) |
OK, I'm looking at this. |
So far, the CLI options are tested by calling Lines 4 to 16 in 5732126
Right now, it would be a bit difficult to write this kind of tests for So, for now, I would suggest to add some command line options for Otherwise, we could also use a new |
Yes for the first two, but I'm not sure about #107. I think this issue proposes to merge all of the command line and |
Since we're bringing in lfs for this feature, we could probably use |
@euclidianAce sounds like a plan! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nitpick: ideally, the --include
flag should be renamed to --include-dir
here
tl/spec/cli/include_dir_spec.lua
Line 3 in d3236c9
describe("-I --include argument", function() |
I've made some pretty big refactors to this now that I've been able to test it and I want to just outline them here:
Internally, the code is a lot cleaner and partitioned for each command. With the forcing of relative paths the pattern matching and source file mapping has become a lot easier to manage as it was previously a hodgepodge of The test coverage is pretty alright, but I still need to write more :P |
@euclidianAce wow, impressive!! Some commentary based on the above comment (haven't looked deeply into details of the code yet)
Nice!
I've seen this being called
This bit I am a little concerned with. If multiple files just declare global functions, then this will work fine, but if each file declares a module, then mere concatenation of the outputs will not produce what I would consider the expected behavior: amalgamation scripts generally end up declaring multiple independent modules (like one would see on a big
👍
If the coverage is alright I guess we can look into reviewing and merging this version. Let's just make sure the new features are covered in the docs. Very cool work in this PR, improving the tooling is super important! |
For the time being I'll limit But this is pretty feature-complete for what I imagined the initial write up of this would be and while I still have some ideas, I think it would be feature creep. So over the next few days I'll try to improve test coverage and documentation to get this ready to merge. 🎉 |
I'll leave this here as a reference for where I think I'm at and suggestions for where to go. TODO
In general, I think I need to write more tests where the expected output is an error. |
I'd like to get this merged as soon as possible since it's getting too big to do a review in one go. :) I took another look at the PR (not a super detailed line-by-line look, I admit! it's a lot of stuff!) and left a couple of comments, apart from those I think we can get it merged now and if anything needs tweaking we can fix in future commits/PRs |
I'd say go ahead and merge this if you'd like. The most basic error cases have tests now and I've been using this since I made the pr on a bunch of tiny things and it hasn't had any trouble. Here's a rundown for the changelog:
|
Adds luafilesystem dependency and the following config options - build_dir - source_dir - files - include - exclude - Original include -> include_dir
In particular adds the following util function: util.write_tmp_dir, which lets us build up a directory structure in /tmp to test out tl gen. The run_mock_project will probably move to util as more tests get written, but in short: it uses util.write_tmp_dir then makes a link to tl and tl.lua in the dir, does a lfs.chdir, and runs ./tl gen. Then it asserts that the generates files are as expected, and cleans up after itself by removing the dir and does a lfs.chdir back to the correct dir
With this commit a lot of tests had to be put as pending to be managable. External changes: - tl gen was reverted to its old behavior in favor of a new tl build command. - tl gen will now always put the generated file in the current dir, unless specified with -o (not implemented yet) - tl build now mimics the behavior of the previous tl gen Internal changes: - I've attempted to separate each command into its own section of the file where it will do its thing and then exit. This favors build to have the last chunk of the file all to itself to build up a source map and all sorts of data structures - build (previously gen) is now a lot more organized in how it handles the directory. In particular paths are now all relative and there is no more messy juggling of absolute vs relative paths. In addition, the 'project' table/object is a good candidate for an api as it provides a neat representation of the project directory as well as some methods to navigate it.
…files going into one
Added a 'relevant commands' section to the option table and updated the examples to use 'build' instead of 'gen'
bd4fcbb
to
8f98af8
Compare
Hey @hishamhm, any updates on getting this merged? |
@euclidianAce hi, sorry for dropping the ball on this! I've been unable to put too much energy on Teal the last couple of weeks. I just merged it manually, squashing some of the commits together. Thank you for the nudge, this PR is a huge win for the project! |
Thanks, no worries! |
Adds luafilesystem dependency and the following config options
Hopefully these changes should remove the need for a Makefile for pure Teal projects (though probably not
tl
itself)This contains some pretty big refactors to
tl
that I will try to outline here.tl gen
andtl check
now build up a source map for file names (src_map: {string:string}
)tl run
will not build up a source map because it only relies on the args passed to it.source_map
config option as well to just directly map inputs and outputs.Some notes:
source_dir
. Technicallybuild_dir
can get by with someos.execute("mkdir ...")
stuff, but that always feels hacky.**/
pattern matching functions, there doesn't seem to be a way to extract local functions with the debug library, so putting them in a module seems like the only way to test them, but having a test suite for these would be helpful.Constructive criticism/reviews are definitely appreciated, especially for testing this. 🎉