Skip to content

Commit 08431bf

Browse files
author
Sander Mertens
committed
Support using bake with msys
1 parent 2d15018 commit 08431bf

File tree

19 files changed

+191
-126
lines changed

19 files changed

+191
-126
lines changed
File renamed without changes.
File renamed without changes.
Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
1-
/*
2-
)
3-
(.)
4-
.|.
5-
| |
6-
_.--| |--._
7-
.-'; ;`-'& ; `&.
8-
\ & ; & &_/
9-
|"""---...---"""|
10-
\ | | | | | | | /
11-
`---.|.|.|.---'
12-
13-
* This file is generated by bake.lang.c for your convenience. Headers of
14-
* dependencies will automatically show up in this file. Include bake_config.h
15-
* in your main project file. Do not edit! */
16-
17-
#ifndef BAKE_AMALGAMATE_BAKE_CONFIG_H
18-
#define BAKE_AMALGAMATE_BAKE_CONFIG_H
19-
20-
/* Headers of public dependencies */
21-
#ifdef __BAKE__
22-
#include <bake_util.h>
23-
#endif
24-
25-
/* Convenience macro for exporting symbols */
26-
#ifndef bake_amalgamate_STATIC
27-
#if defined(bake_amalgamate_EXPORTS) && (defined(_MSC_VER) || defined(__MINGW32__))
28-
#define BAKE_AMALGAMATE_API __declspec(dllexport)
29-
#elif defined(bake_amalgamate_EXPORTS)
30-
#define BAKE_AMALGAMATE_API __attribute__((__visibility__("default")))
31-
#elif defined(_MSC_VER)
32-
#define BAKE_AMALGAMATE_API __declspec(dllimport)
33-
#else
34-
#define BAKE_AMALGAMATE_API
35-
#endif
36-
#else
37-
#define BAKE_AMALGAMATE_API
38-
#endif
39-
40-
#endif
41-
1+
/*
2+
)
3+
(.)
4+
.|.
5+
| |
6+
_.--| |--._
7+
.-'; ;`-'& ; `&.
8+
\ & ; & &_/
9+
|"""---...---"""|
10+
\ | | | | | | | /
11+
`---.|.|.|.---'
12+
13+
* This file is generated by bake.lang.c for your convenience. Headers of
14+
* dependencies will automatically show up in this file. Include bake_config.h
15+
* in your main project file. Do not edit! */
16+
17+
#ifndef BAKE_AMALGAMATE_BAKE_CONFIG_H
18+
#define BAKE_AMALGAMATE_BAKE_CONFIG_H
19+
20+
/* Headers of public dependencies */
21+
#ifdef __BAKE__
22+
#include <bake_util.h>
23+
#endif
24+
25+
/* Convenience macro for exporting symbols */
26+
#ifndef bake_amalgamate_STATIC
27+
#if defined(bake_amalgamate_EXPORTS) && (defined(_MSC_VER) || defined(__MINGW32__))
28+
#define BAKE_AMALGAMATE_API __declspec(dllexport)
29+
#elif defined(bake_amalgamate_EXPORTS)
30+
#define BAKE_AMALGAMATE_API __attribute__((__visibility__("default")))
31+
#elif defined(_MSC_VER)
32+
#define BAKE_AMALGAMATE_API __declspec(dllimport)
33+
#else
34+
#define BAKE_AMALGAMATE_API
35+
#endif
36+
#else
37+
#define BAKE_AMALGAMATE_API
38+
#endif
39+
40+
#endif
41+

drivers/lang/c/run_premake.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
rm -rf build-Darwin
22
rm -rf build-Linux
3-
rm -rf build-MSYS_NT-10.0-22000
3+
rm -rf build-Mingw
44
../../../../premake5 --os=macosx gmake
55
mv build build-Darwin
66
../../../../premake5 --os=linux gmake
77
mv build build-Linux
88
../../../../premake5 --os=windows gmake2
9-
mv build build-MSYS_NT-10.0-22000
9+
mv build build-Mingw

