On 9/16/16 5:07 PM, Patrick Pelletier wrote:
I'm not quite sure how it's supposed to know that the Frege-generated Java files are in src/frege, so I tried adding:

    sourceSets {
        main {
            java.srcDirs.add 'src/frege'

but that didn't seem to do anything.

Well, this was me not understanding Gradle/Groovy. It turns out the correct incantation was:

    sourceSets {
        main {
            java.srcDirs += 'src/frege'

With this change, it worked! I now have a successful example of an Android app that calls Frege code. It is available at this point in my repository:


However, I didn't want to leave it there. I wanted my Frege code to be able to call the Android API. So, I took a look at the FregeAndroid repository:


It doesn't have any build instructions, so I just added it as a submodule of my repository, and added code to my build.gradle to build FregeAndroid along with my own Frege code:

project.afterEvaluate {
    extensions.compileFrege = {
        mkdir 'src/frege'
        description = 'Compile Frege to Java'
        def tree = fileTree(dir: 'FregeAndroid/src', include: '**/*.fr')
        tree += fileTree(dir: 'src/main/frege', include: '**/*.fr')
        tree.each { file ->
            javaexec {
                configurations.compile.resolve().each {
                    //println it.toString()
                    classpath += files(it.toString())
                main = 'frege.compiler.Main'
args '-inline', '-d', 'src/frege', '-make', '-sp', 'src/main/frege', "$file.path"
//        delete fileTree('src/frege') {
//            include '**/*.java'
//        }

Although I'm still sketchy on Groovy, I think this is doing what I want, in terms of trying to build the FregeAndroid files. However, the files don't actually build. I get:

E /Users/ppelleti/programming/android/example/FregeAndroid/src/frege/android/animation/TimeInterpolator.fr:4: `android.animation.TimeInterpolator` is not a known java class Android.animation.TimeInterpolator: build failed because of compilation errors.
Build failed.
runtime 2.801 wallclock seconds.
:compileDebugJavaWithJavac FAILED

FAILURE: Build failed with an exception.

So, I think the problem is that the Frege compiler isn't seeing the Android API classes. I guess I need to somehow put the Android API on the Frege compiler's classpath? I'll look into this, but I wanted to post what I have so far, in case anyone has any ideas:




You received this message because you are subscribed to the Google Groups "Frege 
Programming Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to frege-programming-language+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to