pipeline {
    agent any


agent {
        docker {
            image 'ubuntu:22.04'
            args '-u root'
        }
    }

    stages {
        stage('Install Dependencies') {
            steps {
                sh '''
                    apt update
                    apt install -y build-essential binutils-arm-none-eabi git libpng-dev cmake
                '''
            }
        }

        stage('Checkout') {
            steps {
                checkout scm
            }
        }

        stage('Configure') {
            steps {
                sh '''
                    mkdir -p build
                    cd build
                    cmake ..
                '''
            }
        }

        stage('Build') {
            steps {
                sh '''
                    cd build
                    make -j$(nproc)
                '''
            }
        }
    }
}
