Skip to content

Commit

Permalink
simplify staged frontend starter scripts (#4341)
Browse files Browse the repository at this point in the history
* simplify staged frontend starter scripts

Simply invoke the staged x2cpg.sh script without defining additional
JVM properties. If we want to define those by default, it should
rather be done in `src/universal/x2cpg.sh`

N.b. we can't just symlink to the `target/universal/stage/bin/x2cpg.sh`
because of the `SCRIPT_ABS_PATH` handling - we wouldn't be able to
invoke the frontend from different directories any longer.

For now only c2cpg to gather feedback, if it's to your liking I'll
apply the same to all frontends.

* make other frontends setup more similar

there's still some differences, at the same time I'm afraid to break
things downstream...
  • Loading branch information
mpollmeier authored Mar 26, 2024
1 parent cea9697 commit 7947bee
Show file tree
Hide file tree
Showing 15 changed files with 115 additions and 8 deletions.
2 changes: 1 addition & 1 deletion joern-cli/frontends/c2cpg/c2cpg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
SCRIPT_ABS_PATH=$(readlink -f "$0")
SCRIPT_ABS_DIR=$(dirname $SCRIPT_ABS_PATH)

$SCRIPT_ABS_DIR/target/universal/stage/bin/c2cpg -J-XX:+UseG1GC -J-XX:CompressedClassSpaceSize=128m -J-XX:+UseStringDeduplication $@
$SCRIPT_ABS_DIR/target/universal/stage/bin/c2cpg.sh $@
2 changes: 1 addition & 1 deletion joern-cli/frontends/csharpsrc2cpg/csharpsrc2cpg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
SCRIPT_ABS_PATH=$(readlink -f "$0")
SCRIPT_ABS_DIR=$(dirname $SCRIPT_ABS_PATH)

$SCRIPT_ABS_DIR/target/universal/stage/bin/csharpsrc2cpg -J-XX:+UseG1GC -J-XX:CompressedClassSpaceSize=128m -J-XX:+UseStringDeduplication $@
$SCRIPT_ABS_DIR/target/universal/stage/bin/csharpsrc2cpg $@
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env sh

if [ "$(uname -s)" = "Darwin" ]; then
SCRIPT_ABS_PATH="$0"
else
SCRIPT_ABS_PATH=$(readlink -f "$0")
fi

SCRIPT_ABS_DIR=$(dirname "$0")
SCRIPT="$SCRIPT_ABS_DIR"/csharpsrc2cpg

if [ ! -f "$SCRIPT" ]; then
echo "Unable to find $SCRIPT, have you created the distribution?"
exit 1
fi

$SCRIPT -J-XX:+UseG1GC -J-XX:CompressedClassSpaceSize=128m -Dlog4j.configurationFile="$SCRIPT_ABS_DIR"/conf/log4j2.xml "$@"
6 changes: 6 additions & 0 deletions joern-cli/frontends/ghidra2cpg/ghidra2cpg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env sh

SCRIPT_ABS_PATH=$(readlink -f "$0")
SCRIPT_ABS_DIR=$(dirname $SCRIPT_ABS_PATH)

$SCRIPT_ABS_DIR/target/universal/stage/bin/ghidra2cpg.sh $@
17 changes: 17 additions & 0 deletions joern-cli/frontends/ghidra2cpg/src/universal/bin/ghidra2cpg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env sh

if [ "$(uname -s)" = "Darwin" ]; then
SCRIPT_ABS_PATH="$0"
else
SCRIPT_ABS_PATH=$(readlink -f "$0")
fi

SCRIPT_ABS_DIR=$(dirname "$0")
SCRIPT="$SCRIPT_ABS_DIR"/ghidra2cpg

if [ ! -f "$SCRIPT" ]; then
echo "Unable to find $SCRIPT, have you created the distribution?"
exit 1
fi

$SCRIPT -J-XX:+UseG1GC -J-XX:CompressedClassSpaceSize=128m -Dlog4j.configurationFile="$SCRIPT_ABS_DIR"/conf/log4j2.xml "$@"
2 changes: 1 addition & 1 deletion joern-cli/frontends/gosrc2cpg/gosrc2cpg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
SCRIPT_ABS_PATH=$(readlink -f "$0")
SCRIPT_ABS_DIR=$(dirname $SCRIPT_ABS_PATH)

$SCRIPT_ABS_DIR/target/universal/stage/bin/gosrc2cpg -J-XX:+UseG1GC -J-XX:CompressedClassSpaceSize=128m -J-XX:+UseStringDeduplication $@
$SCRIPT_ABS_DIR/target/universal/stage/bin/gosrc2cpg $@
1 change: 0 additions & 1 deletion joern-cli/frontends/javasrc2cpg/javasrc2cpg.sh

This file was deleted.

6 changes: 6 additions & 0 deletions joern-cli/frontends/javasrc2cpg/javasrc2cpg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env sh

SCRIPT_ABS_PATH=$(readlink -f "$0")
SCRIPT_ABS_DIR=$(dirname $SCRIPT_ABS_PATH)

$SCRIPT_ABS_DIR/target/universal/stage/bin/javasrc2cpg.sh $@
17 changes: 17 additions & 0 deletions joern-cli/frontends/javasrc2cpg/src/universal/bin/javasrc2cpg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env sh

if [ "$(uname -s)" = "Darwin" ]; then
SCRIPT_ABS_PATH="$0"
else
SCRIPT_ABS_PATH=$(readlink -f "$0")
fi

SCRIPT_ABS_DIR=$(dirname "$0")
SCRIPT="$SCRIPT_ABS_DIR"/javasrc2cpg

if [ ! -f "$SCRIPT" ]; then
echo "Unable to find $SCRIPT, have you created the distribution?"
exit 1
fi

$SCRIPT -J-XX:+UseG1GC -J-XX:CompressedClassSpaceSize=128m -Dlog4j.configurationFile="$SCRIPT_ABS_DIR"/conf/log4j2.xml "$@"
6 changes: 6 additions & 0 deletions joern-cli/frontends/jimple2cpg/jimple2cpg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env sh

SCRIPT_ABS_PATH=$(readlink -f "$0")
SCRIPT_ABS_DIR=$(dirname $SCRIPT_ABS_PATH)

$SCRIPT_ABS_DIR/target/universal/stage/bin/jimple2cpg.sh $@
17 changes: 17 additions & 0 deletions joern-cli/frontends/jimple2cpg/src/universal/bin/jimple2cpg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env sh

if [ "$(uname -s)" = "Darwin" ]; then
SCRIPT_ABS_PATH="$0"
else
SCRIPT_ABS_PATH=$(readlink -f "$0")
fi

SCRIPT_ABS_DIR=$(dirname "$0")
SCRIPT="$SCRIPT_ABS_DIR"/jimple2cpg

if [ ! -f "$SCRIPT" ]; then
echo "Unable to find $SCRIPT, have you created the distribution?"
exit 1
fi

$SCRIPT -J-XX:+UseG1GC -J-XX:CompressedClassSpaceSize=128m -Dlog4j.configurationFile="$SCRIPT_ABS_DIR"/conf/log4j2.xml "$@"
2 changes: 1 addition & 1 deletion joern-cli/frontends/jssrc2cpg/jssrc2cpg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
SCRIPT_ABS_PATH=$(readlink -f "$0")
SCRIPT_ABS_DIR=$(dirname $SCRIPT_ABS_PATH)

$SCRIPT_ABS_DIR/target/universal/stage/bin/jssrc2cpg -J-XX:+UseG1GC -J-XX:CompressedClassSpaceSize=128m -J-XX:+UseStringDeduplication $@
$SCRIPT_ABS_DIR/target/universal/stage/bin/jssrc2cpg.sh $@
1 change: 0 additions & 1 deletion joern-cli/frontends/php2cpg/php2cpg.sh

This file was deleted.

6 changes: 6 additions & 0 deletions joern-cli/frontends/php2cpg/php2cpg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env sh

SCRIPT_ABS_PATH=$(readlink -f "$0")
SCRIPT_ABS_DIR=$(dirname $SCRIPT_ABS_PATH)

$SCRIPT_ABS_DIR/target/universal/stage/bin/php2cpg.sh $@
17 changes: 17 additions & 0 deletions joern-cli/frontends/php2cpg/src/universal/bin/php2cpg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env sh

if [ "$(uname -s)" = "Darwin" ]; then
SCRIPT_ABS_PATH="$0"
else
SCRIPT_ABS_PATH=$(readlink -f "$0")
fi

SCRIPT_ABS_DIR=$(dirname "$0")
SCRIPT="$SCRIPT_ABS_DIR"/php2cpg

if [ ! -f "$SCRIPT" ]; then
echo "Unable to find $SCRIPT, have you created the distribution?"
exit 1
fi

$SCRIPT -J-XX:+UseG1GC -J-XX:CompressedClassSpaceSize=128m -Dlog4j.configurationFile="$SCRIPT_ABS_DIR"/conf/log4j2.xml "$@"
2 changes: 1 addition & 1 deletion joern-cli/frontends/rubysrc2cpg/rubysrc2cpg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
SCRIPT_ABS_PATH=$(readlink -f "$0")
SCRIPT_ABS_DIR=$(dirname $SCRIPT_ABS_PATH)

$SCRIPT_ABS_DIR/target/universal/stage/bin/rubysrc2cpg -J-XX:+UseG1GC -J-XX:CompressedClassSpaceSize=128m -J-XX:+UseStringDeduplication "$@"
$SCRIPT_ABS_DIR/target/universal/stage/bin/rubysrc2cpg "$@"
2 changes: 1 addition & 1 deletion joern-cli/frontends/swiftsrc2cpg/swiftsrc2cpg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
SCRIPT_ABS_PATH=$(readlink -f "$0")
SCRIPT_ABS_DIR=$(dirname $SCRIPT_ABS_PATH)

$SCRIPT_ABS_DIR/target/universal/stage/bin/swiftsrc2cpg -J-XX:+UseG1GC -J-XX:CompressedClassSpaceSize=128m -J-XX:+UseStringDeduplication $@
$SCRIPT_ABS_DIR/target/universal/stage/bin/swiftsrc2cpg $@

0 comments on commit 7947bee

Please sign in to comment.