Skip to content
Snippets Groups Projects
Commit ef548df9 authored by Chris Cooper's avatar Chris Cooper
Browse files

Merge build-system to mozilla-central

parents c8590c4f 15ddc7ae
No related branches found
No related tags found
No related merge requests found
Showing
with 2750 additions and 109 deletions
#! /bin/sh
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (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.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1999
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
# allmakefiles.sh - List of all makefiles.
# Appends the list of makefiles to the variable, MAKEFILES.
......@@ -67,7 +35,6 @@ config/autoconf.mk
config/nspr/Makefile
config/doxygen.cfg
config/expandlibs_config.py
config/tests/src-simple/Makefile
mfbt/Makefile
probes/Makefile
extensions/Makefile
......@@ -140,6 +107,9 @@ fi
if [ "$ENABLE_TESTS" ]; then
add_makefiles "
build/autoconf/test/Makefile
config/makefiles/test/Makefile
config/tests/makefiles/autodeps/Makefile
config/tests/src-simple/Makefile
"
if [ ! "$LIBXUL_SDK" ]; then
add_makefiles "
......
......@@ -127,10 +127,14 @@ else
APPFILES = MacOS
endif
libs repackage::
mkdir -p $(DIST)/$(APP_NAME).app/Contents/MacOS
libs-preqs = \
$(call mkdir_deps,$(DIST)/$(APP_NAME).app/Contents/MacOS) \
$(call mkdir_deps,$(DIST)/$(APP_NAME).app/Contents/Resources/$(AB).lproj) \
$(NULL)
.PHONY: repackage
libs repackage:: $(libs-preqs)
rsync -a --exclude "*.in" $(srcdir)/macbuild/Contents $(DIST)/$(APP_NAME).app --exclude English.lproj
mkdir -p $(DIST)/$(APP_NAME).app/Contents/Resources/$(AB).lproj
rsync -a --exclude "*.in" $(srcdir)/macbuild/Contents/Resources/English.lproj/ $(DIST)/$(APP_NAME).app/Contents/Resources/$(AB).lproj
sed -e "s/%MOZ_APP_VERSION%/$(MOZ_APP_VERSION)/" -e "s/%MOZ_APP_NAME%/$(MOZ_APP_NAME)/" -e "s/%APP_VERSION%/$(APP_VERSION)/" -e "s/%APP_NAME%/$(APP_NAME)/" -e "s/%APP_BINARY%/$(APP_BINARY)/" $(srcdir)/macbuild/Contents/Info.plist.in > $(DIST)/$(APP_NAME).app/Contents/Info.plist
sed -e "s/%APP_VERSION%/$(APP_VERSION)/" -e "s/%APP_NAME%/$(APP_NAME)/" $(srcdir)/macbuild/Contents/Resources/English.lproj/InfoPlist.strings.in | iconv -f UTF-8 -t UTF-16 > $(DIST)/$(APP_NAME).app/Contents/Resources/$(AB).lproj/InfoPlist.strings
......@@ -140,7 +144,7 @@ ifdef LIBXUL_SDK
cp $(LIBXUL_DIST)/bin/xulrunner$(BIN_SUFFIX) $(DIST)/$(APP_NAME).app/Contents/MacOS/$(APP_BINARY)
rsync -a --exclude nsinstall --copy-unsafe-links $(LIBXUL_DIST)/XUL.framework $(DIST)/$(APP_NAME).app/Contents/Frameworks
else
rm -f $(DIST)/$(APP_NAME).app/Contents/MacOS/$(PROGRAM)
$(RM) $(DIST)/$(APP_NAME).app/Contents/MacOS/$(PROGRAM)
rsync -aL $(PROGRAM) $(DIST)/$(APP_NAME).app/Contents/MacOS
endif
printf "APPLMOZB" > $(DIST)/$(APP_NAME).app/Contents/PkgInfo
......
......@@ -35,10 +35,10 @@
#
# ***** END LICENSE BLOCK *****
DEPTH = ../..
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
......@@ -102,8 +102,11 @@ REDIST_FILES = \
endif
ifdef REDIST_FILES
libs::
mkdir -p $(FINAL_TARGET)
libs-preqs = \
$(call mkdir_deps,$(FINAL_TARGET)) \
$(NULL)
libs:: $(libs-preqs)
install --preserve-timestamps $(foreach f,$(REDIST_FILES),"$(WIN32_REDIST_DIR)"/$(f)) $(FINAL_TARGET)
endif
......
......@@ -101,7 +101,6 @@ ifeq (,$(strip $(AUTOCONF)))
AUTOCONF=$(error Could not find autoconf 2.13)
endif
MKDIR := mkdir
SH := /bin/sh
PERL ?= perl
PYTHON ?= python
......@@ -181,6 +180,9 @@ OBJDIR_TARGETS = install export libs clean realclean distclean alldep maybe_clob
build::
$(MAKE) -f $(TOPSRCDIR)/client.mk $(if $(MOZ_PGO),profiledbuild,realbuild)
# Define mkdir
include $(TOPSRCDIR)/config/makefiles/makeutils.mk
include $(TOPSRCDIR)/config/makefiles/autotargets.mk
# Print out any options loaded from mozconfig.
all realbuild clean depend distclean export libs install realclean::
......@@ -316,11 +318,13 @@ endif
configure-files: $(CONFIGURES)
configure:: configure-files
ifdef MOZ_BUILD_PROJECTS
@if test ! -d $(MOZ_OBJDIR); then $(MKDIR) $(MOZ_OBJDIR); else true; fi
endif
@if test ! -d $(OBJDIR); then $(MKDIR) $(OBJDIR); else true; fi
configure-preqs = \
configure-files \
$(call mkdir_deps,$(OBJDIR)) \
$(if $(MOZ_BUILD_PROJECTS),$(call mkdir_deps,$(MOZ_OBJDIR))) \
$(NULL)
configure:: $(configure-preqs)
@echo cd $(OBJDIR);
@echo $(CONFIGURE) $(CONFIGURE_ARGS)
@cd $(OBJDIR) && $(BUILD_PROJECT_ARG) $(CONFIGURE_ENV_ARGS) $(CONFIGURE) $(CONFIGURE_ARGS) \
......
# -*- Makefile -*-
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
......@@ -117,8 +118,11 @@ else
endif
ifdef WRAP_SYSTEM_INCLUDES
export::
if test ! -d system_wrappers; then mkdir system_wrappers; fi
export-preqs = \
$(call mkdir_deps,system_wrappers) \
$(NULL)
export:: $(export-preqs)
$(PYTHON) $(topsrcdir)/config/Preprocessor.py $(DEFINES) $(ACDEFINES) \
-DMOZ_TREE_CAIRO=$(MOZ_TREE_CAIRO) \
-DMOZ_TREE_PIXMAN=$(MOZ_TREE_PIXMAN) \
......@@ -190,7 +194,13 @@ PYUNITS := \
unit-writemozinfo.py \
$(NULL)
check:: check-python-modules check-jar-mn
check-preqs = \
check-python-modules \
check-jar-mn \
check-makefiles \
$(NULL)
check:: $(check-preqs)
check-python-modules::
@$(EXIT_ON_ERROR) \
......@@ -205,3 +215,6 @@ check-jar-mn::
ifneq (,$(filter-out WINNT OS2,$(OS_ARCH)))
$(MAKE) -C tests/src-simple check-symlink
endif
check-makefiles:
$(MAKE) -C tests/makefiles/autodeps check
......@@ -46,7 +46,7 @@
# Define an include-at-most-once flag
ifdef INCLUDED_CONFIG_MK
$(error Don't include config.mk twice!)
$(error Do not include config.mk twice!)
endif
INCLUDED_CONFIG_MK = 1
......
# -*- makefile -*-
# vim:set ts=8 sw=8 sts=8 noet:
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
#
###########################################################################
# AUTO_DEPS - A list of deps/targets drived from other macros.
# *_DEPS - Make dependencies derived from a given macro.
###########################################################################
MKDIR ?= mkdir -p
TOUCH ?= touch
###########################################################################
# Threadsafe directory creation
# GENERATED_DIRS - Automated creation of these directories.
###########################################################################
mkdir_deps =$(foreach dir,$(getargv),$(dir)/.mkdir.done)
ifneq (,$(GENERATED_DIRS))
tmpauto :=$(call mkdir_deps,GENERATED_DIRS)
GENERATED_DIRS_DEPS +=$(tmpauto)
GARBAGE_DIRS +=$(tmpauto)
endif
%/.mkdir.done:
$(subst $(SPACE)-p,$(null),$(MKDIR)) -p $(dir $@)
@$(TOUCH) $@
#################################################################
# One ring/dep to rule them all:
# config/rules.mk::all target is available by default
# Add $(AUTO_DEPS) as an explicit target dependency when needed.
#################################################################
AUTO_DEPS +=$(GENERATED_DIRS_DEPS)
# Complain loudly if deps have not loaded so getargv != $(NULL)
ifndef getargv
$(error config/makefiles/makeutil.mk has not been included)
endif
# -*- makefile -*-
# vim:set ts=8 sw=8 sts=8 noet:
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
# Usage: $(call banner,foo bar tans)
banner =\
$(info )\
$(info ***************************************************************************)\
$(info ** BANNER: $(1) $(2) $(3) $(4) $(5) $(6) $(7) $(8) $(9))\
$(info ***************************************************************************)\
## Identify function argument types
istype =$(if $(value ${1}),list,scalar)
isval =$(if $(filter-out list,$(call istype,${1})),true)
isvar =$(if $(filter-out scalar,$(call istype,${1})),true)
# Access up to 9 arguments passed, option needed to emulate $*
# Inline for function expansion, do not use $(call )
argv =$(strip
argv +=$(if $(1), $(1))$(if $(2), $(2))$(if $(3), $(3))$(if $(4), $(4))
argv +=$(if $(5), $(5))$(if $(6), $(6))$(if $(7), $(7))$(if $(8), $(8))
argv +=$(if $(9), $(9))
argv +=$(if $(10), $(error makeutils.mk::argv can only handle 9 arguments))
argv +=)
###########################################################################
## Access function args as a simple list, inline within user functions.
## Usage: $(info ** $(call banner,$(getargv)))
## $(call banner,scalar)
## $(call banner,list0 list1 list2)
## $(call banner,ref) ; ref=foo bar tans
## getarglist() would be a more accurate name but is longer to type
getargv = $(if $(call isvar,$(1)),$($(1)),$(argv))
# -*- makefile -*-
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/makefiles/makeutils.mk
##------------------_##
##---] TARGETS [---##
##------------------_##
all::
###########################################################################
## This test target should really depend on a timestamp to only perform
## work when makeutils.mk is modified. That answer would require using a
## 2nd makefile imposing more shell overhead. Separate makefiles would be
## very handy for testing when pwd==$src/ but for now avoid the overhead.
##
## Test logic will be interpreted at compile time, 'fast' and 'required' so
## the test will always be run when testing is enabled.
###########################################################################
check::
@true
## Logic processed at compile time so be selective about when to test
ifneq ($(NULL),$(findstring check,$(MAKECMDGOALS)))
$(info ===========================================================================)
$(info Running test: $(MAKECMDGOALS): pwd=$(CURDIR))
$(info ===========================================================================)
## Silent errors are oh so much fun
ifndef istype
$(error makeutils.mk was not included)
endif
# arg_scalar = [scalar|literal]
arg_list = foo bar
arg_ref = arg_list
## Identify type of function argument(s)
########################################
ifneq (scalar,$(call istype,arg_scalar))
$(error istype(arg_scalar)=scalar, found [$(call istype,arg_scalar)])
endif
ifneq (list,$(call istype,arg_list))
$(error istype(arg_list)=list, found [$(call istype,arg_list)])
endif
ifneq (list,$(call istype,arg_ref))
$(error istype(arg_ref)=list, found [$(call istype,arg_ref)])
endif
## Type == scalar or a list of values
#####################################
ifneq (true,$(call isval,scalar))
$(error isval(scalar)=true, found [$(call isval,scalar)])
endif
ifneq ($(NULL),$(call isval,arg_list))
$(error isval(arg_list)=null, found [$(call isval,arg_list)])
endif
## type == reference: macro=>macro => $($(1))
#############################################
ifneq ($(NULL),$(call isvar,scalar))
$(error isvar(scalar)=$(NULL), found [$(call isvar,scalar)])
endif
ifneq (true,$(call isvar,arg_list))
$(error isvar(arg_list)=true, found [$(call isvar,arg_list)])
endif
ifneq (true,$(call isvar,arg_ref))
$(error isvar(arg_ref)=true, found [$(call isvar,arg_ref)])
endif
# Verify getargv expansion
##########################
ifneq (scalar,$(call getargv,scalar))
$(error getargv(scalar)=scalar, found [$(call getargv,scalar)])
endif
ifneq ($(arg_list),$(call getargv,arg_list))
$(error getargv(arg_list)=list, found [$(call getargv,arg_list)])
endif
ifneq (arg_list,$(call getargv,arg_ref))
$(error getargv(arg_ref)=list, found [$(call getargv,arg_ref)])
endif
endif # check in MAKECMDGOALS
# -*- makefile -*-
# vim:set ts=8 sw=8 sts=8 noet:
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (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.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Chase Phillips <chase@mozilla.org>
# Benjamin Smedberg <benjamin@smedbergs.us>
# Jeff Walden <jwalden+code@mit.edu>
# Joey Armstrong <joey@mozilla.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either of the GNU General Public License Version 2 or later (the "GPL"),
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
ifndef topsrcdir
$(error topsrcdir was not set))
......@@ -57,6 +22,9 @@ ifndef INCLUDED_VERSION_MK
include $(topsrcdir)/config/version.mk
endif
include $(topsrcdir)/config/makefiles/makeutils.mk
include $(topsrcdir)/config/makefiles/autotargets.mk
ifdef SDK_XPIDLSRCS
XPIDLSRCS += $(SDK_XPIDLSRCS)
endif
......@@ -512,8 +480,8 @@ endif
# A Makefile that needs $(MDDEPDIR) created but doesn't set any of these
# variables we know to check can just set NEED_MDDEPDIR explicitly.
ifneq (,$(OBJS)$(XPIDLSRCS)$(SIMPLE_PROGRAMS)$(NEED_MDDEPDIR))
MAKE_DIRS += $(CURDIR)/$(MDDEPDIR)
GARBAGE_DIRS += $(MDDEPDIR)
MAKE_DIRS += $(CURDIR)/$(MDDEPDIR)
GARBAGE_DIRS += $(CURDIR)/$(MDDEPDIR)
endif
#
......@@ -1461,12 +1429,6 @@ endif
# generate .h files from into $(XPIDL_GEN_DIR), then export to $(DIST)/include;
# warn against overriding existing .h file.
$(XPIDL_GEN_DIR)/.done:
$(MKDIR) -p $(XPIDL_GEN_DIR)
@$(TOUCH) $@
# don't depend on $(XPIDL_GEN_DIR), because the modification date changes
# with any addition to the directory, regenerating all .h files -> everything.
XPIDL_DEPS = \
$(topsrcdir)/xpcom/idl-parser/header.py \
......@@ -1474,7 +1436,12 @@ XPIDL_DEPS = \
$(topsrcdir)/xpcom/idl-parser/xpidl.py \
$(NULL)
$(XPIDL_GEN_DIR)/%.h: %.idl $(XPIDL_DEPS) $(XPIDL_GEN_DIR)/.done
xpidl-preqs = \
$(call mkdir_deps,$(XPIDL_GEN_DIR)) \
$(call mkdir_deps,$(MDDEPDIR)) \
$(NULL)
$(XPIDL_GEN_DIR)/%.h: %.idl $(XPIDL_DEPS) $(xpidl-preqs)
$(REPORT_BUILD)
$(PYTHON_PATH) \
-I$(topsrcdir)/other-licenses/ply \
......@@ -1486,7 +1453,7 @@ $(XPIDL_GEN_DIR)/%.h: %.idl $(XPIDL_DEPS) $(XPIDL_GEN_DIR)/.done
ifndef NO_GEN_XPT
# generate intermediate .xpt files into $(XPIDL_GEN_DIR), then link
# into $(XPIDL_MODULE).xpt and export it to $(FINAL_TARGET)/components.
$(XPIDL_GEN_DIR)/%.xpt: %.idl $(XPIDL_DEPS) $(XPIDL_GEN_DIR)/.done
$(XPIDL_GEN_DIR)/%.xpt: %.idl $(XPIDL_DEPS) $(xpidl-preqs)
$(REPORT_BUILD)
$(PYTHON_PATH) \
-I$(topsrcdir)/other-licenses/ply \
......@@ -2028,8 +1995,18 @@ $(foreach var,$(FREEZE_VARIABLES),$(eval $(var)_FROZEN := '$($(var))'))
CHECK_FROZEN_VARIABLES = $(foreach var,$(FREEZE_VARIABLES), \
$(if $(subst $($(var)_FROZEN),,'$($(var))'),$(error Makefile variable '$(var)' changed value after including rules.mk. Was $($(var)_FROZEN), now $($(var)).)))
libs export libs::
libs export::
$(CHECK_FROZEN_VARIABLES)
default all::
if test -d $(DIST)/bin ; then touch $(DIST)/bin/.purgecaches ; fi
#############################################################################
# Derived targets and dependencies
include $(topsrcdir)/config/makefiles/autotargets.mk
ifneq ($(NULL),$(AUTO_DEPS))
default all libs tools export:: $(AUTO_DEPS)
endif
This diff is collapsed.
# -*- makefile -*-
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
#
PYTHON ?= python
PYTEST = $(PYTHON) -E
# python -B not supported by older interpreters
export PYTHONDONTWRITEBYTECODE=1
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/config.mk
include $(topsrcdir)/config/rules.mk
autotgt_tests = .deps/autotargets.mk.ts
tgts =\
.deps/.mkdir.done\
$(autotgt_tests)
$(NULL)
##------------------_##
##---] TARGETS [---##
##------------------_##
all::
check:: $(tgts)
# Only run unit test when autotargets.mk is modified
$(autotgt_tests): $(topsrcdir)/config/makefiles/autotargets.mk
MAKECMD=$(MAKE) $(PYTEST) $(srcdir)/check_mkdir.tpy
@$(TOUCH) $@
#!/usr/bin/env python
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
#
import os
import sys
import tempfile
from subprocess import call
from shutil import rmtree
import logging
import unittest
def banner():
"""
Display interpreter and system info for the test env
"""
print '*' * 75
cmd = os.path.basename(__file__)
print "%s: python version is %s" % (cmd, sys.version)
print '*' * 75
def myopts(vals):
"""
Storage for extra command line args passed.
Returns:
hash - argparse::Namespace object values
"""
if not hasattr(myopts, 'vals'):
if 'argparse' in sys.modules:
tmp = { } # key existance enables unittest module debug
else:
tmp = { 'debug': False, 'verbose': False }
for k in dir(vals):
if k[0:1] == '_':
continue
tmp[k] = getattr(vals, k)
myopts.vals = tmp
return myopts.vals
def path2posix(src):
"""
Normalize directory path syntax
Keyword arguments:
src - path to normalize
Returns:
scalar - a file path with drive separators and windows slashes removed
Todo:
move to {build,config,tools,toolkit}/python for use in a library
"""
## (drive, tail) = os.path.splitdrive(src)
## Support path testing on all platforms
drive = ''
winpath = src.find(':')
if -1 != winpath and 10 > winpath:
(drive, tail) = src.split(':', 2)
if drive:
todo = [ '', drive.rstrip(':').lstrip('/').lstrip('\\') ]
todo.extend( tail.lstrip('/').lstrip('\\').split('\\') ) # c:\a => [a]
else: # os.name == 'posix'
todo = src.split('\\')
dst = '/'.join(todo)
return dst
def checkMkdir(work, debug=False):
"""
Verify arg permutations for directory mutex creation.
Keyword arguments:
None
Returns:
Exception on error
Note:
Exception() rather than self.assertTrue() is used in this test
function to enable scatch cleanup on test exit/failure conditions.
Not guaranteed by python closures on early exit.
"""
logging.debug("Testing: checkMkdir")
if False:
path = os.path.abspath(__file__).split(os.sep)
else:
path = path2posix(os.path.abspath(__file__)).split('/')
root = os.path.join(os.sep, *path[:-5])
src = os.path.join(os.sep, *path[:-1])
rootP = path2posix(root)
srcP = path2posix(src)
workP = path2posix(work)
# C:\foo -vs- /c/foo
# [0] command paths use /c/foo
# [1] os.path.exists() on mingw() requires C:\
paths = [
[ # function generated
"%s/mkdir_bycall" % (workP),
"%s/mkdir_bycall" % (work),
],
[ # explicit dependency
"%s/mkdir_bydep" % (workP),
"%s/mkdir_bydep" % (work),
],
[ # by GENERATED_DIRS macro
"%s/mkdir_bygen" % (workP),
"%s/mkdir_bygen" % (work),
]
]
## Use make from the parent "make check" call when available
cmd = { 'make': 'make' }
shell0 = os.environ.get('MAKECMD')
if shell0:
shell = os.path.splitext(shell0)[0] # strip: .exe, .py
if -1 != shell.find('make'):
print "MAKE COMMAND FOUND: %s" % (shell0)
cmd['make'] = path2posix(shell0)
args = []
args.append('%s' % (cmd['make']))
args.append('-C %s' % (workP))
args.append("-f %s/testor.tmpl" % (srcP))
args.append('topsrcdir=%s' % (rootP))
args.append('deps_mkdir_bycall=%s' % paths[0][0])
args.append('deps_mkdir_bydep=%s' % paths[1][0])
args.append('deps_mkdir_bygen=%s' % paths[2][0])
args.append('checkup') # target
# Call will fail on mingw with output redirected ?!?
if debug:
pass
if False: # if not debug:
args.append('>/dev/null')
cmd = '%s' % (' '.join(args))
logging.debug("Running: %s" % (cmd))
rc = call(cmd, shell=True)
if rc:
raise Exception("make failed ($?=%s): cmd=%s" % (rc, cmd))
for i in paths:
logging.debug("Did testing mkdir(%s) succeed?" % (i[1]))
if not os.path.exists(i[1]):
raise Exception("Test path %s does not exist" % (i[1]))
def parseargs():
"""
Support additional command line arguments for testing
Returns:
hash - arguments of interested parsed from the command line
"""
opts = None
try:
import argparse2
parser = argparse.ArgumentParser()
parser.add_argument('--debug',
action="store_true",
default=False,
help='Enable debug mode')
# Cannot overload verbose, Verbose: False enables debugging
parser.add_argument('--verbose',
action="store_true",
default=False,
help='Enable verbose mode')
parser.add_argument('unittest_args',
nargs='*'
# help='Slurp/pass remaining args to unittest'
)
opts = parser.parse_args()
except ImportError:
pass
return opts
class TestMakeLogic(unittest.TestCase):
"""
Test suite used to validate makefile library rules and macros
"""
def setUp(self):
opts = myopts(None) # NameSpace object not hash
self.debug = opts['debug']
self.verbose = opts['verbose']
if self.debug:
logging.basicConfig(level=logging.DEBUG)
if self.verbose:
print
print "ENVIRONMENT DUMP:"
print '=' * 75
for k,v in os.environ.items():
print "env{%s} => %s" % (k, v)
print
def test_path2posix(self):
todo = {
'/dev/null' : '/dev/null',
'A:\\a\\b\\c' : '/A/a/b/c',
'B:/x/y' : '/B/x/y',
'C:/x\\y/z' : '/C/x/y/z',
'//FOO/bar/tans': '//FOO/bar/tans',
'//X\\a/b\\c/d' : '//X/a/b/c/d',
'\\c:mozilla\\sandbox': '/c/mozilla/sandbox',
}
for val,exp in todo.items():
found = path2posix(val)
tst = "posix2path(%s): %s != %s)" % (val, exp, found)
self.assertEqual(exp, found, "%s: invalid path detected" % (tst))
def test_mkdir(self):
"""
Verify directory creation rules and macros
"""
failed = True
# Exception handling is used to cleanup scratch space on error
try:
work = tempfile.mkdtemp()
checkMkdir(work, self.debug)
failed = False
finally:
if os.path.exists(work):
rmtree(work)
self.assertFalse(failed, "Unit test failure detected")
if __name__ == '__main__':
banner()
opts = parseargs()
myopts(opts)
if opts:
if hasattr(opts, 'unittest_args'):
sys.argv[1:] = opts.unittest_args
else:
sys.argv[1:] = []
unittest.main()
# -*- makefile -*-
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
#
###########################################################################
## Intent: Standalone unit tests for makefile rules and target logic
###########################################################################
deps =$(NULL)
tgts =$(NULL)
ifdef VERBOSE
tgts += show
endif
# Define macros
include $(topsrcdir)/config/makefiles/makeutils.mk
include $(topsrcdir)/config/makefiles/autotargets.mk
##########################
## Verify threadsafe mkdir
##########################
ifdef deps_mkdir_bycall
deps += $(call mkdir_deps,deps_mkdir_bycall)
tgts += check_mkdir
endif
ifdef deps_mkdir_bydep
deps += $(foreach dir,$(deps_mkdir_bydep),$(dir)/.mkdir.done)
tgts += check_mkdir
endif
ifdef deps_mkdir_bygen
GENERATED_DIRS += $(deps_mkdir_bygen)
tgts += check_mkdir
endif
###########################
## Minimal environment load
###########################
MKDIR ?= mkdir -p
TOUCH ?= touch
INCLUDED_CONFIG_MK = 1
include $(topsrcdir)/config/rules.mk
##-------------------##
##---] TARGETS [---##
##-------------------##
all::
# Quarks:
# o Use of 'all' would trigger export target processing
checkup: $(tgts)
# AUTO_DEPS - verify GENERATED_DIRS
check_mkdir: $(deps) $(AUTO_DEPS)
show:
@echo "tgts=[$(tgts)]"
@echo "deps=[$(deps)]"
find $(dir $(deps)) -print
......@@ -52,8 +52,9 @@ DIST_FILES = \
TEST_EXTENSIONS_DIR = $(DEPTH)/_tests/testing/mochitest/extensions
GENERATED_DIRS = $(TEST_EXTENSIONS_DIR)
include $(topsrcdir)/config/rules.mk
libs::
$(MKDIR) -p $(TEST_EXTENSIONS_DIR)
@(cd $(DIST)/xpi-stage && tar $(TAR_CREATE_FLAGS) - $(XPI_NAME)) | (cd $(TEST_EXTENSIONS_DIR) && tar -xf -)
......@@ -61,8 +61,9 @@ DIST_FILES = \
TEST_EXTENSIONS_DIR = $(DEPTH)/_tests/testing/mochitest/extensions
GENERATED_DIRS = $(TEST_EXTENSIONS_DIR)
include $(topsrcdir)/config/rules.mk
libs::
$(MKDIR) -p $(TEST_EXTENSIONS_DIR)
@(cd $(DIST)/xpi-stage && tar $(TAR_CREATE_FLAGS) - $(XPI_NAME)) | (cd $(TEST_EXTENSIONS_DIR) && tar -xf -)
......@@ -89,8 +89,9 @@ ifdef HOST_PROGRAM
endif
ifdef WRAP_SYSTEM_INCLUDES
export::
if test ! -d system_wrappers_js; then mkdir system_wrappers_js; fi
export:: \
$(call mkdir_deps,system_wrappers_js) \
$(NULL)
$(PYTHON) $(srcdir)/Preprocessor.py $(DEFINES) $(ACDEFINES) \
$(srcdir)/system-headers | $(PERL) $(srcdir)/make-system-wrappers.pl system_wrappers_js
$(INSTALL) system_wrappers_js $(DIST)
......
......@@ -46,7 +46,7 @@
# Define an include-at-most-once flag
ifdef INCLUDED_CONFIG_MK
$(error Don't include config.mk twice!)
$(error Do not include config.mk twice!)
endif
INCLUDED_CONFIG_MK = 1
......
# -*- makefile -*-
# vim:set ts=8 sw=8 sts=8 noet:
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
#
###########################################################################
# AUTO_DEPS - A list of deps/targets drived from other macros.
# *_DEPS - Make dependencies derived from a given macro.
###########################################################################
MKDIR ?= mkdir -p
TOUCH ?= touch
###########################################################################
# Threadsafe directory creation
# GENERATED_DIRS - Automated creation of these directories.
###########################################################################
mkdir_deps =$(foreach dir,$(getargv),$(dir)/.mkdir.done)
ifneq (,$(GENERATED_DIRS))
tmpauto :=$(call mkdir_deps,GENERATED_DIRS)
GENERATED_DIRS_DEPS +=$(tmpauto)
GARBAGE_DIRS +=$(tmpauto)
endif
%/.mkdir.done:
$(subst $(SPACE)-p,$(null),$(MKDIR)) -p $(dir $@)
@$(TOUCH) $@
#################################################################
# One ring/dep to rule them all:
# config/rules.mk::all target is available by default
# Add $(AUTO_DEPS) as an explicit target dependency when needed.
#################################################################
AUTO_DEPS +=$(GENERATED_DIRS_DEPS)
# Complain loudly if deps have not loaded so getargv != $(NULL)
ifndef getargv
$(error config/makefiles/makeutil.mk has not been included)
endif
# -*- makefile -*-
# vim:set ts=8 sw=8 sts=8 noet:
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
# Usage: $(call banner,foo bar tans)
banner =\
$(info )\
$(info ***************************************************************************)\
$(info ** BANNER: $(1) $(2) $(3) $(4) $(5) $(6) $(7) $(8) $(9))\
$(info ***************************************************************************)\
## Identify function argument types
istype =$(if $(value ${1}),list,scalar)
isval =$(if $(filter-out list,$(call istype,${1})),true)
isvar =$(if $(filter-out scalar,$(call istype,${1})),true)
# Access up to 9 arguments passed, option needed to emulate $*
# Inline for function expansion, do not use $(call )
argv =$(strip
argv +=$(if $(1), $(1))$(if $(2), $(2))$(if $(3), $(3))$(if $(4), $(4))
argv +=$(if $(5), $(5))$(if $(6), $(6))$(if $(7), $(7))$(if $(8), $(8))
argv +=$(if $(9), $(9))
argv +=$(if $(10), $(error makeutils.mk::argv can only handle 9 arguments))
argv +=)
###########################################################################
## Access function args as a simple list, inline within user functions.
## Usage: $(info ** $(call banner,$(getargv)))
## $(call banner,scalar)
## $(call banner,list0 list1 list2)
## $(call banner,ref) ; ref=foo bar tans
## getarglist() would be a more accurate name but is longer to type
getargv = $(if $(call isvar,$(1)),$($(1)),$(argv))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment