请选择 进入手机版 | 继续访问电脑版

 找回密码
 点一下
查看: 4716|回复: 7

[原创工具]jmake, jass make编译环境优化工具

[复制链接]
发表于 2008-4-10 00:22:13 | 显示全部楼层 |阅读模式
这是一个提供jass编程环境的小工具
简介:
  本工具提供一个更方便,更友好的编译环境
  本包内自带了pjass和mpq2k工具
  使用pjass进行编译,使用mpq2k进行打包和解包
  本工具为命令行工具,无图形界面,所有命令通过命令行执行
  本工具刚完成,欢迎试用者上报bug
  
特性:
  1.可以支持#include "???.j"包含另一个jass文件
  2.可以自动校正常见语法错误(可单独执行)
      自动校正的错有:
          自动去掉最后的<;>
          前面自动加set
          前面自动加local
          前面自动加call
          if/elseif后面自动加then   
  3.可以对jass文件进行加密,把所有函数名,变量名变成数字,并去掉所有注释(可单独执行)
  4.完善的字符集处理,支持各种字符集
  5.可以支持#import "???.j" object1来把???.j使用object1关键字进行展开, 把???.j里的所有变量名和函数名前面都加上object1关键字(主要针对数组不能作为参数和返回值)
  6.提供一种较好的结合world edit图形界面工具和jass程序的build方式, 参看下面使用说明的build命令
  7.支持__FILE__, __LINE__的替换
  8.支持调试函数,会把调试函数如dbg_error( str )替换为dbg_error( "main.j(26) "+str )
  
  

使用说明:
1.首先下载压缩包 jmake.rar (1.48 MB, 下载次数: 158) ,解压到本地的某个目录,比如c:\jmake
2.在系统path里加上此目录(c:\jmake),优先最好,(添加系统path不用说明了吧), 这样可以在任意路径下执行jmake
3.设置一些环境变量,首先创建一个空目录,作为地图项目的根目录, 比如c:\maps,设置环境变量WM_HOME为这个路径, 在此目录下创建一个目录include,并把blizzard.j,common.ai,common.j这几个文件复制到下面去,不要告诉我不知道哪里有这些文件
  另外设置环境变量WAR3_HOME为warIII所在路径,jmake build成功以后,会把目标地图复制到%WAR3_HOME%\maps\test下,方便测试
