Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions kodi_game_scripting/template_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@
'templates')


def get_list(value):
""" Filter: Returns a list (existing list or new single elemented list) """
return value if isinstance(value, list) else [value]


def regex_replace(string, find, replace, *, multiline=False):
""" Filter: Replace regex in string """
flags = 0
if multiline:
flags += re.MULTILINE
return re.sub(find, replace, string, flags=flags)


class TemplateProcessor:
""" Process Jinja2 templates """

Expand All @@ -51,17 +64,7 @@ def __getattr__(self, key):
trim_blocks=True, lstrip_blocks=True, keep_trailing_newline=True,
undefined=_TreeUndefined)

def regex_replace(string, find, replace, multiline=False):
""" Replaces regex in string """
flags = 0
if multiline:
flags += re.MULTILINE
return re.sub(find, replace, string, flags=flags)
template_env.filters["regex_replace"] = regex_replace

def get_list(value):
""" Returns a list (existing list or new single elemented list) """
return value if isinstance(value, list) else [value]
template_env.filters["get_list"] = get_list

# Loop over all templates
Expand Down
4 changes: 2 additions & 2 deletions templates/addon/{{ game.addon }}/addon.xml.in.j2
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@
{% endif %}
{% set description = xml.addon.extension[1].description.content | default('') %}
{% if ("Supported files: " in xml.addon.extension[1].description.content) %}
{% set description = xml.addon.extension[1].description.content | regex_replace('Supported files: (?:\.\w+)(?:,\s*\.\w+)*', extensions | default('')) %}
{% set description = xml.addon.extension[1].description.content | regex_replace('Supported files: (?:\\.\\w+)(?:,\\s*\\.\\w+)*', extensions | default('')) %}
{% elif extensions %}
{% set description = xml.addon.extension[1].description.content | default('') + '\n\n' + extensions %}
{% endif %}
{% if ("License: " in xml.addon.extension[1].description.content) %}
{% set description = description | regex_replace('License: .*', '') %}
{% endif %}
{% set description = description | regex_replace('^(\s*\\n){2,}', '\n', multiline=True) | trim %}
{% set description = description | regex_replace('^(\\s*\\n){2,}', '\n', multiline=True) | trim %}
<description lang="en_GB">{{ description | e }}</description>
{% if xml.addon.extension[1].disclaimer %}
<disclaimer>{{ xml.addon.extension[1].disclaimer.content | e }}</disclaimer>
Expand Down
2 changes: 1 addition & 1 deletion templates/addon/{{ game.addon }}/resources/settings.xml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<settings>
<category label="30000">
{% for setting in settings %}
<setting label="{{ 30000 + loop.index }}" type="select" id="{{ setting.id | e }}" values="{{ setting.values|join('|') | e }}" default="{{ setting.default | e }}"/>
<setting label="{{ 30000 + loop.index }}" type="select" id="{{ setting.id | e }}" values="{{ setting['values']|join('|') | e }}" default="{{ setting.default | e }}"/>
{% endfor %}
</category>
</settings>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
name: Problem report
about: Create an extensive report to help us document a problem

---
<!--- Please fill out this template to the best of your ability. You can always edit this issue once you have created it. -->
<!--- Read the following link before you create a new problem report: https://kodi.wiki/view/HOW-TO:Submit_a_bug_report -->
## Bug report
### Describe the bug
Here is a clear and concise description of what the problem is:
<!--- Provide a more detailed introduction to the issue itself, and why you consider it to be a bug -->
<!--- A bug report that is not clear will be closed -->
<!--- Put your text below this line -->



## RetroArch Behavior
Here is a clear and concise description of what happens in RetroArch with the same core/game:
<!--- Please test the core and game in RetroArch and tell us if the same bug happens -->
<!--- Put your text below this line -->



### To Reproduce
Steps to reproduce the behavior:
<!--- Provide a link to a live example, or an unambiguous set of steps to -->
<!--- reproduce this bug. Include code to reproduce, if relevant -->
<!--- Put your text below this line -->
1.
2.
3.


### Debuglog
<!--- Put your text below this line -->
<!--- A debuglog is always mandatory when creating an issue. Provide one! -->
The debuglog can be found here:



### Screenshots
Here are some links or screenshots to help explain the problem:
<!--- Put your text below this line -->



### Your Environment
Used Operating system:
<!--- Include as many relevant details about the environment you experienced the bug in -->
<!--- Put your text below this line. Checkboxes can easily be ticked once issue is created -->
- [ ] Android
- [ ] iOS
- [ ] Linux
- [ ] OSX
- [ ] Raspberri-Pi
- [ ] Windows
- [ ] Windows UWP

Operating system version/name:

Kodi version:



<!--- End of this issue -->
*note: Once the issue is made we require you to update it with new information or Kodi versions should that be required.
Team Kodi will consider your problem report however, we will not make any promises the problem will be solved.*
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
name: Problem report
about: Create an extensive report to help us document a problem

