#sdk #plugin #config-toml #log-file #filemaker #filemaker-sdk

sys fm_plugin

为FileMaker Pro和FileMaker Server构建插件

16个版本

0.1.17 2021年4月3日
0.1.16 2021年4月2日
0.1.15 2021年1月6日
0.1.12 2020年12月28日

#1161 in 开发工具

每月 33次下载

MIT 许可协议

4MB
63K SLoC

包含 (ELF库, 2MB) libraries/Linux/libFMWrapper.so, (静态库, 140KB) libraries/Win/x64/FMWrapper.lib, (Mach-o可执行文件, 89KB) iOSAppSDK, (Mach-o可执行文件, 56KB) FMWrapper, (Mach-o可执行文件, 48KB) iOSAppSDK

fm_plugin

Actions Status Crates.io Docs.rs

FileMaker插件的SDK的Rust版本

Cargo.toml:

[package]
resolver = "2"

[lib]
path = "src/lib.rs"
crate-type = ["cdylib"]

[dependencies]
fm_plugin = "0.1.17"

[build-dependencies]
fm_plugin = { version = "0.1.17", default-features = false }

[package.metadata.cargo-post.dependencies]
fm_plugin = { version = "0.1.17", default-features = false }
toml = "0.5"
serde = { version = "1.0", features = ["derive"] }

config.toml:

[filemaker]
ext_path = "/path/to/Extentions"
bin_path = "/Applications/FileMaker Pro.app"
kill = true
launch = true

[plugin]
name = "plugin name"
bundle = true
move_to_ext = true

[code_signing]
sign = true

[code_signing.macos]
identity = "common name"

[code_signing.windows]
signtool_path = "/path/to/signtool.exe"
cert_path = "/path/to/cert.p12"
cert_pass = "password"
timestamp_url = "http://cert.timestamp.server.com"

[log]
path = "/path/to/plugin.log"
clear_on_launch = true

build.rs:

#[cfg(any(target_os = "windows", target_os = "macos"))]
fn main() -> Result<(), Box<dyn std::error::Error>> {
    fm_plugin::kill_filemaker()?;
    Ok(())
}

post_build.rs:

#[cfg(any(target_os = "windows", target_os = "macos"))]
fn main() -> Result<(), Box<dyn std::error::Error>> {
    fm_plugin::post_build::bundle_plugin()?;
    Ok(())
}

lib.rs:

use fm_plugin::prelude::*;

struct MyPlugin;

impl Plugin for MyPlugin {
    fn id() -> &'static [u8; 4] {
        &b"MyPl"
    }

    fn name() -> &'static str {
        "MY PLUGIN"
    }

    fn register_functions() -> Vec<Registration> {
        vec![Registration::Function {
            id: 100,
            name: "MyPlugin_MyFunction",
            definition: "MyPlugin_MyFunction( arg1 ; arg2 )",
            description: "Does some really great stuff.",
            min_args: 2,
            max_args: 2,
            display_in_dialogs: true,
            compatibility_flags: Compatibility::Future as u32,
            min_ext_version: ExternVersion::V160,
            min_fm_version: "18.0.2",
            allowed_versions: AllowedVersions {developer: true, pro: true, web: true, sase: true, runtime: true},
            function_ptr: Some(MyFunction::extern_func),
            }
        ]
    }

    ...
}

pub struct MyFunction;

impl FileMakerFunction for MyFunction {
    fn function(id: i16, env: &ExprEnv, args: &DataVect, result: &mut Data) -> FMError {
        //log some info to the file set in config.toml
        log("some troubleshooting info")?;

        ...

        FMError::NoError
    }
}

register_plugin!(MyPlugin);

cargo安装 cargo-post

如果你按照上述方式设置了构建/post_build脚本,运行 cargo post build --release 将会

  1. 退出FileMaker
  2. 编译库
  3. 清除日志文件
  4. 打包插件
  5. 将插件移动到FileMaker扩展文件夹
  6. 签名插件
  7. 启动FileMaker

依赖