Move logic from "cbuild.sh" into portable "Makefile.configuration"

In "com.ibm.wala.cast.test", the "cbuild.sh" script is gone entirely.
Instead, "pom.xml" directs Maven to run "make" directly.  We still
have a "Makefile.configuration" file in this project, but this file is
now independent of where WALA is being built and of where Java is
installed.

In "com.ibm.wala.cast", a small "cbuild.sh" remains, to do some
special processing involving Visual Studio variables under Windows.
When not building under Windows, "cbuild.sh" now simply runs "make".
It may well be possible to hoist the special Windows stuff up into
this subproject's "pom.xml", or to change that "pom.xml" to run
"cbuild.sh" only when on Windows, and to run "make" directly
otherwise.  I don't know "pom.xml" stuff very well, though.  We still
have a "Makefile.configuration" file in this project, but this file is
now independent of where WALA is being built and of where Java is
installed.

The changes I've made in both "Makefile.configuration" files use GNU
make extensions.  I assume that's safe because "Makefile.definitions"
already relies on GNU make.
This commit is contained in:
Ben Liblit 2017-07-14 21:44:33 -07:00
parent 0aadaa7aa0
commit 433cd78f65
9 changed files with 19 additions and 92 deletions

View File

@ -1 +1,4 @@
CAST_TEST_BIN = /home/vagrant/WALA/com.ibm.wala.cast.test/target/classes/
SCRIPT_NAME := $(realpath $(lastword $(MAKEFILE_LIST)))
C_DIR := $(dir $(SCRIPTINAME))
CAST_TEST_DIR := $(realpath $(C_DIR)../..)/
CAST_TEST_BIN := $(CAST_TEST_DIR)target/classes/

View File

@ -1,17 +0,0 @@
#!/bin/bash
SCRIPT_NAME=`realpath $0`
C_DIR=`dirname $SCRIPT_NAME`
CAST_TEST_DIR=`realpath $C_DIR/../..`
pushd $CAST_TEST_DIR/harness-src/c
cat > $CAST_TEST_DIR/harness-src/c/Makefile.configuration <<EOF
CAST_TEST_BIN = $CAST_TEST_DIR/target/classes/
EOF
make
make main
popd

View File

@ -19,10 +19,12 @@
<execution>
<phase>compile</phase>
<configuration>
<executable>bash</executable>
<executable>make</executable>
<arguments>
<argument>${basedir}/harness-src/c/cbuild.sh</argument>
<argument>default</argument>
<argument>main</argument>
</arguments>
<workingDirectory>${basedir}/harness-src/c</workingDirectory>
</configuration>
<goals>
<goal>exec</goal>

View File

@ -23,6 +23,7 @@
<arguments>
<argument>${basedir}/source/c/cbuild.sh</argument>
</arguments>
<workingDirectory>${basedir}/source/c</workingDirectory>
</configuration>
<goals>
<goal>exec</goal>

View File

@ -1,3 +1,2 @@
Makefile.configuration
CAstWrapper.lib
CAstWrapper.exp

View File

@ -1,5 +1,10 @@
JAVA_SDK = /usr/lib/jvm/jdk1.8.0_111/
DOMO_AST_BIN = /home/vagrant/WALA/com.ibm.wala.cast/target/classes/
JAVAH_CLASS_PATH = :/home/vagrant/WALA/com.ibm.wala.cast/target/classes/
TRACE =
JNI_MD_DIR = linux
# configuration of installed Java SDK
JRE_DIR := $(shell java -XshowSettings:properties -version 2>&1 | sed -n 's/^ *java\.home = \(.*\)/\1/p')/
JAVA_SDK := $(realpath $(JRE_DIR)..)/
JNI_MD_DIR := $(notdir $(patsubst %/,%,$(dir $(wildcard $(JAVA_SDK)include/*/jni_md.h))))
# configuration of WALA build tree
CAST_DIR := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))../..)/
DOMO_AST_BIN := $(CAST_DIR)target/classes/
JAVAH_CLASS_PATH := :$(CAST_DIR)target/classes/
TRACE :=

View File

@ -1,18 +0,0 @@
#
# global configuration. adjust for your system.
#
# The root of the java SDK to use (must end in /)
JAVA_SDK = /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/
# Path .class files of the com.ibm.domo.ast Java code (must end in /)
DOMO_AST_BIN = /Users/dolby/git/WALA/com.ibm.wala.cast/bin/
# Extra stuff needed in the classpath of javah (must start with path separator)
JAVAH_CLASS_PATH =
# enable debugging flags
TRACE =
# low-level JNI path
JNI_MD_DIR = darwin

View File

@ -1,15 +0,0 @@
#
# global configuration. adjust for your system.
#
# The root of the java SDK to use (must end in /)
JAVA_SDK = /System/Library/Frameworks/JavaVM.framework/Home/
# Path .class files of the com.ibm.domo.ast Java code (must end in /)
DOMO_AST_BIN = <Workspace>/com.ibm.wala.cast/bin/
# Extra stuff needed in the classpath of javah (must start with path separator)
JAVAH_CLASS_PATH = :<Workspace>/com.ibm.wala.cast/bin/
# enable debugging flags
TRACE =

View File

@ -1,37 +1,5 @@
#!/bin/bash
SCRIPT=`realpath $0`
C_DIR=`dirname $SCRIPT`
CAST_DIR=`realpath $C_DIR/../..`
pushd $CAST_DIR/source/c
cat > /tmp/JrePath.java <<EOF
class JrePath {
public static void main(String[] args) {
System.out.println(System.getProperty("java.home"));
}
}
EOF
pushd /tmp
javac JrePath.java
JRE_DIR=`java JrePath`
JDK_DIR=`realpath $JRE_DIR/..`
popd
JNI_MD_H=`ls $JDK_DIR/include/*/jni_md.h`
JNI_MD_PATH=`dirname $JNI_MD_H`
JNI_MD_DIR=`basename $JNI_MD_PATH`
cat > $CAST_DIR/source/c/Makefile.configuration <<EOF
JAVA_SDK = $JDK_DIR/
DOMO_AST_BIN = $CAST_DIR/target/classes/
JAVAH_CLASS_PATH = :$CAST_DIR/target/classes/
TRACE =
JNI_MD_DIR = $JNI_MD_DIR
EOF
if (uname | grep -i "cygwin"); then
# This should be the default for most of cases;
# adjust to your environment if necessary.
@ -43,4 +11,3 @@ else
make
fi
popd