[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/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]