---
<!--- Please fill out this template to the best of your ability. You can always edit this issue once you have created it. -->
<!--- Read the following link before you create a new problem report: https://kodi.wiki/view/HOW-TO:Submit_a_bug_report -->
## Bug report
### Describe the bug
Here is a clear and concise description of what the problem is:
<!--- Provide a more detailed introduction to the issue itself, and why you consider it to be a bug -->
<!--- A bug report that is not clear will be closed -->
<!--- Put your text below this line -->



## RetroArch Behavior
Here is a clear and concise description of what happens in RetroArch with the same core/game:
<!--- Please test the core and game in RetroArch and tell us if the same bug happens -->
<!--- Put your text below this line -->



### To Reproduce
Steps to reproduce the behavior:
<!--- Provide a link to a live example, or an unambiguous set of steps to -->
<!--- reproduce this bug. Include code to reproduce, if relevant -->
<!--- Put your text below this line -->
1.
2.
3.


### Debuglog
<!--- Put your text below this line -->
<!--- A debuglog is always mandatory when creating an issue. Provide one! -->
The debuglog can be found here:



### Screenshots
Here are some links or screenshots to help explain the problem:
<!--- Put your text below this line -->



### Your Environment
Used Operating system:
<!--- Include as many relevant details about the environment you experienced the bug in -->
<!--- Put your text below this line. Checkboxes can easily be ticked once issue is created -->
- [ ] Android
- [ ] iOS
- [ ] Linux
- [ ] OSX
- [ ] Raspberri-Pi
- [ ] Windows
- [ ] Windows UWP

Operating system version/name:

Kodi version:



<!--- End of this issue -->
*note: Once the issue is made we require you to update it with new information or Kodi versions should that be required.
Team Kodi will consider your problem report however, we will not make any promises the problem will be solved.*
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# build artifacts
build/
obj-x86_64-linux-gnu/
game.*/addon.xml

# commonly used editors
# vim
*.swp

# Eclipse
*.project
*.cproject
.classpath
.settings/

# Sublime
*.sublime-*

# KDevelop 4
*.kdev4

# gedit
*~

# CLion
.idea

# OSX ignorables
.DS_Store
._*
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
language: cpp

#
# Define the build matrix
#
# Travis defaults to building on Ubuntu Precise when building on
# Linux. We need Trusty in order to get up to date versions of
# cmake and g++.
#
env:
global:
- app_id=game.libretro.mygame

matrix:
include:
- os: linux
dist: xenial
sudo: required
compiler: gcc
- os: linux
dist: xenial
sudo: required
compiler: clang
- os: osx
osx_image: xcode9
- os: osx
osx_image: xcode9.3

#
# The addon source is automatically checked out in $TRAVIS_BUILD_DIR,
# we'll put the Kodi source on the same level
#
before_script:
- cd $TRAVIS_BUILD_DIR/..
- git clone --depth=1 https://github.com/xbmc/xbmc.git
- cd ${app_id} && mkdir build && cd build
- mkdir -p definition/${app_id}
- echo ${app_id} $TRAVIS_BUILD_DIR $TRAVIS_COMMIT > definition/${app_id}/${app_id}.txt
- cmake -DADDONS_TO_BUILD=${app_id} -DADDON_SRC_PREFIX=$TRAVIS_BUILD_DIR/.. -DADDONS_DEFINITION_DIR=$TRAVIS_BUILD_DIR/build/definition -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$TRAVIS_BUILD_DIR/../xbmc/addons -DPACKAGE_ZIP=1 $TRAVIS_BUILD_DIR/../xbmc/cmake/addons

script: make -j$(getconf _NPROCESSORS_ONLN)
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
cmake_minimum_required(VERSION 3.1)
project(game.libretro.mygame)

list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR})

find_package(Kodi REQUIRED)
find_package(libretro-mygame REQUIRED)

set(MYGAME_CUSTOM_BINARY ${MYGAME_LIB}
${PROJECT_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX})

build_addon(${PROJECT_NAME} MYGAME "")

include(CPack)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
buildPlugin(deploy: ['android-armv7', 'android-aarch64', 'osx-x86_64', 'windows-i686', 'windows-x86_64'])
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# game.libretro.mygame addon for Kodi

