[gem5-dev] Change in gem5/gem5[develop]: util: Rework some checks in the m5 util scons to use Configure().

2020-12-10 Thread Gabe Black (Gerrit) via gem5-dev
Gabe Black has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/28180 )


Change subject: util: Rework some checks in the m5 util scons to use  
Configure().

..

util: Rework some checks in the m5 util scons to use Configure().

This is the official scons way to check for things on the system. This
adds two custom checks, one for java packages and one for pkg-config
packages. This change also adds a check for the org.junit java package
which is/will be used for a test for the java wrapper.

Change-Id: I59ca559f257a4c671e9b72a50b5635b5eb61ee69
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/28180
Tested-by: kokoro 
Reviewed-by: Bobby R. Bruce 
Maintainer: Gabe Black 
---
M util/m5/SConstruct
1 file changed, 38 insertions(+), 3 deletions(-)

Approvals:
  Bobby R. Bruce: Looks good to me, approved
  Gabe Black: Looks good to me, approved
  kokoro: Regressions pass



diff --git a/util/m5/SConstruct b/util/m5/SConstruct
index 6f1ca9f..5725f6c 100644
--- a/util/m5/SConstruct
+++ b/util/m5/SConstruct
@@ -91,12 +91,47 @@
 main['ENV']['PATH'] = os.environ['PATH']
 # Pass through terminal information to, for instance, enable color output.
 main['ENV']['TERM'] = os.environ['TERM']
+# Pass through the java CLASSPATH (if it exists) so we can find libraries.
+main['ENV']['CLASSPATH'] = os.environ.get('CLASSPATH', '')

 # Detect some dependencies of some forms of the m5 utility/library.
+def CheckForJavaPkg(context, pkg_name):
+context.Message('Checking for java package %s...' % pkg_name)
+result = main['HAVE_JAVA'] and \
+ context.TryAction('${JAVAC} ${JAVACFLAGS} ${SOURCES}',
+   'import %s.*;' % pkg_name, '.java')[0]
+context.Result(result)
+return result
+
+def CheckForPkgConfigPackage(context, package):
+context.Message('Checking for pkg-config package %s...' % package)
+result = main['HAVE_PKG_CONFIG'] and \
+ os.system('pkg-config --exists %s' % package) == 0
+context.Result(result)
+return result;
+
+conf = Configure(main, conf_dir=build_dir.Dir('.scons_config'),
+log_file=build_dir.File('scons_config.log'), custom_tests={
+'CheckForJavaPkg' : CheckForJavaPkg,
+'CheckForPkgConfigPackage' : CheckForPkgConfigPackage
+})
 main['HAVE_JAVA'] = all(key in main for key in ('JAVAC', 'JAR'))
-main['HAVE_PKG_CONFIG'] = main.Detect('pkg-config') is not None
-main['HAVE_LUA51'] = (main['HAVE_PKG_CONFIG'] and
-  os.system('pkg-config --exists lua51') == 0)
+if not main['HAVE_JAVA']:
+print('javac and/or jar not detected, not building java wrapper.')
+
+main['HAVE_JUNIT'] = conf.CheckForJavaPkg('org.junit')
+if main['HAVE_JAVA'] and not main['HAVE_JUNIT']:
+print('junit test framework not found, not build java wrapper test')
+
+main['HAVE_PKG_CONFIG'] = conf.CheckProg('pkg-config')
+if not main['HAVE_PKG_CONFIG']:
+print("pkg-config not detected, can't check for lua51.")
+
+main['HAVE_LUA51'] = conf.CheckForPkgConfigPackage('lua51')
+if not main['HAVE_LUA51']:
+print('lua 5.1 not detected, not building lua wrapper.')
+
+conf.Finish()

 # Put the sconsign file in the build dir so everything can be deleted at  
