-
-
Notifications
You must be signed in to change notification settings - Fork 617
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a
os.hostarch()
function to get the host system architecture.
- Loading branch information
Showing
7 changed files
with
71 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* \file os_hostarch.c | ||
* \brief Get the architecture for the current host OS we're executing on. | ||
* \author Copyright (c) 2014-2024 Jason Perkins and the Premake project | ||
*/ | ||
|
||
#include "premake.h" | ||
|
||
#if defined(__x86_64__) || defined(__x86_64) || defined(__amd64__) || defined(__amd64) || \ | ||
defined(_M_X64) || defined(_M_AMD64) | ||
#define PLATFORM_ARCHITECTURE "x86_64" | ||
#elif defined(i386) || defined(__i386) || defined(__i386__) || defined(__i486__) || defined(__i586__) || \ | ||
defined(__i686__) || defined(_M_IX86)|| defined(__X86__) || defined(_X86_) | ||
#define PLATFORM_ARCHITECTURE "x86" | ||
#elif defined(__aarch64__) || defined(_M_ARM64) || defined(__AARCH64EL__) || defined(__arm64) | ||
#define PLATFORM_ARCHITECTURE "ARM64" | ||
#elif defined(__arm__) || defined(__thumb__) || defined(__TARGET_ARCH_ARM) || defined(__TARGET_ARCH_THUMB) || \ | ||
defined(__ARM) || defined(_M_ARM) || defined(_M_ARM_T) || defined(__ARM_ARCH) | ||
#define PLATFORM_ARCHITECTURE "ARM" | ||
#endif | ||
|
||
int os_hostarch(lua_State* L) | ||
{ | ||
lua_pushstring(L, PLATFORM_ARCHITECTURE); | ||
return 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
Identify the architecture for the currently executing operating system. | ||
|
||
```lua | ||
id = os.hostarch() | ||
``` | ||
|
||
### Parameters ### | ||
|
||
None. | ||
|
||
### Return Value ### | ||
|
||
An architecture identifier; see [architecture()](architecture.md) for a complete list of identifiers. | ||
|
||
Note that this function returns the architecture for the OS that Premake is currently running on, which is not necessarily the same as the architecture that Premake is generating files for. | ||
|
||
### Availability ### | ||
|
||
Premake 5.0.0 beta 3 or later. | ||
|
||
### Examples ### | ||
|
||
```lua | ||
if os.hostarch() == "x86_64" then | ||
-- do something x64-specific | ||
end | ||
``` | ||
|
||
### See Also ### | ||
|
||
* [architecture](architecture.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters