store_build_artifacts Subroutine

public subroutine store_build_artifacts(hash_key, build_dir, success)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: hash_key

Store compiled modules and executables in cache

character(len=*), intent(in) :: build_dir

Store compiled modules and executables in cache

logical, intent(out) :: success

Source Code

    subroutine store_build_artifacts(hash_key, build_dir, success)
        !> Store compiled modules and executables in cache
        character(len=*), intent(in) :: hash_key, build_dir
        logical, intent(out) :: success
        character(len=:), allocatable :: cache_path, command
        integer :: exitstat

        ! Create cache directory for this hash
        cache_path = join_path(trim(get_cache_subdir('builds')), trim(hash_key))
        call ensure_cache_dir(cache_path, success)
        if (.not. success) return

        ! Copy build artifacts to cache using cross-platform commands
        if (get_os_type() == OS_WINDOWS) then
            command = 'xcopy /E /I /Y "'//trim(escape_shell_arg(build_dir))//'" "'// &
                      trim(escape_shell_arg(cache_path))//'" >nul 2>&1'
        else
            command = 'cp -r "'//trim(escape_shell_arg(build_dir))//'/." "'// &
                      trim(escape_shell_arg(cache_path))//'/" >/dev/null 2>&1'
        end if

        call run(command, exitstat=exitstat)
        success = (exitstat == 0)

    end subroutine store_build_artifacts