[gem5-dev] Change in gem5/gem5[develop]: util, scons: Detect java and lua51 in the m5 utility scons files.

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


Change subject: util,scons: Detect java and lua51 in the m5 utility scons  
files.

..

util,scons: Detect java and lua51 in the m5 utility scons files.

These will enable or disable the java and lua51 m5 op wrappers depending
on whether the required tools are available on the host system.

Change-Id: I2b11a13a39b2dfd5d45a9ed57702d2e225ef7d2e
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/27214
Maintainer: Bobby R. Bruce 
Tested-by: kokoro 
Reviewed-by: Daniel Carvalho 
---
M util/m5/SConstruct
M util/m5/src/SConscript
2 files changed, 30 insertions(+), 23 deletions(-)

Approvals:
  Daniel Carvalho: Looks good to me, approved
  Bobby R. Bruce: Looks good to me, approved
  kokoro: Regressions pass



diff --git a/util/m5/SConstruct b/util/m5/SConstruct
index ab34112..c1cf193 100644
--- a/util/m5/SConstruct
+++ b/util/m5/SConstruct
@@ -51,6 +51,12 @@
 main['LD'] = '${CROSS_COMPILE}ld'
 main['AR'] = '${CROSS_COMPILE}ar'

+# Detect some dependencies of some forms of the m5 utility/library.
+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)
+
 # Put the sconsign file in the build dir so everything can be deleted at  
once.

 main.SConsignFile(os.path.join(abspath(build_dir), 'sconsign'))
 # Use soft links instead of hard links when setting up a build directory.
diff --git a/util/m5/src/SConscript b/util/m5/src/SConscript
index a3f7a8f..464da64 100644
--- a/util/m5/src/SConscript
+++ b/util/m5/src/SConscript
@@ -51,28 +51,29 @@
 # The shared version of the m5 op call sights, used by mutliple targets  
below.

 m5op_shared = env.SharedObject(m5op)

-
-#
-# A wrapper to make the m5 ops available in Java through the JNI.
-#
-java_env = env.Clone()
-# SCons provides Java and JavaH builders, but the JavaH builder assumes  
that
-# the javah tool exists. Java has dropped that tool in favor of a -h  
option on
-# javac which the Java builder doesn't know how to use. To get around  
this, we

-# set up our own builder which does the "right thing" here.
-java_env.Command([ 'jni_gem5Op.h', 'gem5OpJni.jar' ], 'jni/gem5Op.java',
- [ '${JAVAC} ${JAVACFLAGS} -d ${CWD} ${SOURCES} -h  
${CWD} ',

-   '${JAR} cvf ${TARGETS[1]} ${JNI_DIR}/*.class' ],
- JNI_DIR=Dir('jni'), CWD=Dir('.'))
-# Set include paths to the C headers from the JDK which scons found for us.
-java_env.Append(CPPPATH='${JAVAINCLUDES}')
-java_env.SharedLibrary('gem5OpJni', [ jni, m5op_shared ])
+if env['HAVE_JAVA']:
+#
+# A wrapper to make the m5 ops available in Java through the JNI.
+#
+java_env = env.Clone()
+# SCons provides Java and JavaH builders, but the JavaH builder assumes
+# that the javah tool exists. Java has dropped that tool in favor of a  
-h
+# option on javac which the Java builder doesn't know how to use. To  
get
+# around this, we set up our own builder which does the "right thing"  
here.
+java_env.Command([ 'jni_gem5Op.h', 'gem5OpJni.jar'  
], 'jni/gem5Op.java',
+ [ '${JAVAC} ${JAVACFLAGS} -d ${CWD} ${SOURCES} -h  
${CWD}',

+   '${JAR} cvf ${TARGETS[1]} ${JNI_DIR}/*.class' ],
+ JNI_DIR=Dir('jni'), CWD=Dir('.'))
+# Set include paths to the C headers from the JDK which scons found  
for us.

+java_env.Append(CPPPATH='${JAVAINCLUDES}')
+java_env.SharedLibrary('gem5OpJni', [ jni, m5op_shared ])


-#
-# A wrapper to make the m5 ops available in lua version 5.1.
-#
-lua_env = env.Clone()
-# Extract the include paths needed for lua51 using pkg-config.
-lua_env.ParseConfig('pkg-config --cflags lua51')
-lua_env.SharedLibrary('gem5OpLua', [ lua, m5op_shared, m5_mmap ])
+if env['HAVE_LUA51']:
+#
+# A wrapper to make the m5 ops available in lua version 5.1.
+#
+lua_env = env.Clone()
+# Extract the include paths needed for lua51 using pkg-config.
+lua_env.ParseConfig('pkg-config --cflags lua51')
+lua_env.SharedLibrary('gem5OpLua', [ lua, m5op_shared, m5_mmap ])

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/27214
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: I2b11a13a39b2dfd5d45a9ed57702d2e225ef7d2e
Gerrit-Change-Number: 27214
Gerrit-PatchSet: 7
Gerrit-Owner: Gabe Black 
Gerrit-Reviewer: Bobby R. Bruce 
Gerrit-Reviewer: Daniel Carvalho 
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: 

