Skip to content

Commit

Permalink
Revert "Bug 1333826 - Remove SDK_FILES, SDK_LIBRARY, and related is_s…
Browse files Browse the repository at this point in the history
…dk support in the build goop, r=mshal"

This reverts commit ca77995.
  • Loading branch information
rainemak committed Aug 19, 2020
1 parent e8825be commit 408fd38
Show file tree
Hide file tree
Showing 25 changed files with 161 additions and 7 deletions.
3 changes: 3 additions & 0 deletions build/docs/defining-binaries.rst
Expand Up @@ -297,6 +297,9 @@ needs to be prefixed with ``static:`` in ``USE_LIBS``
Miscellaneous
=============

The ``SDK_LIBRARY`` boolean variable defines whether the library in the current
directory is going to be installed in the SDK.

The ``SONAME`` variable declares a "shared object name" for the library. It
defaults to the ``Library`` name or the ``SHARED_LIBRARY_NAME`` if set. When
linking to a library with a ``SONAME``, the resulting library or program will
Expand Down
17 changes: 15 additions & 2 deletions config/rules.mk
Expand Up @@ -109,8 +109,8 @@ else
LIBRARY := $(REAL_LIBRARY).$(LIBS_DESC_SUFFIX)
endif
else
# Only build actual library if it is installed in DIST/lib
ifeq (,$(DIST_INSTALL)$(NO_EXPAND_LIBS))
# Only build actual library if it is installed in DIST/lib or SDK
ifeq (,$(SDK_LIBRARY)$(DIST_INSTALL)$(NO_EXPAND_LIBS))
LIBRARY := $(REAL_LIBRARY).$(LIBS_DESC_SUFFIX)
else
ifdef NO_EXPAND_LIBS
Expand Down Expand Up @@ -243,6 +243,7 @@ SIMPLE_PROGRAMS :=
HOST_LIBRARY :=
HOST_PROGRAM :=
HOST_SIMPLE_PROGRAMS :=
SDK_LIBRARY :=
endif

ALL_TRASH = \
Expand Down Expand Up @@ -1232,6 +1233,18 @@ ifneq (,$(DIST_SUBDIR)$(XPI_NAME))
PREF_DIR = defaults/preferences
endif

################################################################################
# SDK

ifneq (,$(SDK_LIBRARY))
ifndef NO_DIST_INSTALL
SDK_LIBRARY_FILES := $(SDK_LIBRARY)
SDK_LIBRARY_DEST := $(SDK_LIB_DIR)
SDK_LIBRARY_TARGET := target
INSTALL_TARGETS += SDK_LIBRARY
endif
endif # SDK_LIBRARY

################################################################################
# CHROME PACKAGING

Expand Down
2 changes: 2 additions & 0 deletions intl/unicharutil/util/moz.build
Expand Up @@ -25,4 +25,6 @@ UNIFIED_SOURCES += [
'nsUnicodeProperties.cpp',
]

SDK_LIBRARY = True

FINAL_LIBRARY = 'xul'
5 changes: 5 additions & 0 deletions js/xpconnect/shell/moz.build
Expand Up @@ -6,6 +6,11 @@

GeckoProgram('xpcshell', linkage='dependent')

if CONFIG['COMPILE_ENVIRONMENT']:
SDK_FILES.bin += [
'!xpcshell%s' % CONFIG['BIN_SUFFIX'],
]

SOURCES += [
'xpcshell.cpp',
]
Expand Down
2 changes: 2 additions & 0 deletions mozglue/build/moz.build
Expand Up @@ -14,6 +14,8 @@ elif CONFIG['OS_TARGET'] in ('WINNT', 'Darwin', 'Android'):
else:
Library('mozglue')

SDK_LIBRARY = True

