From f1f63823b8c066bfb2f1189244ed78e075ae663e Mon Sep 17 00:00:00 2001 From: acco32 Date: Tue, 6 Mar 2018 21:52:08 -0800 Subject: [PATCH 1/4] Add nuget package --- examples/fsharp/README.md | 25 -------------- makefiles/Makefile.csharp.mk | 4 +-- makefiles/Makefile.fsharp.mk | 14 +++++++- .../fsharp/Google.OrTools.AssemblyInfo.fsx | 14 ++++++++ ortools/fsharp/Google.OrTools.FSharp.nuspec | 21 ++++++++++++ ortools/fsharp/README.md | 33 +++++++++++++++++++ 6 files changed, 83 insertions(+), 28 deletions(-) create mode 100644 ortools/fsharp/Google.OrTools.AssemblyInfo.fsx create mode 100644 ortools/fsharp/Google.OrTools.FSharp.nuspec create mode 100644 ortools/fsharp/README.md 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 4d015ce2c6..48d67484eb 100755 --- a/makefiles/Makefile.csharp.mk +++ b/makefiles/Makefile.csharp.mk @@ -38,9 +38,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 ec327f62fc..5f75b6eef5 100644 --- a/makefiles/Makefile.fsharp.mk +++ b/makefiles/Makefile.fsharp.mk @@ -1,13 +1,19 @@ 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 ifeq ($(SYSTEM), win) FSHARP_COMPILER:=fsc + NUGET_CMD:=nuget.exe FLAG_PREFIX:=/ else FSHARP_COMPILER:=fsharpc + NUGET_CMD:=nuget FLAG_PREFIX:=-- endif @@ -34,11 +40,17 @@ fsharp-help: .PHONY: fsharp # Build F# OR-Tools. Set environment variable FSHARP_DEBUG=1 for debug symbols. fsharp: ifneq ($(FSHARP_COMPILER_CHECK),) - $(FSHARP_COMPILER) $(FLAG_PREFIX)target:library $(FLAG_PREFIX)out:bin$S$(FSHARP_ORTOOLS_DLL_NAME).dll $(FLAG_PREFIX)platform:anycpu $(FLAG_PREFIX)nocopyfsharpcore $(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/VVVV/$(OR_TOOLS_VERSION)/" ortools$Sfsharp$S$(FSHARP_ORTOOLS_DLL_ASSEMBLYINFO_FILE) ortools$Sfsharp$S$(FSHARP_ORTOOLS_NUSPEC_FILE) + $(FSHARP_COMPILER) $(FLAG_PREFIX)target:library $(FLAG_PREFIX)out:bin$S$(FSHARP_ORTOOLS_DLL_NAME).dll $(FLAG_PREFIX)platform:anycpu $(FLAG_PREFIX)nocopyfsharpcore $(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 $(error Cannot find '$(FSHARP_COMPILER)' command which is needed for build. Please make sure it is installed and in system path.) endif +.PHONY: fsharp-build-nuget # Build Nuget Package for distribution. +fsharp-build-nuget: fsharp + $(SED) -i -e "s/VVVV/$(OR_TOOLS_VERSION)/" ortools$Sfsharp$S$(FSHARP_ORTOOLS_NUSPEC_FILE) + $(NUGET_CMD) pack ortools$Sfsharp$S$(FSHARP_ORTOOLS_NUSPEC_FILE) -Basepath . -OutputDirectory $(ORTOOLS_NUGET_DIR) + .PHONY: fsharp-clean # Clean output from previous build. fsharp-clean: @rm bin$S$(CLEAN_FILES) diff --git a/ortools/fsharp/Google.OrTools.AssemblyInfo.fsx b/ortools/fsharp/Google.OrTools.AssemblyInfo.fsx new file mode 100644 index 0000000000..9a61513123 --- /dev/null +++ b/ortools/fsharp/Google.OrTools.AssemblyInfo.fsx @@ -0,0 +1,14 @@ +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..d028582ac5 --- /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 fsharp-help`. 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 fsharp-build-nuget +``` +The output package will include the FSharp binary and examples. It is compiled against the `netstandard2.0` metaframework. From e1354344979a7a411d82c90b7f78e79323ecb5a8 Mon Sep 17 00:00:00 2001 From: acco32 Date: Tue, 6 Mar 2018 21:52:08 -0800 Subject: [PATCH 2/4] Add nuget package --- examples/fsharp/README.md | 25 -------------- makefiles/Makefile.csharp.mk | 4 +-- makefiles/Makefile.fsharp.mk | 4 +++ .../fsharp/Google.OrTools.AssemblyInfo.fsx | 14 ++++++++ ortools/fsharp/Google.OrTools.FSharp.nuspec | 21 ++++++++++++ ortools/fsharp/README.md | 33 +++++++++++++++++++ 6 files changed, 74 insertions(+), 27 deletions(-) create mode 100644 ortools/fsharp/Google.OrTools.AssemblyInfo.fsx create mode 100644 ortools/fsharp/Google.OrTools.FSharp.nuspec create mode 100644 ortools/fsharp/README.md 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 b1a49ca073..c7d9c71b6f 100755 --- a/makefiles/Makefile.csharp.mk +++ b/makefiles/Makefile.csharp.mk @@ -123,9 +123,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..bda8dcdd93 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 diff --git a/ortools/fsharp/Google.OrTools.AssemblyInfo.fsx b/ortools/fsharp/Google.OrTools.AssemblyInfo.fsx new file mode 100644 index 0000000000..9a61513123 --- /dev/null +++ b/ortools/fsharp/Google.OrTools.AssemblyInfo.fsx @@ -0,0 +1,14 @@ +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..d028582ac5 --- /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 fsharp-help`. 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 fsharp-build-nuget +``` +The output package will include the FSharp binary and examples. It is compiled against the `netstandard2.0` metaframework. From 6da81fb774b8cf1f9643da6cd7712e0e1d58141d Mon Sep 17 00:00:00 2001 From: acco32 Date: Wed, 7 Mar 2018 20:49:19 -0800 Subject: [PATCH 3/4] Makefile updates --- makefiles/Makefile.fsharp.mk | 9 ++++++++- ortools/fsharp/Google.OrTools.AssemblyInfo.fsx | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/makefiles/Makefile.fsharp.mk b/makefiles/Makefile.fsharp.mk index bda8dcdd93..4a3b17ca6f 100644 --- a/makefiles/Makefile.fsharp.mk +++ b/makefiles/Makefile.fsharp.mk @@ -48,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 index 9a61513123..5423f94a07 100644 --- a/ortools/fsharp/Google.OrTools.AssemblyInfo.fsx +++ b/ortools/fsharp/Google.OrTools.AssemblyInfo.fsx @@ -1,6 +1,6 @@ open System.Reflection -[] +[] [] [] @@ -10,5 +10,6 @@ open System.Reflection [] [] +[] () \ No newline at end of file From 362d71620fd0a6575a5248a02eacea916e430151 Mon Sep 17 00:00:00 2001 From: acco32 Date: Wed, 7 Mar 2018 21:08:46 -0800 Subject: [PATCH 4/4] Update README --- ortools/fsharp/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ortools/fsharp/README.md b/ortools/fsharp/README.md index d028582ac5..b2feca00f8 100644 --- a/ortools/fsharp/README.md +++ b/ortools/fsharp/README.md @@ -23,11 +23,11 @@ One can also use the makefile found in the root folder to accomplish the same ta ```shell make fsharp ``` -To see the targets type `make fsharp-help`. Note that a keyfile must exist in the `bin` folder as it will be used to sign the assembly. +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 fsharp-build-nuget +make nuget-pkg_fsharp ``` The output package will include the FSharp binary and examples. It is compiled against the `netstandard2.0` metaframework.