once.

 main.SConsignFile(os.path.join(abspath(build_dir), 'sconsign'))

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/28180
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: I59ca559f257a4c671e9b72a50b5635b5eb61ee69
Gerrit-Change-Number: 28180
Gerrit-PatchSet: 30
Gerrit-Owner: Gabe Black 
Gerrit-Reviewer: Bobby R. Bruce 
Gerrit-Reviewer: Earl Ou 
Gerrit-Reviewer: Gabe Black 
Gerrit-Reviewer: Giacomo Travaglini 
Gerrit-Reviewer: Jason Lowe-Power 
Gerrit-Reviewer: Yu-hsin Wang 
Gerrit-Reviewer: kokoro 
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]: util: Rework some checks in the m5 util scons to use Configure().

2020-04-25 Thread Gabe Black (Gerrit) via gem5-dev
Gabe Black has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/28180 )



Change subject: util: Rework some checks in the m5 util scons to use  
Configure().

..

util: Rework some checks in the m5 util scons to use Configure().

This is the official scons way to check for things on the system. This
adds two custom checks, one for java packages and one for pkg-config
packages. This change also adds a check for the org.junit java package
which is/will be used for a test for the java wrapper.

Change-Id: I59ca559f257a4c671e9b72a50b5635b5eb61ee69
---
M util/m5/SConstruct
1 file changed, 38 insertions(+), 3 deletions(-)



diff --git a/util/m5/SConstruct b/util/m5/SConstruct
index 41513d8..270b848 100644
--- a/util/m5/SConstruct
+++ b/util/m5/SConstruct
@@ -89,12 +89,47 @@
 main['ENV']['PATH'] = os.environ['PATH']
 # Pass through terminal information to, for instance, enable color output.
 main['ENV']['TERM'] = os.environ['TERM']
+# Pass through the java CLASSPATH (if it exists) so we can find libraries.
+main['ENV']['CLASSPATH'] = os.environ.get('CLASSPATH', '')

 # Detect some dependencies of some forms of the m5 utility/library.
+def CheckForJavaPkg(context, pkg_name):
+context.Message('Checking for java package %s...' % pkg_name)
+result = main['HAVE_JAVA'] and \
+ context.TryAction('${JAVAC} ${JAVACFLAGS} ${SOURCES}',
+   'import %s.*;' % pkg_name, '.java')[0]
+context.Result(result)
+return result
+
+def CheckForPkgConfigPackage(context, package):
+context.Message('Checking for pkg-config package %s...' % package)
+result = main['HAVE_PKG_CONFIG'] and \
+ os.system('pkg-config --exists %s' % package) == 0
+context.Result(result)
+return result;
+
+conf = Configure(main, conf_dir=build_dir.Dir('.scons_config'),
+log_file=build_dir.File('scons_config.log'), custom_tests={
+'CheckForJavaPkg' : CheckForJavaPkg,
+'CheckForPkgConfigPackage' : CheckForPkgConfigPackage
+})
 main['HAVE_JAVA'] = all(key in main for key in ('JAVAC', 'JAR'))
-main['HAVE_PKG_CONFIG'] = main.Detect('pkg-config') is not None
-main['HAVE_LUA51'] = (main['HAVE_PKG_CONFIG'] and
-  os.system('pkg-config --exists lua51') == 0)
+if not main['HAVE_JAVA']:
+print('javac and/or jar not detected, not building java wrapper.')
+
+main['HAVE_JUNIT'] = conf.CheckForJavaPkg('org.junit')
+if main['HAVE_JAVA'] and not main['HAVE_JUNIT']:
+print('junit test framework not found, not build java wrapper test')
+
+main['HAVE_PKG_CONFIG'] = conf.CheckProg('pkg-config')
+if not main['HAVE_PKG_CONFIG']:
+print("pkg-config not detected, can't check for lua51.")
+
+main['HAVE_LUA51'] = conf.CheckForPkgConfigPackage('lua51')
+if not main['HAVE_LUA51']:
+print('lua 5.1 not detected, not building lua wrapper.')
+
+conf.Finish()

 # Put the sconsign file in the build dir so everything can be deleted at  
once.

 main.SConsignFile(os.path.join(abspath(build_dir), 'sconsign'))

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/28180
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: I59ca559f257a4c671e9b72a50b5635b5eb61ee69
Gerrit-Change-Number: 28180
Gerrit-PatchSet: 1
Gerrit-Owner: 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