[gem5-dev] Change in gem5/gem5[develop]: scons: Add a priority field to the SourceLib construct.

2022-03-31 Thread Gabe Black (Gerrit) via gem5-dev
Gabe Black has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/58350 )


Change subject: scons: Add a priority field to the SourceLib construct.
..

scons: Add a priority field to the SourceLib construct.

This helps specify ordering for libraries that need it. Libraries with
a higher priority will be sorted earlier in the list, which can be
necessary when working with static libraries/archives.

The default value for "priority" is zero. It's only really necessary
to ensure relative ordering of particular pairings of libraries, so
it should be ok to use an absolute integer value for this. If you
need to order relative to a library, there is a good chance you're
adding it, or the place it's added is well known and you can easily
find its priority value. It's also unlikely that there would be a
complex series of interactions between libraries that would make a
more complicated system warranted.

Change-Id: Ie94a35e6563c07f8d462a4a52d0173ea3cf4f8de
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/58350
Maintainer: Gabe Black 
Reviewed-by: Jui-min Lee 
Tested-by: kokoro 
Reviewed-by: Yu-hsin Wang 
---
M src/SConscript
1 file changed, 32 insertions(+), 1 deletion(-)

Approvals:
  Jui-min Lee: Looks good to me, but someone else must approve
  Yu-hsin Wang: Looks good to me, approved
  Gabe Black: Looks good to me, approved
  kokoro: Regressions pass




diff --git a/src/SConscript b/src/SConscript
index 746d3f1..a7b6cec 100644
--- a/src/SConscript
+++ b/src/SConscript
@@ -76,7 +76,9 @@
 pass

 class SourceLib(SourceItem):
-pass
+def __init__(self, *args, **kwargs):
+self.priority = kwargs.pop('priority', 0)
+super().__init__(*args, **kwargs)

 build_tools = Dir('#build_tools')

@@ -388,6 +390,8 @@
 env['BUILDDIR'], self.path(env).dir.abspath)

 libs = self.libs(env)
+# Higher priority libraries should be earlier in the list.
+libs.sort(key=lambda l: l.priority, reverse=True)
 if libs:
 env.Append(LIBS=list(lib.source for lib in libs))


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/58350
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Ie94a35e6563c07f8d462a4a52d0173ea3cf4f8de
Gerrit-Change-Number: 58350
Gerrit-PatchSet: 3
Gerrit-Owner: Gabe Black 
Gerrit-Reviewer: Andreas Sandberg 
Gerrit-Reviewer: Gabe Black 
Gerrit-Reviewer: Jui-min Lee 
Gerrit-Reviewer: Yu-hsin Wang 
Gerrit-Reviewer: kokoro 
Gerrit-CC: Gabe Black 
Gerrit-MessageType: merged
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

[gem5-dev] Change in gem5/gem5[develop]: scons: Add a priority field to the SourceLib construct.

2022-03-30 Thread Gabe Black (Gerrit) via gem5-dev
Gabe Black has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/58350 )



Change subject: scons: Add a priority field to the SourceLib construct.
..

scons: Add a priority field to the SourceLib construct.

This helps specify ordering for libraries that need it. Libraries with
a higher priority will be sorted earlier in the list, which can be
necessary when working with static libraries/archives.

The default value for "priority" is zero. It's only really necessary
to ensure relative ordering of particular pairings of libraries, so
it should be ok to use an absolute integer value for this. If you
need to order relative to a library, there is a good chance you're
adding it, or the place it's added is well known and you can easily
find its priority value. It's also unlikely that there would be a
complex series of interactions between libraries that would make a
more complicated system warranted.

Change-Id: Ie94a35e6563c07f8d462a4a52d0173ea3cf4f8de
---
M src/SConscript
1 file changed, 27 insertions(+), 1 deletion(-)



diff --git a/src/SConscript b/src/SConscript
index c1b00f0..b950d81 100644
--- a/src/SConscript
+++ b/src/SConscript
@@ -75,7 +75,9 @@
 pass

 class SourceLib(SourceItem):
-pass
+def __init__(self, *args, **kwargs):
+self.priority = kwargs.pop('priority', 0)
+super().__init__(*args, **kwargs)

 build_tools = Dir('#build_tools')

@@ -392,6 +394,8 @@
 env['BUILDDIR'], self.path(env).dir.abspath)

 libs = self.libs(env)
+# Higher priority libraries should be earlier in the list.
+libs.sort(key=lambda l: l.priority, reverse=True)
 if libs:
 env.Append(LIBS=list(lib.source for lib in libs))


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/58350
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Ie94a35e6563c07f8d462a4a52d0173ea3cf4f8de
Gerrit-Change-Number: 58350
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black 
Gerrit-CC: Gabe Black 
Gerrit-MessageType: newchange
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s