From: Jean Privat Date: Tue, 27 Jan 2015 01:28:54 +0000 (+0700) Subject: Merge: lib/github: uses nitcorn to listen Github hook events. X-Git-Tag: v0.7.1~9 X-Git-Url: http://nitlanguage.org?hp=5ade49f56ca8b51a742680cd4436f0cd80c4443a Merge: lib/github: uses nitcorn to listen Github hook events. This module introduces an abstract listener for Github hooks with nitcorn. PS: OMG first PR with syntax highligh!!!! Thx @R4PaSs ! Signed-off-by: Alexandre Terrasa Pull-Request: #1115 Reviewed-by: Jean Privat Reviewed-by: Lucas Bajolet --- diff --git a/.gitignore b/.gitignore index 5cd49a0..2156619 100644 --- a/.gitignore +++ b/.gitignore @@ -55,3 +55,4 @@ nitunit.xml *.stub.nit.[ch] .metadata/* +.github_data diff --git a/contrib/pep8analysis/src/pep8analysis_web.nit b/contrib/pep8analysis/src/pep8analysis_web.nit index dacc9ff..b991952 100644 --- a/contrib/pep8analysis/src/pep8analysis_web.nit +++ b/contrib/pep8analysis/src/pep8analysis_web.nit @@ -20,8 +20,8 @@ # analysis results. The result graph will be sent to the JavaScript function # `show_graph` with the source of the graph in Graphviz's dot. module pep8analysis_web is - cpp_compiler_option("--std=c++11 --bind") - c_linker_option("--bind") + cppflags "--std=c++11 --bind" + ldflags "--bind" end import emscripten diff --git a/examples/rosettacode/doors_with_classes.nit b/examples/rosettacode/doors_with_classes.nit new file mode 100644 index 0000000..62c5f14 --- /dev/null +++ b/examples/rosettacode/doors_with_classes.nit @@ -0,0 +1,34 @@ +#!/usr/bin/env nit +# +# This file is part of NIT ( http://www.nitlanguage.org ). +# This program is public domain + +# Task: 100 doors +# SEE: + +# A door with two states: open or closed +class Door + # Is this door open? + var open = false + + # Toggle bool value of open + fun toggle do open = not open + + redef fun to_s: String + do + return if open then "Open" else "Closed" + end +end + +var doors = new Array[Door] +for door in [0..100[ do doors.add(new Door) + +var n = 100 +for visit in [0..n[ do + var i = visit + while i < n do + doors[i].toggle + i += visit+1 + end +end +for i in [0..n[ do print "Door {i+1}: {doors[i]}" diff --git a/lib/android/native_app_glue.nit b/lib/android/native_app_glue.nit index fc5a19f..af3c797 100644 --- a/lib/android/native_app_glue.nit +++ b/lib/android/native_app_glue.nit @@ -301,7 +301,10 @@ extern class NativeAppGlue `{ struct android_app* `} # We use the `userData` field of the C structure to store an handle to # the associated App private fun user_data: App `{ return recv->userData; `} - private fun user_data=(val: App) `{ recv->userData = val; `} + private fun user_data=(val: App) `{ + App_incr_ref(val); + recv->userData = val; + `} # Fill this in with the function to process input events. At this point # the event has already been pre-dispatched, and it will be finished upon diff --git a/lib/android/ui.nit b/lib/android/ui.nit index 98ee444..ae5d572 100644 --- a/lib/android/ui.nit +++ b/lib/android/ui.nit @@ -331,22 +331,15 @@ extern class NativeTextView in "Java" `{ android.widget.TextView `} fun text=(value: JavaString) in "Java" `{ - android.util.Log.d("Nity", "1"); final TextView final_recv = recv; final String final_value = value; - android.util.Log.d("Nity", "4"); ((NativeActivity)recv.getContext()).runOnUiThread(new Runnable() { @Override public void run() { - android.util.Log.d("Nity", "-5"); - android.util.Log.d("Nity", final_value); - android.util.Log.d("Nity", "-5.5"); final_recv.setText(final_value); - android.util.Log.d("Nity", "-6"); } }); - android.util.Log.d("Nity", "7"); `} fun enabled: Bool in "Java" `{ return recv.isEnabled(); `} diff --git a/lib/cocoa/app_kit.nit b/lib/cocoa/app_kit.nit index 91bc87c..5fe0af2 100644 --- a/lib/cocoa/app_kit.nit +++ b/lib/cocoa/app_kit.nit @@ -15,7 +15,7 @@ # limitations under the License. # The Application Kit provides services to create GUI -module app_kit is c_linker_option "-framework AppKit" +module app_kit is ldflags "-framework AppKit" import foundation diff --git a/lib/cocoa/cocoa.nit b/lib/cocoa/cocoa.nit index 99c6b12..09e1291 100644 --- a/lib/cocoa/cocoa.nit +++ b/lib/cocoa/cocoa.nit @@ -20,7 +20,7 @@ # # This wrapper of the Cocoa API regroups the Foundation Kit and the # Application Kit. -module cocoa is c_linker_option "-framework Cocoa" +module cocoa is ldflags "-framework Cocoa" import foundation import app_kit diff --git a/lib/cocoa/foundation.nit b/lib/cocoa/foundation.nit index ab027fd..cbe8f08 100644 --- a/lib/cocoa/foundation.nit +++ b/lib/cocoa/foundation.nit @@ -15,7 +15,7 @@ # limitations under the License. # The Foundation Kit provides basic Objective-C classes and structures -module foundation is c_linker_option "-framework Foundation" +module foundation is ldflags "-framework Foundation" in "ObjC Header" `{ #import diff --git a/lib/cpp.nit b/lib/cpp.nit index 6fe897a..78bb96c 100644 --- a/lib/cpp.nit +++ b/lib/cpp.nit @@ -16,7 +16,7 @@ # Offers features to interface with C++ code and libraries module cpp is - new_annotation cpp_compiler_option + new_annotation cppflags end # A pointer to a C++ std::string instance diff --git a/lib/github/api.nit b/lib/github/api.nit index b979b5d..2655ae3 100644 --- a/lib/github/api.nit +++ b/lib/github/api.nit @@ -133,7 +133,7 @@ class GithubAPI # Load the json object from Github. # See `GithubEntity::load_from_github`. - private fun load_from_github(key: String): JsonObject do + protected fun load_from_github(key: String): JsonObject do message(1, "Get {key} (github)") var res = get(key) if was_error then return new JsonObject diff --git a/lib/github/cache.nit b/lib/github/cache.nit new file mode 100644 index 0000000..559b4a8 --- /dev/null +++ b/lib/github/cache.nit @@ -0,0 +1,80 @@ +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Enable caching on Github API accesses. +# +# If `GithubAPI::enable_cache` is set to true then Github JSON responses +# will be cached locally using `JsonStore`. +# +# Cache can be used to limit the number of access on the API and lighten +# the rate limit on your github key. +# +# Usage: +# +# ~~~ +# var api = new GithubAPI(get_github_oauth) +# api.enable_cache = true +# +# var name = "privat/nit" +# assert not api.has_cache(name) +# var repo = api.load_repo(name) # load from GitHub +# assert api.has_cache(name) +# repo = api.load_repo(name) # load from cache +# +# api.clear_cache +# assert not api.has_cache(name) +# ~~~ +module cache + +intrude import github::api +import json::store + +redef class GithubAPI + + # Enable caching for this client. + # Default is `false`. + var enable_cache = false is writable + + # JsonStore used to cache data. + # + # Default directory is `".github_data/"`. + var store = new JsonStore(".github_data/") is writable, lazy + + # Delete the cache directory. + fun clear_cache do store.clear + + # If no cache data is found for `key` then json is loaded from Github API. + redef fun load_from_github(key) do + if not enable_cache then return super + if store.has_key(key) then + message(1, "Get {key} (cache)") + was_error = false + return store.load_object(key) + end + var obj = super + if not was_error then cache(key, obj) + return obj + end + + # Save `json` data in cache under `key`. + private fun cache(key: String, json: JsonObject) do + message(2, "Cache key {key}") + store.store_object(key, json) + end + + # Check if a cache file exists for `key`. + fun has_cache(key: String): Bool do + return store.has_key(key) + end +end diff --git a/lib/github/github.nit b/lib/github/github.nit index 778f826..9bc63a8 100644 --- a/lib/github/github.nit +++ b/lib/github/github.nit @@ -15,4 +15,4 @@ # Github API related features. module github -import api +import cache diff --git a/lib/java/java.nit b/lib/java/java.nit index c3db430..2020e30 100644 --- a/lib/java/java.nit +++ b/lib/java/java.nit @@ -27,8 +27,8 @@ # most of JNI functions. You can use it to further customize the behavior # of your code. module java is - c_compiler_option "-I $(JAVA_HOME)/include/ -I $(JAVA_HOME)/include/linux/" - c_linker_option("-L $(JNI_LIB_PATH) -ljvm") + cflags "-I $(JAVA_HOME)/include/ -I $(JAVA_HOME)/include/linux/" + ldflags "-L $(JNI_LIB_PATH) -ljvm" new_annotation extra_java_files end diff --git a/lib/jvm.nit b/lib/jvm.nit index 6063f23..abdcab6 100644 --- a/lib/jvm.nit +++ b/lib/jvm.nit @@ -19,8 +19,8 @@ # # See: http://docs.oracle.com/javase/1.5.0/docs/guide/jni/spec/jniTOC.html module jvm is - c_compiler_option "-I $(JAVA_HOME)/include/ -I $(JAVA_HOME)/include/linux/" - c_linker_option "-L $(JNI_LIB_PATH) -ljvm" + cflags "-I $(JAVA_HOME)/include/ -I $(JAVA_HOME)/include/linux/" + ldflags "-L $(JNI_LIB_PATH) -ljvm" end in "C Header" `{ diff --git a/lib/mpi.nit b/lib/mpi.nit index 01137f7..de91686 100644 --- a/lib/mpi.nit +++ b/lib/mpi.nit @@ -26,8 +26,8 @@ # Since this module is a thin wrapper around OpenMPI, in case of missing # documentation, you can refer to https://www.open-mpi.org/doc/v1.8/. module mpi is - c_compiler_option(exec("mpicc", "-showme:compile")) - c_linker_option(exec("mpicc", "-showme:link")) + cflags exec("mpicc", "-showme:compile") + ldflags exec("mpicc", "-showme:link") end import c diff --git a/lib/pthreads/extra.nit b/lib/pthreads/extra.nit index 416b174..e408270 100644 --- a/lib/pthreads/extra.nit +++ b/lib/pthreads/extra.nit @@ -16,8 +16,8 @@ # Offers some POSIX threads services that are not available on all platforms module extra is - c_compiler_option("-pthread") - c_linker_option("-pthread") + cflags "-pthread" + ldflags "-pthread" end intrude import pthreads diff --git a/lib/pthreads/pthreads.nit b/lib/pthreads/pthreads.nit index bce93c4..5d6b80d 100644 --- a/lib/pthreads/pthreads.nit +++ b/lib/pthreads/pthreads.nit @@ -16,8 +16,8 @@ # Main POSIX threads support and intro the classes `Thread`, `Mutex` and `Barrier` module pthreads is - c_compiler_option("-pthread") - c_linker_option("-pthread") + cflags "-pthread" + ldflags "-pthread" pkgconfig "bdw-gc" end diff --git a/lib/realtime.nit b/lib/realtime.nit index b66ade0..3a02d86 100644 --- a/lib/realtime.nit +++ b/lib/realtime.nit @@ -11,7 +11,7 @@ # another product. # Provides the Clock utility class to keep time of real time flow -module realtime is c_linker_option("-lrt") +module realtime is ldflags "-lrt" in "C header" `{ #ifdef _POSIX_C_SOURCE diff --git a/lib/sdl.nit b/lib/sdl.nit index 16695e2..41ddc5b 100644 --- a/lib/sdl.nit +++ b/lib/sdl.nit @@ -16,8 +16,8 @@ # SDL display support (used in Linux for windows and inputes only) module sdl is - c_compiler_option(exec("sdl-config", "--cflags")) - c_linker_option(exec("sdl-config", "--libs"), "-lSDL_image -lSDL_ttf") + cflags exec("sdl-config", "--cflags") + ldflags(exec("sdl-config", "--libs"), "-lSDL_image -lSDL_ttf") end import mnit_display diff --git a/lib/sdl2/image.nit b/lib/sdl2/image.nit index 6dc53b3..ce642b8 100644 --- a/lib/sdl2/image.nit +++ b/lib/sdl2/image.nit @@ -20,7 +20,7 @@ # alone: JPG, PNG, TIF, GIT, ICO and much more. module image is pkgconfig "sdl2" - c_linker_option "-lSDL2_image" + ldflags "-lSDL2_image" end import sdl2 diff --git a/share/libgc/.gitignore b/share/libgc/.gitignore new file mode 100644 index 0000000..98279d0 --- /dev/null +++ b/share/libgc/.gitignore @@ -0,0 +1,4 @@ +include +lib +share +src diff --git a/share/libgc/android-setup-libgc.sh b/share/libgc/android-setup-libgc.sh new file mode 100755 index 0000000..8e20ca0 --- /dev/null +++ b/share/libgc/android-setup-libgc.sh @@ -0,0 +1,98 @@ +#!/bin/bash +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Fetch, configure and build libgc (the Boehm GC) for Android +# +# Will produce libgc.a which can be linked to Android NDK applications. +# +# The `ndk-build` tool from the Android NDK must be in PATH before +# invoking this tool. It will be used to guess the path to the NDK. +# +# Alternatively, you may define a custom path to the NDK by setting +# `ANDROID_NDK`. + +# If ANDROID_NDK is not set, get it from the path to `ndk-build` +if test -z "$ANDROID_NDK"; then + ndk_build_path=`which ndk-build` + if test $? -ne 0; then + echo "Error: ndk-build from the Android NDK must be in your PATH" + exit 1 + fi + + ANDROID_NDK=`dirname $ndk_build_path` +fi + +# Get the first platform available (it shouldn't change much, but it may +# have to be adjusted) +for platform in `echo $ANDROID_NDK/platforms/android-*/arch-arm`; do + SYS_ROOT=$platform + break +done + +if test -z "$SYS_ROOT"; then + echo "Error: could not an Android platform in the NDK, define ANDROID_NDK to the correct path." + exit 1 +fi + +# Information on the currently targeted libgc and libatomic_ops source URL +# These may have to be updated according to server-side changes and newer +# versions of the Boehm GC. +libgc_url=http://www.hboehm.info/gc/gc_source/gc-7.4.0.tar.gz +libgc_dir=gc-7.4.0 +libatomic_ops_url=http://www.hboehm.info/gc/gc_source/libatomic_ops-7.4.0.tar.gz +libatomic_ops_dir=libatomic_ops-7.4.0 + +# Absolute installation path +if expr match "$0" "^/.*"; then + install="`dirname "$0"`" +else + install="`pwd`/`dirname "$0"`" +fi + +# Local source directory +mkdir -p "$install/src" +cd "$install/src" + +# Download libs +for url in $libgc_url $libatomic_ops_url; do + echo "Downloading $url..." + curl --progress-bar -o `basename $url` $url || exit 1 +done + +if test -d $libgc_dir; then + rm -r $libgc_dir +fi + +# Extract +tar -xzf `basename $libgc_url` || exit 1 +tar -xzf `basename $libatomic_ops_url` || exit 1 +mv $libatomic_ops_dir $libgc_dir/libatomic_ops || exit 1 + +cd $libgc_dir || exit 1 + +# Configure for Android +path="$ANDROID_NDK/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/" +export CC="$path/arm-linux-androideabi-gcc --sysroot=$SYS_ROOT" +export CXX="$path/arm-linux-androideabi-g++ --sysroot=$SYS_ROOT" +export LD="$path/arm-linux-androideabi-ld" +export AR="$path/arm-linux-androideabi-ar" +export RANLIB="$path/arm-linux-androideabi-ranlib" +export STRIP="$path/arm-linux-androideabi-strip" +export CFLAGS="-DIGNORE_DYNAMIC_LOADING -DPLATFORM_ANDROID -I libatomic_ops/src/" +export LIBS="-lc -lgcc" +./configure --host=arm-linux-androideabi --enable-static --disable-shared --prefix="$install" || exit 1 + +# Compile and install locally +make install -j 4 || exit 1 diff --git a/src/changelog.sh b/src/changelog.sh index 754f545..e85393d 100755 --- a/src/changelog.sh +++ b/src/changelog.sh @@ -26,8 +26,10 @@ echo "shortstat" git diff --shortstat "$orig".."$cur" echo "PR" git log --first-parent "$orig".."$cur" | grep 'Pull-Request: #' | wc -l +echo "non-merge commits" +git log --no-merges --oneline "$orig".."$cur" | wc -l echo "shortlog" -git shortlog -ens "$orig".."$cur" +git shortlog -ens --no-merges "$orig".."$cur" echo log echo git log --format="* %s [[!commit %h]]" --first-parent "$orig".."$cur" | tac diff --git a/src/compiler/compiler_ffi.nit b/src/compiler/compiler_ffi.nit index 8466af1..ac7bad3 100644 --- a/src/compiler/compiler_ffi.nit +++ b/src/compiler/compiler_ffi.nit @@ -52,7 +52,7 @@ extern void nitni_global_ref_decr(void*); nitni_ccu.write_as_nitni(self, v.compiler.modelbuilder.compile_dir) for file in nitni_ccu.files do - var f = new ExternCFile(file, c_compiler_options) + var f = new ExternCFile(file, cflags) f.pkgconfigs.add_all pkgconfigs v.compiler.extern_bodies.add(f) end @@ -76,7 +76,7 @@ extern void nitni_global_ref_decr(void*); redef fun collect_linker_libs do - var s = c_linker_options + var s = ldflags if s.is_empty then return null var res = new ArraySet[String] res.add s diff --git a/src/ffi/c.nit b/src/ffi/c.nit index 8ae08b9..ebd2277 100644 --- a/src/ffi/c.nit +++ b/src/ffi/c.nit @@ -72,8 +72,8 @@ redef class Location end redef class MModule - var c_compiler_options = "" is writable - var c_linker_options = "" is writable + var cflags = "" is writable + var ldflags = "" is writable # Additional libraries needed for the compilation # Will be used with pkg-config diff --git a/src/ffi/c_compiler_options.nit b/src/ffi/c_compiler_options.nit index af4e938..e4756a8 100644 --- a/src/ffi/c_compiler_options.nit +++ b/src/ffi/c_compiler_options.nit @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Offers the annotations `c_compiler_option` and `c_linker_option` to specify +# Offers the annotations `cflags` and `ldflags` to specify # options for the C compiler directly or indirectly. Differs from the `pkgconfig` # annotation by the separation of the options between the compiler and linker. module c_compiler_options @@ -24,15 +24,15 @@ import cpp private import annotation redef class ToolContext - var c_compiler_options_phase: Phase = new CCompilerOptionsPhase(self, null) + var cflags_phase: Phase = new CCompilerOptionsPhase(self, null) end private class CCompilerOptionsPhase super Phase - fun compiler_annotation_name: String do return "c_compiler_option" - fun linker_annotation_name: String do return "c_linker_option" - fun cpp_compiler_annotation_name: String do return "cpp_compiler_option" + fun compiler_annotation_name: String do return "cflags" + fun linker_annotation_name: String do return "ldflags" + fun cpp_compiler_annotation_name: String do return "cppflags" redef fun process_annotated_node(nmoduledecl, nat) do @@ -145,17 +145,17 @@ private class CCompilerOptionsPhase fun process_c_compiler_annotation(mmodule: MModule, opt: String) do - mmodule.c_compiler_options = "{mmodule.c_compiler_options} {opt}" + mmodule.cflags = "{mmodule.cflags} {opt}" end fun process_c_linker_annotation(mmodule: MModule, opt: String) do - mmodule.c_linker_options = "{mmodule.c_linker_options} {opt}" + mmodule.ldflags = "{mmodule.ldflags} {opt}" end fun process_cpp_compiler_annotation(mmodule: MModule, opt: String) do - mmodule.cpp_compiler_options = "{mmodule.cpp_compiler_options} {opt}" + mmodule.cppflags = "{mmodule.cppflags} {opt}" end end diff --git a/src/ffi/cpp.nit b/src/ffi/cpp.nit index a6a8ca3..e114cd2 100644 --- a/src/ffi/cpp.nit +++ b/src/ffi/cpp.nit @@ -27,7 +27,7 @@ end redef class MModule private var cpp_file: nullable CPPCompilationUnit = null - var cpp_compiler_options = "" is writable + var cppflags = "" is writable end class CPPLanguage @@ -133,7 +133,7 @@ class CPPLanguage mmodule.ffi_files.add(file) # add linked option to support C++ - mmodule.c_linker_options = "{mmodule.c_linker_options} -lstdc++" + mmodule.ldflags = "{mmodule.ldflags} -lstdc++" end redef fun compile_callback(callback, mmodule, mainmodule, ecc) @@ -180,7 +180,7 @@ class ExternCppFile var mmodule: MModule redef fun makefile_rule_name do return "{filename.basename("")}.o" - redef fun makefile_rule_content do return "$(CXX) $(CFLAGS) {mmodule.cpp_compiler_options} -c {filename.basename("")} -o {filename.basename("")}.o" + redef fun makefile_rule_content do return "$(CXX) $(CFLAGS) {mmodule.cppflags} -c {filename.basename("")} -o {filename.basename("")}.o" redef fun compiles_to_o_file do return true end diff --git a/src/ffi/ffi.nit b/src/ffi/ffi.nit index b854750..cccb7a0 100644 --- a/src/ffi/ffi.nit +++ b/src/ffi/ffi.nit @@ -62,7 +62,7 @@ redef class MModule ffi_ccu.write_as_impl(self, compdir) for filename in ffi_ccu.files do - var f = new ExternCFile(filename, c_compiler_options) + var f = new ExternCFile(filename, cflags) f.pkgconfigs.add_all pkgconfigs ffi_files.add(f) end diff --git a/src/ffi/java.nit b/src/ffi/java.nit index 1fa56e9..77c3c56 100644 --- a/src/ffi/java.nit +++ b/src/ffi/java.nit @@ -242,8 +242,8 @@ redef class MModule # Tell the C compiler where to find jni.h and how to link with libjvm private fun insert_compiler_options do - c_compiler_options = "{c_compiler_options} -I $(JAVA_HOME)/include/ -I $(JAVA_HOME)/include/linux/" - c_linker_options = "{c_linker_options} -L $(JNI_LIB_PATH) -ljvm" + cflags = "{cflags} -I $(JAVA_HOME)/include/ -I $(JAVA_HOME)/include/linux/" + ldflags = "{ldflags} -L $(JNI_LIB_PATH) -ljvm" end # Name of the generated Java class where to store all implementation methods of this module diff --git a/src/ffi/objc.nit b/src/ffi/objc.nit index f031289..7e309bc 100644 --- a/src/ffi/objc.nit +++ b/src/ffi/objc.nit @@ -154,7 +154,7 @@ private class ObjCCompilationUnit files.add compdir/c_file - mmodule.c_linker_options = "{mmodule.c_linker_options} -lobjc" + mmodule.ldflags = "{mmodule.ldflags} -lobjc" return new ExternObjCFile(compdir/c_file, mmodule) end diff --git a/src/frontend/check_annotation.nit b/src/frontend/check_annotation.nit index fa909bc..a51bece 100644 --- a/src/frontend/check_annotation.nit +++ b/src/frontend/check_annotation.nit @@ -92,8 +92,8 @@ extern no_warning pkgconfig -c_compiler_option -c_linker_option +cflags +ldflags platform """ diff --git a/src/platform/android.nit b/src/platform/android.nit index 6ba5502..78ba820 100644 --- a/src/platform/android.nit +++ b/src/platform/android.nit @@ -34,6 +34,8 @@ end class AndroidPlatform super Platform + redef fun supports_libgc do return true + redef fun supports_libunwind do return false redef fun supports_linker_script do return false @@ -146,11 +148,11 @@ include $(call all-subdir-makefiles) LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) -LOCAL_CFLAGS := -D ANDROID +LOCAL_CFLAGS := -D ANDROID -D WITH_LIBGC LOCAL_MODULE := main LOCAL_SRC_FILES := \\ {{{cfiles.join(" \\\n")}}} -LOCAL_LDLIBS := -llog -landroid -lEGL -lGLESv1_CM -lz +LOCAL_LDLIBS := -llog -landroid -lEGL -lGLESv1_CM -lz libgc.a LOCAL_STATIC_LIBRARIES := android_native_app_glue png include $(BUILD_SHARED_LIBRARY) @@ -219,6 +221,15 @@ $(call import-module,android/native_app_glue) toolcontext.exec_and_check(["ln", "-s", "{share_dir}/png/", target_png_dir], "Android project error") end + # Ensure that android-setup-libgc.sh has been executed + if not "{share_dir}/libgc/lib".file_exists then + toolcontext.exec_and_check(["{share_dir}/libgc/android-setup-libgc.sh"], "Android project error") + end + + # Copy GC files + toolcontext.exec_and_check(["cp", "{share_dir}/libgc/lib/libgc.a", "{android_project_root}/libgc.a"], "Android project error") + toolcontext.exec_and_check(["ln", "-s", "{share_dir}/libgc/include/gc/", "{android_project_root}/jni/nit_compile/gc"], "Android project error") + ### Link to assets (for mnit and others) # This will be accessed from `android_project_root` var assets_dir diff --git a/tests/error_annot_c_compiler.nit b/tests/error_annot_c_compiler.nit index 69e3f0d..6eddab1 100644 --- a/tests/error_annot_c_compiler.nit +++ b/tests/error_annot_c_compiler.nit @@ -14,12 +14,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -#alt1# module error_annot_c_compiler_alt1 is c_compiler_option -#alt2# module error_annot_c_compiler_alt2 is c_compiler_option(foo("llvm-config")) -#alt3# module error_annot_c_compiler_alt3 is c_compiler_option(foo("llvm-config", "2nd arg")) -#alt4# module error_annot_c_compiler_alt4 is c_linker_option -#alt5# module error_annot_c_compiler_alt5 is c_compiler_option(exec("invalid-program")) -#alt6# module error_annot_c_compiler_alt6 is c_compiler_option(exec) +#alt1# module error_annot_c_compiler_alt1 is cflags +#alt2# module error_annot_c_compiler_alt2 is cflags(foo("llvm-config")) +#alt3# module error_annot_c_compiler_alt3 is cflags(foo("llvm-config", "2nd arg")) +#alt4# module error_annot_c_compiler_alt4 is ldflags +#alt5# module error_annot_c_compiler_alt5 is cflags(exec("invalid-program")) +#alt6# module error_annot_c_compiler_alt6 is cflags(exec) fun foo `{ printf("nothing...\n"); `} diff --git a/tests/sav/doors_with_classes.res b/tests/sav/doors_with_classes.res new file mode 100644 index 0000000..23c9daf --- /dev/null +++ b/tests/sav/doors_with_classes.res @@ -0,0 +1,100 @@ +Door 1: Open +Door 2: Closed +Door 3: Closed +Door 4: Open +Door 5: Closed +Door 6: Closed +Door 7: Closed +Door 8: Closed +Door 9: Open +Door 10: Closed +Door 11: Closed +Door 12: Closed +Door 13: Closed +Door 14: Closed +Door 15: Closed +Door 16: Open +Door 17: Closed +Door 18: Closed +Door 19: Closed +Door 20: Closed +Door 21: Closed +Door 22: Closed +Door 23: Closed +Door 24: Closed +Door 25: Open +Door 26: Closed +Door 27: Closed +Door 28: Closed +Door 29: Closed +Door 30: Closed +Door 31: Closed +Door 32: Closed +Door 33: Closed +Door 34: Closed +Door 35: Closed +Door 36: Open +Door 37: Closed +Door 38: Closed +Door 39: Closed +Door 40: Closed +Door 41: Closed +Door 42: Closed +Door 43: Closed +Door 44: Closed +Door 45: Closed +Door 46: Closed +Door 47: Closed +Door 48: Closed +Door 49: Open +Door 50: Closed +Door 51: Closed +Door 52: Closed +Door 53: Closed +Door 54: Closed +Door 55: Closed +Door 56: Closed +Door 57: Closed +Door 58: Closed +Door 59: Closed +Door 60: Closed +Door 61: Closed +Door 62: Closed +Door 63: Closed +Door 64: Open +Door 65: Closed +Door 66: Closed +Door 67: Closed +Door 68: Closed +Door 69: Closed +Door 70: Closed +Door 71: Closed +Door 72: Closed +Door 73: Closed +Door 74: Closed +Door 75: Closed +Door 76: Closed +Door 77: Closed +Door 78: Closed +Door 79: Closed +Door 80: Closed +Door 81: Open +Door 82: Closed +Door 83: Closed +Door 84: Closed +Door 85: Closed +Door 86: Closed +Door 87: Closed +Door 88: Closed +Door 89: Closed +Door 90: Closed +Door 91: Closed +Door 92: Closed +Door 93: Closed +Door 94: Closed +Door 95: Closed +Door 96: Closed +Door 97: Closed +Door 98: Closed +Door 99: Closed +Door 100: Open diff --git a/tests/sav/error_annot_c_compiler_alt1.res b/tests/sav/error_annot_c_compiler_alt1.res index 981a90b..23b9437 100644 --- a/tests/sav/error_annot_c_compiler_alt1.res +++ b/tests/sav/error_annot_c_compiler_alt1.res @@ -1 +1 @@ -alt/error_annot_c_compiler_alt1.nit:17,39--55: Syntax error: "c_compiler_option" expects at least one argument. +alt/error_annot_c_compiler_alt1.nit:17,39--44: Syntax error: "cflags" expects at least one argument. diff --git a/tests/sav/error_annot_c_compiler_alt2.res b/tests/sav/error_annot_c_compiler_alt2.res index b460682..2459cd4 100644 --- a/tests/sav/error_annot_c_compiler_alt2.res +++ b/tests/sav/error_annot_c_compiler_alt2.res @@ -1 +1 @@ -alt/error_annot_c_compiler_alt2.nit:18,39--75: Syntax error: "c_compiler_option" accepts only calls to `exec` with the command as arguments. +alt/error_annot_c_compiler_alt2.nit:18,39--64: Syntax error: "cflags" accepts only calls to `exec` with the command as arguments. diff --git a/tests/sav/error_annot_c_compiler_alt3.res b/tests/sav/error_annot_c_compiler_alt3.res index 8142bf8..a584f16 100644 --- a/tests/sav/error_annot_c_compiler_alt3.res +++ b/tests/sav/error_annot_c_compiler_alt3.res @@ -1 +1 @@ -alt/error_annot_c_compiler_alt3.nit:19,39--86: Syntax error: "c_compiler_option" accepts only calls to `exec` with the command as arguments. +alt/error_annot_c_compiler_alt3.nit:19,39--75: Syntax error: "cflags" accepts only calls to `exec` with the command as arguments. diff --git a/tests/sav/error_annot_c_compiler_alt4.res b/tests/sav/error_annot_c_compiler_alt4.res index d753ea9..f34ea44 100644 --- a/tests/sav/error_annot_c_compiler_alt4.res +++ b/tests/sav/error_annot_c_compiler_alt4.res @@ -1 +1 @@ -alt/error_annot_c_compiler_alt4.nit:20,39--53: Syntax error: "c_linker_option" expects at least one argument. +alt/error_annot_c_compiler_alt4.nit:20,39--45: Syntax error: "ldflags" expects at least one argument. diff --git a/tests/sav/error_annot_c_compiler_alt5.res b/tests/sav/error_annot_c_compiler_alt5.res index 2251e01..133d200 100644 --- a/tests/sav/error_annot_c_compiler_alt5.res +++ b/tests/sav/error_annot_c_compiler_alt5.res @@ -1 +1 @@ -alt/error_annot_c_compiler_alt5.nit:21,57--79: Annotation error: Something went wrong executing the argument of annotation "c_compiler_option", make sure the command is valid. +alt/error_annot_c_compiler_alt5.nit:21,46--68: Annotation error: Something went wrong executing the argument of annotation "cflags", make sure the command is valid. diff --git a/tests/sav/error_annot_c_compiler_alt6.res b/tests/sav/error_annot_c_compiler_alt6.res index 694b887..cc29f8a 100644 --- a/tests/sav/error_annot_c_compiler_alt6.res +++ b/tests/sav/error_annot_c_compiler_alt6.res @@ -1 +1 @@ -alt/error_annot_c_compiler_alt6.nit:22,39--61: Syntax error: "c_compiler_option" accepts only calls to `exec` with the command as arguments. +alt/error_annot_c_compiler_alt6.nit:22,39--50: Syntax error: "cflags" accepts only calls to `exec` with the command as arguments. diff --git a/tests/test_annot_c_compiler.nit b/tests/test_annot_c_compiler.nit index e55ae8a..7277957 100644 --- a/tests/test_annot_c_compiler.nit +++ b/tests/test_annot_c_compiler.nit @@ -15,10 +15,10 @@ # limitations under the License. module test_annot_c_compiler is - c_compiler_option("-I /usr/include") - c_compiler_option(exec("pkg-config", "--cflags", "sdl")) - c_linker_option("-lm") - c_linker_option("-lm", "-L /usr/bin") + cflags "-I /usr/include" + cflags exec("pkg-config", "--cflags", "sdl") + ldflags "-lm" + ldflags("-lm", "-L /usr/bin") end fun dummy `{ printf("nothing...\n"); `}