如何使用GCJ使用Ant? [英] How to use GCJ with Ant?

查看:162
本文介绍了如何使用GCJ使用Ant?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是相当新的这两个Apache Ant和GCJ,而我有一个很难试图通过Ant构建具有GCJ。

I'm fairly new to both Apache Ant and GCJ, and I'm having a hard time trying to build with GCJ via Ant.

我的应用程序是Scala,所以我需要使用GCJ把.class文件作为来源。没问题,编译.scala到的.class使用Ant。

My app is in Scala, so I need to use GCJ to take .class files as source. No problem compiling .scala to .class with Ant.

首先,我想通了如何手动编译的.class文件.O(对象),这种方式:

First I figured out how to manually compile a .class file to .o (object), this way:

gcj --classpath=(...) -c (somepath)MouseClickListener.class -o (somepath)MouseClickListener.o

我看到这里蚂蚁支持通过标记的javac编译GCJ。所以我想这应该工作:

I see here that Ant supports GCJ compilation through the javac tag. So I figured this should work:

<target name="gcjCompile" depends="compile">
    <mkdir dir="${object.dir}" />
    <javac srcdir="${build.dir}"
           destdir="${object.dir}"
           compiler="gcj"
           executable="C:/gcc/gcc-4.3/bin/gcj.exe"
           classpathref="gcjProject.classpath">
        <include name="**/*.class"/>
    </javac>
</target>

但是,这javac任务什么都不做,我没有得到任何错误。任何线索?
谢谢

But this javac task does nothing and I get no errors. Any clues? Thanks

推荐答案

这听起来像你想你的应用程序链接到本地​​的可执行文件。这意味着,你已经编译源成JVM字节code(如你想通了,通过编译.scala成.class文件做)。你需要使用手动运行 GCJ 命令&LT; EXEC&GT; 任务编译字节$ C $ ç到GCC对象code文件。

It sounds like you want to link your app into a native executable. That means that you've already compiled the source into JVM bytecode (as you've figured out to do by compiling .scala into .class files). You'll need to run the gcj command manually using the <exec> task to compile the bytecode into gcc object code files.

我建议是这样的:

<property name="main.class" value="Main" />
<property name="class.dir" value="${basedir}/classes" />
<target name="compile">
  <mkdir dir="${class.dir}" />
  <javac srcdir="${build.dir}"
         destdir="${class.dir}"
         compiler="gcj"
         executable="C:/gcc/gcc-4.3/bin/gcj.exe"
         classpathref="gcjProject.classpath">
    <include name="**/*.java"/>
  </javac>
</target>
<target name="link" depends="compile">
  <mkdir dir="${object.dir"} />
  <exec cmd="C:/gcc/gcc-4.3/bin/gcj.exe">
    <arg value="-classpath=${object.dir}" />
    <arg value="-c" />
    <arg value="*.class" />
  </exec>
</target>

请记住,你需要定义 build.dir object.dir 属性,你可能需要在编译目标的javac前添加取决于任务(或每次都从头开始重新编译只)。我可能已经错过了很多东西,你应该检查手册页(对于GCJ,GCC,和蚂蚁),如果它不能在第一次工作。

Keep in mind that you need to define the build.dir and object.dir properties, and you may need to add a depends task before the javac in the compile target (or just recompile from scratch each time). I may have missed a lot of things, you should check the manual pages (for gcj, gcc, and ant) if it doesn't work at first.

这篇关于如何使用GCJ使用Ant?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