From 699ec2c3a94ae9c32706a8b4323c5be8e8ee248d Mon Sep 17 00:00:00 2001 From: Corentin Le Molgat Date: Fri, 25 Feb 2022 17:11:38 +0100 Subject: [PATCH] make: Clean and polish * use BUILD_DIR instead of dependencies * bring back target doc * Fix few archive recipe (WiP) --- makefiles/Makefile.archive.mk | 10 +++--- makefiles/Makefile.dotnet.mk | 35 +++++++++++------- makefiles/Makefile.java.mk | 30 +++++++++------- makefiles/Makefile.python.mk | 49 +++++++++++++++----------- makefiles/Makefile.third_party.unix.mk | 16 ++++----- makefiles/Makefile.third_party.win.mk | 16 ++++----- makefiles/Makefile.unix.mk | 1 + makefiles/Makefile.win.mk | 1 + 8 files changed, 90 insertions(+), 68 deletions(-) diff --git a/makefiles/Makefile.archive.mk b/makefiles/Makefile.archive.mk index 68fd4f24c6..4b815c8f65 100644 --- a/makefiles/Makefile.archive.mk +++ b/makefiles/Makefile.archive.mk @@ -127,10 +127,10 @@ archive_java: java \ $(SAMPLE_JAVA_FILES) \ $(EXAMPLE_JAVA_FILES) \ | $(TEMP_ARCHIVE_DIR)/$(INSTALL_DIR)/examples/java - $(COPY) $(TEMP_JAVA_DIR)$S$(JAVA_ORTOOLS_NATIVE_PROJECT)$Starget$Sortools-*.jar $(TEMP_ARCHIVE_DIR)$S$(INSTALL_DIR) - $(COPY) $(TEMP_JAVA_DIR)$S$(JAVA_ORTOOLS_NATIVE_PROJECT)$Spom.xml $(TEMP_ARCHIVE_DIR)$S$(INSTALL_DIR)$Spom-runtime.xml - $(COPY) $(TEMP_JAVA_DIR)$S$(JAVA_ORTOOLS_PROJECT)$Starget$Sortools-*.jar $(TEMP_ARCHIVE_DIR)$S$(INSTALL_DIR) - $(COPY) $(TEMP_JAVA_DIR)$S$(JAVA_ORTOOLS_PROJECT)$Spom.xml $(TEMP_ARCHIVE_DIR)$S$(INSTALL_DIR)$Spom-local.xml + $(COPY) $(JAVA_BUILD_DIR)$S$(JAVA_ORTOOLS_NATIVE_PROJECT)$Starget$Sortools-*.jar $(TEMP_ARCHIVE_DIR)$S$(INSTALL_DIR) + $(COPY) $(JAVA_BUILD_DIR)$S$(JAVA_ORTOOLS_NATIVE_PROJECT)$Spom.xml $(TEMP_ARCHIVE_DIR)$S$(INSTALL_DIR)$Spom-runtime.xml + $(COPY) $(JAVA_BUILD_DIR)$S$(JAVA_ORTOOLS_PROJECT)$Starget$Sortools-*.jar $(TEMP_ARCHIVE_DIR)$S$(INSTALL_DIR) + $(COPY) $(JAVA_BUILD_DIR)$S$(JAVA_ORTOOLS_PROJECT)$Spom.xml $(TEMP_ARCHIVE_DIR)$S$(INSTALL_DIR)$Spom-local.xml $(COPY) $(JAVA_EX_PATH)$SREADME.md $(TEMP_ARCHIVE_DIR)$S$(INSTALL_DIR)$Sexamples$Sjava ############## @@ -184,7 +184,7 @@ archive_dotnet: dotnet \ $(EXAMPLE_DOTNET_FILES) \ | $(TEMP_ARCHIVE_DIR)/$(INSTALL_DIR)/examples/dotnet -$(MKDIR_P) $(TEMP_ARCHIVE_DIR)$S$(INSTALL_DIR)$Spackages - $(COPY) $(TEMP_DOTNET_DIR)$Spackages$S*.nupkg $(TEMP_ARCHIVE_DIR)$S$(INSTALL_DIR)$Spackages + $(COPY) $(DOTNET_BUILD_DIR)$Spackages$S*.nupkg $(TEMP_ARCHIVE_DIR)$S$(INSTALL_DIR)$Spackages -$(COPY) $(DOTNET_EX_PATH)$SREADME.md $(TEMP_ARCHIVE_DIR)$S$(INSTALL_DIR)$Sexamples$Sdotnet ################ diff --git a/makefiles/Makefile.dotnet.mk b/makefiles/Makefile.dotnet.mk index 94136ccaaf..1ceed3b999 100644 --- a/makefiles/Makefile.dotnet.mk +++ b/makefiles/Makefile.dotnet.mk @@ -1,12 +1,4 @@ -ifeq ($(BUILD_DOTNET),OFF) -dotnet: - $(warning Either .NET support was turned of, of the dotnet binary was not found.) - -test_dotnet: dotnet -package_dotnet: dotnet -check_dotnet: dotnet -else - +# ---------- .Net support ---------- .PHONY: help_dotnet # Generate list of dotnet targets with descriptions. help_dotnet: @echo Use one of the following dotnet targets: @@ -18,13 +10,30 @@ else @echo endif + +ifeq ($(BUILD_DOTNET),OFF) +dotnet: + $(warning Either .NET support was turned of, of the dotnet binary was not found.) + +test_dotnet: dotnet +package_dotnet: dotnet +check_dotnet: dotnet + +else # BUILD_DOTNET=ON + +DOTNET_BUILD_DIR = $(BUILD_DIR)$Sdotnet + # All libraries and dependencies TEMP_DOTNET_DIR = temp_dotnet DOTNET_PACKAGE_DIR = temp_dotnet/packages DOTNET_PACKAGE_PATH = $(subst /,$S,$(DOTNET_PACKAGE_DIR)) DOTNET_ORTOOLS_ASSEMBLY_NAME := Google.OrTools +# Main target .PHONY: dotnet # Build .Net OR-Tools library. +.PHONY: check_dotnet # Quick check only running .Net OR-Tools samples. +.PHONY: test_dotnet # Run all .Net OR-Tools test targets. +.PHONY: package_dotnet # Create .Net OR-Tools Nuget package. dotnet: cc temp_dotnet: @@ -71,7 +80,7 @@ $$(TEMP_DOTNET_DIR)/$1/%: \ $$(TEMP_DOTNET_DIR)/$1/%/%.csproj: \ $${SRC_DIR}/ortools/dotnet/Sample.csproj.in \ | $$(TEMP_DOTNET_DIR)/$1/% - $$(SED) -e "s/@DOTNET_PACKAGES_DIR@/..\/..\/..\/dependencies\/dotnet\/packages/" \ + $$(SED) -e "s/@DOTNET_PACKAGES_DIR@/..\/..\/..\/$(BUILD_DIR)\/dotnet\/packages/" \ ortools$$Sdotnet$$SSample.csproj.in \ > $$(TEMP_DOTNET_DIR)$$S$1$$S$$*$$S$$*.csproj $$(SED) -i -e 's/@DOTNET_PROJECT@/$$(DOTNET_ORTOOLS_ASSEMBLY_NAME)/' \ @@ -120,7 +129,7 @@ $$(TEMP_DOTNET_DIR)/$1/%: \ $$(TEMP_DOTNET_DIR)/$1/%/%.csproj: \ $${SRC_DIR}/ortools/dotnet/Sample.csproj.in \ | $$(TEMP_DOTNET_DIR)/$1/% - $$(SED) -e "s/@DOTNET_PACKAGES_DIR@/..\/..\/..\/dependencies\/dotnet\/packages/" \ + $$(SED) -e "s/@DOTNET_PACKAGES_DIR@/..\/..\/..\/$(BUILD_DIR)\/dotnet\/packages/" \ ortools$$Sdotnet$$SSample.csproj.in \ > $$(TEMP_DOTNET_DIR)$$S$1$$S$$*$$S$$*.csproj $$(SED) -i -e 's/@DOTNET_PROJECT@/$$(DOTNET_ORTOOLS_ASSEMBLY_NAME)/' \ @@ -168,7 +177,7 @@ $(TEMP_DOTNET_DIR)/tests/%: \ $(TEMP_DOTNET_DIR)/tests/%/%.csproj: \ ${SRC_DIR}/ortools/dotnet/Test.csproj.in \ | $(TEMP_DOTNET_DIR)/tests/% - $(SED) -e "s/@DOTNET_PACKAGES_DIR@/..\/..\/..\/dependencies\/dotnet\/packages/" \ + $(SED) -e "s/@DOTNET_PACKAGES_DIR@/..\/..\/..\/$(BUILD_DIR)\/dotnet\/packages/" \ ortools$Sdotnet$STest.csproj.in \ > $(TEMP_DOTNET_DIR)$Stests$S$*$S$*.csproj $(SED) -i -e 's/@DOTNET_PROJECT@/$(DOTNET_ORTOOLS_ASSEMBLY_NAME)/' \ @@ -544,7 +553,7 @@ endif package_dotnet: $(OR_TOOLS_LIBS) -$(DEL) $.*pkg - $(COPY) dependencies$Sdotnet$Spackages$S*.*pkg . + $(COPY) $(DOTNET_BUILD_DIR)$Spackages$S*.*pkg . .PHONY: nuget_archive # Build .Net "Google.OrTools" Nuget Package nuget_archive: dotnet | $(TEMP_DOTNET_DIR) diff --git a/makefiles/Makefile.java.mk b/makefiles/Makefile.java.mk index 51f1ed64fd..3826ce6ead 100644 --- a/makefiles/Makefile.java.mk +++ b/makefiles/Makefile.java.mk @@ -1,3 +1,16 @@ +# ---------- Java support ---------- +.PHONY: help_java # Generate list of Java targets with descriptions. +help_java: + @echo Use one of the following Java targets: +ifeq ($(SYSTEM),win) + @$(GREP) "^.PHONY: .* #" $(CURDIR)/makefiles/Makefile.java.mk | $(SED) "s/\.PHONY: \(.*\) # \(.*\)/\1\t\2/" + @echo off & echo( +else + @$(GREP) "^.PHONY: .* #" $(CURDIR)/makefiles/Makefile.java.mk | $(SED) "s/\.PHONY: \(.*\) # \(.*\)/\1\t\2/" | expand -t24 + @echo +endif + + ifeq ($(BUILD_JAVA),OFF) java_runtime: java java: @@ -16,17 +29,7 @@ package_java: java else # BUILD_JAVA=ON -.PHONY: help_java # Generate list of Java targets with descriptions. -help_java: - @echo Use one of the following Java targets: -ifeq ($(SYSTEM),win) - @$(GREP) "^.PHONY: .* #" $(CURDIR)/makefiles/Makefile.java.mk | $(SED) "s/\.PHONY: \(.*\) # \(.*\)/\1\t\2/" - @echo off & echo( -else - @$(GREP) "^.PHONY: .* #" $(CURDIR)/makefiles/Makefile.java.mk | $(SED) "s/\.PHONY: \(.*\) # \(.*\)/\1\t\2/" | expand -t24 - @echo -endif - +JAVA_BUILD_DIR = $(BUILD_DIR)$Sjava TEMP_JAVA_DIR = temp_java JAVA_ORTOOLS_PACKAGE := com.google.ortools @@ -34,6 +37,7 @@ JAVA_ORTOOLS_PACKAGE := com.google.ortools .PHONY: java_runtime # Build Java OR-Tools runtime. .PHONY: java # Build Java OR-Tools. .PHONY: test_java # Test Java OR-Tools using various examples. +.PHONY: package_java # Create jar OR-Tools Maven package. java: cc # Detect RuntimeIDentifier @@ -62,8 +66,8 @@ $(TEMP_JAVA_DIR): package_java: $(OR_TOOLS_LIBS) -$(DEL) *.jar - $(COPY) dependencies$Sjava$Sortools-java$Starget$S*.jar . - $(COPY) dependencies$Sjava$Sortools-$(JAVA_NATIVE_IDENTIFIER)$Starget$S*.jar . + $(COPY) $(JAVA_BUILD_DIR)$Sortools-java$Starget$S*.jar . + $(COPY) $(JAVA_BUILD_DIR)$Sortools-$(JAVA_NATIVE_IDENTIFIER)$Starget$S*.jar . ############################# diff --git a/makefiles/Makefile.python.mk b/makefiles/Makefile.python.mk index b14c9ac170..f13f447196 100644 --- a/makefiles/Makefile.python.mk +++ b/makefiles/Makefile.python.mk @@ -1,13 +1,4 @@ -ifeq ($(BUILD_PYTHON),OFF) -python: - $(warning Either Python support was turned off, or the python3 binary was not found.) - -test_python: python -package_python: python -check_python: python - -else # BUILD_PYTHON=ON - +# ---------- Python support ---------- .PHONY: help_python # Generate list of Python targets with descriptions. help_python: @echo Use one of the following Python targets: @@ -19,13 +10,33 @@ else @echo endif -ifeq ($(SYSTEM),win) -PYTHON_EXECUTABLE := dependencies\\python\\venv\\Scripts\\python -else -PYTHON_EXECUTABLE := dependencies/python/venv/bin/python -endif -python: $(OR_TOOLS_LIBS) +ifeq ($(BUILD_PYTHON),OFF) +python: + $(warning Either Python support was turned off, or the python3 binary was not found.) + +test_python: python +package_python: python +check_python: python + +else # BUILD_PYTHON=ON + +PYTHON_BUILD_DIR = $(BUILD_DIR)$Spython + +# Main target +.PHONY: python # Build Python OR-Tools. +.PHONY: check_python # Quick check only running Python OR-Tools samples. +.PHONY: test_python # Run all Python OR-Tools test targets. +.PHONY: package_python # Create Python ortools Wheel package. +.PHONY: test_package_python # Test Python "ortools" Wheel package +.PHONY: install_python # Install Python OR-Tools on the host system +python: cc + +ifeq ($(SYSTEM),win) +PYTHON_EXECUTABLE := $(PYTHON_BUILD_DIR)\\venv\\Scripts\\python +else +PYTHON_EXECUTABLE := $(PYTHON_BUILD_DIR)/venv/bin/python +endif ####################### ## Python SOURCE ## @@ -146,7 +157,6 @@ test_python_sat_samples: \ rpy_step_function_sample_sat \ rpy_stop_after_n_solutions_sample_sat -.PHONY: check_python check_python: \ test_python_algorithms_samples \ test_python_constraint_solver_samples \ @@ -342,7 +352,6 @@ test_python_python: \ rpy_worker_schedule_sat \ rpy_zebra_sat -.PHONY: test_python test_python: \ check_python \ test_python_tests \ @@ -500,9 +509,8 @@ $(PYPI_ARCHIVE_TEMP_DIR)/ortools/ortools/.libs: | $(PYPI_ARCHIVE_TEMP_DIR)/ortoo ifneq ($(PYTHON_EXECUTABLE),) package_python: $(OR_TOOLS_LIBS) -$(DEL) $.*whl - $(COPY) dependencies$Spython$Sdist$S*.whl . + $(COPY) $(PYTHON_BUILD_DIR)$Sdist$S*.whl . -.PHONY: test_package_python # Test Python "ortools" wheel package test_package_python: package_python -$(DELREC) $(PYPI_ARCHIVE_TEMP_DIR)$Svenv $(PYTHON_EXECUTABLE) -m venv --system-site-packages $(PYPI_ARCHIVE_TEMP_DIR)$Svenv @@ -551,7 +559,6 @@ endif # ifneq ($(PYTHON_EXECUTABLE),) publish_python_pimpl: package_python cd $(PYPI_ARCHIVE_TEMP_DIR)$Sortools && "$(TWINE_EXECUTABLE)" upload "*.whl" -.PHONY: install_python # Install Python OR-Tools on the host system install_python: pypi_archive cd "$(PYPI_ARCHIVE_TEMP_DIR)$Sortools" && "$(PYTHON_EXECUTABLE)" setup.py install --user diff --git a/makefiles/Makefile.third_party.unix.mk b/makefiles/Makefile.third_party.unix.mk index 878ffae70f..19fc60d646 100644 --- a/makefiles/Makefile.third_party.unix.mk +++ b/makefiles/Makefile.third_party.unix.mk @@ -15,15 +15,15 @@ PROTOC ?= $(OR_TOOLS_TOP)/bin/protoc # Main target. .PHONY: third_party # Build OR-Tools Prerequisite -third_party: dependencies/Makefile +third_party: $(BUILD_DIR)/Makefile -THIRD_PARTY_TARGET = dependencies/Makefile +THIRD_PARTY_TARGET = $(BUILD_DIR)/Makefile -dependencies: - mkdir dependencies +$(BUILD_DIR): + mkdir $(BUILD_DIR) -dependencies/Makefile: | dependencies - cmake -S . -B dependencies -DBUILD_DEPS=ON \ +$(BUILD_DIR)/Makefile: | $(BUILD_DIR) + cmake -S . -B $(BUILD_DIR) -DBUILD_DEPS=ON \ -DBUILD_PYTHON=$(BUILD_PYTHON) \ -DBUILD_JAVA=$(BUILD_JAVA) \ -DBUILD_DOTNET=$(BUILD_DOTNET) \ @@ -37,10 +37,10 @@ dependencies/Makefile: | dependencies -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) \ -DCMAKE_INSTALL_PREFIX=$(OR_ROOT_FULL) -.PHONY: clean_third_party # Clean everything. Remember to also delete archived dependencies, i.e. in the event of download failure, etc. +.PHONY: clean_third_party # Clean everything. clean_third_party: -$(DEL) Makefile.local - -$(DELREC) dependencies/* + -$(DELREC) $(BUILD_DIR)/* -$(DELREC) include -$(DELREC) share -$(DELREC) lib/*.a diff --git a/makefiles/Makefile.third_party.win.mk b/makefiles/Makefile.third_party.win.mk index 35b2270415..94f84ec633 100644 --- a/makefiles/Makefile.third_party.win.mk +++ b/makefiles/Makefile.third_party.win.mk @@ -14,17 +14,17 @@ USE_XPRESS ?= OFF PROTOC = "$(OR_TOOLS_TOP)\\bin\\protoc.exe" # Main target. -dependencies: - mkdir dependencies +$(BUILD_DIR): + mkdir $(BUILD_DIR) .PHONY: third_party # Build OR-Tools Prerequisite -third_party: dependencies/ortools.sln | dependencies +third_party: $(BUILD_DIR)/ortools.sln | $(BUILD_DIR) -THIRD_PARTY_TARGET = dependencies/ortools.sln +THIRD_PARTY_TARGET = $(BUILD_DIR)/ortools.sln GENERATOR ?= $(CMAKE_PLATFORM) -dependencies/ortools.sln: | dependencies - cmake -S . -B dependencies -DBUILD_DEPS=ON \ +$(BUILD_DIR)/ortools.sln: | $(BUILD_DIR) + cmake -S . -B $(BUILD_DIR) -DBUILD_DEPS=ON \ -DBUILD_PYTHON=$(BUILD_PYTHON) \ -DBUILD_JAVA=$(BUILD_JAVA) \ -DBUILD_DOTNET=$(BUILD_DOTNET) \ @@ -39,10 +39,10 @@ dependencies/ortools.sln: | dependencies -DCMAKE_INSTALL_PREFIX=$(OR_ROOT_FULL) \ -G $(GENERATOR) -.PHONY: clean_third_party +.PHONY: clean_third_party # clean everything. clean_third_party: -$(DEL) Makefile.local - -$(DELREC) dependencies\\* + -$(DELREC) $(BUILD_DIR)\\* -$(DELREC) include -$(DELREC) share -$(DELREC) lib\\*.lib diff --git a/makefiles/Makefile.unix.mk b/makefiles/Makefile.unix.mk index 5e939251ed..923217cecc 100644 --- a/makefiles/Makefile.unix.mk +++ b/makefiles/Makefile.unix.mk @@ -6,6 +6,7 @@ LIB_PREFIX = lib DEP_BIN_DIR = $(OR_ROOT)bin # C++ relevant directory +BUILD_DIR = $(OR_ROOT)dependencies INC_DIR = $(OR_ROOT)include SRC_DIR = $(OR_ROOT). GEN_DIR = $(OR_ROOT)ortools/gen diff --git a/makefiles/Makefile.win.mk b/makefiles/Makefile.win.mk index b536b35941..6d5e8fbff5 100644 --- a/makefiles/Makefile.win.mk +++ b/makefiles/Makefile.win.mk @@ -14,6 +14,7 @@ STATIC_LIB_SUFFIX = lib LINK_CMD = lib STATIC_LINK_CMD = lib # C++ relevant directory +BUILD_DIR = $(OR_ROOT)dependencies INC_DIR = $(OR_ROOT)include SRC_DIR = $(OR_ROOT). GEN_DIR = $(OR_ROOT)ortools/gen