mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #186 from screamerbg/library-build-fix
Fix the differences between how projects and libraries are built
commit
9bbc532f4f
|
@ -300,26 +300,43 @@ def build_library(src_paths, build_path, target, toolchain_name,
|
||||||
toolchain.info("Building library %s (%s, %s)" % (name, target.name, toolchain_name))
|
toolchain.info("Building library %s (%s, %s)" % (name, target.name, toolchain_name))
|
||||||
|
|
||||||
# Scan Resources
|
# Scan Resources
|
||||||
resources = []
|
resources = None
|
||||||
for src_path in src_paths:
|
for path in src_paths:
|
||||||
resources.append(toolchain.scan_resources(src_path))
|
# Scan resources
|
||||||
|
resource = toolchain.scan_resources(path)
|
||||||
|
|
||||||
|
# Copy headers, objects and static libraries - all files needed for static lib
|
||||||
|
toolchain.copy_files(resource.headers, build_path, rel_path=resource.base_path)
|
||||||
|
toolchain.copy_files(resource.objects, build_path, rel_path=resource.base_path)
|
||||||
|
toolchain.copy_files(resource.libraries, build_path, rel_path=resource.base_path)
|
||||||
|
if resource.linker_script:
|
||||||
|
toolchain.copy_files(resource.linker_script, build_path, rel_path=resource.base_path)
|
||||||
|
|
||||||
|
# Extend resources collection
|
||||||
|
if not resources:
|
||||||
|
resources = resource
|
||||||
|
else:
|
||||||
|
resources.add(resource)
|
||||||
|
|
||||||
|
# We need to add if necessary additional include directories
|
||||||
|
if inc_dirs:
|
||||||
|
if type(inc_dirs) == ListType:
|
||||||
|
resources.inc_dirs.extend(inc_dirs)
|
||||||
|
else:
|
||||||
|
resources.inc_dirs.append(inc_dirs)
|
||||||
|
|
||||||
# Add extra include directories / files which are required by library
|
# Add extra include directories / files which are required by library
|
||||||
# This files usually are not in the same directory as source files so
|
# This files usually are not in the same directory as source files so
|
||||||
# previous scan will not include them
|
# previous scan will not include them
|
||||||
if inc_dirs_ext is not None:
|
if inc_dirs_ext is not None:
|
||||||
for inc_ext in inc_dirs_ext:
|
for inc_ext in inc_dirs_ext:
|
||||||
resources.append(toolchain.scan_resources(inc_ext))
|
resources.add(toolchain.scan_resources(inc_ext))
|
||||||
|
|
||||||
# Dependencies Include Paths
|
# Dependencies Include Paths
|
||||||
dependencies_include_dir = []
|
|
||||||
if dependencies_paths is not None:
|
if dependencies_paths is not None:
|
||||||
for path in dependencies_paths:
|
for path in dependencies_paths:
|
||||||
lib_resources = toolchain.scan_resources(path)
|
lib_resources = toolchain.scan_resources(path)
|
||||||
dependencies_include_dir.extend(lib_resources.inc_dirs)
|
resources.inc_dirs.extend(lib_resources.inc_dirs)
|
||||||
|
|
||||||
if inc_dirs:
|
|
||||||
dependencies_include_dir.extend(inc_dirs)
|
|
||||||
|
|
||||||
if archive:
|
if archive:
|
||||||
# Use temp path when building archive
|
# Use temp path when building archive
|
||||||
|
@ -330,25 +347,19 @@ def build_library(src_paths, build_path, target, toolchain_name,
|
||||||
|
|
||||||
# Handle configuration
|
# Handle configuration
|
||||||
config = Config(target)
|
config = Config(target)
|
||||||
|
# Update the configuration with any .json files found while scanning
|
||||||
# Copy headers, objects and static libraries
|
config.add_config_files(resources.json_files)
|
||||||
for resource in resources:
|
# And add the configuration macros to the toolchain
|
||||||
toolchain.copy_files(resource.headers, build_path, rel_path=resource.base_path)
|
|
||||||
toolchain.copy_files(resource.objects, build_path, rel_path=resource.base_path)
|
|
||||||
toolchain.copy_files(resource.libraries, build_path, rel_path=resource.base_path)
|
|
||||||
if resource.linker_script:
|
|
||||||
toolchain.copy_files(resource.linker_script, build_path, rel_path=resource.base_path)
|
|
||||||
config.add_config_files(resource.json_files)
|
|
||||||
|
|
||||||
toolchain.add_macros(config.get_config_data_macros())
|
toolchain.add_macros(config.get_config_data_macros())
|
||||||
|
|
||||||
# Compile Sources
|
# Compile Sources
|
||||||
objects = []
|
for path in src_paths:
|
||||||
for resource in resources:
|
src = toolchain.scan_resources(path)
|
||||||
objects.extend(toolchain.compile_sources(resource, abspath(tmp_path), dependencies_include_dir))
|
objects = toolchain.compile_sources(src, abspath(tmp_path), resources.inc_dirs)
|
||||||
|
resources.objects.extend(objects)
|
||||||
|
|
||||||
if archive:
|
if archive:
|
||||||
needed_update = toolchain.build_library(objects, build_path, name)
|
needed_update = toolchain.build_library(resources.objects, build_path, name)
|
||||||
else:
|
else:
|
||||||
needed_update = True
|
needed_update = True
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue