Unverified Commit 2be7a411 authored by Pavitra Golchha's avatar Pavitra Golchha Committed by GitHub

Add Build Tools for App Inventor (#2358)

parent 723d20da
......@@ -113,6 +113,19 @@ If you need to switch back to a branch that does contains the Blockly and Closur
to clear out the submodules ___before switching branches___. When switching back, you will need to repeat the initialization and update procedure above.
### Troubleshooting common installation issues
Run this command to run a self-diagnosis of your environment. This command tries to figure out common installation issues and offers you a solution to fix them yourself. Make sure this passes all the checks before you proceed further.
#### Linux and macOS
```bash
./buildtools doctor
```
#### Windows
```bash
buildtools doctor
```
### Compiling
Before compiling the code, an [auth key](https://docs.google.com/document/pub?id=1Xc9yt02x3BRoq5m1PJHBr81OOv69rEBy8LVG_84j9jc#h.yikyg2e1rfut) is needed. You can create one by running the following commands:
......
#!/usr/bin/env bash
title() {
echo -ne "\e]0;$*\a"
}
pause() {
echo ""
read -p "Press Enter key to continue..."
}
open_url() {
case "$(uname -s)" in
Darwin) open "$1" ;;
Linux) xdg-open "$1" &> /dev/null || echo "Open $1 in your browser" ;;
esac
}
menu() {
until [ "$choice" = "0" ]; do
title Build Tools for App Inventor
clear
echo " MENU"
echo " - - What do you want to do? - - - - - - - - - - - - - - - - - - - - - - -"
echo ""
echo " 1.Clean Build"
echo " 2.Make Auth Key"
echo ""
echo " 3.Build App Inventor"
echo " 4.Build Without Companion"
echo " 5.Build Companion App"
echo " 6.Build Extension"
echo ""
echo " 7.Run Local Server"
echo " 8.Run Super Dev Mode"
echo " 9.Run Build Server"
echo " A.Run Tests"
echo ""
echo " B.Doctor"
echo ""
echo " 0.Exit"
echo ""
echo " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"
read -p "Enter your choice:" choice
echo ""
case $choice in
1) clear ; clean ; pause ;;
2) clear ; makeauthkey ; pause ;;
3) clear ; build ; pause ;;
4) clear ; buildnoplay ; pause ;;
5) clear ; companion ; pause ;;
6) clear ; extension ; pause ;;
7) clear ; localserver ; pause ;;
8) clear ; sdm ; pause ;;
9) clear ; buildserver ; pause ;;
a|A) clear ; tests ; pause ;;
b|B) clear ; doctor ; pause ;;
0) clear ; exit 0 ;;
esac
done
}
clean() {
title Cleaning Build...
ant clean
}
makeauthkey() {
title Making Auth Key...
ant MakeAuthKey
}
build() {
title Building...
ant all
}
buildnoplay() {
title Building without companion...
ant noplay
}
companion() {
title Building Companion...
any PlayApp
if [ $? -eq 0 ]; then
echo ""
echo The companion is generated at:
echo $PWD/appinventor/build/buildserver/MIT AI2 Companion.apk
fi
}
extension() {
title Building Extension...
ant extensions
if [ $? -eq 0 ]; then
echo ""
echo The extension is generated at:
echo $PWD/appinventor/components/build/extensions
fi
}
localserver() {
title Running Local Server...
start java_dev_appserver --address=0.0.0.0 --port=8888 appengine/build/war/
# wait for 10 seconds for app engine server to start
sleep 10
open_url http://localhost:8888
}
sdm() {
title Running Super Dev Mode...
open_url http://localhost:9876
start ant devmode
}
buildserver() {
title Running Build Server...
start ant RunLocalBuildServer
}
tests() {
title Running Tests...
ant tests
}
doctor() {
title Doctor
echo Diagnosing your system...
echo ""
pass=0
fail=0
# Check if Java is installed
if command -v java &> /dev/null; then
((pass++))
echo [PASS] Java is installed.
# Check Java version
if java -version 2>&1 | grep -q "version \"1.8" &> /dev/null; then
((pass++))
echo [PASS] Required version of Java is installed.
else
((fail++))
echo [FAIL] Required version of Java is not installed or not found on PATH.
echo _______Please install Java 8 and try again.
fi
else
((fail++))
echo [FAIL] Java is not installed or not found on PATH.
echo _______Please install Java 8 and try again.
fi
# Check if git is installed
if command -v git &> /dev/null; then
((pass++))
echo [PASS] Git is installed.
# Check if git submodules are present
if git submodule status lib/blockly lib/closure-library &> /dev/null; then
((pass++))
echo [PASS] Git submodules are properly set up.
else
((fail++))
echo [FAIL] Git submodules are not properly set up.
echo _______Please run `git submodule update --init`
fi
else
((fail++))
echo [FAIL] Git is not installed or not found on PATH.
echo _______Please install Git and try again.
fi
# Check if gcloud is installed
if command -v where gcloud &> /dev/null; then
((pass++))
echo [PASS] Google Cloud SDK is installed.
else
((fail++))
echo [FAIL] Google Cloud SDK is not installed or not found on PATH.
echo _______Download gcloud from here: https://cloud.google.com/appengine/docs/standard/java/download
fi
echo ""
echo Passed $pass checks and $fail failing
}
# Run the script inside the appinventor dir
cd appinventor
if [[ $1 == "doctor" ]]; then
doctor
else
menu
fi
@echo off
:: Run the script inside the appinventor dir
cd appinventor
if /i "%1" equ "doctor" goto doctor
:menu
title Build Tools for App Inventor
cls
echo MENU
echo - - What do you want to do? - - - - - - - - - - - - - - - - - - - - - - -
echo.
echo 1.Clean Build
echo 2.Make Auth Key
echo.
echo 3.Build App Inventor
echo 4.Build Without Companion
echo 5.Build Companion App
echo 6.Build Extension
echo.
echo 7.Run Local Server
echo 8.Run Super Dev Mode
echo 9.Run Build Server
echo A.Run Tests
echo.
echo B.Doctor
echo.
echo 0.Exit
echo.
echo - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
set /p choice=Enter your choice:
if %choice% == 1 goto clean
if %choice% == 2 goto makeauthkey
if %choice% == 3 goto build
if %choice% == 4 goto buildnoplay
if %choice% == 5 goto companion
if %choice% == 6 goto extension
if %choice% == 7 goto localserver
if %choice% == 8 goto sdm
if %choice% == 9 goto buildserver
if /i %choice% == A goto tests
if /i %choice% == B goto doctor
if %choice% == 0 goto eof
goto menu
:clean
title Cleaning Build...
cls
call ant clean
echo.
pause
goto menu
:makeauthkey
title Making Auth Key...
cls
call ant MakeAuthKey
echo.
pause
goto menu
:build
title Building...
cls
call ant all
echo.
pause
goto menu
:buildnoplay
title Building without companion...
cls
call ant noplay
echo.
pause
goto menu
:companion
title Building Companion...
cls
call ant PlayApp
echo.
if /i "%ERRORLEVEL%" equ "0" (
echo The companion is generated at:
echo %cd%/appinventor/build/buildserver/MIT AI2 Companion.apk
echo.
)
pause
goto menu
:extension
title Building Extension...
cls
call ant extensions
echo.
if /i "%ERRORLEVEL%" equ "0" (
echo The extension is generated at:
echo %cd%/appinventor/components/build/extensions
echo.
)
pause
goto menu
:localserver
title Running Local Server...
cls
start java_dev_appserver --address=0.0.0.0 --port=8888 appengine/build/war/
:: wait for 10 seconds for app engine server to start
timeout 10
start http://localhost:8888
echo.
pause
goto menu
:sdm
title Running Super Dev Mode...
cls
start http://localhost:9876
start ant devmode
echo.
pause
goto menu
:buildserver
title Running Build Server...
cls
start ant RunLocalBuildServer
echo.
pause
goto menu
:tests
title Running Tests...
cls
call ant tests
echo.
pause
goto menu
:doctor
title Doctor
cls
echo Diagnosing your system...
echo.
set pass=0
set fail=0
:: Check if Java is installed
where java > nul 2>&1
if /i "%ERRORLEVEL%" equ "0" (
set /a pass=pass+1
echo [PASS] Java is installed.
:: Check Java version
java -version 2>&1 | find "version ""1.8" > nul 2>&1
if /i "%ERRORLEVEL%" equ "0" (
set /a pass=pass+1
echo [PASS] Required version of Java is installed.
) else (
set /a fail=fail+1
echo [FAIL] Required version of Java is not installed or not found on PATH.
echo _______Please install Java 8 and try again.
)
) else (
set /a fail=fail+1
echo [FAIL] Java is not installed or not found on PATH.
echo _______Please install Java 8 and try again.
)
:: Check if git is installed
where git > nul 2>&1
if /i "%ERRORLEVEL%" equ "0" (
set /a pass=pass+1
echo [PASS] Git is installed.
:: Check if git submodules are present
git submodule status lib/blockly lib/closure-library > nul 2>&1
if /i "%ERRORLEVEL%" equ "0" (
set /a pass=pass+1
echo [PASS] Git submodules are properly set up.
) else (
set /a fail=fail+1
echo [FAIL] Git submodules are not properly set up.
echo _______Please run `git submodule update --init`
)
) else (
set /a fail=fail+1
echo [FAIL] Git is not installed or not found on PATH.
echo _______Please install Git and try again.
)
:: Check if gcloud is installed
where gcloud > nul 2>&1
if /i "%ERRORLEVEL%" equ "0" (
set /a pass=pass+1
echo [PASS] Google Cloud SDK is installed.
) else (
set /a fail=fail+1
echo [FAIL] Google Cloud SDK is not installed or not found on PATH.
echo _______Download gcloud from here: https://cloud.google.com/appengine/docs/standard/java/download
)
echo.
echo Passed %pass% checks and %fail% failing
:: Exit if run using doctor command
if /i "%1" equ "doctor" goto eof
echo.
pause
goto menu
:eof
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment