代码拉取完成,页面将自动刷新
package plugin
import (
"fmt"
"os"
"path/filepath"
"gitee.com/spock2300/vmake/internal/fs"
"gitee.com/spock2300/vmake/internal/gocompile"
)
type CompileResult struct {
gocompile.CompileResult
PluginDir string
PluginName string
}
func Compile(pluginDir string, force bool) CompileResult {
info, err := LoadPluginInfo(pluginDir)
if err != nil {
return CompileResult{CompileResult: gocompile.NewFailResult(err), PluginDir: pluginDir}
}
entryPath := filepath.Join(pluginDir, info.Entry)
if !fs.FileExists(entryPath) {
return CompileResult{CompileResult: gocompile.NewFailResult(fmt.Errorf("entry file not found: %s", entryPath)), PluginDir: pluginDir, PluginName: info.Name}
}
outputPath := filepath.Join(pluginDir, "plugin.so")
if force {
os.Remove(outputPath)
}
if fs.FileExists(outputPath) {
return CompileResult{CompileResult: gocompile.NewOkResult(outputPath), PluginDir: pluginDir, PluginName: info.Name}
}
entryFile := filepath.Base(filepath.Join(pluginDir, "src", "main.go"))
workDir := filepath.Dir(entryPath)
opts := gocompile.PluginOptions{
WorkDir: workDir,
OutputPath: outputPath,
EntryFile: entryFile,
ModuleName: info.Name,
Prefix: "vmake_plugin_",
}
if err := gocompile.CompilePlugin(opts); err != nil {
return CompileResult{CompileResult: gocompile.NewFailResultAt(err, outputPath), PluginDir: pluginDir, PluginName: info.Name}
}
return CompileResult{CompileResult: gocompile.NewOkResult(outputPath), PluginDir: pluginDir, PluginName: info.Name}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。