Skip to content

Commit

Permalink
Modify wish_resource_mapping CMAKE_SOURCE_DIR marker from / to @ or @/
Browse files Browse the repository at this point in the history
  • Loading branch information
VaderDev committed Jul 2, 2023
1 parent d5f1fbf commit 8c62f0f
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 10 deletions.
3 changes: 3 additions & 0 deletions Notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ place.it:



document wish_resource_mapping
example wish_resource_mapping



runtime stuffy
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ wget https://raw.githubusercontent.com/VaderY/wish/master/cmake/wish.cmake -P cm
Inside your root CMakeLists.txt file just set the version and include the primary script:
TODO: More documentation
```
set(WISH_REQUEST_VERSION v5.4.0)
set(WISH_REQUEST_VERSION v5.4.1)
include(cmake/wish.cmake)
```

Expand All @@ -32,6 +32,8 @@ include(cmake/wish.cmake)
TODO: Format, place
TODO: Auto self update the wish.cmake script (not just the wish/ folder)

- v5.4.1
- Change: Modify wish_resource_mapping CMAKE_SOURCE_DIR marker from / to @ or @/
- v5.4.0
- Change: Modify wish_resource_mapping expose the resource file mapping instead of the mapping function
- Rename wish_resource_mapping arguments:
Expand Down
2 changes: 1 addition & 1 deletion cmake/wish.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
if (NOT DEFINED WISH_REQUEST_VERSION)
message(FATAL_ERROR "Wish: WISH_REQUEST_VERSION is not defined\n"
" Usage:\n"
" set(WISH_REQUEST_VERSION v5.4.0)\n"
" set(WISH_REQUEST_VERSION v5.4.1)\n"
" include(cmake/wish.cmake)\n")
endif ()

Expand Down
14 changes: 8 additions & 6 deletions cmake/wish/wish_resource.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

include_guard(GLOBAL)

# RESOURCE paths starting with / will be interpreted as relative to CMAKE_SOURCE_DIR
# RESOURCE paths starting with @ and @/ will be interpreted as relative to CMAKE_SOURCE_DIR
function(wish_resource_mapping)
cmake_parse_arguments(PARSE_ARGV 0 arg "DEBUG" "TARGET;MAPPING_FILE;MAPPING_FUNCTION;RELATIVE" "RESOURCE;MAPPING")

Expand All @@ -20,16 +20,18 @@ function(wish_resource_mapping)
endif ()

# GLOB
# Remap / to relative to CMAKE_SOURCE_DIR
# Remap @/ and @ to relative to CMAKE_SOURCE_DIR
set(arg_RESOURCE_root ${arg_RESOURCE})
list(FILTER arg_RESOURCE_root INCLUDE REGEX "^/")
list(FILTER arg_RESOURCE EXCLUDE REGEX "^/")
list(FILTER arg_RESOURCE_root INCLUDE REGEX "^@")
list(FILTER arg_RESOURCE EXCLUDE REGEX "^@")
file(GLOB_RECURSE physical_files LIST_DIRECTORIES false RELATIVE "${arg_RELATIVE}" CONFIGURE_DEPENDS ${arg_RESOURCE})
set(virtual_files ${physical_files})

foreach (resource IN LISTS arg_RESOURCE_root)
file(GLOB_RECURSE matching_physical LIST_DIRECTORIES false RELATIVE "${arg_RELATIVE}" CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}${resource}")
file(GLOB_RECURSE matching_virtual LIST_DIRECTORIES false RELATIVE "${CMAKE_SOURCE_DIR}" CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}${resource}")
string(REPLACE @/ "" resource "${resource}")
string(REPLACE @ "" resource "${resource}")
file(GLOB_RECURSE matching_physical LIST_DIRECTORIES false RELATIVE "${arg_RELATIVE}" CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/${resource}")
file(GLOB_RECURSE matching_virtual LIST_DIRECTORIES false RELATIVE "${CMAKE_SOURCE_DIR}" CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/${resource}")
list(APPEND physical_files ${matching_physical})
list(APPEND virtual_files ${matching_virtual})
endforeach ()
Expand Down
2 changes: 1 addition & 1 deletion cmake/wish/wish_version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

include_guard(GLOBAL)

set(wish_version v5.4.0)
set(wish_version v5.4.1)

# Remove the leading 'v' from version. The v is present for convenience with search-and-replace on new release.
string(SUBSTRING "${wish_version}" 1 -1 wish_version)
2 changes: 1 addition & 1 deletion sandbox/versions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ wish_resource_mapping(

RESOURCE res/*.lua
RESOURCE "${CMAKE_SOURCE_DIR}/res/*.lua"
RESOURCE /res_at/*.lua
RESOURCE @/res_at/*.lua

MAPPING ../../res/global_ res/global_
MAPPING res/rename_me.lua res/file2.lua
Expand Down

0 comments on commit 8c62f0f

Please sign in to comment.