From 058a8648276f4aa1472185b9a48fa9785ba57a5c Mon Sep 17 00:00:00 2001 From: Corentin Le Molgat Date: Fri, 10 Jun 2022 17:00:31 +0200 Subject: [PATCH] make: Add USE_DOTNET_CORE_31 and USE_DOTNET_6 --- makefiles/Makefile.cpp.mk | 5 ++ makefiles/Makefile.dotnet.mk | 48 ++++++++++++++++++++ makefiles/docker/archlinux/dotnet.Dockerfile | 3 +- makefiles/docker/ubuntu/dotnet.Dockerfile | 3 +- 4 files changed, 57 insertions(+), 2 deletions(-) diff --git a/makefiles/Makefile.cpp.mk b/makefiles/Makefile.cpp.mk index cd2c4e9bc0..e52619ef20 100644 --- a/makefiles/Makefile.cpp.mk +++ b/makefiles/Makefile.cpp.mk @@ -26,6 +26,9 @@ USE_PDLP := ON # OFF not supported USE_SCIP ?= ON USE_CPLEX ?= OFF USE_XPRESS ?= OFF + +USE_DOTNET_CORE_31 ?= ON +USE_DOTNET_6 ?= ON JOBS ?= 4 # Main targets. @@ -53,6 +56,8 @@ third_party: -DUSE_SCIP=$(USE_SCIP) \ -DUSE_CPLEX=$(USE_CPLEX) \ -DUSE_XPRESS=$(USE_XPRESS) \ + -DUSE_DOTNET_CORE_31=$(USE_DOTNET_CORE_31) \ + -DUSE_DOTNET_6=$(USE_DOTNET_6) \ -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) \ -DCMAKE_INSTALL_PREFIX=$(INSTALL_DIR) \ $(CMAKE_ARGS) \ diff --git a/makefiles/Makefile.dotnet.mk b/makefiles/Makefile.dotnet.mk index 7a8975d874..de057fde30 100644 --- a/makefiles/Makefile.dotnet.mk +++ b/makefiles/Makefile.dotnet.mk @@ -94,8 +94,18 @@ $(TEMP_DOTNET_DIR)/$1/%/%.csproj: \ $(SED) -e "s/@DOTNET_PACKAGES_DIR@/..\/..\/..\/$(BUILD_DIR)\/dotnet\/packages/" \ ortools$Sdotnet$SSample.csproj.in \ > $(TEMP_DOTNET_DIR)$S$1$S$$*$S$$*.csproj +ifeq ($(USE_DOTNET_6)_$(USE_DOTNET_CORE_31),ON_ON) $(SED) -i -e 's/@DOTNET_TFM@/netcoreapp3.1;net6.0<\/TargetFrameworks>/' \ $(TEMP_DOTNET_DIR)$S$1$S$$*$S$$*.csproj +else + ifeq ($(USE_DOTNET_6),ON) + $(SED) -i -e 's/@DOTNET_TFM@/net6.0<\/TargetFramework>/' \ + $(TEMP_DOTNET_DIR)$S$1$S$$*$S$$*.csproj + else + $(SED) -i -e 's/@DOTNET_TFM@/netcoreapp3.1<\/TargetFramework>/' \ + $(TEMP_DOTNET_DIR)$S$1$S$$*$S$$*.csproj + endif +endif $(SED) -i -e 's/@DOTNET_PROJECT@/$(DOTNET_ORTOOLS_ASSEMBLY_NAME)/' \ $(TEMP_DOTNET_DIR)$S$1$S$$*$S$$*.csproj $(SED) -i -e 's/@SAMPLE_NAME@/$$*/' \ @@ -122,8 +132,14 @@ rdotnet_%: \ $(TEMP_DOTNET_DIR)/$1/%/%.csproj \ $(TEMP_DOTNET_DIR)/$1/%/%.cs \ FORCE +ifeq ($(USE_DOTNET_6),ON) cd $(TEMP_DOTNET_DIR)$S$1$S$$* && "$(DOTNET_BIN)" build --framework net6.0 -c Release cd $(TEMP_DOTNET_DIR)$S$1$S$$* && "$(DOTNET_BIN)" run --no-build --framework net6.0 -c Release $(ARGS) +endif +ifeq ($(USE_DOTNET_CORE_31),ON) + cd $(TEMP_DOTNET_DIR)$S$1$S$$* && "$(DOTNET_BIN)" build --framework netcoreapp3.1 -c Release + cd $(TEMP_DOTNET_DIR)$S$1$S$$* && "$(DOTNET_BIN)" run --no-build --framework netcoreapp3.1 -c Release $(ARGS) +endif cd $(TEMP_DOTNET_DIR)$S$1$S$$* && "$(DOTNET_BIN)" clean -c Release -v minimal endef @@ -146,8 +162,18 @@ $(TEMP_DOTNET_DIR)/$1/%/%.csproj: \ $(SED) -e "s/@DOTNET_PACKAGES_DIR@/..\/..\/..\/$(BUILD_DIR)\/dotnet\/packages/" \ ortools$Sdotnet$SSample.csproj.in \ > $(TEMP_DOTNET_DIR)$S$1$S$$*$S$$*.csproj +ifeq ($(USE_DOTNET_6)_$(USE_DOTNET_CORE_31),ON_ON) $(SED) -i -e 's/@DOTNET_TFM@/netcoreapp3.1;net6.0<\/TargetFrameworks>/' \ $(TEMP_DOTNET_DIR)$S$1$S$$*$S$$*.csproj +else + ifeq ($(USE_DOTNET_6),ON) + $(SED) -i -e 's/@DOTNET_TFM@/net6.0<\/TargetFramework>/' \ + $(TEMP_DOTNET_DIR)$S$1$S$$*$S$$*.csproj + else + $(SED) -i -e 's/@DOTNET_TFM@/netcoreapp3.1<\/TargetFramework>/' \ + $(TEMP_DOTNET_DIR)$S$1$S$$*$S$$*.csproj + endif +endif $(SED) -i -e 's/@DOTNET_PROJECT@/$(DOTNET_ORTOOLS_ASSEMBLY_NAME)/' \ $(TEMP_DOTNET_DIR)$S$1$S$$*$S$$*.csproj $(SED) -i -e 's/@SAMPLE_NAME@/$$*/' \ @@ -174,8 +200,14 @@ rdotnet_%: \ $(TEMP_DOTNET_DIR)/$1/%/%.csproj \ $(TEMP_DOTNET_DIR)/$1/%/%.cs \ FORCE +ifeq ($(USE_DOTNET_6),ON) cd $(TEMP_DOTNET_DIR)$S$1$S$$* && "$(DOTNET_BIN)" build --framework net6.0 -c Release cd $(TEMP_DOTNET_DIR)$S$1$S$$* && "$(DOTNET_BIN)" run --no-build --framework net6.0 -c Release $(ARGS) +endif +ifeq ($(USE_DOTNET_CORE_31),ON) + cd $(TEMP_DOTNET_DIR)$S$1$S$$* && "$(DOTNET_BIN)" build --framework netcoreapp3.1 -c Release + cd $(TEMP_DOTNET_DIR)$S$1$S$$* && "$(DOTNET_BIN)" run --no-build --framework netcoreapp3.1 -c Release $(ARGS) +endif cd $(TEMP_DOTNET_DIR)$S$1$S$$* && "$(DOTNET_BIN)" clean -c Release -v minimal endef @@ -199,8 +231,18 @@ $(TEMP_DOTNET_DIR)/tests/%/%.csproj: \ $(SED) -e "s/@DOTNET_PACKAGES_DIR@/..\/..\/..\/$(BUILD_DIR)\/dotnet\/packages/" \ ortools$Sdotnet$STest.csproj.in \ > $(TEMP_DOTNET_DIR)$Stests$S$*$S$*.csproj +ifeq ($(USE_DOTNET_6)_$(USE_DOTNET_CORE_31),ON_ON) $(SED) -i -e 's/@DOTNET_TFM@/netcoreapp3.1;net6.0<\/TargetFrameworks>/' \ $(TEMP_DOTNET_DIR)$Stests$S$*$S$*.csproj +else + ifeq ($(USE_DOTNET_6),ON) + $(SED) -i -e 's/@DOTNET_TFM@/net6.0<\/TargetFramework>/' \ + $(TEMP_DOTNET_DIR)$Stests$S$*$S$*.csproj + else + $(SED) -i -e 's/@DOTNET_TFM@/netcoreapp3.1<\/TargetFramework>/' \ + $(TEMP_DOTNET_DIR)$Stests$S$*$S$*.csproj + endif +endif $(SED) -i -e 's/@DOTNET_PROJECT@/$(DOTNET_ORTOOLS_ASSEMBLY_NAME)/' \ $(TEMP_DOTNET_DIR)$Stests$S$*$S$*.csproj $(SED) -i -e 's/@TEST_NAME@/$*/' \ @@ -229,8 +271,14 @@ rdotnet_%: \ $(TEMP_DOTNET_DIR)/tests/%/%.cs \ $(TEMP_DOTNET_DIR)/tests/%/%.csproj \ FORCE +ifeq ($(USE_DOTNET_6),ON) cd $(TEMP_DOTNET_DIR)$Stests$S$* && "$(DOTNET_BIN)" build --framework net6.0 -c Release cd $(TEMP_DOTNET_DIR)$Stests$S$* && "$(DOTNET_BIN)" test --no-build --framework net6.0 -c Release $(ARGS) +endif +ifeq ($(USE_DOTNET_CORE_31),ON) + cd $(TEMP_DOTNET_DIR)$Stests$S$* && "$(DOTNET_BIN)" build --framework netcoreapp3.1 -c Release + cd $(TEMP_DOTNET_DIR)$Stests$S$* && "$(DOTNET_BIN)" test --no-build --framework netcoreapp3.1 -c Release $(ARGS) +endif cd $(TEMP_DOTNET_DIR)$Stests$S$* && "$(DOTNET_BIN)" clean -c Release -v minimal #################### diff --git a/makefiles/docker/archlinux/dotnet.Dockerfile b/makefiles/docker/archlinux/dotnet.Dockerfile index ea3cb43569..bd382ac719 100644 --- a/makefiles/docker/archlinux/dotnet.Dockerfile +++ b/makefiles/docker/archlinux/dotnet.Dockerfile @@ -8,7 +8,8 @@ WORKDIR /home/project COPY . . FROM devel AS build -RUN make dotnet CMAKE_ARGS="-DUSE_DOTNET_CORE_31=OFF" +ENV USE_DOTNET_CORE_31=OFF +RUN make dotnet FROM build AS test RUN make test_dotnet diff --git a/makefiles/docker/ubuntu/dotnet.Dockerfile b/makefiles/docker/ubuntu/dotnet.Dockerfile index 6f24f39533..7d14a50ef5 100644 --- a/makefiles/docker/ubuntu/dotnet.Dockerfile +++ b/makefiles/docker/ubuntu/dotnet.Dockerfile @@ -20,7 +20,8 @@ WORKDIR /home/project COPY . . FROM devel AS build -RUN make dotnet CMAKE_ARGS="-DUSE_DOTNET_CORE_31=OFF" +ENV USE_DOTNET_CORE_31=OFF +RUN make dotnet FROM build AS test RUN make test_dotnet