[VOL-5222] - Upgrade golang version for VOLTHA jobs
Makefile
--------
o Remove redundant rm -fr java_temp commands, makefile target
java-clean is already setup to remove the temp directory.
o Add flag LOCAL_FIX_PERMS=1 to adjust permissions so make
build, test and lint can be used locally. Not perfect but close
(new files created from docker are still a problem).
makefiles/etc/include.mk
makefiles/etc/features.mk
------------------------
o Copy in banner functions from repo:onf-make.
makefiles/golang/commands.mk
makefiles/golang/include.mk
makefiles/golang/upgrade.mk
----------------------------
o Added target golang-version to display version from docker image.
o Added target golang-upgrade to update min version required by go.mod.
[HOWTO: Test]
-------------
o make help | grep golang
o make help-golang
o make golang-version
o make golang-upgrade # golang-version-upgrade=1.21.5
o make sterile build test LOCAL_FIX_PERMS=1
Change-Id: I4ffe0cd8785769d00d1b0a802fa49aebef3142f7
diff --git a/Makefile b/Makefile
index 7a9991f..e1c4b16 100755
--- a/Makefile
+++ b/Makefile
@@ -101,7 +101,6 @@
clean :: python-clean java-clean go-clean
sterile :: clean
- $(RM) -r java_temp
## -----------------------------------------------------------------------
## Python targets
@@ -253,17 +252,17 @@
java-protos-dirs += java_temp/src/main/java/org/opencord/voltha/adapter_service
mkdir-args += -vp
-# mkdir-args += --mode=0777# # Only a problem for local docker builds
java-protos: voltha.pb
$(call banner-enter,target $@)
-# $(RM) -fr java_temp
mkdir $(mkdir-args) $(java-protos-dirs)
+
$(docker-sh) $(quote-double) find $(java-protos-dirs) -print0 \
| xargs -0 -n1 /bin/ls -ld $(quote-double)
+ $(if $(LOCAL_FIX_PERMS),chmod -R o+w java_temp)
@${PROTOC_SH} $(quote-double) \
set -e -o pipefail; \
for x in ${PROTO_FILES}; do \
@@ -271,6 +270,7 @@
protoc --java_out=java_temp/src/main/java -I protos \$$x; \
done\
$(quote-double)
+ $(if $(LOCAL_FIX_PERMS),chmod -R o-w java_temp)
# Move files into place after all prototypes have generated.
# TODO: Remove the extra step, use makefile deps and
diff --git a/makefiles/etc/features.mk b/makefiles/etc/features.mk
new file mode 100644
index 0000000..b1bf482
--- /dev/null
+++ b/makefiles/etc/features.mk
@@ -0,0 +1,48 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2017-2024 Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-FileCopyrightText: 2017-2024 Open Networking Foundation (ONF) and the ONF Contributors
+# SPDX-License-Identifier: Apache-2.0
+# -----------------------------------------------------------------------
+# Usage:
+#
+# mytarget:
+# $(call banner-enter,target $@)
+# @echo "Hello World"
+# $(call banner-leave,target $@)
+# -----------------------------------------------------------------------
+
+$(if $(DEBUG),$(warning ENTER))
+
+target-banner = ** ---------------------------------------------------------------------------
+
+## -----------------------------------------------------------------------
+## Intent: Return a command line able to display a banner hilighting
+## make target processing within a logfile.
+## -----------------------------------------------------------------------
+banner-enter=\
+ @echo -e \
+ "\n"\
+ "$(target-banner)\n"\
+ "** $(MAKE) ENTER: $(1)\n"\
+ "$(target-banner)"\
+
+banner-leave=\
+ @echo -e "** $(MAKE) LEAVE: $(1)"
+
+$(if $(DEBUG),$(warning LEAVE))
+
+# [EOF]
diff --git a/makefiles/etc/include.mk b/makefiles/etc/include.mk
index 541c1db..24ef929 100644
--- a/makefiles/etc/include.mk
+++ b/makefiles/etc/include.mk
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-# SPDX-FileCopyrightText: 2017-2023 Open Networking Foundation (ONF) and the ONF Contributors
+# SPDX-FileCopyrightText: 2017-2024 Open Networking Foundation (ONF) and the ONF Contributors
# SPDX-License-Identifier: Apache-2.0
# -----------------------------------------------------------------------
# Usage:
@@ -27,21 +27,10 @@
$(if $(DEBUG),$(warning ENTER))
-target-banner = ** ---------------------------------------------------------------------------
-
-## -----------------------------------------------------------------------
-## Intent: Return a command line able to display a banner hilighting
-## make target processing within a logfile.
-## -----------------------------------------------------------------------
-banner-enter=\
- @echo -e \
- "\n"\
- "$(target-banner)\n"\
- "** $(MAKE) ENTER: $(1)\n"\
- "$(target-banner)"\
-
-banner-leave=\
- @echo -e "** $(MAKE) LEAVE: $(1)"
+##--------------------##
+##---] INCLUDES [---##
+##--------------------##
+include $(MAKEDIR)/etc/features.mk
$(if $(DEBUG),$(warning LEAVE))
diff --git a/makefiles/golang/commands.mk b/makefiles/golang/commands.mk
new file mode 100644
index 0000000..28d9a5c
--- /dev/null
+++ b/makefiles/golang/commands.mk
@@ -0,0 +1,28 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2024 Open Networking Foundation (ONF) and the ONF Contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-FileCopyrightText: 2024 Open Networking Foundation (ONF) and the ONF Contributors
+# SPDX-License-Identifier: Apache-2.0
+# -----------------------------------------------------------------------
+
+$(if $(DEBUG),$(warning ENTER))
+
+# Distinguish between local and docker go command
+# GO ?= go
+
+$(if $(DEBUG),$(warning LEAVE))
+
+# [EOF]
diff --git a/makefiles/golang/include.mk b/makefiles/golang/include.mk
new file mode 100644
index 0000000..05c3ee3
--- /dev/null
+++ b/makefiles/golang/include.mk
@@ -0,0 +1,39 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2024 Open Networking Foundation (ONF) and the ONF Contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-FileCopyrightText: 2024 Open Networking Foundation (ONF) and the ONF Contributors
+# SPDX-License-Identifier: Apache-2.0
+# -----------------------------------------------------------------------
+
+$(if $(DEBUG),$(warning ENTER))
+
+help-golang := $(null)
+
+##--------------------##
+##---] INCLUDES [---##
+##--------------------##
+include $(MAKEDIR)/golang/commands.mk
+include $(MAKEDIR)/golang/upgrade.mk
+
+help-golang : $(help-golang)
+
+help ::
+ @printf ' %-33.33s %s\n' 'help-golang' \
+ 'Display available targets for the golang interpreter'
+
+$(if $(DEBUG),$(warning LEAVE))
+
+# [EOF]
diff --git a/makefiles/golang/upgrade.mk b/makefiles/golang/upgrade.mk
new file mode 100644
index 0000000..224998f
--- /dev/null
+++ b/makefiles/golang/upgrade.mk
@@ -0,0 +1,79 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2024 Open Networking Foundation (ONF) and the ONF Contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-FileCopyrightText: 2024 Open Networking Foundation (ONF) and the ONF Contributors
+# SPDX-License-Identifier: Apache-2.0
+# -----------------------------------------------------------------------
+
+$(if $(DEBUG),$(warning ENTER))
+
+##-------------------##
+##---] GLOBALS [---##
+##-------------------###
+# repo:voltha-protos v1.16.3
+# [VOL-5222] v1.21.5
+golang-version-upgrade ?= \
+ $(error $(MAKE) $@: golang-version-upgrade= is required)
+
+## -----------------------------------------------------------------------
+## Intent: Display version of the golang interpreter.
+## -----------------------------------------------------------------------
+## Note:
+## - Two versions are available:
+## - The first is installed on the local system
+## - The second is installed and access through a docker image.
+## -----------------------------------------------------------------------
+.PHONY: golang-version golang-version-help
+golang-version:
+
+ $(call banner-enter,$@)
+ ${GO} version
+ $(call banner-leave,$@)
+
+help-golang += golang-version-help
+golang-version-help:
+ @printf ' %-33.33s %s\n' "$@" \
+ 'Display golang interpreter version'
+
+## -----------------------------------------------------------------------
+## Intent: Update intrepter version to install (go.mod)
+## -----------------------------------------------------------------------
+.PHONY: golang-upgrade golang-upgrade-help
+golang-upgrade:
+
+ # Access early to avoid error manifestation in docker
+ @assigned_for_side_effects="$(golang-version-upgrade)"
+
+ $(call banner-enter,$@)
+
+ ${GO} mod edit -go $(golang-version-upgrade)
+ ${GO} version
+
+ $(GO) mod edit -go $(golang-version-upgrade)
+ $(GO) version
+
+ $(call banner-leave,$@)
+
+help-golang += golang-upgrade-help
+golang-upgrade-help:
+ @printf ' %-33.33s %s\n' "$@" \
+ 'Upgrade installed version of the golang interpreter (go.mod)'
+
+help-golang : $(help-golang)
+
+$(if $(DEBUG),$(warning LEAVE))
+
+# [EOF]
diff --git a/makefiles/include.mk b/makefiles/include.mk
index fef212c..ecf52d5 100644
--- a/makefiles/include.mk
+++ b/makefiles/include.mk
@@ -38,6 +38,8 @@
include $(MAKEDIR)/etc/include.mk
include $(MAKEDIR)/virtualenv.mk
+include $(MAKEDIR)/golang/include.mk
+
include $(MAKEDIR)/help/variables.mk
include $(MAKEDIR)/lint/include.mk
include $(MAKEDIR)/todo.mk