diff --git a/examples/fsharp/README.md b/examples/fsharp/README.md index bd54ae174e..34ea34ba7f 100644 --- a/examples/fsharp/README.md +++ b/examples/fsharp/README.md @@ -16,28 +16,3 @@ fsharpc --target:exe --out:bin/.exe --platform:anycpu --lib:bin ex DYLD_FALLBACK_LIBRARY_PATH=lib mono bin/.exe ``` - -## Compiling a standalone binary -This command must be run from the root folder of the repository: -```shell -fsharpc --target:library --out:bin/Google.OrTools.FSharp.dll --platform:anycpu --lib:bin --nocopyfsharpcore --keyfile:bin/keyfile.snk -r:Google.OrTools.dll ortools/fsharp/Google.OrTools.FSharp.fsx -``` -For debug information add the `--debug` flag. The library must be coupled with the `Google.OrTools.dll`. Once installed it can be used as follows: -```fsharp -#r "Google.OrTools.dll" -#r "Google.OrTools.Fsharp.dll" - -open System -open Google.OrTools.FSharp - -let opts = SolverOpts.Default - .Name("Equality Constraints") - .Goal(Minimize) -... -``` - -One can also use the makefile found in the root folder to accomplish the same task. -```shell -make fsharp -``` -To see the targets type `make fsharp-help`. Note that a keyfile must exists in the `bin` folder as it will be used to sign the assembly. diff --git a/makefiles/Makefile.csharp.mk b/makefiles/Makefile.csharp.mk index 08cefda471..7eae8248ce 100755 --- a/makefiles/Makefile.csharp.mk +++ b/makefiles/Makefile.csharp.mk @@ -124,9 +124,9 @@ NETSTANDARD_RUNTIME_IDENTIFIER= # NuGet specification file name ORTOOLS_NUSPEC_NAME := or-tools.nuspec -ORTOOLS_NUGET_DIR = temp\or-tools +ORTOOLS_NUGET_DIR = temp$Sor-tools FZ_NUSPEC_NAME := fz.nuspec -FZ_NUGET_DIR = temp\flatzinc +FZ_NUGET_DIR = temp$Sflatzinc # TODO: TBD: add FlatZinc variables... # Building to DLLs named per-platform diff --git a/makefiles/Makefile.fsharp.mk b/makefiles/Makefile.fsharp.mk index 83e120283e..4a3b17ca6f 100644 --- a/makefiles/Makefile.fsharp.mk +++ b/makefiles/Makefile.fsharp.mk @@ -12,6 +12,10 @@ endif BASE_ORTOOLS_DLL_NAME=Google.OrTools FSHARP_ORTOOLS_DLL_NAME=$(BASE_ORTOOLS_DLL_NAME).FSharp + +FSHARP_ORTOOLS_DLL_ASSEMBLYINFO_FILE=$(BASE_ORTOOLS_DLL_NAME).AssemblyInfo.fsx +FSHARP_ORTOOLS_NUSPEC_FILE=$(FSHARP_ORTOOLS_DLL_NAME).nuspec + CLEAN_FILES=$(FSHARP_ORTOOLS_DLL_NAME).* # Check for required build tools @@ -44,11 +48,18 @@ endif .PHONY: fsharp # Build F# OR-Tools. Set environment variable FSHARP_DEBUG=1 for debug symbols. fsharp: csharp ifneq ($(FSHARP_EXECUTABLE),) - "$(FSHARP_EXECUTABLE)" $(FLAG_PREFIX)target:library $(FLAG_PREFIX)out:bin$S$(FSHARP_ORTOOLS_DLL_NAME).dll $(FLAG_PREFIX)platform:anycpu $(FS_NOCPYCORE) $(FLAG_PREFIX)lib:bin $(FLAG_PREFIX)reference:$(BASE_ORTOOLS_DLL_NAME).dll $(FSHARP_DEBUG) $(FS_SIGNING_FLAGS) ortools$Sfsharp$S$(FSHARP_ORTOOLS_DLL_NAME).fsx + $(SED) -i -e "s/MMMM/$(FSHARP_ORTOOLS_DLL_NAME)/" ortools$Sfsharp$S$(FSHARP_ORTOOLS_DLL_ASSEMBLYINFO_FILE) + $(SED) -i -e "s/VVVV/$(OR_TOOLS_VERSION)/" ortools$Sfsharp$S$(FSHARP_ORTOOLS_DLL_ASSEMBLYINFO_FILE) + "$(FSHARP_EXECUTABLE)" $(FLAG_PREFIX)target:library $(FLAG_PREFIX)out:bin$S$(FSHARP_ORTOOLS_DLL_NAME).dll $(FLAG_PREFIX)platform:anycpu $(FS_NOCPYCORE) $(FLAG_PREFIX)lib:bin $(FLAG_PREFIX)reference:$(BASE_ORTOOLS_DLL_NAME).dll $(FSHARP_DEBUG) $(FS_SIGNING_FLAGS) ortools$Sfsharp$S$(FSHARP_ORTOOLS_DLL_NAME).fsx ortools$Sfsharp$S$(FSHARP_ORTOOLS_DLL_ASSEMBLYINFO_FILE) else $(warning Cannot find '$(FSHARP_COMPILER)' command which is needed for build. Please make sure it is installed and in system path.) endif +.PHONY: nuget-pkg_fsharp # Build Nuget Package for distribution. +nuget-pkg_fsharp: fsharp + $(SED) -i -e "s/VVVV/$(OR_TOOLS_VERSION)/" ortools$Sfsharp$S$(FSHARP_ORTOOLS_NUSPEC_FILE) + $(NUGET_EXECUTABLE) pack ortools$Sfsharp$S$(FSHARP_ORTOOLS_NUSPEC_FILE) -Basepath . -OutputDirectory $(ORTOOLS_NUGET_DIR) + .PHONY: test_fsharp # Test F# OR-Tools using various examples. ifneq ($(FSHARP_EXECUTABLE),) test_fsharp: test_fsharp_examples diff --git a/ortools/fsharp/Google.OrTools.AssemblyInfo.fsx b/ortools/fsharp/Google.OrTools.AssemblyInfo.fsx new file mode 100644 index 0000000000..5423f94a07 --- /dev/null +++ b/ortools/fsharp/Google.OrTools.AssemblyInfo.fsx @@ -0,0 +1,15 @@ +open System.Reflection + +[] +[] + +[] +[] +[] +[] +[] + +[] +[] + +() \ No newline at end of file diff --git a/ortools/fsharp/Google.OrTools.FSharp.nuspec b/ortools/fsharp/Google.OrTools.FSharp.nuspec new file mode 100644 index 0000000000..e3d72522a8 --- /dev/null +++ b/ortools/fsharp/Google.OrTools.FSharp.nuspec @@ -0,0 +1,21 @@ + + + + Google.OrTools.FSharp + VVVV + Google + https://github.com/google/or-tools/blob/master/LICENSE-2.0.txt + https://developers.google.com/optimization + F# wrapper for the Operations Research Tools project + Copyright 2018 Google, Inc + Operations Research Math Linear Constraint Programming F# + + + + + + + + + + \ No newline at end of file diff --git a/ortools/fsharp/README.md b/ortools/fsharp/README.md new file mode 100644 index 0000000000..b2feca00f8 --- /dev/null +++ b/ortools/fsharp/README.md @@ -0,0 +1,33 @@ +# Google OrTools - F# + +## Compiling a standalone binary +This command must be run from the root folder of the repository: +```shell +fsharpc --target:library --out:bin/Google.OrTools.FSharp.dll --platform:anycpu --lib:bin --nocopyfsharpcore --keyfile:bin/keyfile.snk -r:Google.OrTools.dll ortools/fsharp/Google.OrTools.FSharp.fsx +``` +For debug information add the `--debug` flag. The library must be coupled with the `Google.OrTools.dll`. Once installed it can be used as follows: +```fsharp +#r "Google.OrTools.dll" +#r "Google.OrTools.Fsharp.dll" + +open System +open Google.OrTools.FSharp + +let opts = SolverOpts.Default + .Name("Equality Constraints") + .Goal(Minimize) +... +``` + +One can also use the makefile found in the root folder to accomplish the same task. +```shell +make fsharp +``` +To see the targets type `make help_fsharp`. Note that a keyfile must exist in the `bin` folder as it will be used to sign the assembly. + +## Building Nuget package +Ensure nuget executable is installed and then from root folder run the following: +```shell +make nuget-pkg_fsharp +``` +The output package will include the FSharp binary and examples. It is compiled against the `netstandard2.0` metaframework.