mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 912293 - Add a generic header and footer to generated Makefiles. r=gps
This commit is contained in:
parent
bf046a6397
commit
9a4e27117c
@ -1,3 +1,6 @@
|
||||
ifndef INCLUDED_AUTOCONF_MK
|
||||
INCLUDED_AUTOCONF_MK = 1
|
||||
include $(DEPTH)/config/emptyvars.mk
|
||||
@ALLSUBSTS@
|
||||
include $(topsrcdir)/config/baseconfig.mk
|
||||
endif
|
||||
|
@ -1,5 +1,3 @@
|
||||
INCLUDED_AUTOCONF_MK = 1
|
||||
|
||||
includedir := $(includedir)/$(MOZ_APP_NAME)-$(MOZ_APP_VERSION)
|
||||
idldir = $(datadir)/idl/$(MOZ_APP_NAME)-$(MOZ_APP_VERSION)
|
||||
installdir = $(libdir)/$(MOZ_APP_NAME)-$(MOZ_APP_VERSION)
|
||||
|
@ -10,6 +10,12 @@ ifndef topsrcdir
|
||||
$(error topsrcdir was not set))
|
||||
endif
|
||||
|
||||
# Define an include-at-most-once flag
|
||||
ifdef INCLUDED_RULES_MK
|
||||
$(error Do not include rules.mk twice!)
|
||||
endif
|
||||
INCLUDED_RULES_MK = 1
|
||||
|
||||
# Integrate with mozbuild-generated make files. We first verify that no
|
||||
# variables provided by the automatically generated .mk files are
|
||||
# present. If they are, this is a violation of the separation of
|
||||
|
@ -1,3 +1,6 @@
|
||||
ifndef INCLUDED_AUTOCONF_MK
|
||||
INCLUDED_AUTOCONF_MK = 1
|
||||
include $(DEPTH)/config/emptyvars.mk
|
||||
@ALLSUBSTS@
|
||||
include $(topsrcdir)/config/baseconfig.mk
|
||||
endif
|
||||
|
@ -1,5 +1,3 @@
|
||||
INCLUDED_AUTOCONF_MK = 1
|
||||
|
||||
installdir = $(libdir)/$(MOZ_APP_NAME)-$(MOZ_APP_VERSION)
|
||||
sdkdir = $(libdir)/$(MOZ_APP_NAME)-devel-$(MOZ_APP_VERSION)
|
||||
|
||||
|
@ -10,6 +10,12 @@ ifndef topsrcdir
|
||||
$(error topsrcdir was not set))
|
||||
endif
|
||||
|
||||
# Define an include-at-most-once flag
|
||||
ifdef INCLUDED_RULES_MK
|
||||
$(error Do not include rules.mk twice!)
|
||||
endif
|
||||
INCLUDED_RULES_MK = 1
|
||||
|
||||
# Integrate with mozbuild-generated make files. We first verify that no
|
||||
# variables provided by the automatically generated .mk files are
|
||||
# present. If they are, this is a violation of the separation of
|
||||
|
@ -4341,7 +4341,7 @@ AC_SUBST(ac_configure_args)
|
||||
dnl Spit out some output
|
||||
dnl ========================================================
|
||||
|
||||
AC_OUTPUT([js-confdefs.h Makefile config/autoconf.mk config/emptyvars.mk])
|
||||
AC_OUTPUT([js-confdefs.h config/autoconf.mk config/emptyvars.mk])
|
||||
|
||||
# Produce the js-config script at configure time; see the comments for
|
||||
# 'js*-config' in Makefile.in.
|
||||
|
@ -205,7 +205,42 @@ class ConfigEnvironment(object):
|
||||
"relativesrcdir" for its source directory relative to the top
|
||||
"DEPTH" for the path to the top object directory
|
||||
'''
|
||||
input = self.get_input(path)
|
||||
if os.path.basename(path) == 'Makefile':
|
||||
return self.create_makefile(path, extra=extra)
|
||||
pp = self._get_preprocessor(path, extra)
|
||||
pp.do_include(self.get_input(path))
|
||||
return pp.out.close()
|
||||
|
||||
def create_makefile(self, path, stub=False, extra=None):
|
||||
'''Creates the given makefile. Makefiles are treated the same as
|
||||
config files, but some additional header and footer is added to the
|
||||
output.
|
||||
|
||||
When the stub argument is True, no source file is used, and a stub
|
||||
makefile with the default header and footer only is created.
|
||||
'''
|
||||
pp = self._get_preprocessor(path, extra)
|
||||
pp.handleLine('# THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT MODIFY BY HAND.\n');
|
||||
pp.handleLine('DEPTH := @DEPTH@\n')
|
||||
pp.handleLine('topsrcdir := @top_srcdir@\n')
|
||||
pp.handleLine('srcdir := @srcdir@\n')
|
||||
pp.handleLine('VPATH := @srcdir@\n')
|
||||
pp.handleLine('relativesrcdir := @relativesrcdir@\n')
|
||||
pp.handleLine('include $(DEPTH)/config/autoconf.mk\n')
|
||||
if not stub:
|
||||
pp.do_include(self.get_input(path))
|
||||
# Empty line to avoid failures when last line in Makefile.in ends
|
||||
# with a backslash.
|
||||
pp.handleLine('\n')
|
||||
pp.handleLine('ifndef INCLUDED_RULES_MK\n')
|
||||
pp.handleLine('include $(topsrcdir)/config/rules.mk\n')
|
||||
pp.handleLine('endif\n')
|
||||
return pp.out.close()
|
||||
|
||||
def _get_preprocessor(self, path, extra):
|
||||
'''Returns a preprocessor for use by create_config_file and
|
||||
create_makefile.
|
||||
'''
|
||||
pp = Preprocessor()
|
||||
pp.context.update(self.substs)
|
||||
pp.context.update(top_srcdir = self.get_top_srcdir(path))
|
||||
@ -218,8 +253,7 @@ class ConfigEnvironment(object):
|
||||
pp.setMarker(None)
|
||||
|
||||
pp.out = FileAvoidWrite(path)
|
||||
pp.do_include(input)
|
||||
return pp.out.close()
|
||||
return pp
|
||||
|
||||
def create_config_header(self, path):
|
||||
'''Creates the given config header. A config header is generated by
|
||||
|
@ -31,19 +31,6 @@ from ..frontend.data import (
|
||||
from ..util import FileAvoidWrite
|
||||
|
||||
|
||||
STUB_MAKEFILE = '''
|
||||
# THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT MODIFY BY HAND.
|
||||
|
||||
DEPTH := {depth}
|
||||
topsrcdir := {topsrc}
|
||||
srcdir := {src}
|
||||
VPATH := {src}
|
||||
relativesrcdir := {relsrc}
|
||||
|
||||
include {topsrc}/config/rules.mk
|
||||
'''.lstrip()
|
||||
|
||||
|
||||
class BackendMakeFile(object):
|
||||
"""Represents a generated backend.mk file.
|
||||
|
||||
@ -237,14 +224,11 @@ class RecursiveMakeBackend(CommonBackend):
|
||||
|
||||
# If Makefile.in exists, use it as a template. Otherwise, create a
|
||||
# stub.
|
||||
if os.path.exists(makefile_in):
|
||||
stub = not os.path.exists(makefile_in)
|
||||
if not stub:
|
||||
self.log(logging.DEBUG, 'substitute_makefile',
|
||||
{'path': makefile}, 'Substituting makefile: {path}')
|
||||
|
||||
self._update_from_avoid_write(
|
||||
bf.environment.create_config_file(makefile))
|
||||
self.summary.managed_count += 1
|
||||
|
||||
# Adding the Makefile.in here has the desired side-effect that
|
||||
# if the Makefile.in disappears, this will force moz.build
|
||||
# traversal. This means that when we remove empty Makefile.in
|
||||
@ -255,17 +239,9 @@ class RecursiveMakeBackend(CommonBackend):
|
||||
self.log(logging.DEBUG, 'stub_makefile',
|
||||
{'path': makefile}, 'Creating stub Makefile: {path}')
|
||||
|
||||
params = {
|
||||
'topsrc': bf.environment.get_top_srcdir(makefile),
|
||||
'src': bf.environment.get_file_srcdir(makefile),
|
||||
'depth': bf.environment.get_depth(makefile),
|
||||
'relsrc': bf.environment.get_relative_srcdir(makefile),
|
||||
}
|
||||
|
||||
aw = FileAvoidWrite(makefile)
|
||||
aw.write(STUB_MAKEFILE.format(**params))
|
||||
self._update_from_avoid_write(aw.close())
|
||||
self.summary.managed_count += 1
|
||||
self._update_from_avoid_write(
|
||||
bf.environment.create_makefile(makefile, stub=stub))
|
||||
self.summary.managed_count += 1
|
||||
|
||||
self._update_from_avoid_write(bf.close())
|
||||
self.summary.managed_count += 1
|
||||
|
@ -1,11 +1,4 @@
|
||||
# Any copyright is dedicated to the Public Domain.
|
||||
# http://creativecommons.org/publicdomain/zero/1.0/
|
||||
|
||||
DEPTH := @DEPTH@
|
||||
topsrcdir := @top_srcdir@
|
||||
srcdir := @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
FOO := foo
|
||||
|
@ -47,16 +47,20 @@ class TestRecursiveMakeBackend(BackendTester):
|
||||
|
||||
p = os.path.join(env.topobjdir, 'Makefile')
|
||||
|
||||
lines = [l.strip() for l in open(p, 'rt').readlines()[3:]]
|
||||
lines = [l.strip() for l in open(p, 'rt').readlines()[1:] if not l.startswith('#')]
|
||||
self.assertEqual(lines, [
|
||||
'DEPTH := .',
|
||||
'topsrcdir := %s' % env.topsrcdir,
|
||||
'srcdir := %s' % env.topsrcdir,
|
||||
'VPATH = %s' % env.topsrcdir,
|
||||
'',
|
||||
'VPATH := %s' % env.topsrcdir,
|
||||
'relativesrcdir := .',
|
||||
'include $(DEPTH)/config/autoconf.mk',
|
||||
'',
|
||||
'include $(topsrcdir)/config/rules.mk'
|
||||
'FOO := foo',
|
||||
'',
|
||||
'ifndef INCLUDED_RULES_MK',
|
||||
'include $(topsrcdir)/config/rules.mk',
|
||||
'endif',
|
||||
])
|
||||
|
||||
def test_missing_makefile_in(self):
|
||||
@ -67,7 +71,7 @@ class TestRecursiveMakeBackend(BackendTester):
|
||||
self.assertTrue(os.path.exists(p))
|
||||
|
||||
lines = [l.strip() for l in open(p, 'rt').readlines()]
|
||||
self.assertEqual(len(lines), 9)
|
||||
self.assertEqual(len(lines), 11)
|
||||
|
||||
self.assertTrue(lines[0].startswith('# THIS FILE WAS AUTOMATICALLY'))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user