diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 853cfad..ff1be74 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ on: - "docs/**" env: - ROCKSPEC_VERSION: 0.0.3 + ROCKSPEC_VERSION: 0.0.4 DEV_ROCKSPEC: lua-uuid-dev-1.rockspec jobs: diff --git a/README.md b/README.md index 811ba4e..1fede35 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,9 @@ **lua-uuid** is a lightweight, native library for Lua (5.1 and newer) to deal with Universally Unique Id (UUID). -* On Linux, it uses ```libuuid``` to generate UUIDs; +* On Linux and BSD, it uses ```libuuid``` to generate UUIDs; * On Windows, it uses the WINAPI ```rpcrt4``` library; -* On MacOS / iOS, it uses the ```CoreFoundation``` framework. +* On macOS / iOS, it uses the ```CoreFoundation``` framework. ## Table of Contents @@ -33,19 +33,25 @@ > [!IMPORTANT] > -> On Linux, ```lua-uuid``` depends on ```libuuid```: +> On Linux and BSD, ```lua-uuid``` depends on ```libuuid```: > -> * On Debian-based distributions: +> * On Debian-based (e.g: Ubuntu) distributions: > > ```bash > sudo apt install -y uuid-dev > ``` > -> * On RedHat-based distributions: +> * On RedHat-based (e.g: Fedora) distributions: > > ```bash > sudo dnf install libuuid-devel > ``` +> +> * On BSD-based (e.g: FreeBSD) distributions: +> +> ```bash +> pkg install e2fsprogs-libuuid +> ``` Assuming that [LuaRocks](https://luarocks.org/) is properly installed and configured on your system, execute the following command: @@ -165,7 +171,7 @@ print(id3:isnil()) ### parse -* *Description*: Generates a new GUID / UUID from a string value +* *Description*: Parses a GUID / UUID from a string value * *Signature*: ```parse(value)``` * *value* (string): the string to be parsed * *return*: ```(userdata)``` @@ -207,8 +213,11 @@ print(id3:isnil()) ## Change log +* v0.0.4: + * Added support for BSD (e.g: FreeBSD, NetBSD, OpenBSD and DragonFly); + * Moved ```#include ``` and ```LUA_UUID_EXPORT``` macro definition to outside of ```__cplusplus``` declarations on ```lua-uuid.h```. * v0.0.3: - * Changed to throw issue when ```lua_newuserdata``` returns ```NULL```; + * Changed to throw error when ```lua_newuserdata``` returns ```NULL```; * Added macro ```LUA_UUID_BUILD_SHARED``` to ```CFLAGS_EXTRA``` on macos; * Changed ```luajit-master``` to ```luajit``` on CI when testing for ```LuaJIT```; * Added print statements on [tostring.lua](./samples/tostring.lua) sample; diff --git a/rockspecs/lua-uuid-0.0.4-0.rockspec b/rockspecs/lua-uuid-0.0.4-0.rockspec new file mode 100644 index 0000000..186320a --- /dev/null +++ b/rockspecs/lua-uuid-0.0.4-0.rockspec @@ -0,0 +1,105 @@ +package = "lua-uuid" +version = "0.0.4-0" + +source = { + url = "git://github.com/luau-project/lua-uuid.git", + tag = "v0.0.4" +} + +description = { + homepage = "https://github.com/luau-project/lua-uuid", + summary = [[Lightweight, native GUID / UUID library for Lua]], + detailed = [=[ +lua-uuid is a lightweight, native library for Lua (5.1 and newer) to deal with Universally Unique Id (UUID). + +* On Linux and BSD, it uses libuuid to generate UUIDs; +* On Windows, it uses the WINAPI rpcrt4 library; +* On macOS / iOS, it uses the CoreFoundation framework. + +Visit the GitHub repository for more information.]=], + license = "MIT" +} + +supported_platforms = { "linux", "windows", "cygwin", "macosx", "bsd" } + +dependencies = { + "lua >= 5.1" +} + +external_dependencies = { + platforms = { + linux = { + ["UUID"] = { + header = "uuid/uuid.h" + } + }, + bsd = { + ["UUID"] = { + header = "uuid/uuid.h" + } + } + } +} + +local function build_plat(plat) + if (plat == "linux" or plat == "bsd") then + return { + type = "builtin", + modules = { + ["lua-uuid"] = { + sources = { "src/lua-uuid.c" }, + libraries = { "uuid" }, + defines = { "LUA_UUID_BUILD_SHARED", "LUA_UUID_USE_LIBUUID" }, + incdirs = { "src", "$(UUID_INCDIR)" }, + libdirs = { "$(UUID_LIBDIR)" } + } + } + } + elseif (plat == "windows" or plat == "cygwin") then + return { + type = "builtin", + modules = { + ["lua-uuid"] = { + sources = { "src/lua-uuid.c" }, + libraries = { "rpcrt4" }, + defines = { "LUA_UUID_BUILD_SHARED", "LUA_UUID_USE_WIN32" }, + incdirs = { "src" }, + libdirs = { } + } + } + } + elseif (plat == "macosx") then + return { + type = "make", + makefile = "Makefile.macosx", + build_variables = { + CFLAGS = "$(CFLAGS)", + LIBFLAG = "$(LIBFLAG)", + CFLAGS_EXTRA = "-DLUA_UUID_BUILD_SHARED -DLUA_UUID_USE_APPLE", + LIBFLAG_EXTRA = "-framework CoreFoundation", + LUA_INCDIR = "$(LUA_INCDIR)", + LUA_LIBDIR = "$(LUA_INCDIR)/../lib", + OBJ_EXTENSION = "$(OBJ_EXTENSION)", + LIB_EXTENSION = "$(LIB_EXTENSION)" + }, + install_variables = { + INSTALL_PREFIX = "$(PREFIX)", + INSTALL_LIBDIR = "$(LIBDIR)", + LUA_VERSION = "$(LUA_VERSION)", + LIB_EXTENSION = "$(LIB_EXTENSION)" + } + } + else + error("Unknown platform", 2) + end +end + +build = { + platforms = { + linux = build_plat("linux"), + windows = build_plat("windows"), + cygwin = build_plat("cygwin"), + macosx = build_plat("macosx"), + bsd = build_plat("bsd") + } +} diff --git a/rockspecs/lua-uuid-dev-1.rockspec b/rockspecs/lua-uuid-dev-1.rockspec index 3b45b24..8765546 100644 --- a/rockspecs/lua-uuid-dev-1.rockspec +++ b/rockspecs/lua-uuid-dev-1.rockspec @@ -11,15 +11,15 @@ description = { detailed = [=[ lua-uuid is a lightweight, native library for Lua (5.1 and newer) to deal with Universally Unique Id (UUID). -* On Linux, it uses libuuid to generate UUIDs; +* On Linux and BSD, it uses libuuid to generate UUIDs; * On Windows, it uses the WINAPI rpcrt4 library; -* On MacOS / iOS, it uses the CoreFoundation framework. +* On macOS / iOS, it uses the CoreFoundation framework. Visit the GitHub repository for more information.]=], license = "MIT" } -supported_platforms = { "linux", "win32", "mingw", "cygwin", "macosx" } +supported_platforms = { "linux", "windows", "cygwin", "macosx", "bsd" } dependencies = { "lua >= 5.1" @@ -31,12 +31,17 @@ external_dependencies = { ["UUID"] = { header = "uuid/uuid.h" } + }, + bsd = { + ["UUID"] = { + header = "uuid/uuid.h" + } } } } -local function make_plat(plat) - if (plat == "linux") then +local function build_plat(plat) + if (plat == "linux" or plat == "bsd") then return { type = "builtin", modules = { @@ -49,7 +54,7 @@ local function make_plat(plat) } } } - elseif (plat == "win32" or plat == "mingw" or plat == "cygwin") then + elseif (plat == "windows" or plat == "cygwin") then return { type = "builtin", modules = { @@ -58,7 +63,7 @@ local function make_plat(plat) libraries = { "rpcrt4" }, defines = { "LUA_UUID_BUILD_SHARED", "LUA_UUID_USE_WIN32" }, incdirs = { "src" }, - libdirs = {} + libdirs = { } } } } @@ -90,10 +95,10 @@ end build = { platforms = { - linux = make_plat("linux"), - win32 = make_plat("win32"), - mingw = make_plat("mingw"), - cygwin = make_plat("cygwin"), - macosx = make_plat("macosx") + linux = build_plat("linux"), + windows = build_plat("windows"), + cygwin = build_plat("cygwin"), + macosx = build_plat("macosx"), + bsd = build_plat("bsd") } } diff --git a/src/lua-uuid.h b/src/lua-uuid.h index 792e547..41288c1 100644 --- a/src/lua-uuid.h +++ b/src/lua-uuid.h @@ -1,9 +1,7 @@ #ifndef LUA_UUID_H #define LUA_UUID_H -#ifdef __cplusplus -extern "C" { -#endif +#include #ifdef LUA_UUID_BUILD_STATIC #define LUA_UUID_EXPORT @@ -31,7 +29,9 @@ extern "C" { #endif #endif -#include +#ifdef __cplusplus +extern "C" { +#endif LUA_UUID_EXPORT int luaopen_uuid(lua_State *L);