diff --git a/init.mk b/init.mk new file mode 100644 index 00000000..78f9e583 --- /dev/null +++ b/init.mk @@ -0,0 +1,89 @@ +################################################################ +# +# Copyright 2013, Big Switch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.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.eclipse.org/legal/epl-v10.html +# +# 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. +# +################################################################ + +# +# The root of of our repository is here: +# +ROOT := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))) + +# +# Resolve submodule dependencies. +# +ifndef SUBMODULE_INFRA + ifdef SUBMODULES + SUBMODULE_INFRA := $(SUBMODULES)/infra + else + SUBMODULE_INFRA := $(ROOT)/submodules/infra + SUBMODULES_LOCAL += infra + endif +endif + +ifndef SUBMODULE_BIGCODE + ifdef SUBMODULES + SUBMODULE_BIGCODE := $(SUBMODULES)/bigcode + else + SUBMODULE_BIGCODE := $(ROOT)/submodules/bigcode + SUBMODULES_LOCAL += bigcode + endif +endif + +ifndef SUBMODULE_INDIGO + ifdef SUBMODULES + SUBMODULE_INDIGO := $(SUBMODULES)/indigo + else + SUBMODULE_INDIGO := $(ROOT)/submodules/indigo + SUBMODULES_LOCAL += indigo + endif +endif + +ifndef SUBMODULE_LUAJIT2 + ifdef SUBMODULES + SUBMODULE_LUAJIT2 := $(SUBMODULES)/luajit-2.0 + else + SUBMODULE_LUAJIT2 := $(ROOT)/submodules/luajit-2.0 + SUBMODULES_LOCAL += luajit2 + endif +endif + +ifdef SUBMODULES_LOCAL + SUBMODULES_LOCAL_UPDATE := $(shell python $(ROOT)/submodules/init.py --update $(SUBMODULES_LOCAL)) + ifneq ($(lastword $(SUBMODULES_LOCAL_UPDATE)),submodules:ok.) + $(info Local submodule update failed.) + $(info Result:) + $(info $(SUBMODULES_LOCAL_UPDATE)) + $(error Abort) + endif +endif + +export SUBMODULE_INFRA +export SUBMODULE_BIGCODE +export SUBMODULE_INDIGO +export SUBMODULE_LUAJIT2 +export BUILDER := $(SUBMODULE_INFRA)/builder/unix + +MODULE_DIRS := $(ROOT)/Modules \ + $(SUBMODULE_INFRA)/modules \ + $(SUBMODULE_BIGCODE)/modules \ + $(SUBMODULE_INDIGO)/modules + +.show-submodules: + @echo infra @ $(SUBMODULE_INFRA) + @echo bigcode @ $(SUBMODULE_BIGCODE) + @echo indigo @ $(SUBMODULE_INDIGO) + @echo luajit2 @ $(SUBMODULE_LUAJIT2) diff --git a/submodules/init.py b/submodules/init.py new file mode 100644 index 00000000..04de4860 --- /dev/null +++ b/submodules/init.py @@ -0,0 +1,85 @@ +#!/usr/bin/python +################################################################ +# +# Copyright 2013, Big Switch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.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.eclipse.org/legal/epl-v10.html +# +# 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. +# +################################################################ + +################################################################ +# +# This script updates all local submodules if they haven't +# been initialized. +# +################################################################ +import os +import sys +import subprocess +import argparse + +ap = argparse.ArgumentParser(description="Submodule Management.") + +# +# The root of the repository. +# We assume by default that this script resides in +# the $(ROOT)/submodules directory. +# +root_default = os.path.abspath("%s/../" % os.path.dirname(__file__)) + +ap.add_argument("--root", help="The root of the respository.", + default=root_default) + +ap.add_argument("--update", help="Update the named submodules.", + nargs='+', default=None, metavar='SUBMODULE') + +ap.add_argument("--list", help="List all submodules.", + action='store_true') + +ops = ap.parse_args(); + +# Move to the root of the repository +os.chdir(ops.root) + +# Get the status of all submodules +submodule_status = {} +try: + for entry in subprocess.check_output(['git', 'submodule', 'status']).split("\n"): + data = entry.split() + if len(data) >= 2: + submodule_status[data[1].replace("submodules/", "")] = data[0] +except Exception as e: + print repr(e) + raise + +if ops.list: + for (module, status) in submodule_status.iteritems(): + print module + +if ops.update: + for (module, status) in submodule_status.iteritems(): + if module in ops.update or "all" in ops.update: + if status[0] == '-': + # This submodule has not yet been updated + print "Updating submodule %s" % module + if subprocess.check_call(['git', 'submodule', 'update', '--init', 'submodules/%s' % module]) != 0: + print "git error updating module '%s'." % (module, switchlight_root, module) + sys.exit(1) + else: + print "Submodule %s is already checked out." % module + print "submodules:ok." + + + + diff --git a/targets/flowtable-benchmark/Makefile b/targets/flowtable-benchmark/Makefile index f8f888db..c518bbfb 100644 --- a/targets/flowtable-benchmark/Makefile +++ b/targets/flowtable-benchmark/Makefile @@ -16,38 +16,13 @@ # License. # ################################################################ - -ifndef ROOT -ROOT := $(dir $(lastword $(MAKEFILE_LIST)))/../.. -endif - -ifndef INFRA -INFRA := $(ROOT)/submodules/infra -endif - -ifndef BIGCODE -BIGCODE := $(ROOT)/submodules/bigcode -endif - -ifndef INDIGO -INDIGO := $(ROOT)/submodules/indigo -endif - -ifndef BUILDER -BUILDER := $(INFRA)/builder/unix -endif - -ifndef BUILD_DIR -export BUILD_DIR := ./build -endif +include ../../init.mk ALLOW_DECLARATION_AFTER_STATEMENT = 1 MODULE := flowtable_benchmark include $(BUILDER)/standardinit.mk -MODULE_DIRS := $(INDIGO)/modules $(INFRA)/modules $(BIGCODE)/modules $(ROOT)/Modules - LIBRARY := flowtable_benchmark_main $(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) include $(BUILDER)/lib.mk diff --git a/targets/ivs-ctl/Makefile b/targets/ivs-ctl/Makefile index 13b8fee2..46c627cd 100644 --- a/targets/ivs-ctl/Makefile +++ b/targets/ivs-ctl/Makefile @@ -16,36 +16,17 @@ # License. # ################################################################ - -ifndef ROOT -ROOT := $(dir $(lastword $(MAKEFILE_LIST)))/../.. -endif - -ifndef INFRA -INFRA := $(ROOT)/submodules/infra -endif - -ifndef BUILDER -BUILDER := $(INFRA)/builder/unix -endif - -ifndef BUILD_DIR -export BUILD_DIR := ./build -endif +include ../../init.mk ALLOW_DECLARATION_AFTER_STATEMENT = 1 MODULE := IVSCtl include $(BUILDER)/standardinit.mk -MODULE_DIRS := $(INDIGO)/Modules $(ROOT)/Modules - LIBRARY := IVSCtlMain $(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) include $(BUILDER)/lib.mk -MODULEMANIFEST := $(INDIGO)/Modules/Manifest.mk - DEPENDMODULES := include $(BUILDER)/dependmodules.mk diff --git a/targets/ivs/Makefile b/targets/ivs/Makefile index 5f978fc6..60fb96a7 100644 --- a/targets/ivs/Makefile +++ b/targets/ivs/Makefile @@ -16,43 +16,7 @@ # License. # ################################################################ - -############################################################################### -# -# Makefile -# -# ivs -# -############################################################################### - -# Not needed by the build system directly, but necessary for some -# of the variables we are going to set -ifndef ROOT -ROOT := $(dir $(lastword $(MAKEFILE_LIST)))/../.. -endif - -ifndef INFRA -INFRA := $(ROOT)/submodules/infra -endif - -ifndef INDIGO -INDIGO := $(ROOT)/submodules/indigo -endif - -ifndef BIGCODE -BIGCODE := $(ROOT)/submodules/bigcode -endif - -ifndef BUILDER -BUILDER := $(INFRA)/builder/unix -endif - -# -# Default to a local build directory for everything -# -ifndef BUILD_DIR -export BUILD_DIR := ./build -endif +include ../../init.mk ALLOW_DECLARATION_AFTER_STATEMENT = 1 @@ -64,8 +28,6 @@ ALLOW_DECLARATION_AFTER_STATEMENT = 1 MODULE := IVS include $(BUILDER)/standardinit.mk -MODULE_DIRS := $(INDIGO)/modules $(INFRA)/modules $(BIGCODE)/modules $(ROOT)/Modules - # # We're now ready to specify the "stuff" we want built. # @@ -75,20 +37,6 @@ LIBRARY := IVSMain $(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) include $(BUILDER)/lib.mk -# -# Our binary is going to depend upon BigCode modules. -# -# The Manifest.mk for BigCode, which describes the locations -# of all of the available modules, is in $INDIGO/Modules/Manifest.mk -# -# The settings in the Manifest.mk file will provide the information -# necessary to build the modules on which this binary will depend. -# -# All you have to do is point to the Manifest.mk, -# specify which Modules you want built, and include dependmodules.mk: -# -MODULEMANIFEST := $(INDIGO)/modules/Manifest.mk $(INFRA)/modules/Manifest.mk - # # Set the modules we want to automatically build for this binary # diff --git a/targets/l2table-benchmark/Makefile b/targets/l2table-benchmark/Makefile index 35435833..e32426f6 100644 --- a/targets/l2table-benchmark/Makefile +++ b/targets/l2table-benchmark/Makefile @@ -16,38 +16,13 @@ # License. # ################################################################ - -ifndef ROOT -ROOT := $(dir $(lastword $(MAKEFILE_LIST)))/../.. -endif - -ifndef INFRA -INFRA := $(ROOT)/submodules/infra -endif - -ifndef BIGCODE -BIGCODE := $(ROOT)/submodules/bigcode -endif - -ifndef INDIGO -INDIGO := $(ROOT)/submodules/indigo -endif - -ifndef BUILDER -BUILDER := $(INFRA)/builder/unix -endif - -ifndef BUILD_DIR -export BUILD_DIR := ./build -endif +include ../../init.mk ALLOW_DECLARATION_AFTER_STATEMENT = 1 MODULE := l2table_benchmark include $(BUILDER)/standardinit.mk -MODULE_DIRS := $(INDIGO)/modules $(INFRA)/modules $(BIGCODE)/modules $(ROOT)/Modules - LIBRARY := l2table_benchmark_main $(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) include $(BUILDER)/lib.mk diff --git a/targets/upcall-latency-benchmark/Makefile b/targets/upcall-latency-benchmark/Makefile index 3688fc16..d4c3ca3b 100644 --- a/targets/upcall-latency-benchmark/Makefile +++ b/targets/upcall-latency-benchmark/Makefile @@ -16,38 +16,13 @@ # License. # ################################################################ - -ifndef ROOT -ROOT := $(dir $(lastword $(MAKEFILE_LIST)))/../.. -endif - -ifndef INFRA -INFRA := $(ROOT)/submodules/infra -endif - -ifndef BIGCODE -BIGCODE := $(ROOT)/submodules/bigcode -endif - -ifndef INDIGO -INDIGO := $(ROOT)/submodules/indigo -endif - -ifndef BUILDER -BUILDER := $(INFRA)/builder/unix -endif - -ifndef BUILD_DIR -export BUILD_DIR := ./build -endif +include ../../init.mk ALLOW_DECLARATION_AFTER_STATEMENT = 1 MODULE := upcall_latency_benchmark include $(BUILDER)/standardinit.mk -MODULE_DIRS := $(INDIGO)/modules $(INFRA)/modules $(BIGCODE)/modules $(ROOT)/Modules - LIBRARY := upcall_latency_benchmark_main $(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) include $(BUILDER)/lib.mk diff --git a/targets/upcall-throughput-benchmark/Makefile b/targets/upcall-throughput-benchmark/Makefile index 5862bd29..b306636d 100644 --- a/targets/upcall-throughput-benchmark/Makefile +++ b/targets/upcall-throughput-benchmark/Makefile @@ -16,38 +16,13 @@ # License. # ################################################################ - -ifndef ROOT -ROOT := $(dir $(lastword $(MAKEFILE_LIST)))/../.. -endif - -ifndef INFRA -INFRA := $(ROOT)/submodules/infra -endif - -ifndef BIGCODE -BIGCODE := $(ROOT)/submodules/bigcode -endif - -ifndef INDIGO -INDIGO := $(ROOT)/submodules/indigo -endif - -ifndef BUILDER -BUILDER := $(INFRA)/builder/unix -endif - -ifndef BUILD_DIR -export BUILD_DIR := ./build -endif +include ../../init.mk ALLOW_DECLARATION_AFTER_STATEMENT = 1 MODULE := upcall_throughput_benchmark include $(BUILDER)/standardinit.mk -MODULE_DIRS := $(INDIGO)/modules $(INFRA)/modules $(BIGCODE)/modules $(ROOT)/Modules - LIBRARY := upcall_throughput_benchmark_main $(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) include $(BUILDER)/lib.mk diff --git a/targets/utests/make/common.mk b/targets/utests/make/common.mk deleted file mode 100644 index dc4c0a5d..00000000 --- a/targets/utests/make/common.mk +++ /dev/null @@ -1,65 +0,0 @@ -################################################################ -# -# Copyright 2013, Big Switch Networks, Inc. -# -# Licensed under the Eclipse Public License, Version 1.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.eclipse.org/legal/epl-v10.html -# -# 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. -# -################################################################ - -############################################################################### -# -# BigCode Unit Tests -# -# Common Make and build settings for all unit tests. -# -############################################################################### -ifndef MODULE -$(error Need to define $$MODULE) -endif - -ifndef ROOT -ROOT := $(dir $(lastword $(MAKEFILE_LIST)))/../../.. -endif - -ifndef INFRA -INFRA := $(ROOT)/submodules/infra -endif - -ifndef BIGCODE -BIGCODE := $(ROOT)/submodules/bigcode -endif - -ifndef INDIGO -INDIGO := $(ROOT)/submodules/indigo -endif - -ifndef BUILDER -BUILDER := $(INFRA)/builder/unix -endif - -# -# Default to Builder in BigCode -# -ifndef BUILDER -export BUILDER := $(INDIGO)/Builder/unix -endif - -# -# Default to local build directory -# -ifndef BUILD_DIR -export BUILD_DIR := ./build -endif - -GLOBAL_CFLAGS += -DOF_WIRE_BUFFER_DEBUG diff --git a/targets/utests/make/utestmodule.mk b/targets/utests/make/utestmodule.mk index 24570f44..dd570a77 100644 --- a/targets/utests/make/utestmodule.mk +++ b/targets/utests/make/utestmodule.mk @@ -24,9 +24,9 @@ ############################################################################### UCODE_MAKE := $(dir $(lastword $(MAKEFILE_LIST))) -DEBUG := 1 +include ../../../init.mk -include $(UCODE_MAKE)/common.mk +DEBUG := 1 .DEFAULT_GOAL := tests @@ -37,7 +37,9 @@ ifndef TEST_MODULE $(error $$(TEST_MODULE) is not defined. Please define relative to BigCode) endif -MODULE_DIRS := $(INDIGO)/modules $(INFRA)/modules $(BIGCODE)/modules $(ROOT)/Modules +ifndef MODULE +$(error Need to define $$MODULE) +endif # At the very least we need the test module DEPENDMODULES += $(TEST_MODULE) @@ -54,6 +56,8 @@ ifdef VALGRIND HARNESS:=valgrind --leak-check=full --show-reachable=yes --suppressions=$(INDIGO)/Tools/valgrind.suppressions endif +GLOBAL_CFLAGS += -DOF_WIRE_BUFFER_DEBUG + # By Convention ifdef $(TEST_MODULE)UtestBinary