• compile LuaJIT with xmake


    LuaJIT自带的编译脚本虽然很纯正,不依赖编译器之外的程序,但是在不便于阅读和维护,打算改为xmake描述编译过程。
    原版在Windows上是一个简单的bat定义了编译过程,内容比较简洁,已经翻译成了对应的xmake,只编译了链接库,没编译luajit.exe,暂时不需要exe
    翻译过程借助了编译输出日志,日志如下:

    
    D:UEProjectLuaJITsrc>cl /nologo /c /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_STDIO_INLINE=__declspec(dllexport)__inline  /DLUAJIT_ENABLE_LUA52COMPAT hostminilua.c 
    minilua.c
    
    D:UEProjectLuaJITsrc>link /nologo /out:minilua.exe minilua.obj 
       Creating library minilua.lib and object minilua.exp
    
    D:UEProjectLuaJITsrc>if exist minilua.exe.manifest mt /nologo -manifest minilua.exe.manifest -outputresource:minilua.exe 
    
    D:UEProjectLuaJITsrc>minilua ..dynasmdynasm.lua -LN -D WIN -D JIT -D FFI -D P64 -o hostuildvm_arch.h vm_x64.dasc 
    
    D:UEProjectLuaJITsrc>cl /nologo /c /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_STDIO_INLINE=__declspec(dllexport)__inline  /DLUAJIT_ENABLE_LUA52COMPAT /I "." /I ..dynasm hostuildvm*.c 
    buildvm.c
    buildvm_asm.c
    buildvm_fold.c
    buildvm_lib.c
    buildvm_peobj.c
    Generating Code...
    
    D:UEProjectLuaJITsrc>link /nologo /out:buildvm.exe buildvm*.obj 
       Creating library buildvm.lib and object buildvm.exp
    
    D:UEProjectLuaJITsrc>if exist buildvm.exe.manifest mt /nologo -manifest buildvm.exe.manifest -outputresource:buildvm.exe 
    
    D:UEProjectLuaJITsrc>buildvm -m peobj -o lj_vm.obj 
    
    D:UEProjectLuaJITsrc>buildvm -m bcdef -o lj_bcdef.h lib_base.c lib_math.c lib_bit.c lib_string.c lib_table.c lib_io.c lib_os.c lib_package.c lib_debug.c lib_jit.c lib_ffi.c 
    
    D:UEProjectLuaJITsrc>buildvm -m ffdef -o lj_ffdef.h lib_base.c lib_math.c lib_bit.c lib_string.c lib_table.c lib_io.c lib_os.c lib_package.c lib_debug.c lib_jit.c lib_ffi.c 
    
    D:UEProjectLuaJITsrc>buildvm -m libdef -o lj_libdef.h lib_base.c lib_math.c lib_bit.c lib_string.c lib_table.c lib_io.c lib_os.c lib_package.c lib_debug.c lib_jit.c lib_ffi.c 
    
    D:UEProjectLuaJITsrc>buildvm -m recdef -o lj_recdef.h lib_base.c lib_math.c lib_bit.c lib_string.c lib_table.c lib_io.c lib_os.c lib_package.c lib_debug.c lib_jit.c lib_ffi.c 
    
    D:UEProjectLuaJITsrc>buildvm -m vmdef -o jitvmdef.lua lib_base.c lib_math.c lib_bit.c lib_string.c lib_table.c lib_io.c lib_os.c lib_package.c lib_debug.c lib_jit.c lib_ffi.c 
    
    D:UEProjectLuaJITsrc>buildvm -m folddef -o lj_folddef.h lj_opt_fold.c 
    
    D:UEProjectLuaJITsrc>cl /nologo /c /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_STDIO_INLINE=__declspec(dllexport)__inline  /DLUAJIT_ENABLE_LUA52COMPAT /MD /DLUA_BUILD_AS_DLL lj_*.c lib_*.c 
    lj_alloc.c
    lj_api.c
    lj_asm.c
    lj_bc.c
    lj_bcread.c
    lj_bcwrite.c
    lj_buf.c
    lj_carith.c
    lj_ccall.c
    lj_ccallback.c
    lj_cconv.c
    lj_cdata.c
    lj_char.c
    lj_clib.c
    lj_cparse.c
    lj_crecord.c
    lj_ctype.c
    lj_debug.c
    lj_dispatch.c
    lj_err.c
    Generating Code...
    Compiling...
    lj_ffrecord.c
    lj_func.c
    lj_gc.c
    lj_gdbjit.c
    lj_ir.c
    lj_lex.c
    lj_lib.c
    lj_load.c
    lj_mcode.c
    lj_meta.c
    lj_obj.c
    lj_opt_dce.c
    lj_opt_fold.c
    lj_opt_loop.c
    lj_opt_mem.c
    lj_opt_narrow.c
    lj_opt_sink.c
    lj_opt_split.c
    lj_parse.c
    lj_profile.c
    Generating Code...
    Compiling...
    lj_record.c
    lj_snap.c
    lj_state.c
    lj_str.c
    lj_strfmt.c
    lj_strfmt_num.c
    lj_strscan.c
    lj_tab.c
    lj_trace.c
    lj_udata.c
    lj_vmevent.c
    lj_vmmath.c
    lib_aux.c
    lib_base.c
    lib_base.c(304): warning C4146: unary minus operator applied to unsigned type, result still unsigned
    lib_bit.c
    lib_debug.c
    lib_ffi.c
    lib_init.c
    lib_io.c
    lib_jit.c
    Generating Code...
    Compiling...
    lib_math.c
    lib_os.c
    lib_package.c
    lib_string.c
    lib_table.c
    Generating Code...
    
    D:UEProjectLuaJITsrc>link /nologo /release /DLL /out:lua51.dll lj_*.obj lib_*.obj 
       Creating library lua51.lib and object lua51.exp
    
    D:UEProjectLuaJITsrc>if exist lua51.dll.manifest mt /nologo -manifest lua51.dll.manifest -outputresource:lua51.dll;2 
    
    D:UEProjectLuaJITsrc>cl /nologo /c /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_STDIO_INLINE=__declspec(dllexport)__inline  /DLUAJIT_ENABLE_LUA52COMPAT luajit.c 
    luajit.c
    
    D:UEProjectLuaJITsrc>link /nologo /release /out:luajit.exe luajit.obj lua51.lib 
       Creating library luajit.lib and object luajit.exp
    
    D:UEProjectLuaJITsrc>if exist luajit.exe.manifest mt /nologo -manifest luajit.exe.manifest -outputresource:luajit.exe 
    
    === Successfully built LuaJIT for Windows/x64 ===
    
    

    xmake.lua如下

    target('minilua')
        set_kind('binary')
        set_languages("c89", "cxx14")
        add_files("./host/minilua.c")
    
        add_defines("_CRT_SECURE_NO_DEPRECATE")
        add_defines("_CRT_STDIO_INLINE=__declspec(dllexport)__inline")
        add_defines("LUAJIT_ENABLE_LUA52COMPAT")
    
        after_build(
            function(target)
                os.trycp('build/windows/x64/release/minilua.exe', 'minilua.exe')
                local ret = os.exec('minilua.exe ./../dynasm/dynasm.lua -LN -D WIN -D JIT -D FFI -D P64 -o host/buildvm_arch.h ./vm_x64.dasc')
            end
        )
    
    target('buildvm')
        set_kind('binary')
        set_languages("c89", "cxx14")
    
        add_files("./host/buildvm*.c")
        add_includedirs('./')
        add_includedirs('./../dynasm/')
    
        add_defines("_CRT_SECURE_NO_DEPRECATE")
        add_defines("_CRT_STDIO_INLINE=__declspec(dllexport)__inline")
        add_defines("LUAJIT_ENABLE_LUA52COMPAT")
    
        after_build(
            function(target)
                --run buildvm
                os.trycp('build/windows/x64/release/buildvm.exe', 'buildvm.exe')
                
                os.exec('buildvm -m peobj -o lj_vm.obj ')
                
                local all_lib = 'lib_base.c lib_math.c lib_bit.c lib_string.c lib_table.c lib_io.c lib_os.c lib_package.c lib_debug.c lib_jit.c lib_ffi.c'
    
                os.exec('buildvm -m bcdef -o lj_bcdef.h ' .. all_lib)
                os.exec('buildvm -m ffdef -o lj_ffdef.h ' .. all_lib)
                os.exec('buildvm -m libdef -o lj_libdef.h ' .. all_lib)
                os.exec('buildvm -m recdef -o lj_recdef.h ' .. all_lib)
                os.exec('buildvm -m vmdef -o jit/vmdef.lua ' .. all_lib)
    
                os.exec('buildvm -m folddef -o lj_folddef.h lj_opt_fold.c ')
            end
        )
    
    target('LuaJIT')
        set_kind('shared')
        set_languages("c89", "cxx14")
    
        add_files('./lj_*.c', 'lib_*.c')
        add_includedirs('./')
        add_includedirs('./../dynasm/')
    
        add_links('lj_*.obj lib_*.obj')
    
        add_rules("mode.debug")
    
        add_cxflags('/nologo /c /O2 /W3 /MD')
    
        add_defines("_CRT_SECURE_NO_DEPRECATE")
        add_defines("_CRT_STDIO_INLINE=__declspec(dllexport)__inline")
        add_defines("LUAJIT_ENABLE_LUA52COMPAT")
        add_defines("LUA_BUILD_AS_DLL")
    
    
  • 相关阅读:
    Introduction to Guid ( globally unique identifier )
    Visual Studio调试技巧 -- Attach to Process #Reprinted#
    ASP.NET PipeLine #Reprinted#
    Introduction to REST #Reprinted#
    HTTP status codes
    Introduction to Json
    Visual Studio shortcut keys
    C# Programming Study #1
    面向对象程序设计-C++ Finial exam review NOTES【第十六次上课笔记】
    几道汇编入门题目(二)
  • 原文地址:https://www.cnblogs.com/rpg3d/p/12905077.html
Copyright © 2020-2023  润新知