if CONFIG['OS_TARGET'] == 'Android':
SOURCES += [
'BionicGlue.cpp',
Expand Down
8 changes: 8 additions & 0 deletions python/mozbuild/mozbuild/backend/recursivemake.py
Expand Up @@ -118,6 +118,8 @@
b'PREF_JS_EXPORTS',
b'PROGRAM',
b'RESOURCE_FILES',
b'SDK_HEADERS',
b'SDK_LIBRARY',
b'SHARED_LIBRARY_LIBS',
b'SHARED_LIBRARY_NAME',
b'SIMPLE_PROGRAMS',
Expand Down Expand Up @@ -397,6 +399,7 @@ def _init(self):
# used for a "magic" rm -rf.
self._install_manifests['dist_public']
self._install_manifests['dist_private']
self._install_manifests['dist_sdk']

self._traversal = RecursiveMakeTraversal()
self._compile_graph = OrderedDefaultDict(set)
Expand Down Expand Up @@ -1279,6 +1282,8 @@ def _process_shared_library(self, libdef, backend_file):
backend_file.write('SHARED_LIBRARY := %s\n' % libdef.lib_name)
if libdef.soname:
backend_file.write('DSO_SONAME := %s\n' % libdef.soname)
if libdef.is_sdk:
backend_file.write('SDK_LIBRARY := %s\n' % libdef.import_name)
if libdef.symbols_file:
backend_file.write('SYMBOLS_FILE := %s\n' % libdef.symbols_file)
if not libdef.cxx_link:
Expand All @@ -1288,6 +1293,8 @@ def _process_static_library(self, libdef, backend_file):
backend_file.write_once('LIBRARY_NAME := %s\n' % libdef.basename)
backend_file.write('FORCE_STATIC_LIB := 1\n')
backend_file.write('REAL_LIBRARY := %s\n' % libdef.lib_name)
if libdef.is_sdk:
backend_file.write('SDK_LIBRARY := %s\n' % libdef.import_name)
if libdef.no_expand_lib:
backend_file.write('NO_EXPAND_LIBS := 1\n')

Expand Down Expand Up @@ -1400,6 +1407,7 @@ def _process_final_target_files(self, obj, files, backend_file):
'dist/xpi-stage',
'_tests',
'dist/include',
'dist/sdk',
))
if not path:
raise Exception("Cannot install to " + target)
Expand Down
20 changes: 20 additions & 0 deletions python/mozbuild/mozbuild/frontend/context.py
Expand Up @@ -1638,6 +1638,26 @@ def aggregate(files):
them correctly.
"""),

'SDK_FILES': (ContextDerivedTypedHierarchicalStringList(Path), list,
"""List of files to be installed into the sdk directory.
``SDK_FILES`` will copy (or symlink, if the platform supports it)
the contents of its files to the ``dist/sdk`` directory. Files that
are destined for a subdirectory can be specified by accessing a field.
For example, to export ``foo.py`` to the top-level directory and
``bar.py`` to the directory ``subdir``, append to
``SDK_FILES`` like so::
SDK_FILES += ['foo.py']
SDK_FILES.subdir += ['bar.py']
"""),

'SDK_LIBRARY': (bool, bool,
"""Whether the library built in the directory is part of the SDK.
The library will be copied into ``SDK_LIB_DIR`` (``$DIST/sdk/lib``).
"""),

'SIMPLE_PROGRAMS': (StrictOrderingOnAppendList, list,
"""Compile a list of executable names.
Expand Down
25 changes: 20 additions & 5 deletions python/mozbuild/mozbuild/frontend/data.py
Expand Up @@ -594,11 +594,13 @@ class Library(BaseLibrary):
"""Context derived container object for a library"""
KIND = 'target'
__slots__ = (
'is_sdk',
)

def __init__(self, context, basename, real_name=None):
def __init__(self, context, basename, real_name=None, is_sdk=False):
BaseLibrary.__init__(self, context, real_name or basename)
self.basename = basename
self.is_sdk = is_sdk


class StaticLibrary(Library):
Expand All @@ -608,9 +610,9 @@ class StaticLibrary(Library):
'no_expand_lib',
)