[gem5-dev] Change in gem5/gem5[develop]: util, scons: Detect java and lua51 in the m5 utility scons files.

2020-03-27 Thread Gabe Black (Gerrit)
Gabe Black has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/27214 )



Change subject: util,scons: Detect java and lua51 in the m5 utility scons  
files.

..

util,scons: Detect java and lua51 in the m5 utility scons files.

These will enable or disable the java and lua51 m5 op wrappers depending
on whether the required tools are available on the host system.

Change-Id: I2b11a13a39b2dfd5d45a9ed57702d2e225ef7d2e
---
M util/m5/SConstruct
M util/m5/src/SConscript
2 files changed, 30 insertions(+), 23 deletions(-)



diff --git a/util/m5/SConstruct b/util/m5/SConstruct
index d38b39e..8e2b4c1 100644
--- a/util/m5/SConstruct
+++ b/util/m5/SConstruct
@@ -52,6 +52,12 @@
 main['LD'] = '${CROSS_COMPILE}ld'
 main['AR'] = '${CROSS_COMPILE}ar'

+# Detect some dependencies of some forms of the m5 utility/library.
+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)
+
 # Put the sconsign file in the build dir so everything can be deleted at  
once.

 main.SConsignFile(os.path.join(abspath(build_dir), 'sconsign'))
 # Use soft links instead of hard links when setting up a build directory.
diff --git a/util/m5/src/SConscript b/util/m5/src/SConscript
index 09c7fca..cb82775 100644
--- a/util/m5/src/SConscript
+++ b/util/m5/src/SConscript
@@ -49,28 +49,29 @@
 # The shared version of the m5 op call sights, used by mutliple targets  
below.

 m5op_shared = env.SharedObject(m5op)

-
-#
-# A wrapper to make the m5 ops available in Java through the JNI.
-#
-java_env = env.Clone()
-# SCons provides Java and JavaH builders, but the JavaH builder assumes  
that
-# the javah tool exists. Java has dropped that tool in favor of a -h  
option on
-# javac which the Java builder doesn't know how to use. To get around  
this, we

-# set up our own builder which does the "right thing" here.
-java_env.Command([ 'jni_gem5Op.h', 'gem5OpJni.jar' ], 'jni/gem5Op.java',
- [ '${JAVAC} ${JAVACFLAGS} -d ${CWD} ${SOURCES} -h  
${CWD} ',

-   '${JAR} cvf ${TARGETS[1]} ${JNI_DIR}/*.class' ],
- JNI_DIR=Dir('jni'), CWD=Dir('.'))
-# Set include paths to the C headers from the JDK which scons found for us.
-java_env.Append(CPPPATH='${JAVAINCLUDES}')
-java_env.SharedLibrary('gem5OpJni', [ jni, m5op_shared ])
+if env['HAVE_JAVA']:
+#
+# A wrapper to make the m5 ops available in Java through the JNI.
+#
+java_env = env.Clone()
+# SCons provides Java and JavaH builders, but the JavaH builder assumes
+# that the javah tool exists. Java has dropped that tool in favor of a  
-h
+# option on javac which the Java builder doesn't know how to use. To  
get
+# around this, we set up our own builder which does the "right thing"  
here.
+java_env.Command([ 'jni_gem5Op.h', 'gem5OpJni.jar'  
], 'jni/gem5Op.java',
+ [ '${JAVAC} ${JAVACFLAGS} -d ${CWD} ${SOURCES} -h  
${CWD}',

+   '${JAR} cvf ${TARGETS[1]} ${JNI_DIR}/*.class' ],
+ JNI_DIR=Dir('jni'), CWD=Dir('.'))
+# Set include paths to the C headers from the JDK which scons found  
for us.

+java_env.Append(CPPPATH='${JAVAINCLUDES}')
+java_env.SharedLibrary('gem5OpJni', [ jni, m5op_shared ])


-#
-# A wrapper to make the m5 ops available in lua version 5.1.
-#
-lua_env = env.Clone()
-# Extract the include paths needed for lua51 using pkg-config.
-lua_env.ParseConfig('pkg-config --cflags lua51')
-lua_env.SharedLibrary('gem5OpLua', [ lua, m5op_shared, m5_mmap ])
+if env['HAVE_LUA51']:
+#
+# A wrapper to make the m5 ops available in lua version 5.1.
+#
+lua_env = env.Clone()
+# Extract the include paths needed for lua51 using pkg-config.
+lua_env.ParseConfig('pkg-config --cflags lua51')
+lua_env.SharedLibrary('gem5OpLua', [ lua, m5op_shared, m5_mmap ])

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/27214
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: I2b11a13a39b2dfd5d45a9ed57702d2e225ef7d2e
Gerrit-Change-Number: 27214
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black 
Gerrit-MessageType: newchange
___
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev