Skip to content

Commit

Permalink
Import onf-make
Browse files Browse the repository at this point in the history
  • Loading branch information
joey-onf committed Sep 8, 2023
1 parent f48ab40 commit 24e0785
Show file tree
Hide file tree
Showing 9 changed files with 318 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "release/validate/makefiles/onf-lib"]
path = release/validate/makefiles/onf-lib
url = https://github.com/opencord/onf-make.git
150 changes: 150 additions & 0 deletions release/validate/config.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
# -*- makefile -*-
# -----------------------------------------------------------------------
# Copyright 2023 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.
# -----------------------------------------------------------------------
# https://gerrit.opencord.org/plugins/gitiles/onf-make
# ONF.makefiles.include.version = 1.1
# ONF.confg.mk = 1.5
# -----------------------------------------------------------------------

--repo-name-- := onf/validate # repo:onf/validate
--repo-name-- ?= $(error --repo-name--= is required)

##--------------------------------##
##---] Disable lint targets [---##
##--------------------------------##
# NO-LINT-DOC8 := true
# NO-LINT-GOLANG := true
# NO-LINT-GROOVY := true# # Note[1]
NO-LINT-JJB := true# # Note[2]
NO-LINT-JSON := true# # Note[1]
NO-LINT-MAKEFILE := true# # Note[1]
NO-LINT-REUSE := true # License check
NO-LINT-ROBOT := true
NO-LINT-SHELL := true# # Note[1]
NO-LINT-TOX := true# # Note[1]
NO-LINT-YAML := true# # Note[1]

NO-LINT-FLAKE8 := true# # Note[1]
NO-LINT-PYTHON := true# # Note[1]
NO-LINT-PYLINT := true# # Note[1]

# Note[1] - A boatload of source to cleanup prior to enable.
# Note[2] - No sources available

##---------------------------------##
##---] Conditional make logic [---##
##---------------------------------##
# USE-ONF-DOCKER-MK := true
# USE-ONF-GERRIT-MK := true
# USE-ONF-GIT-MK := true
# USE-ONF-JJB-MK := true
# USE-VOLTHA-RELEASE-MK := true

##----------------------##
##---] Debug Mode [---##
##----------------------##
# export DEBUG := 1 # makefile debug
# export DISTUTILS_DEBUG := 1 # verbose: pip
# export DOCKER_DEBUG := 1 # verbose: docker
# export VERBOSE := 1 # makefile debug

##-----------------------------------##
##---] JJB/Jenkins Job Builder [---##
##-----------------------------------##
JJB_VERSION ?= 2.8.0
JOBCONFIG_DIR ?= job-configs

##---------------------------------##
##---] Filesystem exclusions [---##
##---------------------------------##
onf-excl-dirs := $(null) # make clean: dirs=
onf-excl-dirs += .venv# # $(venv-name)
onf-excl-dirs += vendor# # golang / voltha*-go
onf-excl-dirs += patches# # voltha docs - python upgrade
onf-excl-dirs += .tox # also a python dependency

ifeq ($(--repo-name--),voltha-docs)
lint-doc8-excl += '_build'
endif

onf-excl-dirs ?= $(error onf-excl-dirs= is required)

##-----------------------------##
##---] Feature Detection [---##
##-----------------------------##
# [TODO] include makefiles/features/include.mk
# [TODO] All logic below can migrate there.

$(if $(filter %ci-management,$(--repo-name--)),\
$(eval --REPO-IS-CI-MANAGEMENT-- := true)\
)
$(if $(filter %voltha-docs,$(--repo-name--)),\
$(eval --REPO-IS-VOLTHA-DOCS-- := true)\
)

# create makefiles/config/byrepo/{--repo-name--}.mk for one-off snowflakes ?
# $(if $(wildcard docker),$(eval USE-ONF-DOCKER-MK := true))

##-------------------------##
##---] Derived Flags [---##
##-------------------------##
ifdef --REPO-IS-CI-MANAGEMENT--
USE-ONF-JJB := true

onf-excl-dirs += global-jjb
onf-excl-dirs += lf-ansible
onf-excl-dirs += packer
endif

ifdef --REPO-IS-VOLTHA-DOCS--
onf-excl-dirs += _build
onf-excl-dirs += repos
endif

ifdef NO-LINT-PYTHON
NO-LINT-FLAKE8 := true
NO-LINT-PYLINT := true
endif

ifndef USE-ONF-JJB
NO-LINT-JJB := true
endif

onf-excl-dirs := $(sort $(strip $(onf-excl-dirs)))

# --------------------------------------------------------------------
# Repository specific values
# --------------------------------------------------------------------
# sterile-dirs += archives

# submodules
# sterile-dirs += global-jjb
# sterile-dirs += lf-ansible
# sterile-dirs += packer

# [TODO]#
# --------------------------------------------------------------------
# o two distinct makefiles/ directories are needed, one for onf-make
# o second for repository specific makefile configs and logic.
# o Two independent vars specify path:
# ONF_MAKEDIR = library makefiles
# MAKEDIR = repository specific content
# o Conditional repository testing above can crush down all the
# "if-this-repository-is-X-do-Y' logic above intoL
# include $(MAKEDIR)/config.mk # repo:$(--repo-name--)
# --------------------------------------------------------------------

# [EOF]
14 changes: 7 additions & 7 deletions release/validate/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@

.DEFAULT_GOAL := args

null :=#
space :=$(null) $(null)

TOP ?= .
MAKEDIR ?= $(TOP)/makefiles
ONF_MAKE ?= $(TOP)/makefiles
TOP ?= .
include $(TOP)/config.mk
include $(TOP)/makefiles/include.mk

PYTHON ?= $(HOME)/.venv/3.10.6/bin/python

Expand Down Expand Up @@ -65,7 +62,7 @@ main-help:
## -----------------------------------------------------------------------
## -----------------------------------------------------------------------
.PHONY: todo
todo:
todo ::
$(main) --$@ stub-required-arg

## -----------------------------------------------------------------------
Expand Down Expand Up @@ -99,4 +96,7 @@ help ::
@echo
@echo "[EOF]"

# submodules:
# git submodule add https://github.com/opencord/onf-make.git
# ssh://[email protected]@gerrit.opencord.org:29418/onf-make
# [EOF]
1 change: 1 addition & 0 deletions release/validate/makefiles/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
onf-lib
56 changes: 56 additions & 0 deletions release/validate/makefiles/include.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# -*- makefile -*-
# -----------------------------------------------------------------------
# Copyright 2023 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: 2023 Open Networking Foundation (ONF) and the ONF Contributors
# SPDX-License-Identifier: Apache-2.0
# -----------------------------------------------------------------------
# https://gerrit.opencord.org/plugins/gitiles/onf-make
# ONF.makefile.version = 1.0
# -----------------------------------------------------------------------

$(if $(DEBUG),$(warning ENTER))

## -----------------------------------------------------------------------
## Define vars based on relative import (normalize symlinks)
## Usage: include makefiles/onf/include.mk
## -----------------------------------------------------------------------
onf-mk-abs ?= $(abspath $(lastword $(MAKEFILE_LIST)))
onf-mk-top := $(subst /include.mk,$(null),$(onf-mk-abs))
onf-mk-lib := $(onf-mk-top)/onf-lib/makefiles
onf-mk-loc := $(onf-mk-top)/local

TOP ?= $(patsubst %/makefiles/include.mk,%,$(onf-mk-abs))

## ------------------------------------------------------
## Two distinct vars needed to access library or project
## ------------------------------------------------------
ONF_MAKEDIR ?= $(onf-mk-lib)
MAKEDIR ?= $(onf-mk-loc)

## -----------------------------------------------------------------------
## Load makefiles in order:
## 1) Library constants and logic loaded first
## 2) Parameterize and augment targets from local (repo specific)
## -----------------------------------------------------------------------
include $(onf-mk-lib)/include.mk
include $(onf-mk-loc)/include.mk

update-submodules:
git submodule foreach git pull

$(if $(DEBUG),$(warning LEAVE))

# [EOF]
Empty file.
27 changes: 27 additions & 0 deletions release/validate/makefiles/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# -*- makefile -*-
# -----------------------------------------------------------------------
# -----------------------------------------------------------------------

all: onf-lib local

## -----------------------------------------------------------------------
## -----------------------------------------------------------------------
repo-onf-make := https://github.com/opencord/onf-make.git
onf-lib:
git submodule add $(repo-onf-make) $@

## -----------------------------------------------------------------------
## -----------------------------------------------------------------------
local:
mkdir -p $@
umask 022 && chmod 755
git add $@

# local:

## -----------------------------------------------------------------------
## -----------------------------------------------------------------------
# sterile ::
# git rm -f onf

# [EOF]
73 changes: 73 additions & 0 deletions release/validate/makefiles/makefiles_include_mk.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# -*- makefile -*-
# -----------------------------------------------------------------------
# Copyright 2023 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: 2023 Open Networking Foundation (ONF) and the ONF Contributors
# SPDX-License-Identifier: Apache-2.0
# -----------------------------------------------------------------------
# https://gerrit.opencord.org/plugins/gitiles/onf-make
# ONF.makefile.version = 1.0
# -----------------------------------------------------------------------
# Setup:
# 1) Makefile
# include config.mk
# include makefiles/include.mk
# 2) cd makefiles
# 23 copy makefiles_include_mk.ex into $repo/makefiles/include.mk
# 4) make create-onf-lib
# -----------------------------------------------------------------------

$(if $(DEBUG),$(warning ENTER))

## -----------------------------------------------------------------------
## Define vars based on relative import (normalize symlinks)
## Usage: include makefiles/onf/include.mk
## -----------------------------------------------------------------------
onf-mk-abs ?= $(abspath $(lastword $(MAKEFILE_LIST)))
onf-mk-top := $(subst /include.mk,$(null),$(onf-mk-abs))
onf-mk-lib := $(onf-mk-top)/onf-lib/makefiles
onf-mk-loc := $(onf-mk-top)/local

TOP ?= $(patsubst %/makefiles/include.mk,%,$(onf-mk-abs))

## ------------------------------------------------------
## Two distinct vars needed to access library or project
## ------------------------------------------------------
ONF_MAKEDIR ?= $(onf-mk-lib)
MAKEDIR ?= $(onf-mk-loc)

## -----------------------------------------------------------------------
## Load makefiles in order:
## 1) Library constants and logic loaded first
## 2) Parameterize and augment targets from local (repo specific)
## -----------------------------------------------------------------------
include $(onf-mk-lib)/include.mk
include $(onf-mk-loc)/include.mk

## -----------------------------------------
## Submodue init target for new repositories
## -----------------------------------------
create-onf-lib : $(onf-mk-lib)
$(onf-mk-lib):
mkdir -p $(dir $@)# makefiles
cd $(dir $@) \
&& git submodule https://github.com/opencord/onf-make.git onf-lib

update-submodules:
git submodule foreach git pull

$(if $(DEBUG),$(warning LEAVE))

# [EOF]
1 change: 1 addition & 0 deletions release/validate/makefiles/onf-lib
Submodule onf-lib added at f548ad

0 comments on commit 24e0785

Please sign in to comment.