Skip to content

Commit

Permalink
Update Windows Workflow for win-gcc, prevent mklink errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Okkoma committed Oct 29, 2024
1 parent 3c1a717 commit 28cd0b1
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 35 deletions.
78 changes: 66 additions & 12 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,69 @@ concurrency:
cancel-in-progress: true

jobs:
windows:
name: 🏁
windows-vs:
name: win-vs 🏁
runs-on: windows-latest
strategy:
fail-fast: false
matrix:

lib-type:
- static
- shared
graphics-api:
- DX11
- OpenGL
env:
HOST: ${{ github.job }}
PLATFORM: win-vs
LIB_TYPE: ${{ matrix.lib-type }}
GRAPHICS_API: ${{ matrix.graphics-api }}
URHO3D_DOCS: 0
steps:
- name: Checkout
uses: actions/checkout@v4
with: { fetch-depth: 0 }
- name: Set cache TTL
run: |
echo ("CACHE_MONTH=" + $(date '+%b %Y')) >> $env:GITHUB_ENV
- name: CMake
run: rake cmake
- name: Build
run: rake build
- name: Test
run: rake test
if: matrix.graphics-api != 'OpenGL'
- name: Install
run: rake install
- name: Scaffolding - new
run: rake new
- name: Scaffolding - build
run: |
cd ~/projects/UrhoApp
rake
- name: Scaffolding - test
run: |
cd ~/projects/UrhoApp
rake test
if: matrix.graphics-api != 'OpenGL'
- name: Scaffolding - cleanup
run: rm -r -fo ~/.urho3d, ~/Projects
- name: Package
run: rake package
if: github.event_name == 'push'
- name: Upload
uses: actions/upload-artifact@v4
with:
name: win-vs-${{ matrix.lib-type }}-64-${{ matrix.graphics-api }}-rel
path: build/ci/*.zip
if: github.event_name == 'push'
windows-gcc:
name: win-gcc 🏁
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
platform:
- win-vs
- win-gcc
lib-type:
- static
- shared
Expand All @@ -23,10 +77,11 @@ jobs:
- OpenGL
env:
HOST: ${{ github.job }}
PLATFORM: ${{ matrix.platform }}
PLATFORM: win-gcc
LIB_TYPE: ${{ matrix.lib-type }}
GRAPHICS_API: ${{ matrix.graphics-api }}
URHO3D_DOCS: 0
MINGW_SYSROOT: 'C:/ProgramData/chocolatey/lib/mingw'
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -36,15 +91,14 @@ jobs:
echo ("CACHE_MONTH=" + $(date '+%b %Y')) >> $env:GITHUB_ENV
- name: Cache MinGW installation
id: cache-mingw
uses: actions/cache@v3
if: matrix.platform == 'win-gcc'
uses: actions/cache@v4
with:
path: C:\ProgramData\chocolatey\lib\mingw
key: ${{ env.CACHE_MONTH }}
- name: Set up MinGW
uses: egor-tensin/setup-mingw@v2
if: matrix.platform == 'win-gcc'
uses: egor-tensin/[email protected]
with:
version: 12.2.0
platform: x64
- name: CMake
run: rake cmake
Expand Down Expand Up @@ -72,8 +126,8 @@ jobs:
run: rake package
if: github.event_name == 'push'
- name: Upload
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.platform }}-${{ matrix.lib-type }}-64-${{ matrix.graphics-api }}-rel
name: win-gcc-${{ matrix.lib-type }}-64-${{ matrix.graphics-api }}-rel
path: build/ci/*.zip
if: github.event_name == 'push'
5 changes: 3 additions & 2 deletions Source/Urho3D/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#
# Copyright (c) 2008-2022 the Urho3D project.
# Copyright (c) 2022-2024 the U3D project.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -230,7 +231,7 @@ endif ()

# Define generated source files
if (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/librevision.h)
execute_process (COMMAND ${CMAKE_COMMAND} -DFILENAME=${CMAKE_CURRENT_BINARY_DIR}/librevision.h -P cmake/Modules/GetUrhoRevision.cmake
execute_process (COMMAND ${CMAKE_COMMAND} -DFILENAME=${CMAKE_CURRENT_BINARY_DIR}/librevision.h -P ${CMAKE_SOURCE_DIR}/cmake/Modules/GetUrhoRevision.cmake
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_QUIET ERROR_QUIET)
endif ()
set (URHO3D_DEPS ${STATIC_LIBRARY_TARGETS})
Expand All @@ -244,7 +245,7 @@ if (TARGET LuaJIT_universal)
endif ()
set_source_files_properties (${SYMBOLIC_SOURCES} PROPERTIES SYMBOLIC TRUE)
add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/librevision.h
COMMAND ${CMAKE_COMMAND} -DFILENAME=${CMAKE_CURRENT_BINARY_DIR}/librevision.h.new -P cmake/Modules/GetUrhoRevision.cmake
COMMAND ${CMAKE_COMMAND} -DFILENAME=${CMAKE_CURRENT_BINARY_DIR}/librevision.h.new -P ${CMAKE_SOURCE_DIR}/cmake/Modules/GetUrhoRevision.cmake
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/librevision.h.new ${CMAKE_CURRENT_BINARY_DIR}/librevision.h
COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_CURRENT_BINARY_DIR}/librevision.h.new
DEPENDS ${URHO3D_DEPS} ${CMAKE_SOURCE_DIR}/cmake/Modules/GetUrhoRevision.cmake
Expand Down
32 changes: 25 additions & 7 deletions cmake/Modules/CheckHost.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#
# Copyright (c) 2008-2022 the Urho3D project.
# Copyright (c) 2022-2024 the U3D project.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -38,13 +39,29 @@
if (CMAKE_HOST_WIN32)
set (NULL_DEVICE nul)
if (NOT DEFINED HAS_MKLINK)
# Test whether the host system is capable of setting up symbolic link
execute_process (COMMAND cmd /C mklink test-link CMakeCache.txt WORKING_DIRECTORY ${CMAKE_BINARY_DIR} RESULT_VARIABLE MKLINK_EXIT_CODE OUTPUT_QUIET ERROR_QUIET)
if (MKLINK_EXIT_CODE EQUAL 0)
set (HAS_MKLINK TRUE)
file (REMOVE ${CMAKE_BINARY_DIR}/test-link)
else ()
set (HAS_MKLINK FALSE)
# Performs a full test to cover cases where symbolic links are malformed (case on dockur/windows)
find_program(MLINK_EXECUTABLE mlink)
set(HAS_MKLINK FALSE)
if (MLINK_EXECUTABLE)
execute_process (COMMAND ${MLINK_EXECUTABLE} --version RESULT_VARIABLE MLINK_RESULT OUTPUT_VARIABLE MLINK_OUTPUT ERROR_VARIABLE MLINK_ERROR)
if (MLINK_RESULT EQUAL 0)
# Test create a symlink
set(TEST_SOURCE_FILE "/tmp/test_source")
set(TEST_LINK_FILE "/tmp/test_link")
file(WRITE ${TEST_SOURCE_FILE} "test file.")
execute_process(COMMAND ${MLINK_EXECUTABLE} ${TEST_SOURCE_FILE} ${TEST_LINK_FILE} RESULT_VARIABLE LINK_RESULT)
# Check if symlink is really working
if (LINK_RESULT EQUAL 0 AND EXISTS ${TEST_LINK_FILE})
file(READ ${TEST_LINK_FILE} LINK_CONTENTS)
if (LINK_CONTENTS STREQUAL "test file.")
set(HAS_MKLINK TRUE)
endif()
# Remove the test link and file
file(REMOVE ${TEST_LINK_FILE} ${TEST_SOURCE_FILE})
endif()
endif()
endif ()
if (NOT HAS_MKLINK)
message (WARNING "Could not use MKLINK to setup symbolic links as this Windows user account does not have the privilege to do so. "
"When MKLINK is not available then the build system will fallback to use file/directory copy of the library headers from source tree to build tree. "
"In order to prevent stale headers being used in the build, this file/directory copy will be redone also as a post-build step for each library targets. "
Expand All @@ -54,6 +71,7 @@ if (CMAKE_HOST_WIN32)
endif ()
set (HAS_MKLINK ${HAS_MKLINK} CACHE INTERNAL "MKLINK capability")
endif ()

else ()
set (NULL_DEVICE /dev/null)
if (NOT DEFINED HAS_LIB64)
Expand Down
8 changes: 6 additions & 2 deletions cmake/Modules/FindDirectX.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#
# Copyright (c) 2008-2022 the Urho3D project.
# Copyright (c) 2022-2024 the U3D project.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -240,5 +241,8 @@ foreach (COMPONENT DInput DSound XInput)
endforeach ()
set (CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVED})

include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (DirectX REQUIRED_VARS HAVE_DIRECTX HANDLE_COMPONENTS FAIL_MESSAGE ${FAIL_MESSAGE})
# do we need this for MINGW ?
if (NOT MINGW)
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (DirectX REQUIRED_VARS HAVE_DIRECTX HANDLE_COMPONENTS FAIL_MESSAGE ${FAIL_MESSAGE})
endif()
19 changes: 14 additions & 5 deletions cmake/Modules/UrhoCommon.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,9 @@ if (WIN32 AND NOT CMAKE_PROJECT_NAME MATCHES ^Urho3D-ExternalProject-)
endif ()
endif ()

# SDL_LIBS : allow to link against Urho3D the external LIBS from SDL
set (SDL_LIBS)

# Platform and compiler specific options
set (CMAKE_CXX_STANDARD 11)
set (CMAKE_CXX_STANDARD_REQUIRED ON)
Expand Down Expand Up @@ -894,10 +897,7 @@ macro (define_dependency_libs TARGET)
list (APPEND LIBS dl log android)
else ()
# Linux
if (${TARGET} MATCHES SDL)
# set external libraries dependencies for SDL and add them later to URHO3D
set (URHO3D_LIBRARIES ${EXTRA_LIBS} PARENT_SCOPE)
elseif (NOT WEB)
if (NOT WEB)
list (APPEND LIBS dl m rt)
endif ()
if (RPI)
Expand All @@ -906,6 +906,13 @@ macro (define_dependency_libs TARGET)
endif ()
endif ()

# Set extra dependencies from SDL and add them later to URHO3D
# Android : need OpenSLES
# Linux : may need Wayland and X11 (only for X11-static)
if (${TARGET} MATCHES SDL)
set (SDL_LIBS ${EXTRA_LIBS} PARENT_SCOPE)
endif ()

# ThirdParty/Civetweb external dependency
if (${TARGET} MATCHES Civetweb|Urho3D)
if (WIN32)
Expand Down Expand Up @@ -1779,7 +1786,9 @@ macro (_setup_target)
include_directories (${INCLUDE_DIRS})
# Link libraries
define_dependency_libs (${TARGET_NAME})
target_link_libraries (${TARGET_NAME} ${ABSOLUTE_PATH_LIBS} ${LIBS})
# Needed external libraries for the current target (SDL_LIBS added)
target_link_libraries (${TARGET_NAME} ${ABSOLUTE_PATH_LIBS} ${SDL_LIBS} ${LIBS})
set (SDL_LIBS)
# Enable PCH if requested
if (${TARGET_NAME}_HEADER_PATHNAME)
enable_pch (${${TARGET_NAME}_HEADER_PATHNAME})
Expand Down
15 changes: 8 additions & 7 deletions rakefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#
# Copyright (c) 2008-2022 the Urho3D project.
# Copyright (c) 2022-2024 the U3D project.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -42,12 +43,12 @@ task :cmake => [:init] do
system 'bash', '-c', 'rm -rf ~/.{ccache,gradle}' or abort 'Failed to clear the build cache'
end
end
next if ENV['PLATFORM'] == 'android' || (Dir.exists?(build_tree) and not ARGV.include?('cmake'))
next if ENV['PLATFORM'] == 'android' || (Dir.exist?(build_tree) and not ARGV.include?('cmake'))
['CMAKE_INSTALL_PREFIX', 'URHO3D_HOME'].each { |var|
if ENV[var] == 'system'
ENV.delete(var)
elsif !ENV[var]
ENV[var] = install_dir if var == 'CMAKE_INSTALL_PREFIX' || Dir.exists?(install_dir)
ENV[var] = install_dir if var == 'CMAKE_INSTALL_PREFIX' || Dir.exist?(install_dir)
end
}
script = "script/cmake_#{ENV['GENERATOR']}#{ENV['OS'] ? '.bat' : '.sh'}"
Expand Down Expand Up @@ -152,7 +153,7 @@ task :new, [:name, :parent_dir, :use_copy] => [:init] do |_, args|
parent_dir = verify_path(args[:parent_dir])
dir = "#{parent_dir}/#{name}"
use_copy = args[:use_copy] || dockerized?
abort "The directory '#{dir}' already exists!" if Dir.exists?(dir)
abort "The directory '#{dir}' already exist!" if Dir.exist?(dir)
puts "Creating a new project in #{dir}..."
func = FileUtils.method(use_copy ? :cp_r : :ln_s)
source_tree(name).split("\n").each do |it|
Expand Down Expand Up @@ -292,7 +293,7 @@ task :init do
unless ENV['PLATFORM']
if /x86/ =~ `uname -m`
ENV['PLATFORM'] = 'linux'
elsif Dir.exists?('/opt/vc')
elsif Dir.exist?('/opt/vc')
ENV['PLATFORM'] = 'rpi'
else
ENV['PLATFORM'] = 'arm'
Expand Down Expand Up @@ -413,7 +414,7 @@ def default_path
end

def dockerized?
File.exists?('/entrypoint.sh')
File.exist?('/entrypoint.sh')
end

def install_dir
Expand All @@ -428,7 +429,7 @@ def verify_path(path, auto_create = false)
require 'pathname'
begin
expanded_path = File.expand_path(path)
FileUtils.mkdir_p(expanded_path) if (auto_create && !Dir.exists?(expanded_path))
FileUtils.mkdir_p(expanded_path) if (auto_create && !Dir.exist?(expanded_path))
Pathname.new(expanded_path).realdirpath.to_s
rescue
abort "The specified path '#{path}' is invalid!"
Expand All @@ -440,7 +441,7 @@ def first_match(regex, from)
if from.instance_of?(Array)
array = from
else
array = File.exists?(from) ? File.readlines(from) : from.split("\n")
array = File.exist?(from) ? File.readlines(from) : from.split("\n")
end
array.grep(regex).first.match(regex).captures.first
rescue
Expand Down

0 comments on commit 28cd0b1

Please sign in to comment.