Skip to content

Commit c67c470

Browse files
authored
Merge pull request #2147 from fesily/ffi-fix-build-path
ffi:fix build path
2 parents f8f04e7 + f1dadae commit c67c470

File tree

6 files changed

+19
-7
lines changed

6 files changed

+19
-7
lines changed

locale/en-us/setting.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,3 +440,5 @@ command.exportDocument =
440440
'Lua: Export Document ...'
441441
command.addon_manager.open =
442442
'Lua: Open Addon Manager ...'
443+
command.reloadFFIMeta =
444+
'Lua: Reload luajit ffi meta'

locale/pt-br/setting.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,3 +440,5 @@ command.exportDocument = -- TODO: need translate!
440440
'Lua: Export Document ...'
441441
command.addon_manager.open = -- TODO: need translate!
442442
'Lua: Open Addon Manager ...'
443+
command.reloadFFIMeta = -- TODO: need translate!
444+
'Lua: Reload luajit ffi meta'

locale/zh-cn/setting.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,3 +439,5 @@ command.exportDocument =
439439
'Lua: 导出文档...'
440440
command.addon_manager.open =
441441
'Lua: 打开插件管理器...'
442+
command.reloadFFIMeta =
443+
'Lua: 重新生成luajit的FFI模块C语言元数据'

locale/zh-tw/setting.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,3 +439,5 @@ command.exportDocument = -- TODO: need translate!
439439
'Lua: Export Document ...'
440440
command.addon_manager.open = -- TODO: need translate!
441441
'Lua: Open Addon Manager ...'
442+
command.reloadFFIMeta = -- TODO: need translate!
443+
'Lua: Reload luajit ffi meta'

script/plugins/ffi/init.lua

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
local searchCode = require 'plugins.ffi.searchCode'
2-
local cdefRerence = require 'plugins.ffi.cdefRerence'
31
local cdriver = require 'plugins.ffi.c-parser.cdriver'
42
local util = require 'plugins.ffi.c-parser.util'
53
local utility = require 'utility'
64
local SDBMHash = require 'SDBMHash'
75
local config = require 'config'
86
local fs = require 'bee.filesystem'
9-
local scope = require 'workspace.scope'
7+
local ws = require 'workspace'
8+
local furi = require 'file-uri'
109

1110
local namespace <const> = 'ffi.namespace*.'
1211

@@ -360,12 +359,15 @@ function m.build_single(codes, fileDir, uri)
360359
if not texts then
361360
return
362361
end
362+
local fullPath = fileDir /ws.getRelativePath(uri)
363363

364-
local hash = ('%08x'):format(SDBMHash():hash(uri))
365-
local encoding = config.get(nil, 'Lua.runtime.fileEncoding')
366-
local filePath = fileDir / table.concat({ hash, encoding }, '_')
364+
if fullPath:stem():string():find '%.' then
365+
local newPath = fullPath:parent_path() / (fullPath:stem():string():gsub('%.', '/') .. ".lua")
366+
fs.create_directories(newPath:parent_path())
367+
fullPath = newPath
368+
end
367369

368-
utility.saveFile(tostring(filePath) .. '.d.lua', table.concat(texts, '\n'))
370+
utility.saveFile(tostring(fullPath), table.concat(texts, '\n'))
369371
return true
370372
end
371373

test/plugins/ffi/test.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ local template = require 'config.template'
88

99
template['Lua.runtime.version'].default = 'LuaJIT'
1010

11+
TESTURI = furi.encode('/unittest.ffi.lua')
12+
1113
---@async
1214
local function TestBuilder()
1315
local builder = require 'core.command.reloadFFIMeta'

0 commit comments

Comments
 (0)