Check-in [af7a2710be]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:added "install & run" logic in packaging tool
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: af7a2710beac3af1ae8d159da1f3cf64502639b3
User & Date: chw 2015-10-02 21:50:31
Context
2015-10-03
09:06
added tcllib upstream changes check-in: e3391ed779 user: chw tags: trunk
2015-10-02
21:50
added "install & run" logic in packaging tool check-in: af7a2710be user: chw tags: trunk
06:50
fixes in packing tool check-in: 3fa5b2295d user: chw tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to sdktools/bones.

1783
1784
1785
1786
1787
1788
1789

1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810










1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833














































1834
1835
1836
1837
1838
1839
1840
    $text configure -state disabled
    if {[catch {open "|ant clean $::page4(debug) $::nullin 2>@1" r} f]} {
	lputs stderr $f
	$text configure -state normal
	$text insert end $f
	$text insert end "\n"
	$text configure -state disabled

	return
    }
    fconfigure $f -blocking 0
    fileevent $f readable [list read_build $text $f]
    .action.b1 configure -state disabled
    .action.b2 configure -text "Stop build" -command [list stop_build $text $f]
}

##############################################################################
# Stop running ant.

proc stop_build {text f {eof 0}} {
    if {!$eof} {
	lputs stderr "*** build stopped"
    }
    if {[catch {close $f} err]} {
	if {$eof} {
	    lputs stderr $err
	}
    }
    .action.b1 configure -state normal










    .action.b2 configure -text "Cleanup & build" \
	-command [list cleanup_and_build $text]
}

##############################################################################
# File handler to read ant output.

proc read_build {text f} {
    if {[gets $f line] < 0} {
	if {[eof $f]} {
	    stop_build $text $f 1
	    return
	}
    } else {
	lputs stdout $line
	$text configure -state normal
	$text insert end $line
	$text insert end "\n"
	$text configure -state disabled
	after cancel [list $text see end]
	after idle [list $text see end]
    }
}















































##############################################################################
# Build GUI

wm withdraw .
wm title . [file tail [info script]]
wm minsize . 400 350







>



|

















>
>
>
>
>
>
>
>
>
>





|

|


|












>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
    $text configure -state disabled
    if {[catch {open "|ant clean $::page4(debug) $::nullin 2>@1" r} f]} {
	lputs stderr $f
	$text configure -state normal
	$text insert end $f
	$text insert end "\n"
	$text configure -state disabled
	$text see end
	return
    }
    fconfigure $f -blocking 0
    fileevent $f readable [list read_pipe_handler $text $f stop_build]
    .action.b1 configure -state disabled
    .action.b2 configure -text "Stop build" -command [list stop_build $text $f]
}

##############################################################################
# Stop running ant.

proc stop_build {text f {eof 0}} {
    if {!$eof} {
	lputs stderr "*** build stopped"
    }
    if {[catch {close $f} err]} {
	if {$eof} {
	    lputs stderr $err
	}
    }
    .action.b1 configure -state normal
    if {[$text search -- "BUILD SUCCESSFUL" 1.0 end] ne ""} {
	set apk [file join $::basedir bin "AndroWishApp-$::page4(debug).apk"]
	if {[file readable $apk] &&
	    ![catch {exec adb get-state $::nullerr} ret] &&
	    [string match "*device*" $ret]} {
	    .action.b2 configure -text "Install & run" \
		-command [list install_and_run $text]
	    return
	}
    }
    .action.b2 configure -text "Cleanup & build" \
	-command [list cleanup_and_build $text]
}

##############################################################################
# File handler to read ant output etc. "endcmd" is invoked on EOF.

proc read_pipe_handler {text f endcmd} {
    if {[gets $f line] < 0} {
	if {[eof $f]} {
	    $endcmd $text $f 1
	    return
	}
    } else {
	lputs stdout $line
	$text configure -state normal
	$text insert end $line
	$text insert end "\n"
	$text configure -state disabled
	after cancel [list $text see end]
	after idle [list $text see end]
    }
}

##############################################################################
# Run adb to install the new APK.

proc install_and_run {text} {
    set apk [file join $::basedir bin "AndroWishApp-$::page4(debug).apk"]
    $text configure -state normal
    $text insert end "\nINSTALLING APK $apk\n\n"
    $text configure -state disabled
    $text see end
    if {[catch {open "|adb install -r $apk $::nullin 2>@1" r} f]} {
	lputs stderr $f
	$text configure -state normal
	$text insert end $f
	$text insert end "\n"
	$text configure -state disabled
	$text see end
	return
    }
    fconfigure $f -blocking 0
    fileevent $f readable [list read_pipe_handler $text $f stop_install]
    .action.b1 configure -state disabled
    .action.b2 configure -text "Stop install" \
	-command [list stop_install $text $f]
}

##############################################################################
# Stop installing. If EOF condition and no errors on "adb install" run
# were detected, try to start new APK using "adb shell am start ...".

proc stop_install {text f {eof 0}} {
    if {!$eof} {
	lputs stderr "*** install stopped"
    }
    if {[catch {close $f} err]} {
	if {$eof} {
	    lputs stderr $err
	}
    } elseif {$eof} {
	catch {exec adb shell am start $::page3(pkg_name)/.$::page3(cls_name) \
		   $::nullin $::nullout $::nullerr}
    }
    .action.b1 configure -state normal
    .action.b2 configure -text "Cleanup & build" \
	-command [list cleanup_and_build $text]
}

##############################################################################
# Build GUI

wm withdraw .
wm title . [file tail [info script]]
wm minsize . 400 350