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 08431bf
Show file tree
Hide file tree
Showing 19 changed files with 191 additions and 126 deletions.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions drivers/lang/c/run_premake.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
rm -rf build-Darwin
rm -rf build-Linux
rm -rf build-MSYS_NT-10.0-22000
rm -rf build-Mingw
../../../../premake5 --os=macosx gmake
mv build build-Darwin
../../../../premake5 --os=linux gmake
mv build build-Linux
../../../../premake5 --os=windows gmake2
mv build build-MSYS_NT-10.0-22000
mv build build-Mingw
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
19 changes: 16 additions & 3 deletions drivers/lang/c/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ bool is_cpp(
static
bool is_darwin(void)
{
if (stricmp(UT_OS_STRING, "Darwin")) {
if (stricmp(UT_OS_STRING, "darwin")) {
return false;
}
return true;
Expand All @@ -67,7 +67,7 @@ bool is_darwin(void)
static
bool is_linux(void)
{
if (stricmp(UT_OS_STRING, "Linux")) {
if (stricmp(UT_OS_STRING, "linux")) {
return false;
}
return true;
Expand All @@ -76,7 +76,15 @@ bool is_linux(void)
static
bool is_windows(void)
{
if (stricmp(UT_OS_STRING, "Windows")) {
if (stricmp(UT_OS_STRING, "windows")) {
return false;
}
return true;
}

static
bool is_msys(void) {
if (stricmp(UT_OS_STRING, "mingw")) {
return false;
}
return true;
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
File renamed without changes.
4 changes: 2 additions & 2 deletions drivers/lang/cpp/run_premake.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
rm -rf build-Darwin
rm -rf build-Linux
rm -rf build-MSYS_NT-10.0-22000
rm -rf build-Mingw
../../../../premake5 --os=macosx gmake
mv build build-Darwin
../../../../premake5 --os=linux gmake
mv build build-Linux
../../../../premake5 --os=windows gmake2
mv build build-MSYS_NT-10.0-22000
mv build build-Mingw
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
4 changes: 2 additions & 2 deletions run_premake.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
rm -rf build-Darwin
rm -rf build-Linux
rm -rf build-MSYS_NT-10.0-22000
rm -rf build-Mingw
../premake5 --os=macosx gmake
mv build build-Darwin
../premake5 --os=linux gmake
mv build build-Linux
../premake5 --os=windows gmake2
mv build build-MSYS_NT-10.0-22000
mv build build-Mingw
Loading

0 comments on commit 08431bf

Please sign in to comment.