def __init__(self, context, basename, real_name=None,
def __init__(self, context, basename, real_name=None, is_sdk=False,
link_into=None, no_expand_lib=False):
Library.__init__(self, context, basename, real_name)
Library.__init__(self, context, basename, real_name, is_sdk)
self.link_into = link_into
self.no_expand_lib = no_expand_lib

Expand Down Expand Up @@ -678,10 +680,10 @@ class SharedLibrary(Library):
FRAMEWORK = 1
MAX_VARIANT = 2

def __init__(self, context, basename, real_name=None,
def __init__(self, context, basename, real_name=None, is_sdk=False,
soname=None, variant=None, symbols_file=False):
assert(variant in range(1, self.MAX_VARIANT) or variant is None)
Library.__init__(self, context, basename, real_name)
Library.__init__(self, context, basename, real_name, is_sdk)
self.variant = variant
self.lib_name = real_name or basename
assert self.lib_name
Expand Down Expand Up @@ -1099,6 +1101,19 @@ def install_target(self):
return 'dist/include'


class SdkFiles(FinalTargetFiles):
"""Sandbox container object for SDK_FILES, which is a
HierarchicalStringList.
We need an object derived from ContextDerived for use in the backend, so
this object fills that role. It just has a reference to the underlying
HierarchicalStringList, which is created when parsing SDK_FILES.
"""
@property
def install_target(self):
return 'dist/sdk'


class GeneratedFile(ContextDerived):
"""Represents a generated file."""

Expand Down
10 changes: 10 additions & 0 deletions python/mozbuild/mozbuild/frontend/emitter.py
Expand Up @@ -62,6 +62,7 @@
HostRustLibrary,
RustProgram,
RustTest,
SdkFiles,
SharedLibrary,
SimpleProgram,
Sources,
Expand Down Expand Up @@ -720,6 +721,14 @@ def check_unique_binary(program, kind):
'SONAME requires FORCE_SHARED_LIB', context)
shared_args['soname'] = soname

# If both a shared and a static library are created, only the
# shared library is meant to be a SDK library.
if context.get('SDK_LIBRARY'):
if shared_lib:
shared_args['is_sdk'] = True
elif static_lib:
static_args['is_sdk'] = True

if context.get('NO_EXPAND_LIBS'):
if not static_lib:
raise SandboxValidationError(
Expand Down Expand Up @@ -1154,6 +1163,7 @@ def emit_from_context(self, context):
('LOCALIZED_PP_FILES', LocalizedPreprocessedFiles),
('OBJDIR_FILES', ObjdirFiles),
('OBJDIR_PP_FILES', ObjdirPreprocessedFiles),
('SDK_FILES', SdkFiles),
('TEST_HARNESS_FILES', TestHarnessFiles),
):
all_files = context.get(var)
Expand Down
Empty file.
Empty file.
11 changes: 11 additions & 0 deletions python/mozbuild/mozbuild/test/backend/data/sdk-files/moz.build
@@ -0,0 +1,11 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/

SDK_FILES += [
'bar.ico',
'sub/quux.png',
]

SDK_FILES.icons += [
'foo.ico',
]
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions python/mozbuild/mozbuild/test/backend/test_recursivemake.py
Expand Up @@ -537,6 +537,18 @@ def test_resources(self):
self.assertIn('res/tests/test.manifest', m)
self.assertIn('res/tests/extra.manifest', m)

def test_sdk_files(self):
"""Ensure SDK_FILES is handled properly."""
env = self._consume('sdk-files', RecursiveMakeBackend)

#SDK_FILES should appear in the dist_sdk install manifest.
m = InstallManifest(path=os.path.join(env.topobjdir,
'_build_manifests', 'install', 'dist_sdk'))
self.assertEqual(len(m), 3)
self.assertIn('bar.ico', m)
self.assertIn('quux.png', m)
self.assertIn('icons/foo.ico', m)

def test_test_manifests_files_written(self):
"""Ensure test manifests get turned into files."""
env = self._consume('test-manifests-written', RecursiveMakeBackend)
Expand Down
Empty file.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
12 changes: 12 additions & 0 deletions python/mozbuild/mozbuild/test/frontend/data/sdk-files/moz.build
@@ -0,0 +1,12 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/

SDK_FILES += [
'bar.ico',
'baz.png',
'foo.xpm',
]

SDK_FILES.icons += [
'quux.icns',
]
Empty file.
17 changes: 17 additions & 0 deletions python/mozbuild/mozbuild/test/frontend/test_emitter.py
Expand Up @@ -36,6 +36,7 @@
Program,
RustLibrary,
RustProgram,
SdkFiles,
SharedLibrary,
SimpleProgram,
Sources,
Expand Down Expand Up @@ -638,6 +639,22 @@ def test_test_harness_files_root(self):
'Cannot install files to the root of TEST_HARNESS_FILES'):
self.read_topsrcdir(reader)

def test_sdk_files(self):
reader = self.reader('sdk-files')
objs = self.read_topsrcdir(reader)

self.assertEqual(len(objs), 1)
self.assertIsInstance(objs[0], SdkFiles)

files = objs[0].files

self.assertEqual(files._strings, ['bar.ico', 'baz.png', 'foo.xpm'])

self.assertIn('icons', files._children)
icons = files._children['icons']

self.assertEqual(icons._strings, ['quux.icns'])

def test_program(self):
reader = self.reader('program')
objs = self.read_topsrcdir(reader)
Expand Down
2 changes: 2 additions & 0 deletions security/moz.build
Expand Up @@ -26,6 +26,8 @@ else:
# TODO: The library name can be changed when bug 845217 is fixed.
SHARED_LIBRARY_NAME = 'nss3'

SDK_LIBRARY = True

USE_LIBS += [
'nspr4',
'nss3_static',
Expand Down
2 changes: 2 additions & 0 deletions toolkit/library/moz.build
Expand Up @@ -79,6 +79,8 @@ def Libxul(name):

Libxul('xul')

SDK_LIBRARY = True

FORCE_STATIC_LIB = True

STATIC_LIBRARY_NAME = 'xul_s'
Expand Down
2 changes: 2 additions & 0 deletions xpcom/glue/standalone/moz.build
Expand Up @@ -11,6 +11,8 @@ SOURCES += [

Library('xpcomglue')

SDK_LIBRARY = True

FORCE_STATIC_LIB = True

if CONFIG['CC_TYPE'] in ('msvc', 'clang-cl'):
Expand Down
14 changes: 14 additions & 0 deletions xpcom/idl-parser/xpidl/moz.build
Expand Up @@ -13,3 +13,17 @@ GENERATED_FILES += [
]

GENERATED_FILES[('xpidl.stub', 'xpidllex.py', 'xpidlyacc.py')].script = 'header.py:main'

SDK_FILES.bin += [
'!xpidllex.py',
'!xpidlyacc.py',
'header.py',
'typelib.py',
'xpidl.py',
]

SDK_FILES.bin.ply += [
'/other-licenses/ply/ply/__init__.py',
'/other-licenses/ply/ply/lex.py',
'/other-licenses/ply/ply/yacc.py',
]
4 changes: 4 additions & 0 deletions xpcom/typelib/xpt/tools/moz.build
Expand Up @@ -7,3 +7,7 @@
PYTHON_UNITTEST_MANIFESTS += [
'python.ini',
]

SDK_FILES.bin += [
'xpt.py',
]

0 comments on commit 408fd38

Please sign in to comment.