Moves ARRAY_SIZE into the kernel only (XCC)
[akaros.git] / tools / jenkins / launcher.sh
index dd03a2b..5d5c07f 100755 (executable)
@@ -4,7 +4,7 @@
 # It analyzes what parts of the codebase have been modified, compiles everything
 # that is needed, and reports on the results. 
 
-set -e
+#set -e
 
 readonly TMP_DIR=tmp
 readonly DIFF_FILE=$TMP_DIR/changes.txt
@@ -32,7 +32,7 @@ readonly BUSYBOX_CONF_FILE=tools/patches/busybox/busybox-1.17.3-config
 ###############                 HELPER FUNCTIONS                 ###############
 ################################################################################
 function last_stable_build() {
-       curl -s localhost:8080/job/Test_akaros_github/lastStableBuild/api/json?tree=actions%5bbuildsByBranchName%5brevision%5bSHA1%5d%5d%5d | \
+       curl -s localhost:8080/job/$JOB_NAME/lastStableBuild/api/json?tree=actions%5bbuildsByBranchName%5brevision%5bSHA1%5d%5d%5d | \
                python -c 'import sys, json; print json.load(sys.stdin)["actions"][3]["buildsByBranchName"]["'$GIT_BRANCH'"]["revision"]["SHA1"]'
 }
 
@@ -69,7 +69,6 @@ fi
 
 function add_cross_compiler_to_path() {
        export PATH=$WORKSPACE/install/riscv-ros-gcc/bin:$PATH
-       export PATH=$WORKSPACE/install/i686-ros-gcc/bin:$PATH
        export PATH=$WORKSPACE/install/x86_64-ros-gcc/bin:$PATH
 }
 
@@ -89,12 +88,6 @@ function build_config() {
        case "$COMPILATION_ARCH" in
        RISCV)  make ARCH=riscv defconfig
            ;;
-       I686)  make ARCH=x86 defconfig
-                  sed -i -e 's/CONFIG_64BIT=y/# CONFIG_64BIT is not set/' \
-                         -e 's/# CONFIG_X86_32 is not set/CONFIG_X86_32=y/' \
-                         -e 's/CONFIG_X86_64=y/# CONFIG_X86_64 is not set/' \
-                         .config
-           ;;
        X86_64)  make ARCH=x86 defconfig
            ;;
        esac
@@ -102,8 +95,9 @@ function build_config() {
        # Enable tests to run.
        # These don't take much to execute so we can run them always and just parse
        # results if needed.
-       echo "CONFIG_KERNEL_POSTBOOT_TESTING=y" >> .config
+       echo "CONFIG_KERNEL_TESTING=y" >> .config
        echo "CONFIG_USERSPACE_TESTING=y" >> .config
+       echo "CONFIG_LOUSY_LAPIC_TIMER=y" >> .config
        # Set all config variables dependent on the above changes to their defaults
        # without prompting
        make olddefconfig 
@@ -113,7 +107,6 @@ function build_config() {
 
 function build_cross_compiler() {
        declare -A ARCH_SUBDIRS=( ["RISCV"]="riscv-ros-gcc" \
-                                 ["I686"]="i686-ros-gcc" \
                                  ["X86_64"]="x86_64-ros-gcc" )
 
        echo -e "\n[BUILD_CROSS_COMPILER]: Begin"
@@ -129,21 +122,17 @@ function build_cross_compiler() {
        echo "# Number of make jobs to spawn.  
 MAKE_JOBS := 3
 RISCV_INSTDIR         := $WORKSPACE/install/${ARCH_SUBDIRS["RISCV"]}/
-I686_INSTDIR          := $WORKSPACE/install/${ARCH_SUBDIRS["I686"]}/
 X86_64_INSTDIR        := $WORKSPACE/install/${ARCH_SUBDIRS["X86_64"]}/
 " > Makelocal
 
        # Create / clean directory where the cross compiler will be installed.
        CROSS_COMP_DIR=$WORKSPACE/install/${ARCH_SUBDIRS["$COMPILATION_ARCH"]}/
-       mkdir -p CROSS_COMP_DIR
-       rm -rf CROSS_COMP_DIR*
+       rm -rf $CROSS_COMP_DIR
 
        # Compile cross compiler.
        case "$COMPILATION_ARCH" in
        RISCV)  make riscv
            ;;
-       I686)  make i686
-           ;;
        X86_64)  make x86_64
            ;;
        esac
@@ -206,13 +195,17 @@ function build_busybox() {
        cp busybox_unstripped ../../kern/kfs/bin/busybox
        cd ../../
 
-       # Recompile kernel to include busybox
-       echo -e "Recompile kernel to include busybox"
-       make
-
        echo -e "[BUILD_BUSYBOX]: End\n"
 }
 
+function build_all() {
+       build_config
+       build_cross_compiler
+       build_userspace
+       build_busybox
+       build_kernel
+}
+
 # TODO: This won't work for RISCV, it must be changed to whatever is used.
 function run_qemu() {
        echo -e "\n[RUN_AKAROS_IN_QEMU]: Begin"
@@ -252,56 +245,57 @@ function run_qemu() {
 
 if [ "$COMPILE_ALL" == true ]; then
        echo "Building all AKAROS"
-       build_config
-       
-       build_cross_compiler
-       build_userspace
-       build_busybox
-       build_kernel
-
+       build_all
        run_qemu
 
        AFFECTED_COMPONENTS="cross-compiler kernel userspace busybox"
 else
        # Save changed files between last tested commit and current one.
        git diff --stat $(last_stable_build) $GIT_COMMIT > $DIFF_FILE
-
-       # Extract build targets by parsing diff file.
-       AFFECTED_COMPONENTS=`$SCR_GIT_CHANGES $DIFF_FILE $CONF_COMP_COMPONENTS_FILE`
-       # Can contain {cross-compiler, kernel, userspace, busybox}
-
-       if [[ -n $AFFECTED_COMPONENTS ]]; 
-       then
-               echo "Detected changes in "$AFFECTED_COMPONENTS
-               build_config
-
-               if [[ $AFFECTED_COMPONENTS == *cross-compiler* ]]
+       if [ $? -ne 0 ]; then
+               echo "Diff failed, rebuild everything"
+               build_all
+               run_qemu
+
+               AFFECTED_COMPONENTS="cross-compiler kernel userspace busybox"
+       else 
+               # Extract build targets by parsing diff file.
+               AFFECTED_COMPONENTS=`$SCR_GIT_CHANGES $DIFF_FILE $CONF_COMP_COMPONENTS_FILE`
+               # Can contain {cross-compiler, kernel, userspace, busybox}
+
+               if [[ -n $AFFECTED_COMPONENTS ]]; 
                then
-                       build_cross_compiler
-                       build_userspace
-                       build_busybox
-                       build_kernel
-               else 
-                       if [[ $AFFECTED_COMPONENTS == *userspace* ]]
-                       then
-                               build_userspace
-                       fi
+                       echo "Detected changes in "$AFFECTED_COMPONENTS
+                       build_config
 
-                       if [[ $AFFECTED_COMPONENTS == *busybox* ]]
+                       if [[ $AFFECTED_COMPONENTS == *cross-compiler* ]]
                        then
+                               build_cross_compiler
+                               build_userspace
                                build_busybox
-                       fi
-
-                       if [[ $AFFECTED_COMPONENTS == *kernel* ]]
-                       then
                                build_kernel
+                       else 
+                               if [[ $AFFECTED_COMPONENTS == *userspace* ]]
+                               then
+                                       build_userspace
+                               fi
+
+                               if [[ $AFFECTED_COMPONENTS == *busybox* ]]
+                               then
+                                       build_busybox
+                               fi
+
+                               if [[ $AFFECTED_COMPONENTS == *kernel* ]]
+                               then
+                                       build_kernel
+                               fi
                        fi
+               else
+                       echo "Skipping build. No changes detected."
                fi
-       else
-               echo "Skipping build. No changes detected."
-       fi
 
-       run_qemu
+               run_qemu
+       fi
 fi