Android的Eclipse中使用外部工具运行于code脚本脚本、运行于、工具、Android

2023-09-06 16:53:51 作者:希羽岚梦

我发现了一个解决方案,我的许多悬而未决的问题是运行在code一个perl脚本来执行一些变化,是很难不可能做regexs或MUSCH比一些建议我勾简单成Dalvik的。

因此​​,这将是一个自回答问题是我告诉你我是如何设法做到这一点,一步步。我希望这将帮助人们解决他们的一些问题。

解决方案

我们的目标是在Eclipse中我的当前打开的文件中运行以下命令行,并刷新才能看到效果:

的perl -S -pi.bak myscript.pl

我要使用外部工具配置。 该指南是基于Eclipse 3.7.1

开启运行 - > 外部工具 - > 外部工具配置... (您也可以从与街角的小红色工具箱中的运行图标,打开它) 选择计划 添加新启动配置(第一个图标上的右上角或右键单击程序的小加 - > 新) 您应该看到以下内容: 填写命名 在的位置放的路径,要启动该工具(在这种情况下的Perl: C:\ Perl的\斌\ perl.exe所在) 在工作direectory从变量选择... $ {container_loc} 这是文件目前IDE的目录 作为论据: -S -pi.bak $ {file_prompt:选择Perl脚本:D:\马塞洛\ Perl的\ BIN \ myscript.pl} $ {} CONTAINER_NAME 同样你不必输入$ {} CONTAINER_NAME或$ {file_prompt ...}你可以从变量选择它... preSS 应用 您现在应该看到这一点: 转到刷新标签和结束在检查刷新资源,并从选项中的选择的资源 选择 转到建立标签,并取消发射前建立

我们都做了,现在的一些注意事项:

在通用标签,你可以检查外部工具在添加到收藏夹菜单,然后你的脚本将出现在外部工具的子菜单,无必须先运行它。 您可能已经注意到还有很多其他的选择,随意尝试 在这个例子只是修改了IDE中的文件。 myscript.pl的内容:        

接下来,除非/Log.i/;     S / \宾特\ S +(\ w +)/ INT N_ $ 1 /克;     S / \ bString \ S +(\ w +)/串S_ $ 1 /克;

   在 $ {file_prompt:选择Perl脚本:D:\马塞洛\ Perl的\ BIN \ myscript.pl} 打开一个对话框,您可以选择Perl脚本来运行。 如果你想始终运行同一个脚本只需更换的 $ {file_prompt ...} 为脚本的名称

我安装的是 EPIC插件 Eclipse的,所以我可以编辑的Perl文件,以及

您不限制修改你的资源。您可以只运行产生输出从当前文件的脚本。该脚本的输出,也遇到任何错误,会显示在控制台 提示:在Perl中,如果你既想写入新文件出来,并打印出一个消息用户,使用STDERR打印出来的消息和标准输出打印出的文件。

eclipse 中的NEW中只剩几个选项了,其他的都在other里面,我也在Customize Perspective中选中了也不出现在NEW中怎么办

I found out that a solution to many of my unanswered questions was to run a perl script on the code to perform some changes that are hard to impossible to do with regexs or musch simpler than some advices I got to hook into DalVik.

So this is going to be a self-answered question were I tell you how I manage to do it, step by step. I hope this will help people to solve some of their problems.

解决方案

The target is to run the following command line from within Eclipse on my currently opened file and refresh it to see the results:

perl -S -pi.bak myscript.pl

I am going to use an External Tools configuration. this guide is based on Eclipse 3.7.1

Open Run -> External Tools -> External Tools Configuration ... (Alternatively you can open it from the Run icon with the small red toolbox on the corner) Select Program Add a New Launch Configuration (First Icon with the little plus on the top right corner or right click on Program -> New) You should see this: Fill the Name On the location put the path to the tool you want to launch (in this case perl: C:\Perl\bin\perl.exe) In the working direectory choose from the Variables..., ${container_loc} which is the directory of the file currently on the IDE As arguments put: -S -pi.bak ${file_prompt:Select Perl Script:D:\marcelo\Perl\bin\myscript.pl} ${container_name}Again you don't have to type ${container_name} or ${file_prompt...} you can choose it from Variables... Press Apply You should see this now: Go to the Refresh tab and check Refresh resources upon completion and choose from the options The selected resource Go to the Build tab and uncheck Build before launch

We are done, now several notes:

In the Common tab you can check External Tools under Add to favorites menu and your script will appear on the External Tools submenu, without having to run it first. You probably noticed there are a lot of other options, feel free to experiment This example just modifies the file in the IDE. The contents of myscript.pl are:

next unless /Log.i/; s/\bint\s+(\w+)/int n_$1/g; s/\bString\s+(\w+)/String s_$1/g;

The ${file_prompt:Select Perl Script:D:\marcelo\Perl\bin\myscript.pl} opens a dialog box where you can select the perl script to run. If you want to run always the same script just replace the ${file_prompt...} with the script name

I installed the EPIC plugin on Eclipse so I can edit perl files as well

You are not constrained to modify you resource. You can just run a script that generates outputs from the current file. The output of the script, also any errors encountered, are displayed in the ConsoleTip: In perl if you want to both write the new file out and also print out a message for the user, use STDERR to print out the message and STDOUT to print out the file.