mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 12:51:06 +00:00
Bug 1375798 - Reorganize the library_name_info function. r=mshal
The function as it currently is matches how things were done in old-configure.in. However, that's just confusing and hard to follow. In fact, the unit test failing numerous times while writing this patch pretty much highlights the problem. So instead of a confusing set of overrides to the prefixes and suffixes, spell out the whole set for each set of platforms. This also happens to make the function shorter. Win/win. At the same time, we normalize the function output as a nested namespace, where we get, for each of dll, lib, import_lib, etc. a prefix/suffix pair. Further down the road, we can imagine changing those to class instances with a method allowing to format file names based on those prefix/suffixes. --HG-- extra : rebase_source : c18520d4df54feeea0a7f9588bc3cf8346793aaf
This commit is contained in:
parent
393d819a1c
commit
2b86683647
@ -156,66 +156,58 @@ def so_version(value):
|
||||
|
||||
@depends(target, target_is_windows, target_is_darwin, c_compiler, so_version)
|
||||
def library_name_info(target, is_windows, is_darwin, c_compiler, so_version):
|
||||
dll_prefix = 'lib'
|
||||
dll_suffix = '.so'
|
||||
lib_prefix = 'lib'
|
||||
lib_suffix = 'a'
|
||||
rust_lib_prefix = 'lib'
|
||||
rust_lib_suffix = 'a'
|
||||
obj_suffix = 'o'
|
||||
import_lib_suffix = ''
|
||||
|
||||
if is_windows:
|
||||
dll_prefix = ''
|
||||
dll_suffix = '.dll'
|
||||
|
||||
rust_lib_prefix = ''
|
||||
rust_lib_suffix = 'lib'
|
||||
|
||||
# There aren't artifacts for mingw builds, so it's OK that the results
|
||||
# are inaccurate in that case.
|
||||
if c_compiler and c_compiler.type not in ('msvc', 'clang-cl'):
|
||||
import_lib_suffix = 'a'
|
||||
else:
|
||||
import_lib_suffix = 'lib'
|
||||
lib_prefix = ''
|
||||
lib_suffix = 'lib'
|
||||
obj_suffix = 'obj'
|
||||
elif is_darwin:
|
||||
dll_suffix = '.dylib'
|
||||
elif so_version:
|
||||
dll_suffix = '.so.%s' % so_version
|
||||
return namespace(
|
||||
dll=namespace(prefix='', suffix='.dll'),
|
||||
lib=namespace(prefix='lib', suffix='a'),
|
||||
import_lib=namespace(prefix='lib', suffix='a'),
|
||||
rust_lib=namespace(prefix='', suffix='lib'),
|
||||
obj=namespace(prefix='', suffix='o'),
|
||||
)
|
||||
|
||||
assert dll_suffix[0] == '.'
|
||||
assert obj_suffix[0] != '.'
|
||||
assert lib_suffix[0] != '.'
|
||||
assert rust_lib_suffix[0] != '.'
|
||||
return namespace(
|
||||
dll=namespace(prefix='', suffix='.dll'),
|
||||
lib=namespace(prefix='', suffix='lib'),
|
||||
import_lib=namespace(prefix='', suffix='lib'),
|
||||
rust_lib=namespace(prefix='', suffix='lib'),
|
||||
obj=namespace(prefix='', suffix='obj'),
|
||||
)
|
||||
|
||||
elif is_darwin:
|
||||
return namespace(
|
||||
dll=namespace(prefix='lib', suffix='.dylib'),
|
||||
lib=namespace(prefix='lib', suffix='a'),
|
||||
import_lib=namespace(prefix=None, suffix=''),
|
||||
rust_lib=namespace(prefix='lib', suffix='a'),
|
||||
obj=namespace(prefix='', suffix='o'),
|
||||
)
|
||||
elif so_version:
|
||||
so = '.so.%s' % so_version
|
||||
else:
|
||||
so = '.so'
|
||||
|
||||
return namespace(
|
||||
dll_prefix=dll_prefix,
|
||||
dll_suffix=dll_suffix,
|
||||
|
||||
lib_prefix=lib_prefix,
|
||||
lib_suffix=lib_suffix,
|
||||
|
||||
rust_lib_prefix=rust_lib_prefix,
|
||||
rust_lib_suffix=rust_lib_suffix,
|
||||
|
||||
obj_suffix=obj_suffix,
|
||||
import_lib_suffix=import_lib_suffix,
|
||||
dll=namespace(prefix='lib', suffix=so),
|
||||
lib=namespace(prefix='lib', suffix='a'),
|
||||
import_lib=namespace(prefix=None, suffix=''),
|
||||
rust_lib=namespace(prefix='lib', suffix='a'),
|
||||
obj=namespace(prefix='', suffix='o'),
|
||||
)
|
||||
|
||||
set_config('DLL_PREFIX', library_name_info.dll_prefix)
|
||||
set_config('DLL_SUFFIX', library_name_info.dll_suffix)
|
||||
set_config('LIB_PREFIX', library_name_info.lib_prefix)
|
||||
set_config('LIB_SUFFIX', library_name_info.lib_suffix)
|
||||
set_config('RUST_LIB_PREFIX', library_name_info.rust_lib_prefix)
|
||||
set_config('RUST_LIB_SUFFIX', library_name_info.rust_lib_suffix)
|
||||
set_config('OBJ_SUFFIX', library_name_info.obj_suffix)
|
||||
set_config('DLL_PREFIX', library_name_info.dll.prefix)
|
||||
set_config('DLL_SUFFIX', library_name_info.dll.suffix)
|
||||
set_config('LIB_PREFIX', library_name_info.lib.prefix)
|
||||
set_config('LIB_SUFFIX', library_name_info.lib.suffix)
|
||||
set_config('RUST_LIB_PREFIX', library_name_info.rust_lib.prefix)
|
||||
set_config('RUST_LIB_SUFFIX', library_name_info.rust_lib.suffix)
|
||||
set_config('OBJ_SUFFIX', library_name_info.obj.suffix)
|
||||
# Lots of compilation tests depend on this variable being present.
|
||||
add_old_configure_assignment('OBJ_SUFFIX', library_name_info.obj_suffix)
|
||||
set_config('IMPORT_LIB_SUFFIX', library_name_info.import_lib_suffix)
|
||||
set_define('MOZ_DLL_SUFFIX', depends(library_name_info)(lambda lni: '"%s"' % lni.dll_suffix))
|
||||
add_old_configure_assignment('OBJ_SUFFIX', library_name_info.obj.suffix)
|
||||
set_config('IMPORT_LIB_SUFFIX', library_name_info.import_lib.suffix)
|
||||
set_define('MOZ_DLL_SUFFIX', depends(library_name_info.dll.suffix)(lambda s: '"%s"' % s))
|
||||
|
||||
include(include_project_configure)
|
||||
|
||||
|
@ -708,8 +708,8 @@ with only_when(building_stylo_bindgen):
|
||||
libclang_choices = []
|
||||
if host.os == 'WINNT':
|
||||
libclang_choices.append('libclang.dll')
|
||||
libclang_choices.append('%sclang%s' % (library_name_info.dll_prefix,
|
||||
library_name_info.dll_suffix))
|
||||
libclang_choices.append('%sclang%s' % (library_name_info.dll.prefix,
|
||||
library_name_info.dll.suffix))
|
||||
if host.kernel == 'Linux':
|
||||
libclang_choices.append('libclang.so.1')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user