11local lm = require " luamake"
2+ local fs = require ' bee.filesystem'
23
34local bindir = " publish/runtime/" .. lm .runtime_platform
45
@@ -9,6 +10,7 @@ local arch = defined.arch
910local LUAJIT_ENABLE_LUA52COMPAT = defined .LUAJIT_ENABLE_LUA52COMPAT
1011local LUAJIT_NUMMODE = defined .LUAJIT_NUMMODE
1112local luajitDir = defined .luajitDir
13+ local is_old_version_luajit = defined .is_old_version_luajit
1214
1315local LJLIB_C = {
1416 luajitDir .. " /lib_base.c " ,
@@ -98,35 +100,39 @@ lm:build "lj_vm.obj" {
98100 outputs = lm .bindir .. " /lj_vm.obj" ,
99101}
100102
101- local lj_str_hash_flags = {
102- " -fno-stack-protector" ,
103- U_FORTIFY_SOURCE ,
104- " -fPIC" ,
105- }
103+ local has_str_hash = fs .exists (luajitDir .. ' /lj_str_hash.c' )
104+ if has_str_hash then
105+ local lj_str_hash_flags = {
106+ " -fno-stack-protector" ,
107+ U_FORTIFY_SOURCE ,
108+ " -fPIC" ,
109+ }
106110
107- if arch == " x64" then
108- table.insert (lj_str_hash_flags , " -msse4.2" )
109- end
111+ if arch == " x64" then
112+ table.insert (lj_str_hash_flags , " -msse4.2" )
113+ end
110114
111- lm :source_set (" lj_str_hash.c" ) {
112- rootdir = luajitDir ,
113- sources = { " lj_str_hash.c" },
114- includes = { ' .' },
115- defines = {
116- LUAJIT_UNWIND_EXTERNAL ,
117- _FILE_OFFSET_BITS ,
118- _LARGEFILE_SOURCE ,
119- LUA_MULTILIB ,
120- LUAJIT_ENABLE_LUA52COMPAT ,
121- LUAJIT_NUMMODE ,
122- },
123- linux = {
115+ lm :source_set (" lj_str_hash.c" ) {
116+ rootdir = luajitDir ,
117+ sources = { " lj_str_hash.c" },
118+ includes = { ' .' },
124119 defines = {
125- " _GNU_SOURCE" ,
126- }
127- },
128- flags = lj_str_hash_flags
129- }
120+ LUAJIT_UNWIND_EXTERNAL ,
121+ _FILE_OFFSET_BITS ,
122+ _LARGEFILE_SOURCE ,
123+ LUA_MULTILIB ,
124+ LUAJIT_ENABLE_LUA52COMPAT ,
125+ LUAJIT_NUMMODE ,
126+ },
127+ linux = {
128+ defines = {
129+ " _GNU_SOURCE" ,
130+ }
131+ },
132+ flags = lj_str_hash_flags
133+ }
134+ end
135+
130136
131137lm :executable (" luajit/lua" ) {
132138 rootdir = luajitDir ,
@@ -139,12 +145,14 @@ lm:executable("luajit/lua") {
139145 " lj_libdef.h" ,
140146 " lj_recdef.h" ,
141147 },
142- deps = " lj_str_hash.c" ,
148+ deps = {
149+ has_str_hash and " lj_str_hash.c" ,
150+ },
143151 sources = {
144152 " luajit.c" ,
145153 " lj_*.c" ,
146154 " lib_*.c" ,
147- " !lj_str_hash.c" ,
155+ has_str_hash and " !lj_str_hash.c" ,
148156 lm .bindir .. " /lj_vm.obj" ,
149157 },
150158 includes = {
0 commit comments