Skip to content

Commit

Permalink
Support using bake with msys
Browse files Browse the repository at this point in the history
  • Loading branch information
Sander Mertens committed Aug 6, 2023
1 parent 2d15018 commit 2b4f542
Show file tree
Hide file tree
Showing 7 changed files with 180 additions and 115 deletions.
82 changes: 41 additions & 41 deletions drivers/amalgamate/include/bake-amalgamate/bake_config.h
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
/*
)
(.)
.|.
| |
_.--| |--._
.-'; ;`-'& ; `&.
\ & ; & &_/
|"""---...---"""|
\ | | | | | | | /
`---.|.|.|.---'
* This file is generated by bake.lang.c for your convenience. Headers of
* dependencies will automatically show up in this file. Include bake_config.h
* in your main project file. Do not edit! */

#ifndef BAKE_AMALGAMATE_BAKE_CONFIG_H
#define BAKE_AMALGAMATE_BAKE_CONFIG_H

/* Headers of public dependencies */
#ifdef __BAKE__
#include <bake_util.h>
#endif

/* Convenience macro for exporting symbols */
#ifndef bake_amalgamate_STATIC
#if defined(bake_amalgamate_EXPORTS) && (defined(_MSC_VER) || defined(__MINGW32__))
#define BAKE_AMALGAMATE_API __declspec(dllexport)
#elif defined(bake_amalgamate_EXPORTS)
#define BAKE_AMALGAMATE_API __attribute__((__visibility__("default")))
#elif defined(_MSC_VER)
#define BAKE_AMALGAMATE_API __declspec(dllimport)
#else
#define BAKE_AMALGAMATE_API
#endif
#else
#define BAKE_AMALGAMATE_API
#endif

#endif

/*
)
(.)
.|.
| |
_.--| |--._
.-'; ;`-'& ; `&.
\ & ; & &_/
|"""---...---"""|
\ | | | | | | | /
`---.|.|.|.---'
* This file is generated by bake.lang.c for your convenience. Headers of
* dependencies will automatically show up in this file. Include bake_config.h
* in your main project file. Do not edit! */

#ifndef BAKE_AMALGAMATE_BAKE_CONFIG_H
#define BAKE_AMALGAMATE_BAKE_CONFIG_H

/* Headers of public dependencies */
#ifdef __BAKE__
#include <bake_util.h>
#endif

/* Convenience macro for exporting symbols */
#ifndef bake_amalgamate_STATIC
#if defined(bake_amalgamate_EXPORTS) && (defined(_MSC_VER) || defined(__MINGW32__))
#define BAKE_AMALGAMATE_API __declspec(dllexport)
#elif defined(bake_amalgamate_EXPORTS)
#define BAKE_AMALGAMATE_API __attribute__((__visibility__("default")))
#elif defined(_MSC_VER)
#define BAKE_AMALGAMATE_API __declspec(dllimport)
#else
#define BAKE_AMALGAMATE_API
#endif
#else
#define BAKE_AMALGAMATE_API
#endif

