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

FscHelper: add fsc function #485

Merged
merged 1 commit into from
Jul 3, 2014
Merged

FscHelper: add fsc function #485

merged 1 commit into from
Jul 3, 2014

Conversation

yawaramin
Copy link
Contributor

The 'fsc' helper function is a simple wrapper for the 'fsc.exe' F#
compiler command-line tool. It takes a source file and an F# list of
options, and compiles the source file.

Fixes #478.

@forki
Copy link
Member

forki commented Jun 29, 2014

This is really cool. I'd like to see this in FAKE.

I think it would be better to encapsulate the compiler switches in a record. This would match the other FAKE tasks.

Is it possible to compile more than one file? I think the default should be to send a fileset to the task.

@yawaramin
Copy link
Contributor Author

I thought about using a record type for the switches, it would probably look something like this in usage:

// (Previously defined:)
type FscTarget = Library | Exe | Winexe

Target "MyFile" (fun _ ->
  fsc
    { FscOptions() with
      In = ["File1.fs"; File2.fs"]
      Target = Library
      Out = "Compiled.dll"
      Debug = true
      References = ["Base.dll"; "Common.dll"]})

This is definitely more type-safe, but arguably clunkier for the user to write, compared to the simple listing of command-line switches that they're probably already used to.

Using the fsc function as it is right now, it's definitely possible to compile multiple files, but I admit the way I've implemented it right now makes it non-obvious (you just include the extra source files in the options list). I could re-implement to take a single parameter as originally planned, e.g.:

fsc ["File1.fs"; "File2.fs"; "-a"; "-o"; "Compiled.dll"; "-g"; "-r"; "Base.dll"; "-r"; "Common.dll"]

So, ultimately your choice: the record style or the string list style?

@forki
Copy link
Member

forki commented Jun 30, 2014

How about a FSC task (in record style) which uses the existing lower case fsc task.

So we give users the chance to fall back to the args list

The 'fsc' and 'Fsc' functions take as input a function inside which you
can set up compile parameters. Defaults are provided and can be
overridden.

'fsc' returns the exit code of the compile, while 'Fsc' discards it. The
latter can be used inside Target task functions.

Both internally use the 'fscList' function which takes parameters as a
simple list of strings. This function also writes error output, if any.

Fixes #478.
@yawaramin
Copy link
Contributor Author

I've implemented the Fsc function in the same style as the Fake.TypeScript.TypeScriptCompiler function. Fsc can thus be used directly inside targets.

forki added a commit that referenced this pull request Jul 3, 2014
@forki forki merged commit e83564e into fsprojects:master Jul 3, 2014
@forki
Copy link
Member

forki commented Jul 3, 2014

I'd like to let the Fsc task take a file set as all the other tasks do.
Can you check if it still works for you?

forki added a commit that referenced this pull request Jul 3, 2014
@yawaramin yawaramin deleted the issues/478 branch July 3, 2014 22:35
@yawaramin
Copy link
Contributor Author

The file set works fine, thanks. I've made some more changes which I think are warranted, will do a PR soon.

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