4.打开一个cmd命令行窗口,输入jmake获得命令列表,可以获得如下响应
    jmake ver 1.0, build on Apr  8 2008 19:26:34 by binbin
    jmake [--optname1=optvalue1] [--optname2=optvalue2] ... command
    -------------------------------------------------------------------
    following command is support:
      help : Get all help information
      help ??? : Get help information of one of the support command
      addheader : add a header to a file
      auto_correct : correct a map scritpt automotic
      build : build a map use jmake
      clean : clean template make files
      expand : insert jmake_main to war3map.j file
      insert_main : insert jmake_main to war3map.j file
      encrypt : encrypt source file
   
    可以通过jmake help 命令,获得某个命令的帮助
    命令行格式总体说明:
            是否有默认值,可以参看帮助中的类似下面
                jmake auto_correct [--debug=N] [--file=war3map.j] --output=? [--debug-functions=] [--charset-from=GB18030] [--charset-to=GB18030]
            这行,如果有中括号包着的参数,就是有默认值
            参数可以写在前,也可在后
                jmake -F myfile.j auto_correct   和    jmake auto_correct -F myfile.j 一样
            参数可以贴在-?后面也可空格
                jmake -F myfile.j auto_correct   和    jmake -Fmyfile.j auto_correct  一样
            参数可以写成--xxxx=???也可使用-? ???的格式
                jmake -F myfile.j auto_correct   和    jmake --file=myfile.j auto_correct  一样

    其中的功能主要有:
        1).addheader: 添加w3x文件头, 帮助如下
            jmake ver 1.0, build on Apr  8 2008 19:26:34 by binbin
            jmake [--optname1=optvalue1] [--optname2=optvalue2] ... command
            -------------------------------------------------------------------
            [addheader]:add a header to a file
                jmake addheader --file=?
                -f --file : file to added
            
            此功能是在某个文件前面加一个w3x的文件头,主要原因是mpq2k打出来的包是mpq格式,不是w3x格式,不能被war3识别,本功能被build功能调用
            例子:
                jmake -f c:\maps\mymap.j addheader
            
        2).auto_correct:自动语法校正, 帮助如下:
            jmake ver 1.0, build on Apr  8 2008 19:26:34 by binbin
            jmake [--optname1=optvalue1] [--optname2=optvalue2] ... command
            -------------------------------------------------------------------
            [auto_correct]:correct a map scritpt automotic
                jmake auto_correct [--debug=N] [--file=war3map.j] --output=? [--debug-functions=] [--charset-from=GB18030] [--charset-to=GB18030]
                -d --debug : show debug information or not Y|N
                -F --file : map file to handle
                -o --output : output file to write
                -D --debug-functions : debug functions
                -f --charset-from : charset to from
                -t --charset-to : charset to to

            参数:
            -d 默认N,使用调试,调试的话会打印更多的提示信息
            -F 需要处理的文件,默认war3map.j
            -o 输出文件,必须输入,处理完的文件写到哪里去
            -D debug函数列表,中间可以用;隔开, debug函数括号后面会添加"__FILE__(__LINE__)"+
            -f 来源字符集,默认GB18030,如果是直接从w3x中提取出来未转码(用edit打开中文是乱码),使用字符集UTF-8
            -t 目标字符集,写入时使用的字符集,默认GB18030, GB18030下汉字才能正常显示,如果需要写会w3x中,应该使用字符集UTF-8
            
            例子:
                jmake -F war3file.j -o war3file_correct.j auto_correct -f UTF-8 -t UTF-8
            

        3).insert_main:
            jmake ver 1.0, build on Apr  8 2008 19:26:34 by binbin
            jmake [--optname1=optvalue1] [--optname2=optvalue2] ... command
            -------------------------------------------------------------------
            [insert_main]:insert jmake_main to war3map.j file
                jmake insert_main [--debug=N] [--war3map=release\war3map.j] [--output=release\war3map_inc.j] [--charset-from=GB18030] [--charset-to=GB18030]
                -d --debug : show debug information or not Y|N, 意义同上
                -j --war3map : war3map.j  ,在这个文件的main函数最后一行插入jmake_main, 在main函数之前加上#include "main.j"
                -o --output : output file , 输出的文件
                -f --charset-from : charset to from, 字符集,上面有说明
                -t --charset-to : charset to to, 字符集,上面有说明
               
            本功能是在一个war3map.j文件中插入#include "main.j", 在main函数最后插入call jmake_main(),来达到图形界面的world edit和脚本编写的统一,
            因为world edit会自动生成war3map.j,所以很麻烦,现在地图的脚本编写者者可以把逻辑都放main.j中,每次现插入到we生成的脚本中即可
            
        4).expand   
            jmake ver 1.0, build on Apr  8 2008 19:26:34 by binbin
            jmake [--optname1=optvalue1] [--optname2=optvalue2] ... command
            -------------------------------------------------------------------
            [expand]:insert jmake_main to war3map.j file
                jmake expand [--debug=N] [--include=.;%WM_HOME%\include] [--war3map=release\war3map_inc.j] [--correct=Y] [--debug-functions=dbg_trace;dbg_log;dbg_inf;dbg_warning;dbg_error;dbg_fatal] [--output=release\war3map_inc_ex.j] [--charset-from=GB18030] [--charset-to=GB18030]
                -d --debug : show debug information or not Y|N, 意义同上
                -I --include : include path, use <:> to split,  知名include目录,中间可以用;隔开,依次在这里目录里寻找#include和#import的文件
                -j --war3map : file name to handle  , 处理的文件
                -c --correct : correct file or not, Y|N, 是否自动校正语法错误,默认是
                -D --debug-functions : debug functions, debug函数列表,默认值是我的函数列表
                -o --output : output file    输出文件
                -f --charset-from : charset to from, 字符集,上面有说明
                -t --charset-to : charset to to, 字符集,上面有说明
        
            本功能,主要是展开一个文件中的#include和#import
            
        5).encrypt
            jmake ver 1.0, build on Apr  8 2008 19:26:34 by binbin
            jmake [--optname1=optvalue1] [--optname2=optvalue2] ... command
            -------------------------------------------------------------------
            [encrypt]:encrypt source file
                jmake encrypt [--debug=N] [--file=release\war3map_inc_ex.j] [--output=release\war3map_inc_ex_en.j] [--charset-from=GB18030] [--charset-to=GB18030]
                -d --debug : show debug information or not Y|N, 意义同上
                -F --file : file to encrypt, 处理的文件
                -o --output : output file , 输出的文件
                -f --charset-from : charset to from, 字符集,上面有说明
                -t --charset-to : charset to to, 字符集,上面有说明
            对一个源码文件进行加密,把函数名和变量名替换掉
            
        6).build
            jmake ver 1.0, build on Apr  8 2008 19:26:34 by binbin
            jmake [--optname1=optvalue1] [--optname2=optvalue2] ... command
            -------------------------------------------------------------------
            [build]:build a map use jmake
                jmake build [--debug=N] [--test=N] [--encrypt=N] [--mapfile=map.w3x]
                -d --debug : show debug information or not Y|N, 意义同上
                -t --test : test map after build Y|N, 是否在完成以后测试地图,
                -e --encrypt : encrypt or not Y|N, 是否加密地图
                -m --mapfile : map file, can be .w3x or .w3m, 本地的map文件,默认map.w3x
               
            这是提供的综合一组命令,提供一个编译环境,
            首先,假设当前目录为c:\maps\test1,此目录下应该有两个文件map.w3x和main.j,其中map.w3x是一个大致完成了但是没有加入脚本的地图( we制作的 )
            main.j中必须有函数jmake_main
            在此目录下执行jmake build即可
            
            build的简单流程如下
                创建release目录,用mpq2k工具把map.w3x解压到.\release\mapfiles中,并复制war3map.j到.\release目录中
                执行jmake insert_main, 把.\release\war3map.j处理为.\release\war3map_inc.j
                执行jmake expand,把.\release\war3map_inc.j处理为.\release\war3map_inc_ex.j( 默认使用的include目录为.;%WM_HOME%\\include, 如果有你自己做的共享脚本,扔到%WM_HOME%\\include下即可 )
                复制.\release\war3map_inc_ex.j到.\release\mapfiles\war3map.j
                调用pjass编译.\release\mapfiles\war3map.j
                编译成功以后,调用mpq2k打包.\release\mapfiles, 打包结果.\release\map_result.w3x
                调用jmake addheader在.\release\map_result.w3x上加个w3x文件头
                复制.\release\map_result.w3x到%WAR3_HOME%\\Maps\\Test\\jmake_test.w3x
                如果用户选择了--test=Y,则调用war3程序测试此地图
               
        7). clean
            对应build, 清除垃圾临时文件
            
            
        
      
