From f52346e24f1a94ee70db861fc555fc7031d53236 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marti=CC=81n=20Lucas=20Golini?= Date: Sat, 1 Apr 2023 17:08:16 -0300 Subject: [PATCH] Fix macOS cross build script. premake5 project now saves lib files in a arch subfolder. --- premake5.lua | 85 ++++++++++++++++--------- projects/haiku/ecode/build.app.sh | 2 +- projects/macos/ecode/build.app.sh | 5 +- projects/macos/ecode/cross.build.app.sh | 4 +- projects/mingw32/make.sh | 10 +-- 5 files changed, 67 insertions(+), 39 deletions(-) diff --git a/premake5.lua b/premake5.lua index f8d3aea81..a5eff7fc2 100644 --- a/premake5.lua +++ b/premake5.lua @@ -30,22 +30,22 @@ function get_dll_extension() end end -function postsymlinklib(src_path, dst_path, lib) - filter { "configurations:release*", "system:windows" } +function postsymlinklib(src_path, dst_path, lib, arch) + filter { "configurations:release*", "system:windows", arch } if os.ishost("windows") then postbuildcommands { "mklink \"" .. dst_path .. lib .. ".dll\"" .. " \"" .. src_path .. lib .. ".dll\" || ver>nul" } else postbuildcommands { "ln -sf \"" .. src_path .. "lib" .. lib .. "." .. get_dll_extension() .. "\" \"" .. dst_path .. "\"" } end - filter { "configurations:debug*", "system:windows" } + filter { "configurations:debug*", "system:windows", arch } if os.ishost("windows") then postbuildcommands { "mklink \"" .. dst_path .. lib .. "-debug.dll\"" .. " \"" .. src_path .. lib .. "-debug.dll\" || ver>nul" } else postbuildcommands { "ln -sf \"" .. src_path .. "lib" .. lib .. "-debug." .. get_dll_extension() .. "\" \"" .. dst_path .. "\"" } end - filter { "configurations:release*", "not system:windows" } + filter { "configurations:release*", "not system:windows", arch } postbuildcommands { "ln -sf \"" .. src_path .. "lib" .. lib .. "." .. get_dll_extension() .. "\" \"" .. dst_path .. "\"" } - filter { "configurations:debug*", "not system:windows" } + filter { "configurations:debug*", "not system:windows", arch } postbuildcommands { "ln -sf \"" .. src_path .. "lib" .. lib .. "-debug." .. get_dll_extension() .. "\" \"" .. dst_path .. "\"" } end @@ -685,6 +685,31 @@ function build_eepp( build_name ) buildoptions { "/bigobj" } end +function target_dir_lib(path) + filter "architecture:x86" + targetdir("libs/" .. os.target() .. "/x86/" .. path .. "/") + filter "architecture:x86_64" + targetdir("libs/" .. os.target() .. "/x86_64/" .. path .. "/") + filter "architecture:ARM" + targetdir("libs/" .. os.target() .. "/arm/" .. path .. "/") + filter "architecture:ARM64" + targetdir("libs/" .. os.target() .. "/arm64/" .. path .. "/") + filter "architecture:universal" + targetdir("libs/" .. os.target() .. "/universal/" .. path .. "/") +end + +function target_dir_thirdparty() + target_dir_lib("thirdparty") +end + +function postsymlinklib_arch(name) + postsymlinklib( _MAIN_SCRIPT_DIR .. "/libs/" .. os.target() .. "/x86/", _MAIN_SCRIPT_DIR .. "/bin/", name, "architecture:x86" ) + postsymlinklib( _MAIN_SCRIPT_DIR .. "/libs/" .. os.target() .. "/x86_64/", _MAIN_SCRIPT_DIR .. "/bin/", name, "architecture:x86_64" ) + postsymlinklib( _MAIN_SCRIPT_DIR .. "/libs/" .. os.target() .. "/arm/", _MAIN_SCRIPT_DIR .. "/bin/", name, "architecture:ARM" ) + postsymlinklib( _MAIN_SCRIPT_DIR .. "/libs/" .. os.target() .. "/arm64/", _MAIN_SCRIPT_DIR .. "/bin/", name, "architecture:ARM64" ) + postsymlinklib( _MAIN_SCRIPT_DIR .. "/libs/" .. os.target() .. "/universal/", _MAIN_SCRIPT_DIR .. "/bin/", name, "architecture:universal" ) +end + workspace "eepp" targetdir("./bin/") if os.istarget("ios") then @@ -732,81 +757,81 @@ workspace "eepp" project "SOIL2-static" kind "StaticLib" language "C" - targetdir("libs/" .. os.target() .. "/thirdparty/") files { "src/thirdparty/SOIL2/src/SOIL2/*.c" } incdirs { "src/thirdparty/SOIL2" } build_base_configuration( "SOIL2" ) + target_dir_thirdparty() project "glew-static" kind "StaticLib" language "C" defines { "GLEW_NO_GLU", "GLEW_STATIC" } - targetdir("libs/" .. os.target() .. "/thirdparty/") files { "src/thirdparty/glew/*.c" } incdirs { "include/thirdparty/glew" } build_base_configuration( "glew" ) + target_dir_thirdparty() project "mbedtls-static" kind "StaticLib" language "C" - targetdir("libs/" .. os.target() .. "/thirdparty/") incdirs { "src/thirdparty/mbedtls/include/" } files { "src/thirdparty/mbedtls/library/*.c" } build_base_cpp_configuration( "mbedtls" ) + target_dir_thirdparty() project "vorbis-static" kind "StaticLib" language "C" - targetdir("libs/" .. os.target() .. "/thirdparty/") incdirs { "src/thirdparty/libvorbis/lib/", "src/thirdparty/libogg/include", "src/thirdparty/libvorbis/include" } files { "src/thirdparty/libogg/**.c", "src/thirdparty/libvorbis/**.c" } build_base_cpp_configuration( "vorbis" ) + target_dir_thirdparty() project "pugixml-static" kind "StaticLib" language "C++" - targetdir("libs/" .. os.target() .. "/thirdparty/") files { "src/thirdparty/pugixml/*.cpp" } build_base_cpp_configuration( "pugixml" ) + target_dir_thirdparty() project "zlib-static" kind "StaticLib" language "C" - targetdir("libs/" .. os.target() .. "/thirdparty/") files { "src/thirdparty/zlib/*.c" } build_base_configuration( "zlib" ) + target_dir_thirdparty() project "libzip-static" kind "StaticLib" language "C" - targetdir("libs/" .. os.target() .. "/thirdparty/") files { "src/thirdparty/libzip/*.c" } incdirs { "src/thirdparty/zlib" } build_base_configuration( "libzip" ) + target_dir_thirdparty() project "libpng-static" kind "StaticLib" language "C" - targetdir("libs/" .. os.target() .. "/thirdparty/") files { "src/thirdparty/libpng/**.c" } incdirs { "src/thirdparty/libpng/include" } build_base_configuration( "libpng" ) + target_dir_thirdparty() project "freetype-static" kind "StaticLib" language "C" - targetdir("libs/" .. os.target() .. "/thirdparty/") defines { "FT2_BUILD_LIBRARY" } files { "src/thirdparty/freetype2/src/**.c" } incdirs { "src/thirdparty/freetype2/include", "src/thirdparty/libpng" } build_base_configuration( "freetype" ) + target_dir_thirdparty() project "chipmunk-static" kind "StaticLib" - targetdir("libs/" .. os.target() .. "/thirdparty/") files { "src/thirdparty/chipmunk/*.c", "src/thirdparty/chipmunk/constraints/*.c" } incdirs { "src/modules/physics/include/eepp/thirdparty/chipmunk" } build_base_configuration( "chipmunk" ) + target_dir_thirdparty() filter "action:vs*" language "C++" buildoptions { "/TP" } @@ -816,25 +841,25 @@ workspace "eepp" project "jpeg-compressor-static" kind "StaticLib" language "C++" - targetdir("libs/" .. os.target() .. "/thirdparty/") files { "src/thirdparty/jpeg-compressor/*.cpp" } build_base_cpp_configuration( "jpeg-compressor" ) + target_dir_thirdparty() project "imageresampler-static" kind "StaticLib" language "C++" - targetdir("libs/" .. os.target() .. "/thirdparty/") files { "src/thirdparty/imageresampler/*.cpp" } build_base_cpp_configuration( "imageresampler" ) + target_dir_thirdparty() project "mojoal-static" kind "StaticLib" language "C" - targetdir("libs/" .. os.target() .. "/thirdparty/") incdirs { "include/eepp/thirdparty/mojoAL" } defines( "AL_LIBTYPE_STATIC" ) files { "src/thirdparty/mojoAL/*.c" } build_base_cpp_configuration( "mojoal" ) + target_dir_thirdparty() filter "options:windows-vc-build" incdirs { "src/thirdparty/" .. remote_sdl2_version .. "/include" } filter { "options:windows-mingw-build", "architecture:x86", "options:cc=mingw" } @@ -846,10 +871,10 @@ workspace "eepp" kind "StaticLib" language "C++" cppdialect "C++17" - targetdir("libs/" .. os.target() .. "/thirdparty/") incdirs { "src/thirdparty/efsw/include", "src/thirdparty/efsw/src" } files { "src/thirdparty/efsw/src/efsw/*.cpp" } build_base_cpp_configuration( "efsw" ) + target_dir_thirdparty() filter "system:windows" files { "src/thirdparty/efsw/src/efsw/platform/win/*.cpp" } excludes { @@ -892,7 +917,6 @@ workspace "eepp" kind "StaticLib" language "C++" cppdialect "C++17" - targetdir("libs/" .. os.target() .. "/") incdirs { "include", "src/modules/maps/include/","src/modules/maps/src/" } files { "src/modules/maps/src/**.cpp" } defines { "EE_MAPS_STATIC" } @@ -900,6 +924,7 @@ workspace "eepp" defines { "EE_STATIC" } end build_base_cpp_configuration( "eepp-maps-static" ) + target_dir_lib("eepp-maps") filter "action:not vs*" buildoptions { "-Wall" } @@ -907,13 +932,13 @@ workspace "eepp" kind "SharedLib" language "C++" cppdialect "C++17" - targetdir("libs/" .. os.target() .. "/") incdirs { "include", "src/modules/maps/include/","src/modules/maps/src/" } files { "src/modules/maps/src/**.cpp" } links { "eepp-shared" } defines { "EE_MAPS_EXPORTS" } build_base_cpp_configuration( "eepp-maps" ) - postsymlinklib( _MAIN_SCRIPT_DIR .. "/libs/" .. os.target() .. "/", _MAIN_SCRIPT_DIR .. "/bin/", "eepp-maps" ) + postsymlinklib_arch( "eepp-maps" ) + target_dir_lib("eepp-maps") filter "action:not vs*" buildoptions { "-Wall" } @@ -921,7 +946,6 @@ workspace "eepp" kind "StaticLib" language "C++" cppdialect "C++17" - targetdir("libs/" .. os.target() .. "/") incdirs { "include", "src/modules/physics/include/","src/modules/physics/src/" } files { "src/modules/physics/src/**.cpp", "src/eepp/physics/constraints/*.cpp" } defines { "EE_PHYSICS_STATIC" } @@ -929,6 +953,7 @@ workspace "eepp" defines { "EE_STATIC" } end build_base_cpp_configuration( "eepp-physics-static" ) + target_dir_lib("eepp-physics") filter "action:not vs*" buildoptions { "-Wall" } @@ -936,13 +961,13 @@ workspace "eepp" kind "SharedLib" language "C++" cppdialect "C++17" - targetdir("libs/" .. os.target() .. "/") incdirs { "include", "src/modules/physics/include/","src/modules/physics/src/" } files { "src/modules/physics/src/**.cpp", "src/eepp/physics/constraints/*.cpp" } links { "chipmunk-static", "eepp-shared" } defines { "EE_PHYSICS_EXPORTS" } build_base_cpp_configuration( "eepp-physics" ) - postsymlinklib( _MAIN_SCRIPT_DIR .. "/libs/" .. os.target() .. "/", _MAIN_SCRIPT_DIR .. "/bin/", "eepp-physics" ) + postsymlinklib_arch( "eepp-physics" ) + target_dir_lib("eepp-physics") filter "action:not vs*" buildoptions { "-Wall" } @@ -950,13 +975,13 @@ workspace "eepp" kind "StaticLib" language "C++" cppdialect "C++17" - targetdir("libs/" .. os.target() .. "/") incdirs { "include", "src/modules/eterm/include/","src/modules/eterm/src/" } files { "src/modules/eterm/src/**.cpp" } if _OPTIONS["with-static-eepp"] then defines { "EE_STATIC" } end build_base_cpp_configuration( "eterm" ) + target_dir_lib("eterm") filter "action:not vs*" buildoptions { "-Wall" } @@ -964,15 +989,15 @@ workspace "eepp" project "eepp-static" kind "StaticLib" language "C++" - targetdir("libs/" .. os.target() .. "/") build_eepp( "eepp-static" ) + target_dir_lib("") project "eepp-shared" kind "SharedLib" language "C++" - targetdir("libs/" .. os.target() .. "/") build_eepp( "eepp" ) - postsymlinklib( _MAIN_SCRIPT_DIR .. "/libs/" .. os.target() .. "/", _MAIN_SCRIPT_DIR .. "/bin/", "eepp" ) + postsymlinklib_arch( "eepp" ) + target_dir_lib("") -- Examples project "eepp-external-shader" @@ -1062,7 +1087,7 @@ workspace "eepp" project "ecode-macos-helper-static" kind "StaticLib" language "C++" - targetdir("libs/" .. os.target() .. "/thirdparty/") + target_dir_thirdparty() filter "system:macosx" files { "src/tools/ecode/macos/*.m" } filter { "configurations:debug*", "action:not vs*" } diff --git a/projects/haiku/ecode/build.app.sh b/projects/haiku/ecode/build.app.sh index 50dff311a..f8feccb1c 100755 --- a/projects/haiku/ecode/build.app.sh +++ b/projects/haiku/ecode/build.app.sh @@ -11,7 +11,7 @@ rm -rf ./ecode.app mkdir -p ecode.app/assets mkdir -p ecode.app/lib cp ../../../bin/assets/icon/ecode.png ecode.app/ecode.png -cp ../../../libs/haiku/libeepp.so ecode.app/lib/ +cp ../../../libs/haiku/x86_64/libeepp.so ecode.app/lib/ cp ../../../bin/ecode ecode.app/ cp -L /boot/system/lib/libSDL2-2.0.so.0 ecode.app/lib/ strip ecode.app/lib/libSDL2-2.0.so.0 diff --git a/projects/macos/ecode/build.app.sh b/projects/macos/ecode/build.app.sh index ff8b9b219..e9689bf5d 100755 --- a/projects/macos/ecode/build.app.sh +++ b/projects/macos/ecode/build.app.sh @@ -7,7 +7,7 @@ else echo "Building using sdl2-config" ../make_no_fw.sh config=release ecode || exit fi - +ARCH=$(uname -m) rm -rf ./ecode.app mkdir -p ecode.app/Contents/MacOS/ mkdir -p ecode.app/Contents/Resources/ @@ -30,13 +30,14 @@ SDL2_LIB_PATH="/Library/SDL2.framework/Versions/A/" cp "$SDL2_LIB_PATH/SDL2" ecode.app/Contents/MacOS/SDL2 install_name_tool -change @rpath/SDL2.framework/Versions/A/SDL2 @executable_path/SDL2 ecode.app/Contents/MacOS/libeepp.dylib codesign --force -s - ecode.app/Contents/MacOS/SDL2 +install_name_tool -change @rpath/libeepp.dylib @executable_path/libeepp.dylib ecode.app/Contents/MacOS/ecode else SDL2_LIB_PATH=$(sdl2-config --libs | awk '{ print $1 }' | cut -b 3-) cp $SDL2_LIB_PATH/libSDL2-2.0.0.dylib ecode.app/Contents/MacOS install_name_tool -change $SDL2_LIB_PATH/libSDL2-2.0.0.dylib @executable_path/libSDL2-2.0.0.dylib ecode.app/Contents/MacOS/libeepp.dylib +install_name_tool -change libeepp.dylib @executable_path/libeepp.dylib ecode.app/Contents/MacOS/ecode fi -install_name_tool -change libeepp.dylib @executable_path/libeepp.dylib ecode.app/Contents/MacOS/ecode #cp -r ../../../bin/assets ecode.app/Contents/MacOS/assets mkdir -p ecode.app/Contents/MacOS/assets/colorschemes cp -r ../../../bin/assets/colorschemes/ ecode.app/Contents/MacOS/assets/colorschemes/ diff --git a/projects/macos/ecode/cross.build.app.sh b/projects/macos/ecode/cross.build.app.sh index 1606b5a20..0504f4244 100755 --- a/projects/macos/ecode/cross.build.app.sh +++ b/projects/macos/ecode/cross.build.app.sh @@ -15,13 +15,13 @@ cp Info.plist ecode.app/Contents/ rm Info.plist chmod +x run.sh cp run.sh ecode.app/Contents/MacOS -cp ../../../libs/macosx/libeepp.dylib ecode.app/Contents/MacOS +cp ../../../libs/macosx/arm64/libeepp.dylib ecode.app/Contents/MacOS cp ../../../bin/ecode ecode.app/Contents/MacOS SDL2_LIB_PATH="/Library/SDL2.framework/Versions/A/" cp "$SDL2_LIB_PATH/SDL2" ecode.app/Contents/MacOS/SDL2 install_name_tool -change @rpath/SDL2.framework/Versions/A/SDL2 @executable_path/SDL2 ecode.app/Contents/MacOS/libeepp.dylib codesign --force -s - ecode.app/Contents/MacOS/SDL2 -install_name_tool -change libeepp.dylib @executable_path/libeepp.dylib ecode.app/Contents/MacOS/ecode +install_name_tool -change @rpath/libeepp.dylib @executable_path/libeepp.dylib ecode.app/Contents/MacOS/ecode #cp -r ../../../bin/assets ecode.app/Contents/MacOS/assets mkdir -p ecode.app/Contents/MacOS/assets/colorschemes cp -r ../../../bin/assets/colorschemes/ ecode.app/Contents/MacOS/assets/colorschemes/ diff --git a/projects/mingw32/make.sh b/projects/mingw32/make.sh index 28d15cc72..fc2e57890 100755 --- a/projects/mingw32/make.sh +++ b/projects/mingw32/make.sh @@ -2,6 +2,7 @@ cd "$(dirname "$0")" || exit ARCH=32 +ARCHI=x86 for i in "$@"; do case $i in config=*) @@ -15,6 +16,7 @@ done if [[ "$CONFIG" == *"x86_64"* ]]; then ARCH=64 + ARCHI=x86_64 fi premake5 --file=../../premake5.lua --os=windows --cc=mingw --with-mojoal --windows-mingw-build gmake2 @@ -23,13 +25,13 @@ cd ../../make/windows/ || exit mingw"$ARCH"-make "$@" case "$OSTYPE" in - darwin*|linux*|freebsd*) + darwin*|linux*|freebsd*) cd ../../bin/ || exit - ln -sf ../libs/windows/eepp.dll eepp.dll - ln -sf ../libs/windows/eepp-debug.dll eepp-debug.dll + ln -sf ../libs/windows/$ARCHI/eepp.dll eepp.dll + ln -sf ../libs/windows/$ARCHI/eepp-debug.dll eepp-debug.dll ;; cygwin*|win*) - cd ../../libs/windows/ || exit + cd ../../libs/windows/$ARCHI || exit if [ -f eepp.dll ]; then cp -f eepp.dll ../../bin/eepp.dll