drivers/lang/c/src/gcc/driver.c

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ void gcc_add_flags(
105105
/* Enable debugging code */
106106
if (!config->debug) {
107107
ut_strbuf_appendstr(cmd, " -DNDEBUG");
108-
} else if (!is_emcc()) {
108+
} else if (!is_emcc() && !is_mingw()) {
109109
ut_strbuf_appendstr(cmd, " -fstack-protector-all");
110110
}
111111

@@ -584,7 +584,7 @@ void gcc_link_dynamic_binary(
584584
ut_strbuf_appendstr(&cmd, " -fno-stack-protector -shared");
585585

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

832832
if (link_static) {
833-
result = ut_asprintf("lib%s.a", id);
833+
result = ut_asprintf(UT_OS_LIB_PREFIX"%s"UT_OS_STATIC_LIB_EXT, id);
834834
} else {
835-
if (is_dylib(driver, project)) {
836-
result = ut_asprintf("lib%s.dylib", id);
837-
} else {
838-
result = ut_asprintf("lib%s.so", id);
839-
}
835+
result = ut_asprintf(UT_OS_LIB_PREFIX"%s"UT_OS_LIB_EXT, id);
840836
}
841837
}
842838
} else {
@@ -883,19 +879,34 @@ char *gcc_link_to_lib(
883879
full_path = NULL;
884880
}
885881

886-
/* Try .so */
882+
/* Try platform default */
887883
if (full_path) {
888-
char *so = ut_asprintf("%s/lib%s.so", full_path, lib_name);
884+
char *so = ut_asprintf("%s/"UT_OS_LIB_PREFIX"%s"UT_OS_LIB_EXT, full_path, lib_name);
889885
if (ut_file_test(so)) {
890886
result = so;
891887
}
892888
} else {
893-
char *so = ut_asprintf("lib%s.so", lib_name);
889+
char *so = ut_asprintf(UT_OS_LIB_PREFIX"%s"UT_OS_LIB_EXT, lib_name);
894890
if (ut_file_test(so)) {
895891
result = so;
896892
}
897893
}
898894

895+
/* Try .so */
896+
if (!result) {
897+
if (full_path) {
898+
char *so = ut_asprintf("%s/lib%s.so", full_path, lib_name);
899+
if (ut_file_test(so)) {
900+
result = so;
901+
}
902+
} else {
903+
char *so = ut_asprintf("lib%s.so", lib_name);
904+
if (ut_file_test(so)) {
905+
result = so;
906+
}
907+
}
908+
}
909+
899910
/* Try .dylib */
900911
if (!result && !strcmp(UT_OS_STRING, "darwin")) {
901912
if (full_path) {

drivers/lang/c/src/main.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ bool is_cpp(
5858
static
5959
bool is_darwin(void)
6060
{
61-
if (stricmp(UT_OS_STRING, "Darwin")) {
61+
if (stricmp(UT_OS_STRING, "darwin")) {
6262
return false;
6363
}
6464
return true;
@@ -67,7 +67,7 @@ bool is_darwin(void)
6767
static
6868
bool is_linux(void)
6969
{
70-
if (stricmp(UT_OS_STRING, "Linux")) {
70+
if (stricmp(UT_OS_STRING, "linux")) {
7171
return false;
7272
}
7373
return true;
@@ -76,7 +76,15 @@ bool is_linux(void)
7676
static
7777
bool is_windows(void)
7878
{
79-
if (stricmp(UT_OS_STRING, "Windows")) {
79+
if (stricmp(UT_OS_STRING, "windows")) {
80+
return false;
81+
}
82+
return true;
83+
}
84+
85+
static
86+
bool is_msys(void) {
87+
if (stricmp(UT_OS_STRING, "mingw")) {
8088
return false;
8189
}
8290
return true;
@@ -186,6 +194,11 @@ bool is_msvc(void) {
186194
return is_compiler("cl.exe", 0);
187195
}
188196

197+
static
198+
bool is_mingw(void) {
199+
return is_compiler("gcc", 0) && is_msys();
200+
}
201+
189202
/* Is binary a dylib */
190203
static
191204
bool is_dylib(

0 commit comments

Comments
 (0)