diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml new file mode 100644 index 0000000..eefe8e0 --- /dev/null +++ b/.github/workflows/macos.yml @@ -0,0 +1,31 @@ +name: macOS Build + +on: [push] + +jobs: + build: + runs-on: macos-latest + permissions: + contents: write + + steps: + - uses: actions/checkout@v2 + with: + submodules: 'recursive' + + - name: Install premake5 + run: brew install premake + + - name: Run Premake + run: premake5 gmake2 + + - name: Build + run: make config=release -C .build + + - name: Deploy + uses: softprops/action-gh-release@v0.1.7 + if: startsWith(github.ref, 'refs/tags/v') + with: + files: .build/bin/Release/ObjEditing + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 30bcfa4..9f1bad9 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .build/ +*.o diff --git a/bin/build.lua b/bin/build.lua index 5c0616f..7e78c5f 100644 --- a/bin/build.lua +++ b/bin/build.lua @@ -129,6 +129,12 @@ local function generateAPI(file, name) end local function main(input, output) + if package.config:sub(1, 1) == '\\' then + os.execute('if not exist "' .. output:gsub('/', '\\') .. '" mkdir "' .. output:gsub('/', '\\') .. '"') + else + os.execute('mkdir -p "' .. output .. '"') + end + local filePath = input:match('src/lua/(.+)$') local fileName = input:match('/([^/]+)$') local funcName = generateFuncName(filePath) diff --git a/init.sh b/init.sh new file mode 100755 index 0000000..303c562 --- /dev/null +++ b/init.sh @@ -0,0 +1,8 @@ +#!/bin/bash +cd "$(dirname "$0")" + +if [ -f "bin/premake5" ]; then + bin/premake5 gmake2 +else + premake5 gmake2 +fi diff --git a/premake5.lua b/premake5.lua index 92c69cf..b7899b0 100644 --- a/premake5.lua +++ b/premake5.lua @@ -7,18 +7,18 @@ workspace 'ObjEditing' configurations { 'Debug', 'Release' } location '.build' symbols 'Full' - architecture 'x86' startproject 'ObjEditing' flags { 'MultiProcessorCompile', - 'Maps', } filter 'system:Windows' + architecture 'x86' systemversion 'latest' characterset 'MBCS' staticruntime 'On' defines { 'WIN32', '_WINDOWS' } + flags { 'Maps' } filter 'configurations:Debug' defines { '_DEBUG' } filter 'configurations:Release' @@ -70,6 +70,10 @@ project 'ObjEditing' filter 'system:Windows' defines { 'PLATFORM_WINDOWS' } + filter 'system:macosx' + defines { 'PLATFORM_MACOS' } + filter 'system:linux' + defines { 'PLATFORM_LINUX' } filter 'files:**.lua' buildmessage 'Compiling %{file.name}' @@ -136,7 +140,8 @@ do -- for lua end function generateBuildLuaCommand(_ENV) - local lua = path.join(cfg.buildtarget.directory, 'Lua.exe') + local luaExe = os.target() == 'windows' and 'Lua.exe' or 'Lua' + local lua = path.join(cfg.buildtarget.directory, luaExe) local script = path.join(_MAIN_SCRIPT_DIR, 'bin/build.lua') local out = getGeneratedDir(_ENV) diff --git a/src/objediting.cpp b/src/objediting.cpp index ee13715..7e43f7a 100644 --- a/src/objediting.cpp +++ b/src/objediting.cpp @@ -3,9 +3,9 @@ #include "luaapi.h" #include "luasource.h" -constexpr char* CMDLINE_MAP = "map"; -constexpr char* CMDLINE_OUTPUT = "output"; -constexpr char* CMDLINE_DUMP_TO_SCRIPT = "dump"; +constexpr const char* CMDLINE_MAP = "map"; +constexpr const char* CMDLINE_OUTPUT = "output"; +constexpr const char* CMDLINE_DUMP_TO_SCRIPT = "dump"; static void RegisterTo(lua_State* L, lua_CFunction f, const char* table, const char* name) { diff --git a/src/os_chdir.c b/src/os_chdir.c index fe8a362..491a2d9 100644 --- a/src/os_chdir.c +++ b/src/os_chdir.c @@ -11,6 +11,8 @@ #if PLATFORM_WINDOWS #include "Windows.h" #define PATH_MAX 4096 +#else +#include #endif int do_chdir(lua_State* L, const char* path)