From: Jean Privat Date: Wed, 16 Sep 2015 17:11:55 +0000 (-0400) Subject: Merge: Extends catalog with a *try it* and a *download apk* links X-Git-Tag: v0.7.8~14 X-Git-Url: http://nitlanguage.org?hp=91708b1b27fe6b700373d33dc71de5780f7e093e Merge: Extends catalog with a *try it* and a *download apk* links Two new package metadata are added * `upstream.tryit` for an URL that points to a demo version or a live version of the main web service offered by the package. * `upstream.apk` for an URL that points to a dry `apk`, or an install page on some store, for the main android application offered by the package. Moreover, packages that have one them will be respectively tagged `tryit` and `apk` A demo is available: http://info.uqam.ca/~privat/catalog/#tag_tryit and http://info.uqam.ca/~privat/catalog/#tag_apk Pull-Request: #1724 Reviewed-by: Lucas Bajolet Reviewed-by: Romain Chanoir --- diff --git a/benchmarks/.gitignore b/benchmarks/.gitignore index 43fa343..b6bd96d 100644 --- a/benchmarks/.gitignore +++ b/benchmarks/.gitignore @@ -7,3 +7,5 @@ index.html nitc nitdoc nitdoc.* +logs +nit_compile diff --git a/benchmarks/Makefile b/benchmarks/Makefile new file mode 100644 index 0000000..6c62287 --- /dev/null +++ b/benchmarks/Makefile @@ -0,0 +1,5 @@ +all: + ./bench_engines.sh all + +check: + ./bench_engines.sh --fast --fast bench_nitc_options diff --git a/benchmarks/bench_common.sh b/benchmarks/bench_common.sh index 4ea5ffe..207edd0 100644 --- a/benchmarks/bench_common.sh +++ b/benchmarks/bench_common.sh @@ -94,3 +94,9 @@ function skip_test() return 1 } +# Helper function. Print the error message and set $died to 1 +function die() +{ + echo >&2 "error: $*" + died=1 +} diff --git a/benchmarks/bench_engines.sh b/benchmarks/bench_engines.sh index b2534e7..37b2fb9 100755 --- a/benchmarks/bench_engines.sh +++ b/benchmarks/bench_engines.sh @@ -26,14 +26,6 @@ source ./bench_plot.sh # Can be overrided with 'the option -n' count=2 -### HELPER FUNCTIONS ## - -function die() -{ - echo >&2 "error: $*" - died=1 -} - # HELPER FOR NIT # # Run standards benchs on a compiler command @@ -93,7 +85,6 @@ function usage() echo " -n count: number of execution for each bar (default: $count)" echo " --dry: Do not run the commands, just reuse the data and generate the graph" echo " --fast: Run less and faster tests" - echo " --html: Generate and HTML output" echo " -h: this help" } @@ -105,11 +96,14 @@ while [ "$stop" = false ]; do -n) count="$2"; shift; shift;; --dry) dry_run=true; shift;; --fast) fast=true$fast; shift;; - --html) html="index.html"; echo >"$html" ""; shift;; + --html) shift;; # Deprecated *) stop=true esac done +html="index.html" +echo >"$html" "" + xml="bench_engines.xml" echo "" > "$xml" @@ -195,12 +189,12 @@ function bench_nitc_options() for opt in "$@"; do ot=${opt// /} - prepare_res "$name$ot.dat" "$opt" "nitc-g with option $opt" + prepare_res "$name$ot.dat" "$opt" "nitc with option $opt" run_compiler "nitc-$name" ./nitc $common $opt done if test -n "$2" -a -n "$withall"; then - prepare_res "$name-all.dat" "all" "nitc-g with all options $@" + prepare_res "$name-all.dat" "all" "nitc with all options $@" run_compiler "nitc-$name" ./nitc $common $@ fi @@ -210,20 +204,22 @@ function bench_nitc_options() bench_nitc_options "slower" --global --hardening --no-shortcut-range bench_nitc_options "nocheck" --global --no-check-null --no-check-autocast --no-check-attr-isset --no-check-covariance --no-check-assert -bench_nitc_options "slower" --separate --hardening --no-shortcut-equal --no-union-attribute --no-shortcut-range --no-inline-intern "--no-gcc-directive likely --no-gcc-directive noreturn" "--no-tag-primitives" +bench_nitc_options "slower" --separate --hardening --no-shortcut-equal --no-union-attribute --no-shortcut-range --no-inline-intern "--no-gcc-directive likely --no-gcc-directive noreturn" "--no-tag-primitives" "--colo-dead-methods" --type-poset bench_nitc_options "nocheck" --separate --no-check-null --no-check-autocast --no-check-attr-isset --no-check-covariance --no-check-assert bench_nitc_options "faster" --separate --skip-dead-methods --inline-coloring-numbers --inline-some-methods --direct-call-monomorph "--inline-some-methods --direct-call-monomorph" bench_nitc_options "slower" --erasure --hardening --no-shortcut-equal --no-union-attribute --no-shortcut-range --no-inline-intern -bench_nitc_options "nocheck" --erasure --no-check-null --no-check-autocast --no-check-attr-isset --no-check-covariance --no-check-assert --no-check-erasure-cast +bench_nitc_options "nocheck" --erasure --no-check-null --no-check-autocast --no-check-attr-isset --no-check-covariance --no-check-assert --no-check-erasure-cast --no-check-all bench_nitc_options "faster" --erasure --skip-dead-methods --inline-coloring-numbers --inline-some-methods --direct-call-monomorph --rta bench_nitc_options "engine" "" NOALL "--separate" "--erasure" "--separate --semi-global" "--erasure --semi-global" "--erasure --semi-global --rta" "--global" bench_nitc_options "policy" "" NOALL "--separate" "--erasure" "--separate --no-check-covariance" "--erasure --no-check-covariance --no-check-erasure-cast" bench_nitc_options "nullables" "" "--no-check-attr-isset" "--no-union-attribute" -bench_nitc_options "linkboost" "" NOALL --trampoline-call --colors-are-symbols "--colors-are-symbols --trampoline-call" "--separate --link-boost" "--separate --colors-are-symbols --guard-call" "--separate --colors-are-symbols --direct-call-monomorph0" +bench_nitc_options "linkboost" "" NOALL --trampoline-call --colors-are-symbols "--colors-are-symbols --trampoline-call" "--separate --link-boost" "--separate --colors-are-symbols --guard-call" "--separate --colors-are-symbols --direct-call-monomorph0" "--substitute-monomorph" bench_nitc_options "monomorph" "" --direct-call-monomorph0 --direct-call-monomorph +bench_nitc_options "misc" "" --log --typing-test-metrics --invocation-metrics --isset-checks-metrics --tables-metrics --no-stacktrace --release --debug #FIXME add --sloppy + function bench_nitc-e_gc() { name="$FUNCNAME" @@ -272,9 +268,7 @@ function bench_compilation_time } bench_compilation_time -if test -n "$html"; then - echo >>"$html" "" -fi +echo >>"$html" "" echo >>"$xml" "" diff --git a/benchmarks/bench_languages.sh b/benchmarks/bench_languages.sh index 0e0b59a..2a33170 100755 --- a/benchmarks/bench_languages.sh +++ b/benchmarks/bench_languages.sh @@ -26,14 +26,6 @@ source ./bench_plot.sh # Can be overrided with 'the option -n' count=2 -### HELPER FUNCTIONS ## - -function die() -{ - echo >&2 "error: $*" - died=1 -} - ## HANDLE OPTIONS ## function usage() diff --git a/benchmarks/bench_nitdoc.sh b/benchmarks/bench_nitdoc.sh index 07613b2..4a1d2a7 100755 --- a/benchmarks/bench_nitdoc.sh +++ b/benchmarks/bench_nitdoc.sh @@ -24,14 +24,6 @@ source ./bench_plot.sh # Can be overrided with 'the option -n' count=3 -### HELPER FUNCTIONS ## - -function die() -{ - echo >&2 "error: $*" - died=1 -} - ## HANDLE OPTIONS ## function usage() diff --git a/benchmarks/bench_nitunit.sh b/benchmarks/bench_nitunit.sh index 53eb38c..23279f1 100755 --- a/benchmarks/bench_nitunit.sh +++ b/benchmarks/bench_nitunit.sh @@ -24,14 +24,6 @@ source ./bench_plot.sh # Can be overrided with 'the option -n' count=3 -### HELPER FUNCTIONS ## - -function die() -{ - echo >&2 "error: $*" - died=1 -} - ## HANDLE OPTIONS ## function usage() diff --git a/benchmarks/bench_plot.sh b/benchmarks/bench_plot.sh index e874308..08a13e6 100755 --- a/benchmarks/bench_plot.sh +++ b/benchmarks/bench_plot.sh @@ -103,7 +103,8 @@ if test -n "$html"; then echo gnuplot -e "set term png; set output \"$bn.png\"" "$1" echo >>"$html" "" -else +fi +if test -n "$DISPLAY"; then echo "# gnuplot -p $1" gnuplot -p "$1" fi diff --git a/benchmarks/markdown/Makefile b/benchmarks/markdown/Makefile index 802fab6..ca25141 100644 --- a/benchmarks/markdown/Makefile +++ b/benchmarks/markdown/Makefile @@ -15,6 +15,9 @@ all: ./bench_markdown.sh all +check: + ./bench_markdown.sh -s 1 nit + clean: $(MAKE) clean -C benches $(MAKE) clean -C engines diff --git a/benchmarks/markdown/bench_markdown.sh b/benchmarks/markdown/bench_markdown.sh index aaa34f0..485b944 100755 --- a/benchmarks/markdown/bench_markdown.sh +++ b/benchmarks/markdown/bench_markdown.sh @@ -24,13 +24,8 @@ source ../bench_plot.sh # Can be overrided with 'the option -n' count=2 -### HELPER FUNCTIONS ## - -function die() -{ - echo >&2 "error: $*" - died=1 -} +# Default number of times the input file is transformed during a single run +s=200 ## HANDLE OPTIONS ## @@ -39,6 +34,7 @@ function usage() echo "run_bench: [options]* benchname" echo " -v: verbose mode" echo " -n count: number of execution for each bar (default: $count)" + echo " -s size: number of transformations for each run (default: $s)" echo " --dry: Do not run the commands, just reuse the data and generate the graph" echo " -h: this help" } @@ -49,6 +45,7 @@ while [ "$stop" = false ]; do -v) verbose=true; shift;; -h) usage; exit;; -n) count="$2"; shift; shift;; + -s) s="$2"; shift; shift;; --dry) dry_run=true; shift;; *) stop=true esac @@ -73,8 +70,8 @@ outdir="./out" engdir="./engines" bncdir="./benches/out" mkdir -p $outdir - -s=200 +html="index.html" +echo >"$html" "" function bench_nitmd() { @@ -140,6 +137,8 @@ if test "$#" -gt 0; then plot $outdir/bench_markdown.gnu fi +echo >>"$html" "" + if test -n "$died"; then echo "Some commands failed" exit 1 diff --git a/benchmarks/polygons/Makefile b/benchmarks/polygons/Makefile index e6bd303..f7d0763 100644 --- a/benchmarks/polygons/Makefile +++ b/benchmarks/polygons/Makefile @@ -1,3 +1,6 @@ all: $(MAKE) all -C nit $(MAKE) all -C java + +check: + $(MAKE) check -C nit diff --git a/benchmarks/polygons/nit/Makefile b/benchmarks/polygons/nit/Makefile index e327368..71dffea 100644 --- a/benchmarks/polygons/nit/Makefile +++ b/benchmarks/polygons/nit/Makefile @@ -17,3 +17,11 @@ convexity_b: contain_b: ./bench_polygon.sh contain + +check: + ./bench_polygon.sh -p 100 add_vertex + ./bench_polygon.sh -p 100 sort_vertices + ./bench_polygon.sh -p 100 intersection + ./bench_polygon.sh -p 100 convex_hull + ./bench_polygon.sh -p 100 convexity + ./bench_polygon.sh -p 100 contain diff --git a/benchmarks/polygons/nit/bench_polygon.sh b/benchmarks/polygons/nit/bench_polygon.sh index 52895e9..8b7fc08 100755 --- a/benchmarks/polygons/nit/bench_polygon.sh +++ b/benchmarks/polygons/nit/bench_polygon.sh @@ -166,3 +166,9 @@ case "$1" in contain) shift; bench_contain $@;; *) usage; exit;; esac + +if test -n "$died"; then + echo "Some commands failed" + exit 1 +fi +exit 0 diff --git a/benchmarks/strings/Makefile b/benchmarks/strings/Makefile index 3717681..2453d1b 100644 --- a/benchmarks/strings/Makefile +++ b/benchmarks/strings/Makefile @@ -12,6 +12,8 @@ iter: index: ./bench_strings.sh index 10000000 50 25 200 +check: basic + basic: ./bench_strings.sh basic diff --git a/benchmarks/strings/bench_strings.sh b/benchmarks/strings/bench_strings.sh index 7a09065..5d24653 100755 --- a/benchmarks/strings/bench_strings.sh +++ b/benchmarks/strings/bench_strings.sh @@ -205,14 +205,14 @@ function launch_bench() echo " Trying variant $variant for benchmark $bench" echo "---------------------------------------------------------" git diff-index --quiet HEAD || { - echo "Cannot run benches on a dirty working directory." - echo "Please commit or stash your modifications and relaunch the command." - exit 1 + die "Cannot run benches on a dirty working directory." + die "Please commit or stash your modifications and relaunch the command." + return } git am $curr_rev || { - echo "Error when applying patch $curr_rev" - git am --abort; - exit 1; + die "Error when applying patch $curr_rev" + git am --abort + return } if [ "$need_bootstrap" = true ]; then prepare_compiler @@ -263,12 +263,6 @@ function main() bench=$1 shift; - git diff-index --quiet HEAD || { - echo "Cannot run benches on a dirty working directory." - echo "Please commit or stash your modifications and relaunch the command." - exit 1 - } - head=`git rev-parse HEAD` variant="HEAD" need_plot=true @@ -314,3 +308,9 @@ function main() } main "$@"; + +if test -n "$died"; then + echo "Some commands failed" + exit 1 +fi +exit 0 diff --git a/contrib/crazy_moles/Makefile b/contrib/crazy_moles/Makefile index 049e851..113329d 100644 --- a/contrib/crazy_moles/Makefile +++ b/contrib/crazy_moles/Makefile @@ -1,3 +1,7 @@ + +SVG2ICONS=../inkscape_tools/bin/svg_to_icons +SVG2PNG=../inkscape_tools/bin/svg_to_png_and_nit + default: bin/moles bin/moles: $(shell ../../bin/nitls -M src/moles_linux.nit) assets/images/drawing.png @@ -13,19 +17,19 @@ android-release: android-icons $(shell ../../bin/nitls -M src/moles_android.nit) mkdir -p bin ../../bin/nitc -o bin/moles.apk src/moles_android.nit --release -../inkscape_tools/bin/svg_to_icons: +$(SVG2ICONS): $(MAKE) -C ../inkscape_tools -android-icons: ../../contrib/inkscape_tools/bin/svg_to_icons art/icon.svg +android-icons: $(SVG2ICONS) art/icon.svg mkdir -p res - ../inkscape_tools/bin/svg_to_icons art/icon.svg --android --out res/ + $(SVG2ICONS) art/icon.svg --android --out res/ android-install: bin/moles.apk adb install -rf bin/moles.apk -assets/images/drawing.png: art/drawing.svg ../../contrib/inkscape_tools/bin/svg_to_icons +assets/images/drawing.png: art/drawing.svg $(SVG2ICONS) mkdir -p assets/images - ../inkscape_tools/bin/svg_to_png_and_nit --src src/ --scale 2.0 art/drawing.svg + $(SVG2PNG) --src src/ --scale 2.0 art/drawing.svg check-android: bin/moles.apk ../../misc/jenkins/check_android.sh bin/moles.apk diff --git a/contrib/friendz/src/friendz.nit b/contrib/friendz/src/friendz.nit index 9425abe..c0554fe 100644 --- a/contrib/friendz/src/friendz.nit +++ b/contrib/friendz/src/friendz.nit @@ -19,7 +19,6 @@ import realtime import solver import mnit::tileset import app::data_store -import md5 intrude import grid intrude import level @@ -217,11 +216,11 @@ class LevelButton self.over = self.level.fullname if self.level.get_state >= l.l_won then - if game.levels[9].get_state >= l.l_won then self.over += " --- {self.level.score}/{self.level.par}" + if game.levels[9].get_state >= l.l_won then self.over += " --- {self.level.score}/{self.level.gold}" else if self.level.get_state >= l.l_open then - if game.levels[9].get_state >= l.l_open then self.over += " --- ?/{self.level.par}" + if game.levels[9].get_state >= l.l_open then self.over += " --- ?/{self.level.gold}" end - #self.enabled = l.get_state >= l.l_open + self.enabled = l.get_state >= l.l_open or game.cheated end redef fun draw(ctx) @@ -242,7 +241,7 @@ class LevelButton end ctx.blit(game.img[ix,iy], self.x, self.y) - if s == l.l_par then + if s == l.l_gold then ctx.blit(game.img2[7,0], self.x + bw*5/8, self.y-bh*1/8) end ctx.textx(self.level.name, self.x+5, self.y+5, 24, null, null) @@ -730,9 +729,9 @@ class Score end if game.levels[9].get_state >= level.l_won then if level.is_challenge then - ctx.textx("GOAL: {level.par}",self.x,self.y+44,21,"yellow",null) + ctx.textx("GOAL: {level.gold}",self.x,self.y+44,21,"yellow",null) else - ctx.textx("PAR: {level.par}",self.x,self.y+44,21,"yellow",null) + ctx.textx("GOLD: {level.gold}",self.x,self.y+44,21,"yellow",null) end end end @@ -777,7 +776,7 @@ class StatusBar do print "***STATUS** {txt}" self.tmp_txt = txt - self.tmp_txt_ttl = 20 + self.tmp_txt_ttl = 60 self.tmp_txt_color = color end @@ -873,26 +872,6 @@ redef class Game # Font var font = new TileSetFont(app.load_image("deltaforce_font.png"), 16, 17, "ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789.:;!?\"'() -,/") - var xxx = """ - fun save_cookie(name, val:String) do - var days = 365 - var date = new Date() - date.setTime(date.getTime()+(days*24*60*60*1000)) - document.cookie = name+"="+val+"; expires="+date.toGMTString()+"; path=/" - end - - fun read_cookie(name:String):String do - var key = name + "=" - var ca = document.cookie.split(';') - for(var i=0; i 0 then score else null + app.data_store["s{str}"] = if score > 0 then score else null + var saved = game.grid.save + saved_str = saved + app.data_store["g{str}"] = saved + print "SAVE: {name}: {saved}" end + + # The saved player grid (to continue games) + var saved_str: nullable String = null end diff --git a/contrib/friendz/src/grid.nit b/contrib/friendz/src/grid.nit index a097ff5..3a141f6 100644 --- a/contrib/friendz/src/grid.nit +++ b/contrib/friendz/src/grid.nit @@ -191,14 +191,14 @@ class Grid fun save: String do var res = "" - var str = ".#ABCDEFGHI" + var str = ".abcdefghi#ABCDEFGHI" for y in [0..height[ do var rle = 0 var last: nullable Int = null for x in [0..width[ do var t = self.grid[x][y] - var tk = 0 - if t.fixed then tk = t.kind + 1 + var tk = t.kind + if t.fixed then tk += 10 if tk == last and rle<9 then rle += 1 else @@ -243,6 +243,7 @@ class Grid x += 1 else if c == '#' then var t = self.get(x,y) + assert t != null t.fixed = true x += 1 else if c >= 'A' and c <= 'I' then @@ -251,6 +252,11 @@ class Grid t.update(c.ascii-'A'.ascii+1) t.fixed = true x += 1 + else if c >= 'a' and c <= 'i' then + var t = self.get(x,y) + assert t != null + t.update(c.ascii-'a'.ascii+1) + x += 1 else if c >= '1' and c <= '9' then rle = c.to_i else @@ -261,7 +267,7 @@ class Grid if x>0 then y += 1 if x > mx then mx = x if y > my then my = y - if mx<3 or my<3 or mx>=max_width or my>=max_height then + if mx<3 or my<3 or mx>max_width or my>max_height then return false end self.resize(mx,my) diff --git a/contrib/friendz/src/level.nit b/contrib/friendz/src/level.nit index 9d8029e..b09f1f2 100644 --- a/contrib/friendz/src/level.nit +++ b/contrib/friendz/src/level.nit @@ -23,7 +23,7 @@ class Level var ls = code.split(";") self.number = i self.str = ls[0] - self.par = ls[1].to_i + self.gold = ls[1].to_i if ls.length >= 3 then self.status = ls[2] end @@ -47,8 +47,8 @@ class Level # initial grid position var str: String - # top score - var par: Int + # top score to get gold + var gold: Int # Help message if any var status: String = "" @@ -72,32 +72,28 @@ class Level var l_disabled = 1 var l_open = 2 var l_won = 3 - var l_par = 4 + var l_gold = 4 fun get_state: Int do if self.score == 0 then if self.number == 0 or game.levels[self.number-1].score > 0 then return l_open if self.number == 25 and game.levels[19].score > 0 then return l_open else return l_disabled - else if self.score < self.par or not game.levels[9].score > 0 then + else if self.score < self.gold or not game.levels[9].score > 0 then return l_won - else return l_par + else return l_gold end # Returns true if g is a wining condition for the level. fun check_won(g: Grid): Bool do - var w = g.won and (not self.is_challenge or g.number >= self.par) + var w = g.won and (not self.is_challenge or g.number >= self.gold) if not w then return false if g.number > self.score then self.score = g.number - self.save end return true end - - # Save the score of the level - fun save do end end # main game object diff --git a/contrib/mnit_test/org.nitlanguage.test_minimal.txt b/contrib/mnit_test/org.nitlanguage.test_minimal.txt new file mode 100644 index 0000000..9f3bb3c --- /dev/null +++ b/contrib/mnit_test/org.nitlanguage.test_minimal.txt @@ -0,0 +1,10 @@ +Categories:Nit +License:Apache2 +Web Site:http://nitlanguage.org +Source Code:http://nitlanguage.org/nit.git/tree/HEAD:/contrib/mnit_test +Issue Tracker:https://github.com/nitlang/nit/issues + +Summary:Minimal Demo for MNit +Description: +A useless application that test various basic API usage of the mnit framework on Android. +. diff --git a/contrib/tinks/net.xymus.tinks.txt b/contrib/tinks/net.xymus.tinks.txt new file mode 100644 index 0000000..ceed2bc --- /dev/null +++ b/contrib/tinks/net.xymus.tinks.txt @@ -0,0 +1,13 @@ +Categories:Nit,Games +License:Apache2 +Web Site:http://nitlanguage.org +Source Code:http://nitlanguage.org/nit.git/tree/HEAD:/contrib/tinks +Issue Tracker:https://github.com/nitlang/nit/issues + +Summary:Multiplayer crossplatform action game with destructible procedurally generated worlds +Description: +Each player controls a tank, opens fire from the turret and navigates between the terrain features. +Explosions from turret fire and tank destruction have different forces and destroy the terrain. +Each tank needs 4 hits to be destroyed. +Destroyed tanks drop health power-ups which can repair other tanks. +. diff --git a/examples/calculator/Makefile b/examples/calculator/Makefile index edcfc14..24b10ab 100644 --- a/examples/calculator/Makefile +++ b/examples/calculator/Makefile @@ -1,17 +1,26 @@ NITC=../../bin/nitc NITLS=../../bin/nitls -all: bin/calculator bin/calculator.apk bin/test +all: bin/calculator bin/test bin/calculator: $(shell ${NITLS} -M src/calculator.nit -m linux) ${NITC} mkdir -p bin ${NITC} -o $@ src/calculator.nit -m linux -bin/calculator.apk: $(shell ${NITLS} -M src/calculator.nit -m android) ${NITC} ../../contrib/inkscape_tools/bin/svg_to_icons - mkdir -p bin res - ../../contrib/inkscape_tools/bin/svg_to_icons art/icon.svg --android --out res/ +android: bin/calculator.apk + +bin/calculator.apk: $(shell ${NITLS} -M src/calculator.nit -m android) ${NITC} res/drawable-ldpi/icon.png + mkdir -p bin ${NITC} -o $@ src/calculator.nit -m ../../lib/android/ui/ -D debug +android-release: $(shell ${NITLS} -M src/calculator.nit -m android) ${NITC} res/drawable-ldpi/icon.png + mkdir -p bin + ${NITC} -o bin/calculator.apk src/calculator.nit -m ../../lib/android/ui/ --release + +res/drawable-ldpi/icon.png: art/icon.svg ../../contrib/inkscape_tools/bin/svg_to_icons + mkdir -p res + ../../contrib/inkscape_tools/bin/svg_to_icons art/icon.svg --android --out res/ + ../../contrib/inkscape_tools/bin/svg_to_icons: make -C ../../contrib/inkscape_tools/ diff --git a/examples/calculator/org.nitlanguage.calculator.txt b/examples/calculator/org.nitlanguage.calculator.txt new file mode 100644 index 0000000..264d18b --- /dev/null +++ b/examples/calculator/org.nitlanguage.calculator.txt @@ -0,0 +1,12 @@ +Categories:Nit +License:Apache2 +Web Site:http://nitlanguage.org +Source Code:http://nitlanguage.org/nit.git/tree/HEAD:/examples/calculator +Issue Tracker:https://github.com/nitlang/nit/issues + +Summary:A Basic Calculator +Description: +10 digits, 4 operations, hours of fun. + +This is the official example of a portable GUI application built using app.nit. +. diff --git a/lib/android/audio.nit b/lib/android/audio.nit index b361b4f..9cc54d7 100644 --- a/lib/android/audio.nit +++ b/lib/android/audio.nit @@ -377,6 +377,16 @@ class MediaPlayer # Load a sound for a given resource id fun load_sound(id: Int, context: NativeActivity): Music do + # FIXME: maybe find a better way to handle this situation + # If two different music are loaded with the same `MediaPlayer`, + # a new `NativeMediaPlayer` will be created for the secondd music + # and the nit program will loose the handle to the previous one + # If the previous music is playing, we need to stop it + if playing then + stop + reset + destroy + end self.nmedia_player = self.nmedia_player.create(context, id) if self.nmedia_player.is_java_null then self.error = new Error("Failed to load a sound") @@ -482,6 +492,10 @@ class MediaPlayer end redef class PlayableAudio + # Flag to know if the user paused the sound + # Used when the app pause all sounds or resume all sounds + var paused: Bool = false + redef init do add_to_sounds(self) end @@ -544,11 +558,13 @@ redef class Sound redef fun pause do if self.error != null or not self.is_loaded then return soundpool.pause_stream(soundpool_id) + paused = true end redef fun resume do if self.error != null or not self.is_loaded then return soundpool.resume(soundpool_id) + paused = false end end @@ -606,11 +622,13 @@ redef class Music redef fun pause do if self.error != null or not self.is_loaded then return media_player.pause + paused = true end redef fun resume do if self.error != null or not self.is_loaded then return play + paused = false end end @@ -674,7 +692,16 @@ redef class App redef fun on_pause do super - for s in sounds do s.pause + for s in sounds do + # Pausing sounds that are not already paused by user + # `s.paused` is set to false because `pause` set it to true + # and we want to know which sound has been paused by the user + # and which one has been paused by the app + if not s.paused then + s.pause + s.paused = false + end + end audio_manager.abandon_audio_focus end @@ -687,7 +714,10 @@ redef class App redef fun on_resume do super audio_manager.request_audio_focus - for s in sounds do s.resume + for s in sounds do + # Resumes only the sounds paused by the App + if not s.paused then s.resume + end end end diff --git a/misc/jenkins/check_contrib.sh b/misc/jenkins/check_contrib.sh index fafeb92..df81660 100755 --- a/misc/jenkins/check_contrib.sh +++ b/misc/jenkins/check_contrib.sh @@ -29,19 +29,22 @@ failed= for p in $projects; do dir=`dirname "$p"` name=`basename "$dir"` - echo "*** make $dir ***" - if misc/jenkins/unitrun.sh "cmd-$name-make" make -C "$dir"; then - # Make OK. Check additional rules if they exists - for rule in $rules; do - make -C "$dir" $rule -n 2>/dev/null || - continue - echo "*** make$rule $dir ***" - misc/jenkins/unitrun.sh "cmd-$name-make$rule" make -C "$dir" $rule || - failed="$failed $name-$rule" - done - else - failed="$failed $name" - fi + echo "### in $dir ###" + # Check each rules, if they exists + for rule in $rules; do + make -C "$dir" $rule -n >/dev/null 2>/dev/null || { + # Special case for `all` that falls back as the default target + if [ "$rule" = "all" ]; then + echo "*** make -C $dir ***" + misc/jenkins/unitrun.sh "cmd-$name-make" make -C "$dir" || + failed="$failed $name" + fi + continue + } + echo "*** make $rule -C $dir ***" + misc/jenkins/unitrun.sh "cmd-$name-make$rule" make -C "$dir" $rule || + failed="$failed $name-$rule" + done done grep '