发表于 2008-4-10 01:46:18 | 显示全部楼层
  [s:129]   这类东西看了就头疼
回复

使用道具 举报

traxex 该用户已被删除
发表于 2008-4-10 01:46:24 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 举报

发表于 2008-4-10 09:39:56 | 显示全部楼层
恩恩。支持支持。值得精華老。
回复

使用道具 举报

发表于 2008-4-10 12:07:08 | 显示全部楼层
楼主写个BAT吧~
回复

使用道具 举报

发表于 2008-4-17 23:15:23 | 显示全部楼层
  [s:180]  [s:180]  [s:180]
回复

使用道具 举报

 楼主| 发表于 2008-4-20 19:25:29 | 显示全部楼层
最新的jmake.exe jmake1.0.0.1.rar (23 KB, 下载次数: 30)
下载后直接覆盖即可(需先下载一楼的大包)
更正了几个bug
1.加密时未考虑main,config函数
2.加密时未考虑函数参数的加密
3.加密时能去掉debug函数
4.不能识别code类型
5.不能识别数组变量的赋值
回复

使用道具 举报

 楼主| 发表于 2008-4-20 20:37:55 | 显示全部楼层
再更正一个bug
使用mpq2k工具时,没有带目录,只能处理一层目录
jmake1.0.0.2.rar (23 KB, 下载次数: 36)
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 点一下

本版积分规则

Archiver|移动端|小黑屋|地精研究院

GMT+8, 2024-3-29 21:43 , Processed in 0.239047 second(s), 22 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表