Skip to content

Eliminate duplicate rules in generated build.ninja caused by PR #873 #1012

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 26, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions lib/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,12 @@ class Library(Product):
def __init__(self, name):
Product.__init__(self, name)

def generate(self, flags):
generated = Product.generate(self)
objects = []
for phase in self.phases:
objects += phase.objects
def generate(self, flags, objects = []):
generated = ""
if len(objects) == 0:
generated = Product.generate(self)
for phase in self.phases:
objects += phase.objects

product_flags = " ".join(flags)
if self.LDFLAGS is not None:
Expand All @@ -106,23 +107,23 @@ def generate(self, flags):

"""

return generated
return objects, generated


class DynamicLibrary(Library):
def __init__(self, name):
Library.__init__(self, name)
self.name = name

def generate(self):
def generate(self, objects = []):
self.rule = "Link"
self.product_name = Configuration.current.target.dynamic_library_prefix + self.name + Configuration.current.target.dynamic_library_suffix
if Configuration.current.target.sdk == OSType.Linux or Configuration.current.target.sdk == OSType.FreeBSD:
self.conformance_begin = '${SDKROOT}/lib/swift/${OS}/${ARCH}/swift_begin.o'
self.conformance_end = '${SDKROOT}/lib/swift/${OS}/${ARCH}/swift_end.o'
return Library.generate(self, ["-shared", "-Wl,-soname," + self.product_name, "-Wl,--no-undefined"])
return Library.generate(self, ["-shared", "-Wl,-soname," + self.product_name, "-Wl,--no-undefined"], objects)
else:
return Library.generate(self, ["-shared"])
return Library.generate(self, ["-shared"], objects)


class Framework(Product):
Expand Down Expand Up @@ -189,7 +190,9 @@ def __init__(self, name):
DynamicLibrary.__init__(self, name)

def generate(self):
return StaticLibrary.generate(self) + DynamicLibrary.generate(self)
objects, generatedForStatic = StaticLibrary.generate(self)
_, generatedForDynamic = DynamicLibrary.generate(self, objects)
return generatedForStatic + generatedForDynamic

class Executable(Product):
def __init__(self, name):
Expand Down