Skip to content

Commit

Permalink
Move platform code.
Browse files Browse the repository at this point in the history
  • Loading branch information
linuscu committed Aug 7, 2024
1 parent 4a251d4 commit b77143c
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 45 deletions.
44 changes: 40 additions & 4 deletions packages/tools/include/tools/platform/Platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,46 @@ enum class platform {
UNKNOWN
};

bool IsPlatformPosixCompatible();
std::string_view GetPlatformName();
std::string_view GetPlatformVersion();
platform GetPlatform();
bool constexpr IsPlatformPosixCompatible() {
#if defined(BSYSTEM_PLATFORM_Linux) || defined(BSYSTEM_PLATFORM_Android) || defined(BSYSTEM_PLATFORM_CYGWIN) || defined(BSYSTEM_PLATFORM_MSYS) || defined(BSYSTEM_PLATFORM_GNU) || defined(BSYSTEM_PLATFORM_iOS) || defined(BSYSTEM_PLATFORM_Darwin)
return true;
#endif
return false;
}

std::string_view constexpr GetPlatformName() {
return BSYSTEM_PLATFORM;
}

std::string_view constexpr GetPlatformVersion() {
return BSYSTEM_VERSION;
}

platform constexpr GetPlatform() {
#if defined(BSYSTEM_PLATFORM_Windows)
return platform::WINDOWS;
#elif defined(BSYSTEM_PLATFORM_WindowsStore)
return platform::UWP;

#elif defined(BSYSTEM_PLATFORM_Linux)
return platform::LINUX;
#elif defined(BSYSTEM_PLATFORM_Android)
return platform::ANDROID;
#elif defined(BSYSTEM_PLATFORM_CYGWIN)
return platform::CYGWIN;
#elif defined(BSYSTEM_PLATFORM_MSYS)
return platform::MSYS;
#elif defined(BSYSTEM_PLATFORM_GNU)
return platform::GNU;

#elif defined(BSYSTEM_PLATFORM_iOS)
return platform::IOS;
#elif defined(BSYSTEM_PLATFORM_Darwin)
return platform::OSX;
#else
return platform::UNKNOWN;
#endif
}

class FS {
public:
Expand Down
41 changes: 0 additions & 41 deletions packages/tools/source/common/platform/Platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,47 +13,6 @@ namespace platform {
std::wstring params;
}

bool constexpr IsPlatformPosixCompatible() {
#if defined(BSYSTEM_PLATFORM_Linux) || defined(BSYSTEM_PLATFORM_Android) || defined(BSYSTEM_PLATFORM_CYGWIN) || defined(BSYSTEM_PLATFORM_MSYS) || defined(BSYSTEM_PLATFORM_GNU) || defined(BSYSTEM_PLATFORM_iOS) || defined(BSYSTEM_PLATFORM_Darwin)
return true;
#endif
return false;
}

std::string_view constexpr GetPlatformName() {
return BSYSTEM_PLATFORM;
}

std::string_view constexpr GetPlatformVersion() {
return BSYSTEM_VERSION;
}

platform constexpr GetPlatform() {
#if defined(BSYSTEM_PLATFORM_Windows)
return platform::WINDOWS;
#elif defined(BSYSTEM_PLATFORM_WindowsStore)
return platform::UWP;

#elif defined(BSYSTEM_PLATFORM_Linux)
return platform::LINUX;
#elif defined(BSYSTEM_PLATFORM_Android)
return platform::ANDROID;
#elif defined(BSYSTEM_PLATFORM_CYGWIN)
return platform::CYGWIN;
#elif defined(BSYSTEM_PLATFORM_MSYS)
return platform::MSYS;
#elif defined(BSYSTEM_PLATFORM_GNU)
return platform::GNU;

#elif defined(BSYSTEM_PLATFORM_iOS)
return platform::IOS;
#elif defined(BSYSTEM_PLATFORM_Darwin)
return platform::OSX;
#else
return platform::UNKNOWN;
#endif
}

std::wstring Cmd::GetCommandLineArgument(size_t index) {
std::lock_guard<std::mutex> lock(global::argument_mutex);
if (index >= global::argument.size()) {
Expand Down

0 comments on commit b77143c

Please sign in to comment.