This is a [Kodi](http://kodi.tv) game addon for mygame.

[![Build Status](https://travis-ci.org/kodi-game/game.libretro.mygame.svg?branch=master)](https://travis-ci.org/kodi-game/game.libretro.mygame)
[![Build Status](https://ci.appveyor.com/api/projects/status/github/kodi-game/game.libretro.mygame?svg=true)](https://ci.appveyor.com/project/kodi-game/game-libretro-mygame)
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
version: BuildNr.{build}

image: Visual Studio 2015

shallow_clone: true

clone_folder: c:\projects\game.libretro.mygame

environment:
app_id: game.libretro.mygame

matrix:
- GENERATOR: "Visual Studio 14"
CONFIGURATION: Release
- GENERATOR: "Visual Studio 14 Win64"
CONFIGURATION: Release

build_script:
- cd ..
- git clone --depth=1 https://github.com/xbmc/xbmc.git
- mklink /j xbmc\project\BuildDependencies\msys64 C:\msys64
- cd %app_id%
- mkdir build
- cd build
- mkdir -p definition\%app_id%
- echo %app_id% %APPVEYOR_BUILD_FOLDER% %APPVEYOR_REPO_COMMIT% > definition\%app_id%\%app_id%.txt
- SET PATH=C:\Program Files (x86)\CMake\bin;C:\msys64\bin;C:\msys64\usr\bin;%PATH%
- cmake -T host=x64 -G "%GENERATOR%" -DADDONS_TO_BUILD=%app_id% -DCMAKE_BUILD_TYPE=%CONFIGURATION% -DADDONS_DEFINITION_DIR=%APPVEYOR_BUILD_FOLDER%/build/definition -DADDON_SRC_PREFIX=../.. -DCMAKE_INSTALL_PREFIX=../../xbmc/addons -DPACKAGE_ZIP=1 ../../xbmc/cmake/addons
- cmake --build . --config %CONFIGURATION% --target %app_id%
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
cmake_minimum_required(VERSION 3.1)
project(mygame)

list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR})

include(ExternalProject)

string(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)

set(LIBRETRO_BINARY_DIR )
set(LIBRETRO_SONAME ${CMAKE_SHARED_LIBRARY_SUFFIX})
set(LIBRETRO_JNISONAME ${CMAKE_SHARED_LIBRARY_SUFFIX})

if(CMAKE_BUILD_TYPE MATCHES Debug)
set(LIBRETRO_DEBUG DEBUG=1)
endif()

if(CORE_SYSTEM_NAME STREQUAL windows)
find_package(MinGW REQUIRED)
set(BUILD_COMMAND ${MINGW_MAKE} -j$ENV{NUMBER_OF_PROCESSORS} -C -f platform=win ${LIBRETRO_DEBUG} GIT_VERSION=)
elseif(CORE_SYSTEM_NAME STREQUAL linux)
set(BUILD_COMMAND $(MAKE) -C -f platform=unix ${LIBRETRO_DEBUG} GIT_VERSION=)
elseif(CORE_SYSTEM_NAME STREQUAL osx)
set(BUILD_COMMAND $(MAKE) -C -f platform=osx ${LIBRETRO_DEBUG} GIT_VERSION=)
elseif(CORE_SYSTEM_NAME STREQUAL ios)
set(LIBRETRO_SONAME _ios${CMAKE_SHARED_LIBRARY_SUFFIX})
set(BUILD_COMMAND IOSSDK=${CMAKE_OSX_SYSROOT} $(MAKE) -C -f platform=ios ${LIBRETRO_DEBUG} GIT_VERSION=)
elseif(CORE_SYSTEM_NAME STREQUAL android)
if(NOT NDKROOT)
message(FATAL_ERROR "${PROJECT_NAME} needs NDKROOT for Android. Missing Toolchain file?")
endif()
if(CPU STREQUAL armeabi-v7a)
set(PLATFORM android-armv7)
elseif(CPU STREQUAL i686)
set(PLATFORM x86)
else()
message(FATAL_ERROR "${PROJECT_NAME} needs Android ${CPU} build command in CMakeLists.txt!")
endif()
set(LIBRETRO_SONAME _android${CMAKE_SHARED_LIBRARY_SUFFIX})
get_filename_component(TOOLCHAIN_DIR ${CMAKE_C_COMPILER} DIRECTORY)
set(BUILD_COMMAND PATH=${TOOLCHAIN_DIR}:$ENV{PATH} $(MAKE) -C -f platform=${PLATFORM} ${LIBRETRO_DEBUG} GIT_VERSION=)
elseif(CORE_SYSTEM_NAME STREQUAL rbpi)
message(FATAL_ERROR "${PROJECT_NAME} needs RPi build command in CMakeLists.txt!")
elseif(CORE_SYSTEM_NAME STREQUAL freebsd)
set(BUILD_COMMAND $(MAKE) -C -f platform=unix ${LIBRETRO_DEBUG} GIT_VERSION=)
else()
message(FATAL_ERROR "${PROJECT_NAME} - Unknown system: ${CORE_SYSTEM_NAME}")
endif()

externalproject_add(${PROJECT_NAME}
SOURCE_DIR ${PROJECT_SOURCE_DIR}
PREFIX ${PROJECT_NAME}
CONFIGURE_COMMAND ""
INSTALL_COMMAND ""
BUILD_COMMAND ${BUILD_COMMAND}
BUILD_IN_SOURCE 1)

# install the generated shared library
install(FILES ${PROJECT_SOURCE_DIR}/${LIBRETRO_BINARY_DIR}/${LIBRETRO_SONAME}
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)

# write the config.cmake script
file(WRITE ${CMAKE_INSTALL_PREFIX}/libretro-${PROJECT_NAME}-config.cmake "set(${PROJECT_NAME_UC}_LIB ${CMAKE_INSTALL_PREFIX}/lib/${LIBRETRO_SONAME})")
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mygame https://github.com/libretro/mygame master
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mingw
Loading