Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Materialize kotlin_home target as part of buckw so the build works with oss buck #915

Merged
merged 1 commit into from
Jul 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 23 additions & 10 deletions buckw
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
link=`expr "$ls" : ".*-> \(.*\)$"`
if expr "$link" : "/.*" > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
Expand Down Expand Up @@ -51,14 +51,14 @@ success ( ) {
}

ensure ( ) {
command -v $1 >/dev/null 2>&1 || die "ERROR: '$1' could be found in your PATH. Please install $1. $2"
command -v $1 >/dev/null 2>&1 || die "ERROR: "$1" could be found in your PATH. Please install $1. $2"
}

jsonq() {
python -c "import sys,json; obj=json.load(sys.stdin); print($1)"
}

ensure python 'https://www.python.org'
ensure python "https://www.python.org"
INSTALLED_WATCHMAN=`command -v watchman`

OKBUCK_SUCCESS="$SCRIPT_DIR/build/okbuck.success"
Expand All @@ -68,9 +68,11 @@ WATCHMAN_TIMEOUT=10
WATCHMAN_FAILED="WATCHMAN FAILED"
BUCK_BINARY_DIR="$OKBUCK_DIR/workspace/buck_binary"

export JAVA_OPTS="${JAVA_OPTS:-\"-Xmx1g\" \"-Xms1g\"}"

# Timeout a call and exit early. This can be called via timeout <time> <command>.
timeout( ) {
perl -e 'alarm shift; exec @ARGV' "$@";
perl -e "alarm shift; exec @ARGV" "$@";
}

ensureWatch ( ) {
Expand Down Expand Up @@ -168,7 +170,7 @@ watchmanWorkflow ( ) {

if [[ $NUM_CHANGES -gt 0 ]]; then
info "CHANGES DETECTED IN:"
echo $CHANGES $NEW_OR_DELETED_SOURCE_ROOTS | tr ' ' '\n' | head -n $MAX_DISPLAY_CHANGES
echo $CHANGES $NEW_OR_DELETED_SOURCE_ROOTS | tr " " "\n" | head -n $MAX_DISPLAY_CHANGES
if [[ $NUM_CHANGES -gt $MAX_DISPLAY_CHANGES ]]; then
DIFF=`expr $NUM_CHANGES - $MAX_DISPLAY_CHANGES`
echo "...and $DIFF more"
Expand Down Expand Up @@ -202,14 +204,25 @@ setupBuckRun ( ) {
elif [[ ! -z "$INSTALLED_WATCHMAN" ]]; then
watchmanWorkflow
else
warn 'ALWAYS RUNNING OKBUCK SINCE WATCHMAN IS NOT INSTALLED'
warn 'INSTALL WATCHMAN FOR FASTER BUILDS'
warn 'https://facebook.github.io/watchman'
warn "ALWAYS RUNNING OKBUCK SINCE WATCHMAN IS NOT INSTALLED"
warn "INSTALL WATCHMAN FOR FASTER BUILDS"
warn "https://facebook.github.io/watchman"
echo
runOkBuck
fi

setupBuckBinary

# Replace kotlin_home config with full path instead of source path
local kotlin_home
kotlin_home=$("$BUCK_BINARY" audit config kotlin.kotlin_home)

if [[ "$kotlin_home" == *":kotlin_home"* ]]; then
echo "changing kotlin home"
local resolved_kotlin_home
resolved_kotlin_home=$("$BUCK_BINARY" build //.okbuck/workspace/kotlin_home:kotlin_home --show-output | awk '{print $2}')
sed -i.bak "s://.okbuck/workspace/kotlin_home\:kotlin_home:${resolved_kotlin_home}:g" .okbuck/config/okbuck.buckconfig
fi
}

setupBuckFlags ( ) {
Expand All @@ -218,7 +231,7 @@ setupBuckFlags ( ) {

# Handle parameters and flags
handleParams ( ) {
SKIP_FLAGS=''
SKIP_FLAGS=""
for arg in "$@"
do
case "$arg" in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ WATCHMAN_TIMEOUT=10
WATCHMAN_FAILED="WATCHMAN FAILED"
BUCK_BINARY_DIR="$OKBUCK_DIR/workspace/buck_binary"

export JAVA_OPTS="${JAVA_OPTS:-\"-Xmx1g\" \"-Xms1g\"}"

# Timeout a call and exit early. This can be called via timeout <time> <command>.
timeout( ) {
perl -e "alarm shift; exec @@ARGV" "$@@";
Expand Down Expand Up @@ -159,8 +161,8 @@ watchmanWorkflow ( ) {
runOkBuck
else
# Format list for simpler output
CHANGES=$(echo $WATCHED_CHANGES | jsonq "" ".join(obj["files"])")
NEW_OR_DELETED_SOURCE_ROOTS=$(echo $SOURCE_ROOTS | jsonq "" ".join([f["name"] for f in obj["files"] if (not f["exists"] or f["new"])])")
CHANGES=$(echo $WATCHED_CHANGES | jsonq '" ".join(obj["files"])')
NEW_OR_DELETED_SOURCE_ROOTS=$(echo $SOURCE_ROOTS | jsonq '" ".join([f["name"] for f in obj["files"] if (not f["exists"] or f["new"])])')
NUM_CHANGES=$(echo $CHANGES $NEW_OR_DELETED_SOURCE_ROOTS | wc -w)

if [[ $NUM_CHANGES -gt 0 ]]; then
Expand Down Expand Up @@ -207,6 +209,17 @@ setupBuckRun ( ) {
fi

setupBuckBinary

# Replace kotlin_home config with full path instead of source path
local kotlin_home
kotlin_home=$("$BUCK_BINARY" audit config kotlin.kotlin_home)

if [[ "$kotlin_home" == *":kotlin_home"* ]]; then
echo "changing kotlin home"
local resolved_kotlin_home
resolved_kotlin_home=$("$BUCK_BINARY" build //.okbuck/workspace/kotlin_home:kotlin_home --show-output | awk '{print $2}')
sed -i.bak "s://.okbuck/workspace/kotlin_home\:kotlin_home:${resolved_kotlin_home}:g" .okbuck/config/okbuck.buckconfig
fi
}

setupBuckFlags ( ) {
Expand Down
2 changes: 0 additions & 2 deletions tooling/ci/build_cmd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ if [ -z "$BUILD_CMD" ]; then
fi

SKIP_OKBUCK= ./buckw --version
export RESOLVED_KOTLIN_HOME=$(./buckw build //.okbuck/workspace/kotlin_home:kotlin_home --show-output | awk '{print $2}')
sed -i.bak "s://.okbuck/workspace/kotlin_home\:kotlin_home:${RESOLVED_KOTLIN_HOME}:g" .okbuck/config/okbuck.buckconfig

echo "Running BUILD_CMD: $BUILD_CMD"

Expand Down