#endif
33 changes: 22 additions & 11 deletions drivers/lang/c/src/gcc/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void gcc_add_flags(
/* Enable debugging code */
if (!config->debug) {
ut_strbuf_appendstr(cmd, " -DNDEBUG");
} else if (!is_emcc()) {
} else if (!is_emcc() && !is_mingw()) {
ut_strbuf_appendstr(cmd, " -fstack-protector-all");
}

Expand Down Expand Up @@ -584,7 +584,7 @@ void gcc_link_dynamic_binary(
ut_strbuf_appendstr(&cmd, " -fno-stack-protector -shared");

/* Fail when symbols are not found in library */
if (!is_clang(cpp) && !is_emcc()) {
if (!is_clang(cpp) && !is_emcc() && !is_mingw()) {
ut_strbuf_appendstr(&cmd, " -z defs");
}
}
Expand Down Expand Up @@ -830,13 +830,9 @@ char* gcc_artefact_name(
bool link_static = driver->get_attr_bool("static");

if (link_static) {
result = ut_asprintf("lib%s.a", id);
result = ut_asprintf(UT_OS_LIB_PREFIX"%s"UT_OS_STATIC_LIB_EXT, id);
} else {
if (is_dylib(driver, project)) {
result = ut_asprintf("lib%s.dylib", id);
} else {
result = ut_asprintf("lib%s.so", id);
}
result = ut_asprintf(UT_OS_LIB_PREFIX"%s"UT_OS_LIB_EXT, id);
}
}
} else {
Expand Down Expand Up @@ -883,19 +879,34 @@ char *gcc_link_to_lib(
full_path = NULL;
}

/* Try .so */
/* Try platform default */
if (full_path) {
char *so = ut_asprintf("%s/lib%s.so", full_path, lib_name);
char *so = ut_asprintf("%s/"UT_OS_LIB_PREFIX"%s"UT_OS_LIB_EXT, full_path, lib_name);
if (ut_file_test(so)) {
result = so;
}
} else {
char *so = ut_asprintf("lib%s.so", lib_name);
char *so = ut_asprintf(UT_OS_LIB_PREFIX"%s"UT_OS_LIB_EXT, lib_name);
if (ut_file_test(so)) {
result = so;
}
}

/* Try .so */
if (!result) {
if (full_path) {
char *so = ut_asprintf("%s/lib%s.so", full_path, lib_name);
if (ut_file_test(so)) {
result = so;
}
} else {
char *so = ut_asprintf("lib%s.so", lib_name);
if (ut_file_test(so)) {
result = so;
}
}
}

/* Try .dylib */
if (!result && !strcmp(UT_OS_STRING, "darwin")) {
if (full_path) {
Expand Down
13 changes: 13 additions & 0 deletions drivers/lang/c/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ bool is_windows(void)
return true;
}

static
bool is_msys(void) {
if (stricmp(UT_OS_STRING, "MSYS_NT-10.0-22000")) {
return false;
}
return true;
}

/* Get compiler */
static
const char *cc(
Expand Down Expand Up @@ -186,6 +194,11 @@ bool is_msvc(void) {
return is_compiler("cl.exe", 0);
}

static
bool is_mingw(void) {
return is_compiler("gcc", 0) && is_msys();
}

/* Is binary a dylib */
static
bool is_dylib(
Expand Down
92 changes: 46 additions & 46 deletions drivers/test/include/bake-test/bake_config.h
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
/*
)
(.)
.|.
| |
_.--| |--._
.-'; ;`-'& ; `&.
\ & ; & &_/
|"""---...---"""|
\ | | | | | | | /
`---.|.|.|.---'
* This file is generated by bake.lang.c for your convenience. Headers of
* dependencies will automatically show up in this file. Include bake_config.h
* in your main project file. Do not edit! */

#ifndef BAKE_TEST_BAKE_CONFIG_H
#define BAKE_TEST_BAKE_CONFIG_H

/* Headers of public dependencies */
/* No dependencies */

/* Headers of private dependencies */
#ifdef bake_test_EXPORTS
#ifdef __BAKE__
#include <bake_util.h>
#endif
#endif

/* Convenience macro for exporting symbols */
#ifndef bake_test_STATIC
#if defined(bake_test_EXPORTS) && (defined(_MSC_VER) || defined(__MINGW32__))
#define BAKE_TEST_API __declspec(dllexport)
#elif defined(bake_test_EXPORTS)
#define BAKE_TEST_API __attribute__((__visibility__("default")))
#elif defined(_MSC_VER)
#define BAKE_TEST_API __declspec(dllimport)
#else
#define BAKE_TEST_API
#endif
#else
#define BAKE_TEST_API
#endif

#endif

/*
)
(.)
.|.
| |
_.--| |--._
.-'; ;`-'& ; `&.
\ & ; & &_/
|"""---...---"""|
\ | | | | | | | /
`---.|.|.|.---'
* This file is generated by bake.lang.c for your convenience. Headers of
* dependencies will automatically show up in this file. Include bake_config.h
* in your main project file. Do not edit! */

#ifndef BAKE_TEST_BAKE_CONFIG_H
#define BAKE_TEST_BAKE_CONFIG_H

/* Headers of public dependencies */
/* No dependencies */

/* Headers of private dependencies */
#ifdef bake_test_EXPORTS
#ifdef __BAKE__
#include <bake_util.h>
#endif
#endif

/* Convenience macro for exporting symbols */
#ifndef bake_test_STATIC
#if defined(bake_test_EXPORTS) && (defined(_MSC_VER) || defined(__MINGW32__))
#define BAKE_TEST_API __declspec(dllexport)
#elif defined(bake_test_EXPORTS)
#define BAKE_TEST_API __attribute__((__visibility__("default")))
#elif defined(_MSC_VER)
#define BAKE_TEST_API __declspec(dllimport)
#else
#define BAKE_TEST_API
#endif
#else
#define BAKE_TEST_API
#endif

#endif
Loading

0 comments on commit 2b4f542

Please sign in to comment.