From 433cd78f657cc96edf833adf61a3c0073c78c263 Mon Sep 17 00:00:00 2001 From: Ben Liblit Date: Fri, 14 Jul 2017 21:44:33 -0700 Subject: [PATCH] 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. --- .../harness-src/c/Makefile.configuration | 5 ++- .../harness-src/c/cbuild.sh | 17 ---------- com.ibm.wala.cast.test/pom.xml | 6 ++-- com.ibm.wala.cast/pom.xml | 1 + com.ibm.wala.cast/source/c/.cvsignore | 1 - .../source/c/Makefile.configuration | 15 ++++++--- .../source/c/Makefile.configuration.mine | 18 ---------- .../source/c/Makefile.configuration.sample | 15 --------- com.ibm.wala.cast/source/c/cbuild.sh | 33 ------------------- 9 files changed, 19 insertions(+), 92 deletions(-) delete mode 100644 com.ibm.wala.cast.test/harness-src/c/cbuild.sh delete mode 100644 com.ibm.wala.cast/source/c/Makefile.configuration.mine delete mode 100644 com.ibm.wala.cast/source/c/Makefile.configuration.sample diff --git a/com.ibm.wala.cast.test/harness-src/c/Makefile.configuration b/com.ibm.wala.cast.test/harness-src/c/Makefile.configuration index d17251fe9..5f99ac62a 100644 --- a/com.ibm.wala.cast.test/harness-src/c/Makefile.configuration +++ b/com.ibm.wala.cast.test/harness-src/c/Makefile.configuration @@ -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/ diff --git a/com.ibm.wala.cast.test/harness-src/c/cbuild.sh b/com.ibm.wala.cast.test/harness-src/c/cbuild.sh deleted file mode 100644 index fce2f7136..000000000 --- a/com.ibm.wala.cast.test/harness-src/c/cbuild.sh +++ /dev/null @@ -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 < compile - bash + make - ${basedir}/harness-src/c/cbuild.sh + default + main + ${basedir}/harness-src/c exec diff --git a/com.ibm.wala.cast/pom.xml b/com.ibm.wala.cast/pom.xml index 696539d4b..edae15159 100644 --- a/com.ibm.wala.cast/pom.xml +++ b/com.ibm.wala.cast/pom.xml @@ -23,6 +23,7 @@ ${basedir}/source/c/cbuild.sh + ${basedir}/source/c exec diff --git a/com.ibm.wala.cast/source/c/.cvsignore b/com.ibm.wala.cast/source/c/.cvsignore index fca313ff1..7a72a8bb8 100644 --- a/com.ibm.wala.cast/source/c/.cvsignore +++ b/com.ibm.wala.cast/source/c/.cvsignore @@ -1,3 +1,2 @@ -Makefile.configuration CAstWrapper.lib CAstWrapper.exp diff --git a/com.ibm.wala.cast/source/c/Makefile.configuration b/com.ibm.wala.cast/source/c/Makefile.configuration index b8c7327a1..5e15390d9 100644 --- a/com.ibm.wala.cast/source/c/Makefile.configuration +++ b/com.ibm.wala.cast/source/c/Makefile.configuration @@ -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 := diff --git a/com.ibm.wala.cast/source/c/Makefile.configuration.mine b/com.ibm.wala.cast/source/c/Makefile.configuration.mine deleted file mode 100644 index ca4041fe9..000000000 --- a/com.ibm.wala.cast/source/c/Makefile.configuration.mine +++ /dev/null @@ -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 \ No newline at end of file diff --git a/com.ibm.wala.cast/source/c/Makefile.configuration.sample b/com.ibm.wala.cast/source/c/Makefile.configuration.sample deleted file mode 100644 index e77bf9a96..000000000 --- a/com.ibm.wala.cast/source/c/Makefile.configuration.sample +++ /dev/null @@ -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 = /com.ibm.wala.cast/bin/ - -# Extra stuff needed in the classpath of javah (must start with path separator) -JAVAH_CLASS_PATH = :/com.ibm.wala.cast/bin/ - -# enable debugging flags -TRACE = diff --git a/com.ibm.wala.cast/source/c/cbuild.sh b/com.ibm.wala.cast/source/c/cbuild.sh index fd6a5f7f0..f8bef900a 100644 --- a/com.ibm.wala.cast/source/c/cbuild.sh +++ b/com.ibm.wala.cast/source/c/cbuild.sh @@ -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 < $CAST_DIR/source/c/Makefile.configuration <