Merge pull request #36 from LukeUsher/master
build: support building for macOS and non-linux unixes
This commit is contained in:
commit
6d4e6590de
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
|
@ -14,7 +14,7 @@ jobs:
|
|||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest]
|
||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||
profile: ['debug', 'release', 'optimized']
|
||||
fail-fast: false
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
|
|
@ -48,8 +48,18 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
}
|
||||
typedef HMODULE _LIBRASHADER_IMPL_HANDLE;
|
||||
#define _LIBRASHADER_LOAD LoadLibraryW(L"librashader.dll")
|
||||
|
||||
#elif defined(__linux__)
|
||||
#elif defined(__APPLE__)
|
||||
#include <dlfcn.h>
|
||||
#define _LIBRASHADER_ASSIGN(HMOD, INSTANCE, NAME) \
|
||||
{ \
|
||||
void *address = dlsym(HMOD, "libra_" #NAME); \
|
||||
if (address != NULL) { \
|
||||
(INSTANCE).NAME = (PFN_libra_##NAME)address; \
|
||||
} \
|
||||
}
|
||||
typedef void* _LIBRASHADER_IMPL_HANDLE;
|
||||
#define _LIBRASHADER_LOAD dlopen("librashader.dylib", RTLD_LAZY)
|
||||
#elif defined(__unix__) || defined (__linux__)
|
||||
#include <dlfcn.h>
|
||||
#define _LIBRASHADER_ASSIGN(HMOD, INSTANCE, NAME) \
|
||||
{ \
|
||||
|
@ -990,7 +1000,7 @@ libra_instance_t __librashader_make_null_instance() {
|
|||
/// \return An `libra_instance_t` struct with loaded function pointers.
|
||||
libra_instance_t librashader_load_instance();
|
||||
|
||||
#if defined(_WIN32) || defined(__linux__)
|
||||
#if defined(_WIN32) || defined(__linux__) || defined(__unix__) || defined(__APPLE__)
|
||||
libra_instance_t librashader_load_instance() {
|
||||
_LIBRASHADER_IMPL_HANDLE librashader = _LIBRASHADER_LOAD;
|
||||
libra_instance_t instance = __librashader_make_null_instance();
|
||||
|
|
|
@ -66,7 +66,15 @@ pub fn main() {
|
|||
.expect("Unable to write bindings.");
|
||||
|
||||
println!("Moving artifacts...");
|
||||
if cfg!(target_os = "linux") {
|
||||
if cfg!(target_os = "macos") {
|
||||
let artifacts = &["liblibrashader_capi.dylib", "liblibrashader_capi.a"];
|
||||
for artifact in artifacts {
|
||||
let ext = artifact.strip_prefix("lib").unwrap();
|
||||
let ext = ext.replace("_capi", "");
|
||||
fs::rename(output_dir.join(artifact), output_dir.join(ext)).unwrap();
|
||||
}
|
||||
}
|
||||
else if cfg!(target_family = "unix") {
|
||||
let artifacts = &["liblibrashader_capi.so", "liblibrashader_capi.a"];
|
||||
for artifact in artifacts {
|
||||
let ext = artifact.strip_prefix("lib").unwrap();
|
||||
|
|
Loading…
Reference in a new issue