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

Build system organization and documentation #21

Merged
merged 14 commits into from
Jun 21, 2021
Merged

Build system organization and documentation #21

merged 14 commits into from
Jun 21, 2021

Conversation

j-hui
Copy link
Collaborator

@j-hui j-hui commented Jun 17, 2021

I realize that I didn't leave behind much top-level documentation, and there's some additional cleanup/touch ups I'd like to add to this.

Not ready for merging at time of writing; I'll indicate when it is.

Now the top-level Build.mk is responsible for creating the build
directory, meaning it can be included from other Makefiles (even ones
beyond the source tree).
@j-hui j-hui changed the title Tidying up and [NOT READY FOR MERGE] Build system organization and documentation Jun 18, 2021
@j-hui j-hui changed the title Build system organization and documentation Build system organization and documentation [DO NOT MERGE] Jun 18, 2021
@j-hui
Copy link
Collaborator Author

j-hui commented Jun 18, 2021

Wow I really butchered this PR title. Hopefully this new one clarifies things a little more.

This PR now includes commits toward #12, by allowing the top-level Build.mk to be included from outside of this project. I would like to close that issue in this PR, as long as I don't hit any snags (even if that oversteps the original intention of this PR, which was primarily to provide better documentation and organization).

Will update the top comment with a TODO list for myself

@j-hui j-hui mentioned this pull request Jun 19, 2021
@j-hui
Copy link
Collaborator Author

j-hui commented Jun 20, 2021

Maybe I'm trying to knock down too many issues with this "documentation" PR, but it looks like I have the beginnings of a solution for #12 in here too (which I will summarily document as that finalizes). Sorry for the lack of focus in this PR.

edsl/Cli.hs Outdated
, transpile
)

compileCli :: SSM () -> IO ()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this, one can write an SSM program like this:

-- in MyFn.hs
import SSM
import Cli (compileCli)

myfn :: SSM ()
myfn = ...

-- | boilerplate to compile myfn to file
main :: IO ()
main = compileCli myfn

and "invoke" the compiler as follows:

stack --stack-yaml /path/to/ssm-edsl/stack.yaml runghc MyFn.hs

which will write the compiled C program to myfn.c (using the entry point of program to derive the C filepath). It also supports the argument -o to explicitly specify the filepath:

stack --stack-yaml /path/to/ssm-edsl/stack.yaml runghc MyFn.hs -- -o mycustomname.c

This allows us to easily write a Make rule for it, something like:

%.c: %.hs
    stack --stack-yaml $(SSMDIR)/stack.yaml runghc $< -- -o $@

@j-hui j-hui requested a review from Rewbert June 21, 2021 16:28
@j-hui j-hui changed the title Build system organization and documentation [DO NOT MERGE] Build system organization and documentation Jun 21, 2021
Copy link
Collaborator

@Rewbert Rewbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks great! Nice documentation for the test & build setup.

@j-hui j-hui merged commit 46e3c22 into master Jun 21, 2021
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

Successfully merging this pull request may close these issues.

2 participants