local docs = {}
docs.header =
[[

                                            __
                           ___  __ _  ___  / /_____
                          / _ `/  ' \/ _ `/  '_/ -_)
                          \_, /_/_/_/\_,_/_/\_\\__/  .lua
                         /___/

                cross platform build system for Gideros plugins

                     "fitter, happier, more productive"

]]

docs.body =
[[
  Usage:

      From your root plugin directory (eg gideros/plugins/myplugin) run:

                          lua ../gmake.lua [options]


  Options:

      -help   | -h :    show help
      -create | -c :    create a skeleton plugin.def.lua file
]]

docs.help =
[[

  Help:

      1. Create a directory for your plugin (eg gideros/plugins/myplugin)

      2. In that directory, create the definition file with the extension .def.lua (eg plugin.def.lua)
         or run lua ../gmake.lua -c to create a skeleton file called plugin.def.lua

      3. Again from that directory (eg gideros/plugins/myplugin/) run:

                          lua ../gmake.lua

  General:

      Remember that once you have created your build files with gmake, you should add/remove files used
      in your project via the plugin.def.lua file and re-run gmake as necessary. This will keep files in
      sync across target build files.


  Warning:

      To be clear, CHANGES WILL BE LOST the next time you run gmake if you change a file in a make or
      project file without updating the .def.lua file. So use gmake either not at all, only once to set up
      your plugin or (recommended) as part of your dev process.
      .
]]


-- allow require to find def.lua files
package.path = "?/?.def.lua;?.def.lua;" .. package.path


-- write to file and output to console
local write = function(file, str)
  file:write(str .."\n")
  print(str)
end

--
local comments = {}
comments.header = [[##BEGIN##
##CONT##     autogenerated by gmake.lua
##END##

]]

local function writeHeader(file, _type)
  local str = comments.header
  _type = _type:upper()
  if     _type == "#" then
    str = str:gsub("##BEGIN##", "#")
    str = str:gsub("##CONT##", "#")
    str = str:gsub("##END##", "#")
  elseif _type == "XML" then
    str = str:gsub("##BEGIN##", "<!--")
    str = str:gsub("##CONT##", "  ")
    str = str:gsub("##END##", "-->")
  elseif _type == "C" or _type == "CXX" or _type == "H" or _type == "HPP" then
    str = str:gsub("##BEGIN##", "/*")
    str = str:gsub("##CONT##", "  ")
    str = str:gsub("##END##", "*/")
  else
    return
  end
  write(file, str)
end

-- for maintaining nice autogenerated indentation
local getPaddedString = function(str, target_length)
  if #str >= target_length then return str end
  return str .. string.rep(" ", target_length - #str)
end

-- get nice string from table, with table entries prefixed and suffixed and
-- separated by custom separator (eg space or comma)
local function getSepStringFromTable(t, separator, prefix, suffix)
  local s = ""
  prefix = prefix and prefix or ""
  suffix = suffix and suffix or ""
  for k, v in ipairs(t) do
    s = s .. prefix .. v .. suffix .. separator
  end
  return s
end

-- one shot file creation function
local function createFileWithContent(dir, file_name, content, header_type)
  local file = io.open(dir .. os.sep .. file_name, "w")
  if not file then return false end
  print("\n\nWriting file.. " .. dir .. os.sep .. file_name .. "\n")
  if header_type then writeHeader(file, header_type) end
  file:write(content)
  file:close()
  print(content)
  return true
end

--
local function appendToFile(dir, file_name, content)
  local file = io.open(dir .. os.sep .. file_name, "a")
  if not file then return false end
  file:write(content)
  file:close()
  return true
end

--
local function createDirectory(dir)
  print("Creating directory:", dir)
  local command = "mkdir " .. dir
  print(command)
  os.execute(command)
end

--
local function getPathFilenameAndExt(full_file_name_with_path_and_extension)
  local f = full_file_name_with_path_and_extension
  local path, name, ext
  path = f:match("^(.+/)")
  path = path and path or ""
  name = f:match("/?([%w_%-_]+)%.")
  name = name and name or ""
  ext = f:match("(%.[%.%w%-_]+)$")
  ext = ext and ext or ""
  return path, name, ext
end

--[=[
-- getPathFileAndExtension tests
do
  local files =
  {
    "../../blah.cpp",
    "blop.c",
    "../../common/../tricky-file_name.mm.lkl.lsp",
    "../sub/../file.txt"
  }

  local columns3 = "%-20s %-20s %-10s"
  print(string.format(columns3, "Path", "Name", "Ext"))
  print(string.rep("-=", 26))
  for k, v in ipairs(files) do
    print(string.format(columns3, getPathFileExtension(v)))
  end
end
--]=]


------------------------------------------------------------------------------
-- android
------------------------------------------------------------------------------

local android = {}
--
android.application_mk =
[[
APP_STL := c++_static
APP_CPPFLAGS += -fexceptions -frtti
APP_PLATFORM := android-9
##APP_ABI := all
APP_OPTIM := release]]

android.header = "LOCAL_PATH := $(call my-dir)\n"
android.clear_sep = "###\n\ninclude $(CLEAR_VARS)\n"
android.library_entry = android.clear_sep ..
[[
LOCAL_MODULE            := ##REPLACE##
LOCAL_SRC_FILES         := ../../../../Sdk/lib/android/$(TARGET_ARCH_ABI)/lib##REPLACE##.so

include $(PREBUILT_SHARED_LIBRARY)]]
android.includes = [[$(LOCAL_PATH)/../../../../Sdk/include \
                          $(LOCAL_PATH)/../../../../lua/src]]
android.source_prefix = "../common/"

--
android.createGpluginSection = function()
  local section = [==[
 <target name="AndroidStudio,APK">
    <template name="binaries" path="[[[sys.pluginDir]]]/bin/Android/libs" dest="app/src/main/jniLibs"/>
    <template name="Activity" path="">
        <replacelist wildcards="[[[project.namews]]]Activity.java">
            <append orig="//GIDEROS-STATIC-INIT//" by="		System.loadLibrary(&quot;##REPLACE##&quot;);"/>
        </replacelist>
    </template>
 </target>

 <target name="Android">
    <template name="binares" path="[[[sys.pluginDir]]]/bin/Android"/>
    <template name="Activity" path="">
        <replacelist wildcards="[[[project.namews]]]Activity.java">
            <append orig="//GIDEROS-STATIC-INIT//" by="		System.loadLibrary(&quot;##REPLACE##&quot;);"/>
        </replacelist>
    </template>
 </target>
]==]
  local lc_name = plugin.name.lower
  appendToFile(".", lc_name .. ".gplugin", section:gsub("##REPLACE##", lc_name) .. "\n")
end

--
android.createFiles = function(plugin)
  print("\n\nCreating Android files\n-----------------------")
  local file, file_name
  local jni_dir = "source" .. os.sep .. "jni"
  createDirectory(jni_dir)

  file_name = "Application.mk"
  print("Writing file: " .. file_name)
  file = io.open(jni_dir .. os.sep .. file_name, "w")
  writeHeader(file, "#")
  write(file, android.application_mk)
  file:close()

  file_name = "Android.mk"
  print("Writing file: " .. file_name)
  file = io.open(jni_dir .. os.sep .. file_name, "w")
  writeHeader(file, "#")
  write(file, android.header)
  for k, v in ipairs(plugin.libs) do
    local res = string.gsub(android.library_entry, "##REPLACE##", v) .. "\n"
    write(file, res)
    print(res)
  end
  write(file, android.clear_sep)
  write(file, "INCS:=")
  for k, v in ipairs(plugin.includes) do
    write(file, "INCS+=../" .. v)
  end
  write(file, "\n")
  local function getSection(str, sep) return getPaddedString(str, 23) .. sep end
  write(file, getSection("LOCAL_MODULE", ":= ") .. plugin.name.lower)
  write(file, getSection("LOCAL_ARM_MODE", ":= ") .. "arm")
  write(file, getSection("LOCAL_CFLAGS", ":= ") .. "-O2")
  write(file, getSection("LOCAL_C_INCLUDES", "+= ") .. "$(addprefix $(LOCAL_PATH),$(INCS))")
  if plugin.sources.cxx ~= nil then
    write(file, getSection("LOCAL_SRC_FILES", ":= ") ..
                            getSepStringFromTable(plugin.sources.cxx, " ", android.source_prefix, ".cpp"))
  else
    -- new version, source files have extensions
    write(file, getSection("LOCAL_SRC_FILES", ":= ") ..
                            getSepStringFromTable(plugin.sources.files, " ", android.source_prefix, ""))
  end

  write(file, getSection("LOCAL_LDLIBS", ":= ") .. "-ldl -llog")
  write(file, getSection("LOCAL_SHARED_LIBRARIES", ":= ") ..
                          getSepStringFromTable(plugin.libs, " "))
  write(file, "\ninclude $(BUILD_SHARED_LIBRARY)\n")
  file:close()

  android.createGpluginSection()
  return "Finished creating Android files."
end


------------------------------------------------------------------------------
-- shared win32/html5
------------------------------------------------------------------------------

-- win32 and emscripten/html5 make files are nearly identical
-- so create shared entries here
local commonMake = function(make_dir)
  file_name = "Makefile"
  print("Writing file: " .. file_name)
  local file = io.open(make_dir .. os.sep .. file_name, "w")
  writeHeader(file, "#")
  write(file, "Target=" .. plugin.name.lower .. "\n")

  if #plugin.sources.dirs > 0 then
    -- create vpath entries by compairing inc paths to sources
    for k, v in ipairs(plugin.sources.dirs) do
      write(file, "vpath %.cpp " .. v)
      write(file, "vpath %.c " .. v)
    end
    write(file, "")
  end

  -- these Makefiles include paths are 1 less deep than relative to common
  -- so strip one level back
  for k, v in ipairs(plugin.includes) do
    write(file, "INCS += " .. v:sub(4, #v))
  end

  -- get one line list of source files, name only
  local str = ""
  if plugin.sources.cxx ~= nil then
    for k, v in ipairs(plugin.sources.cxx) do

      local name = v:match("([%w^_%-]+)$")
      if v:match("^[.\\/]") == nil then
        name = "common/" .. name
      end

      str = str .. name .. " "
    end
  else
    -- new, sources have exts
    for k, v in ipairs(plugin.sources.files) do
      local path, name, ext = getPathFilenameAndExt(v)
      if path == "" then
        name = "common/" .. name
      end

      str = str .. name .. " "
    end
  end

  write(file, "SRCS += " .. str)

  return file
end


------------------------------------------------------------------------------
-- win32
------------------------------------------------------------------------------

local win32 = {}
--
win32.createGpluginSection = function()
  local section = [==[
 <target name="Win32">
    <template name="binaries" path="[[[sys.pluginDir]]]/bin/win32" dest="plugins"/>
 </target>
]==]
  local lc_name = plugin.name.lower
  appendToFile(".", lc_name .. ".gplugin", section:gsub("##REPLACE##", lc_name) .. "\n")
end

--
win32.createFiles = function(plugin)
  print("\n\nCreating win32 Makefile\n-----------------------")
  -- mkdir doesn't like /'s on Windows when os.execute'd
  local make_dir = "source" .. os.sep .. "win32"
  createDirectory(make_dir)

  local file = commonMake(make_dir)

  write(file, "\ninclude $(ROOT)/scripts/GidWin32Plugin.mk")
  file:close()

  win32.createGpluginSection()

  return "Finished creating win32 Makefile."
end


------------------------------------------------------------------------------
-- html5
------------------------------------------------------------------------------

local html5 = {}
--
html5.createGpluginSection = function()
  local section = [==[
 <target name="Html5">
    <lua>require("Tools/export_html5").export("###REPLACE###")</lua>
 </target>
]==]
  local lc_name = plugin.name.lower
  appendToFile(".", lc_name .. ".gplugin", section:gsub("##REPLACE##", lc_name) .. "\n")
end

--
html5.createFiles = function(plugin)
  print("\n\nCreating emscripten Makefile for html5\n-----------------------")
  -- mkdir doesn't like /'s on Windows when os.execute'd
  local make_dir = "source" .. os.sep .. "emscripten"
  createDirectory(make_dir)
  local file = commonMake(make_dir)
  write(file, "\ninclude ../../../../emscripten/Plugin.mk")
  file:close()

  html5.createGpluginSection()

  return "Finished creating emscripten Makefile for html5."
end


------------------------------------------------------------------------------
-- desktop: windows and macos
------------------------------------------------------------------------------

local desktop = {}
--
desktop.createFiles = function(plugin)
  print("\n\nCreating .pro file for Desktop\n-----------------------")
  -- mkdir doesn't like /'s on Windows when os.execute'd
  local dir = "source" .. os.sep .. "desktop"
  createDirectory(dir)

  local file_name = plugin.name.lower .. ".pro"
  print("Writing file: " .. file_name)
  local file = io.open(dir .. os.sep .. file_name, "w")
  writeHeader(file, "#")
  write(file, "QT -= core gui\n")
  write(file, "TARGET = " .. plugin.name.lower)
  write(file, "TEMPLATE = lib\n")

  for k, v in ipairs(plugin.includes) do
    write(file, "INCLUDEPATH += " .. v)
  end
  write(file, "")
  if plugin.sources.cxx ~= nil then
    for i = 1, #plugin.sources.cxx do
      local s = plugin.sources.cxx[i] .. ".cpp"
      write(file, "SOURCES += " .. "../common/" .. s)
    end
  else
    for i = 1, #plugin.sources.files do
      local s = plugin.sources.files[i]
      write(file, "SOURCES += " .. "../common/" .. s)
    end
  end

  write(file, "\nwin32{\n  debug_in_place{") --  for debugging from Qt Creator
  write(file, "    DESTDIR = ../../../../Build.Win/Plugins")
  local libs = getSepStringFromTable(plugin.libs, " ", "-l")
  write(file, [[    LIBS += -L"../../../../Build.Win" ]] .. libs)
  write(file, [[  } else {
    LIBS += -L"../../../../Sdk/lib/desktop" ]] .. libs)
  write(file, "  }\n} else {")
  write(file, [[  LIBS += -L"../../../../Sdk/lib/desktop" ]] .. libs)
  write(file, "}")

  write(file, "\nmacx {")
  local mac_lib = [[ QMAKE_POST_LINK += install_name_tool -change lib##REPLACE##.1.dylib "@executable_path/../Frameworks/lib##REPLACE##.1.dylib" $(TARGET);]]
  for k, v in ipairs(plugin.libs) do
    write(file, mac_lib:gsub("##REPLACE##", v))
  end

  write(file, "}")
  file:close()

  return "Finished creating .pro file for Desktop."
end


------------------------------------------------------------------------------
------------------------------------------------------------------------------

local winrt = {}
--
winrt.createEntries = function(_type, prefix, t, suffix)
  local entries = {}
  for k, v in ipairs(t) do
    local path, name, ext = getPathFilenameAndExt(v)
    -- if root, it's in common dir
    if path == "" then
      v = "../../../common/" .. v
    else
      v = "../../" .. v
    end
    v = v .. suffix
    entries[#entries + 1] = "    " .. _type .. "$(MSBuildThisFileDirectory)" .. prefix .. v
    entries[#entries + 1] = "\n"
  end
  entries[#entries] = nil
  return table.concat(entries)
end

--
winrt.createGpluginSection = function()
  -- TODO: finish winRT gplugin
  local section = [==[
 <target name="WinRT">
    <template name="sources" path="[[[sys.pluginDir]]]/bin/WinRT" />
    <template name="binaries" path="[[[sys.pluginDir]]]/source/common"  dest="giderosgame/giderosgame.Shared/Plugins" include="*.cpp;*.h;*.hpp" exclude="emscripten;win32;jni;iOS"/>
    <template name="project" path="">
        <replacelist wildcards="giderosgame.Shared.vcxitems">
            <append>
                <orig><![CDATA[<!--GIDEROS-PLUGIN-FILES-->]]></orig>
                <by><![CDATA[
##SOURCES##]]>
                </by>
            </append>
            <append>
                <orig><![CDATA[<!--GIDEROS-LINK-SHARED-->]]></orig>
                <by><![CDATA[
    <AdditionalDependencies>%(AdditionalDependencies);##NAME##.$(GidProjectType).lib</AdditionalDependencies>]]>
                </by>
            </append>
        </replacelist>
    </template>
 </target>
]==]
  local lc_name = plugin.name.lower

  section = section:gsub("##NAME##", lc_name)

  local entries = winrt.createEntries("  <ClCompile Include=\"", "", plugin.sources.files, [[">
        <PrecompiledHeader>NotUsing</PrecompiledHeader>
      </ClCompile>]])
  section = section:gsub("##SOURCES##", entries)
  appendToFile(".", lc_name .. ".gplugin", section .. "\n")
end

--
winrt.createFiles = function(plugin)
  print("\n\nCreating winRT solution files\n-----------------------")
  -- mkdir doesn't like /'s on Windows when os.execute'd
  local dir = "source" .. os.sep .. "winrt"
  createDirectory(dir)

  local plugin_sln = string.gsub([[
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Express 2013 for Windows
VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "##REPLACE##", "##REPLACE##", "{2BA44C23-8D6F-4743-9F2A-56D8B26DC02A}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "##REPLACE##.Shared", "##REPLACE##\##REPLACE##.Shared\##REPLACE##.Shared.vcxitems", "{B08EA2BF-55B6-4390-B5A9-ABB1602FCC15}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "##REPLACE##.Windows", "##REPLACE##\##REPLACE##.Windows\##REPLACE##.Windows.vcxproj", "{2040CCF5-6C45-482F-AAAF-16968C3F0834}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "##REPLACE##.WindowsPhone", "##REPLACE##\##REPLACE##.WindowsPhone\##REPLACE##.WindowsPhone.vcxproj", "{73FE7488-063C-4B66-AF11-1D6F33F9899C}"
EndProject
Global
	GlobalSection(SharedMSBuildProjectFiles) = preSolution
		##REPLACE##\##REPLACE##.Shared\##REPLACE##.Shared.vcxitems*{b08ea2bf-55b6-4390-b5a9-abb1602fcc15}*SharedItemsImports = 9
		##REPLACE##\##REPLACE##.Shared\##REPLACE##.Shared.vcxitems*{2040ccf5-6c45-482f-aaaf-16968c3f0834}*SharedItemsImports = 4
		##REPLACE##\##REPLACE##.Shared\##REPLACE##.Shared.vcxitems*{73fe7488-063c-4b66-af11-1d6f33f9899c}*SharedItemsImports = 4
	EndGlobalSection
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|ARM = Debug|ARM
		Debug|Win32 = Debug|Win32
		Debug|x64 = Debug|x64
		Release|ARM = Release|ARM
		Release|Win32 = Release|Win32
		Release|x64 = Release|x64
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{2040CCF5-6C45-482F-AAAF-16968C3F0834}.Debug|ARM.ActiveCfg = Debug|ARM
		{2040CCF5-6C45-482F-AAAF-16968C3F0834}.Debug|ARM.Build.0 = Debug|ARM
		{2040CCF5-6C45-482F-AAAF-16968C3F0834}.Debug|Win32.ActiveCfg = Debug|Win32
		{2040CCF5-6C45-482F-AAAF-16968C3F0834}.Debug|Win32.Build.0 = Debug|Win32
		{2040CCF5-6C45-482F-AAAF-16968C3F0834}.Debug|x64.ActiveCfg = Debug|x64
		{2040CCF5-6C45-482F-AAAF-16968C3F0834}.Debug|x64.Build.0 = Debug|x64
		{2040CCF5-6C45-482F-AAAF-16968C3F0834}.Release|ARM.ActiveCfg = Release|ARM
		{2040CCF5-6C45-482F-AAAF-16968C3F0834}.Release|ARM.Build.0 = Release|ARM
		{2040CCF5-6C45-482F-AAAF-16968C3F0834}.Release|Win32.ActiveCfg = Release|Win32
		{2040CCF5-6C45-482F-AAAF-16968C3F0834}.Release|Win32.Build.0 = Release|Win32
		{2040CCF5-6C45-482F-AAAF-16968C3F0834}.Release|x64.ActiveCfg = Release|x64
		{2040CCF5-6C45-482F-AAAF-16968C3F0834}.Release|x64.Build.0 = Release|x64
		{73FE7488-063C-4B66-AF11-1D6F33F9899C}.Debug|ARM.ActiveCfg = Debug|ARM
		{73FE7488-063C-4B66-AF11-1D6F33F9899C}.Debug|ARM.Build.0 = Debug|ARM
		{73FE7488-063C-4B66-AF11-1D6F33F9899C}.Debug|Win32.ActiveCfg = Debug|Win32
		{73FE7488-063C-4B66-AF11-1D6F33F9899C}.Debug|Win32.Build.0 = Debug|Win32
		{73FE7488-063C-4B66-AF11-1D6F33F9899C}.Debug|x64.ActiveCfg = Debug|Win32
		{73FE7488-063C-4B66-AF11-1D6F33F9899C}.Release|ARM.ActiveCfg = Release|ARM
		{73FE7488-063C-4B66-AF11-1D6F33F9899C}.Release|ARM.Build.0 = Release|ARM
		{73FE7488-063C-4B66-AF11-1D6F33F9899C}.Release|Win32.ActiveCfg = Release|Win32
		{73FE7488-063C-4B66-AF11-1D6F33F9899C}.Release|Win32.Build.0 = Release|Win32
		{73FE7488-063C-4B66-AF11-1D6F33F9899C}.Release|x64.ActiveCfg = Release|Win32
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
	GlobalSection(NestedProjects) = preSolution
		{B08EA2BF-55B6-4390-B5A9-ABB1602FCC15} = {2BA44C23-8D6F-4743-9F2A-56D8B26DC02A}
		{2040CCF5-6C45-482F-AAAF-16968C3F0834} = {2BA44C23-8D6F-4743-9F2A-56D8B26DC02A}
		{73FE7488-063C-4B66-AF11-1D6F33F9899C} = {2BA44C23-8D6F-4743-9F2A-56D8B26DC02A}
	EndGlobalSection
EndGlobal
]], "##REPLACE##", plugin.name.lower)

  local file_name = plugin.name.lower .. ".sln"
  print("Writing file: " .. file_name)
  local file = io.open(dir .. os.sep .. file_name, "w")
  writeHeader(file, "#")
  write(file, plugin_sln)
  file:close()

  local source_dir = dir .. os.sep .. plugin.name.lower -- "source"
  print("Creating directory:", source_dir)
  command = "mkdir " .. source_dir
  print(command)
  os.execute(command)

  --
  -- plugin.Shared directory
  local shared_dir = source_dir .. os.sep .. plugin.name.lower .. ".Shared"
  print("Creating directory:", shared_dir)
  command = "mkdir " .. shared_dir
  print(command)
  os.execute(command)
  createFileWithContent(shared_dir, "pch.cpp", [[#include "pch.h"]], "C")

  createFileWithContent(shared_dir, "pch.h", [[
#pragma once

#include "targetver.h"

#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif

#include <windows.h>
]])
  --
  createFileWithContent(shared_dir, "targetver.h", [[#pragma once

// Si vous incluez SDKDDKVer.h, cela définit la dernière plateforme Windows disponible.

// Si vous souhaitez générer votre application pour une plateforme Windows précédente, incluez WinSDKVer.h et
// définissez la macro _WIN32_WINNT à la plateforme que vous souhaitez prendre en charge avant d'inclure SDKDDKVer.h.

#include <SDKDDKVer.h>
]])
  local content = "#include \"pch.h\"\n#include \"##REPLACE##.h\"\n"
  createFileWithContent(shared_dir, plugin.name.lower .. ".cpp", content:gsub("##REPLACE##", plugin.name.lower), "CXX")
  createFileWithContent(shared_dir, plugin.name.lower .. ".h", "#pragma once\n", "CXX")

  -- plugin.Shared.vcxitems
  content =
[==[
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup Label="Globals">
    <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
    <HasSharedItems>true</HasSharedItems>
    <ItemsProjectGuid>{b08ea2bf-55b6-4390-b5a9-abb1602fcc15}</ItemsProjectGuid>
    <ItemsRootNamespace>##NAME##</ItemsRootNamespace>
    <ItemsProjectName>##NAME##.Shared</ItemsProjectName>
    <CodeSharingProject>248F659F-DAC5-46E8-AC09-60EC9FC95053</CodeSharingProject>
  </PropertyGroup>
  <ItemDefinitionGroup>
    <ClCompile>
      <AdditionalIncludeDirectories>
        %(AdditionalIncludeDirectories);
        $(MSBuildThisFileDirectory);
##INCLUDES##
      </AdditionalIncludeDirectories>
    </ClCompile>
  </ItemDefinitionGroup>
  <ItemGroup>
##HEADERS##
    <ClInclude Include="$(MSBuildThisFileDirectory)targetver.h" />
    <ClInclude Include="$(MSBuildThisFileDirectory)pch.h" />
  </ItemGroup>
  <ItemGroup>
##SOURCES##
    <ClCompile Include="$(MSBuildThisFileDirectory)pch.cpp">
      <PrecompiledHeader>Create</PrecompiledHeader>
    </ClCompile>
  </ItemGroup>
  <ItemGroup>
    <ProjectCapability Include="SourceItemsFromImports" />
  </ItemGroup>
</Project>
]==]
  content = content:gsub("##NAME##", plugin.name.lower)

  content = content:gsub("##INCLUDES##", winrt.createEntries("    ", "", plugin.includes, ";"))
  content = content:gsub("##HEADERS##", winrt.createEntries("<ClInclude Include=\"", "", plugin.headers, "\" />"))
  content = content:gsub("##SOURCES##", winrt.createEntries("<ClCompile Include=\"", "", plugin.sources.files, "\" />"))

  createFileWithContent(shared_dir, plugin.name.lower .. ".Shared.vcxitems", content, "XML")

  content =
[==[
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup>
    <ClInclude Include="$(MSBuildThisFileDirectory)targetver.h" />
    <ClInclude Include="$(MSBuildThisFileDirectory)pch.h" />
##HEADERS##
  </ItemGroup>
  <ItemGroup>
    <ClCompile Include="$(MSBuildThisFileDirectory)pch.cpp">
      <PrecompiledHeader>Create</PrecompiledHeader>
    </ClCompile>
##SOURCES##
  </ItemGroup>
</Project>
]==]

  content = content:gsub("##HEADERS##", winrt.createEntries("<ClInclude Include=\"", "", plugin.headers, "\" />"))
  content = content:gsub("##SOURCES##", winrt.createEntries("<ClCompile Include=\"", "", plugin.sources.files, "\" />"))
  createFileWithContent(shared_dir, plugin.name.lower .. ".Shared.vcxitems.filters", content .. "\n")

  --
  -- plugin.Windows directory
  local windows_dir = source_dir .. os.sep .. plugin.name.lower .. ".Windows"
  print("Creating directory:", windows_dir)
  command = "mkdir " .. windows_dir
  print(command)
  os.execute(command)

  content =
[==[
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup Label="ProjectConfigurations">
    <ProjectConfiguration Include="Debug|ARM">
      <Configuration>Debug</Configuration>
      <Platform>ARM</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Debug|Win32">
      <Configuration>Debug</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Debug|x64">
      <Configuration>Debug</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|ARM">
      <Configuration>Release</Configuration>
      <Platform>ARM</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|Win32">
      <Configuration>Release</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|x64">
      <Configuration>Release</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
  </ItemGroup>
  <PropertyGroup Label="Globals">
    <ProjectGuid>{2040ccf5-6c45-482f-aaaf-16968c3f0834}</ProjectGuid>
    <RootNamespace>##NAME##</RootNamespace>
    <DefaultLanguage>fr-FR</DefaultLanguage>
    <MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>
    <AppContainerApplication>true</AppContainerApplication>
    <ApplicationType>Windows Store</ApplicationType>
    <ApplicationTypeRevision>8.1</ApplicationTypeRevision>
    <ConvergedProjectType>CodeSharingStaticLibrary</ConvergedProjectType>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
    <ConfigurationType>StaticLibrary</ConfigurationType>
    <UseDebugLibraries>true</UseDebugLibraries>
    <PlatformToolset>v120</PlatformToolset>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">
    <ConfigurationType>StaticLibrary</ConfigurationType>
    <UseDebugLibraries>true</UseDebugLibraries>
    <PlatformToolset>v120</PlatformToolset>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
    <ConfigurationType>StaticLibrary</ConfigurationType>
    <UseDebugLibraries>true</UseDebugLibraries>
    <PlatformToolset>v120</PlatformToolset>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
    <ConfigurationType>StaticLibrary</ConfigurationType>
    <UseDebugLibraries>false</UseDebugLibraries>
    <WholeProgramOptimization>true</WholeProgramOptimization>
    <PlatformToolset>v120</PlatformToolset>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration">
    <ConfigurationType>StaticLibrary</ConfigurationType>
    <UseDebugLibraries>false</UseDebugLibraries>
    <WholeProgramOptimization>true</WholeProgramOptimization>
    <PlatformToolset>v120</PlatformToolset>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
    <ConfigurationType>StaticLibrary</ConfigurationType>
    <UseDebugLibraries>false</UseDebugLibraries>
    <WholeProgramOptimization>true</WholeProgramOptimization>
    <PlatformToolset>v120</PlatformToolset>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
  <Import Project="..\##NAME##.Shared\##NAME##.Shared.vcxitems" Label="Shared" />
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <PropertyGroup Label="UserMacros" />
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <GenerateManifest>false</GenerateManifest>
    <OutDir>$(ProjectDir)$(Configuration)\$(ProjectName)\</OutDir>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <GenerateManifest>false</GenerateManifest>
    <OutDir>$(ProjectDir)$(Configuration)\$(ProjectName)\</OutDir>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
    <GenerateManifest>false</GenerateManifest>
    <OutDir>$(ProjectDir)$(Configuration)\$(ProjectName)\</OutDir>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
    <GenerateManifest>false</GenerateManifest>
    <OutDir>$(ProjectDir)$(Configuration)\$(ProjectName)\</OutDir>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <GenerateManifest>false</GenerateManifest>
    <OutDir>$(ProjectDir)$(Configuration)\$(ProjectName)\</OutDir>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <GenerateManifest>false</GenerateManifest>
    <OutDir>$(ProjectDir)$(Configuration)\$(ProjectName)\</OutDir>
  </PropertyGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <ClCompile>
      <PrecompiledHeader>NotUsing</PrecompiledHeader>
      <CompileAsWinRT>false</CompileAsWinRT>
      <SDLCheck>true</SDLCheck>
      <AdditionalIncludeDirectories>$(ProjectDir)..\..\..\..\..\..\Sdk\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
      <PreprocessorDefinitions>WINSTORE;_CRT_SECURE_NO_WARNINGS;CUSTOM_ALLOC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>
      <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
      <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <ClCompile>
      <PrecompiledHeader>NotUsing</PrecompiledHeader>
      <CompileAsWinRT>false</CompileAsWinRT>
      <SDLCheck>true</SDLCheck>
      <AdditionalIncludeDirectories>$(ProjectDir)..\..\..\..\..\..\Sdk\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
      <PreprocessorDefinitions>WINSTORE;_CRT_SECURE_NO_WARNINGS;CUSTOM_ALLOC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>
      <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
      <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|arm'">
    <ClCompile>
      <PrecompiledHeader>NotUsing</PrecompiledHeader>
      <CompileAsWinRT>false</CompileAsWinRT>
      <SDLCheck>true</SDLCheck>
      <AdditionalIncludeDirectories>$(ProjectDir)..\..\..\..\..\..\Sdk\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
      <PreprocessorDefinitions>WINSTORE;_CRT_SECURE_NO_WARNINGS;CUSTOM_ALLOC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>
      <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
      <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|arm'">
    <ClCompile>
      <PrecompiledHeader>NotUsing</PrecompiledHeader>
      <CompileAsWinRT>false</CompileAsWinRT>
      <SDLCheck>true</SDLCheck>
      <AdditionalIncludeDirectories>$(ProjectDir)..\..\..\..\..\..\Sdk\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
      <PreprocessorDefinitions>WINSTORE;_CRT_SECURE_NO_WARNINGS;CUSTOM_ALLOC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>
      <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
      <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <ClCompile>
      <PrecompiledHeader>NotUsing</PrecompiledHeader>
      <CompileAsWinRT>false</CompileAsWinRT>
      <SDLCheck>true</SDLCheck>
      <AdditionalIncludeDirectories>$(ProjectDir)..\..\..\..\..\..\Sdk\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
      <PreprocessorDefinitions>WINSTORE;_CRT_SECURE_NO_WARNINGS;CUSTOM_ALLOC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>
      <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
      <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <ClCompile>
      <PrecompiledHeader>NotUsing</PrecompiledHeader>
      <CompileAsWinRT>false</CompileAsWinRT>
      <SDLCheck>true</SDLCheck>
      <AdditionalIncludeDirectories>$(ProjectDir)..\..\..\..\..\..\Sdk\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
      <PreprocessorDefinitions>WINSTORE;_CRT_SECURE_NO_WARNINGS;CUSTOM_ALLOC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>
      <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
      <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
    </Link>
  </ItemDefinitionGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
  <ImportGroup Label="ExtensionTargets">
  </ImportGroup>
</Project>
]==]
  content = content:gsub("##NAME##", plugin.name.lower)
  createFileWithContent(windows_dir, plugin.name.lower .. ".Windows.vcxproj", content .. "\n")

  content =
[==[
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
	<ItemGroup>
	</ItemGroup>
</Project>
]==]
  createFileWithContent(windows_dir, plugin.name.lower .. ".Windows.vcxproj.filters", content .. "\n")


  --
  -- plugin.WindowsPhone directory
  local windowsphone_dir = source_dir .. os.sep .. plugin.name.lower .. ".WindowsPhone"
  print("Creating directory:", windowsphone_dir)
  command = "mkdir " .. windowsphone_dir
  print(command)
  os.execute(command)

  content =
[==[
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup Label="ProjectConfigurations">
    <ProjectConfiguration Include="Debug|ARM">
      <Configuration>Debug</Configuration>
      <Platform>ARM</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Debug|Win32">
      <Configuration>Debug</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|ARM">
      <Configuration>Release</Configuration>
      <Platform>ARM</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|Win32">
      <Configuration>Release</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
  </ItemGroup>
  <PropertyGroup Label="Globals">
    <ProjectGuid>{73fe7488-063c-4b66-af11-1d6f33f9899c}</ProjectGuid>
    <RootNamespace>##NAME##</RootNamespace>
    <DefaultLanguage>fr-FR</DefaultLanguage>
    <MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>
    <AppContainerApplication>true</AppContainerApplication>
    <ApplicationType>Windows Phone</ApplicationType>
    <ApplicationTypeRevision>8.1</ApplicationTypeRevision>
    <ConvergedProjectType>CodeSharingStaticLibrary</ConvergedProjectType>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
    <ConfigurationType>StaticLibrary</ConfigurationType>
    <UseDebugLibraries>true</UseDebugLibraries>
    <PlatformToolset>v120_wp81</PlatformToolset>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">
    <ConfigurationType>StaticLibrary</ConfigurationType>
    <UseDebugLibraries>true</UseDebugLibraries>
    <PlatformToolset>v120_wp81</PlatformToolset>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
    <ConfigurationType>StaticLibrary</ConfigurationType>
    <UseDebugLibraries>false</UseDebugLibraries>
    <WholeProgramOptimization>true</WholeProgramOptimization>
    <PlatformToolset>v120_wp81</PlatformToolset>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration">
    <ConfigurationType>StaticLibrary</ConfigurationType>
    <UseDebugLibraries>false</UseDebugLibraries>
    <WholeProgramOptimization>true</WholeProgramOptimization>
    <PlatformToolset>v120_wp81</PlatformToolset>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
  <Import Project="..\##NAME##.Shared\##NAME##.Shared.vcxitems" Label="Shared" />
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <PropertyGroup Label="UserMacros" />
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <GenerateManifest>false</GenerateManifest>
    <OutDir>$(ProjectDir)$(Platform)\$(Configuration)\$(ProjectName)\</OutDir>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <GenerateManifest>false</GenerateManifest>
    <OutDir>$(ProjectDir)$(Platform)\$(Configuration)\$(ProjectName)\</OutDir>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
    <GenerateManifest>false</GenerateManifest>
    <OutDir>$(ProjectDir)$(Platform)\$(Configuration)\$(ProjectName)\</OutDir>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
    <GenerateManifest>false</GenerateManifest>
    <OutDir>$(ProjectDir)$(Platform)\$(Configuration)\$(ProjectName)\</OutDir>
  </PropertyGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <ClCompile>
      <PrecompiledHeader>NotUsing</PrecompiledHeader>
      <CompileAsWinRT>false</CompileAsWinRT>
      <SDLCheck>true</SDLCheck>
      <AdditionalIncludeDirectories>$(ProjectDir)..\..\..\..\..\..\..\Sdk\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
      <PreprocessorDefinitions>WINSTORE;_CRT_SECURE_NO_WARNINGS;CUSTOM_ALLOC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>
      <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
      <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <ClCompile>
      <PrecompiledHeader>NotUsing</PrecompiledHeader>
      <CompileAsWinRT>false</CompileAsWinRT>
      <SDLCheck>true</SDLCheck>
      <AdditionalIncludeDirectories>$(ProjectDir)..\..\..\..\..\..\..\Sdk\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
      <PreprocessorDefinitions>WINSTORE;_CRT_SECURE_NO_WARNINGS;CUSTOM_ALLOC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>
      <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
      <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|arm'">
    <ClCompile>
      <PrecompiledHeader>NotUsing</PrecompiledHeader>
      <CompileAsWinRT>false</CompileAsWinRT>
      <SDLCheck>true</SDLCheck>
      <AdditionalIncludeDirectories>$(ProjectDir)..\..\..\..\..\..\..\Sdk\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
      <PreprocessorDefinitions>WINSTORE;_CRT_SECURE_NO_WARNINGS;CUSTOM_ALLOC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>
      <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
      <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|arm'">
    <ClCompile>
      <PrecompiledHeader>NotUsing</PrecompiledHeader>
      <CompileAsWinRT>false</CompileAsWinRT>
      <SDLCheck>true</SDLCheck>
      <AdditionalIncludeDirectories>$(ProjectDir)..\..\..\..\..\..\..\Sdk\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
      <PreprocessorDefinitions>WINSTORE;_CRT_SECURE_NO_WARNINGS;CUSTOM_ALLOC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>
      <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
      <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
    </Link>
  </ItemDefinitionGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
  <ImportGroup Label="ExtensionTargets">
  </ImportGroup>
</Project>
]==]
  content = content:gsub("##NAME##", plugin.name.lower)
  createFileWithContent(windowsphone_dir, plugin.name.lower .. ".WindowsPhone.vcxproj", content .. "\n")

  content =
[==[
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
	<ItemGroup>
	</ItemGroup>
</Project>
]==]
  createFileWithContent(windowsphone_dir, plugin.name.lower .. ".WindowsPhone.vcxproj.filters", content .. "\n")

  winrt.createGpluginSection()
  return "Finished creating winrt solution files."
end


------------------------------------------------------------------------------
-- ios
------------------------------------------------------------------------------

ios = {}
--
ios.createFiles = function()
  print("\n\nCreating iOS solution files\n-----------------------")
  -- mkdir doesn't like /'s on Windows when os.execute'd
  local dir = "source" .. os.sep .. "ios"
  createDirectory(dir)

  local function printTable(t)
    for k, v in pairs(t) do
      print(k, v)
    end
  end

  package.path = "../../ui/Tools/?.lua;" .. package.path
  Export = {} -- avoid error on import
  Export.registerPreFinish = function() end -- ""
  require("export_init")
  require("export_ios")

  print(iOSProject.addGroup("public_name_sources_group", "../../common", "SourceBuild", "SourceBuild"))
  print(iOSProject.addGroup("source3", "source4", plugin.name.lower .."1", plugin.name.lower .."1"))


  iOSProject.addSources(plugin.sources.files, plugin.name.lower .. "1", "chocolate")

  printTable(iOSProject.insertPoints["Refs"].data)

  -- TODO: create PBXFileReferences and store in table with name of file
  content =
  [==[
// !$*UTF8*$!
{
	archiveVersion = 1;
	classes = {
	};
	objectVersion = 46;
	objects = {

/* Begin PBXBuildFile section */
		5F9FAAA115DD87E20039718F /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5F9FAAA015DD87E20039718F /* Foundation.framework */; };

		EB0781B81FA233C100320DD5 /* spinebinder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EB0781AF1FA233BD00320DD5 /* spinebinder.cpp */; };
		EB0781C11FA233ED00320DD5 /* binder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EB0781C01FA233EC00320DD5 /* binder.cpp */; };
    EB172CEA213683140029BCC5 /* Json.h in Headers */ = {isa = PBXBuildFile; fileRef = EB172CC12136830F0029BCC5 /* Json.h */; };

/* End PBXBuildFile section */

/* Begin PBXFileReference section */
		5F9FAA9D15DD87E20039718F /* lib##NAME##.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = lib##NAME##.a; sourceTree = BUILT_PRODUCTS_DIR; };
		5F9FAAA015DD87E20039718F /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };

		EB0781AF1FA233BD00320DD5 /* spinebinder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = spinebinder.cpp; path = common/spinebinder.cpp; sourceTree = "<group>"; };
		EB0781C01FA233EC00320DD5 /* binder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = binder.cpp; path = ../../../luabinding/binder.cpp; sourceTree = "<group>"; };

/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
		5F9FAA9A15DD87E10039718F /* Frameworks */ = {
			isa = PBXFrameworksBuildPhase;
			buildActionMask = 2147483647;
			files = (
				5F9FAAA115DD87E20039718F /* Foundation.framework in Frameworks */,
			);
			runOnlyForDeploymentPostprocessing = 0;
		};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
		5F9FAA9215DD87E10039718F = {
			isa = PBXGroup;
			children = (
				EB172CAA21366F310029BCC5 /* ##NAME## */,
				EB0781C01FA233EC00320DD5 /* binder.cpp */,
				EB0781AF1FA233BD00320DD5 /* spinebinder.cpp */,
				5F9FAA9F15DD87E20039718F /* Frameworks */,
				5F9FAA9E15DD87E20039718F /* Products */,
			);
			sourceTree = "<group>";
		};
		5F9FAA9E15DD87E20039718F /* Products */ = {
			isa = PBXGroup;
			children = (
				5F9FAA9D15DD87E20039718F /* lib##NAME##.a */,
			);
			name = Products;
			sourceTree = "<group>";
		};
		5F9FAA9F15DD87E20039718F /* Frameworks */ = {
			isa = PBXGroup;
			children = (
				5F9FAAA015DD87E20039718F /* Foundation.framework */,
			);
			name = Frameworks;
			sourceTree = "<group>";
		};
		EB172CAA21366F310029BCC5 /* ##NAME## */ = {
			isa = PBXGroup;
			children = (
				EB172CCA213683110029BCC5 /* Animation.c */,
				EB172CB62136830D0029BCC5 /* AnimationState.c */,
				EB172CBF2136830F0029BCC5 /* AnimationStateData.c */,
				EB172CAF2136830C0029BCC5 /* Array.c */,
				EB172CCE213683120029BCC5 /* Atlas.c */,
				EB172CC5213683100029BCC5 /* AtlasAttachmentLoader.c */,
				EB172CAC2136830B0029BCC5 /* Attachment.c */,
				EB172CC3213683100029BCC5 /* AttachmentLoader.c */,
				EB172CB32136830D0029BCC5 /* Bone.c */,
				EB172CBB2136830E0029BCC5 /* BoneData.c */,
				EB172CD2213683140029BCC5 /* BoundingBoxAttachment.c */,
				EB172CB72136830D0029BCC5 /* ClippingAttachment.c */,
				EB172CBA2136830E0029BCC5 /* Color.c */,
				EB172CCD213683120029BCC5 /* Event.c */,
				EB172CCF213683130029BCC5 /* EventData.c */,
				EB172CAB2136830B0029BCC5 /* extension.c */,
				EB172CC9213683110029BCC5 /* IkConstraint.c */,
				EB172CB02136830C0029BCC5 /* IkConstraintData.c */,
				EB172CC22136830F0029BCC5 /* Json.c */,
				EB172CC12136830F0029BCC5 /* Json.h */,
				EB172CC6213683100029BCC5 /* kvec.h */,
				EB172CD0213683130029BCC5 /* MeshAttachment.c */,
				EB172CD3213683140029BCC5 /* PathAttachment.c */,
				EB172CB82136830E0029BCC5 /* PathConstraint.c */,
				EB172CB42136830D0029BCC5 /* PathConstraintData.c */,
				EB172CBC2136830E0029BCC5 /* PointAttachment.c */,
				EB172CAD2136830B0029BCC5 /* RegionAttachment.c */,
				EB172CB52136830D0029BCC5 /* Skeleton.c */,
				EB172CC02136830F0029BCC5 /* SkeletonBinary.c */,
				EB172CCB213683110029BCC5 /* SkeletonBounds.c */,
				EB172CC4213683100029BCC5 /* SkeletonClipping.c */,
				EB172CBD2136830E0029BCC5 /* SkeletonData.c */,
				EB172CC8213683110029BCC5 /* SkeletonJson.c */,
				EB172CCC213683120029BCC5 /* Skin.c */,
				EB172CB22136830D0029BCC5 /* Slot.c */,
				EB172CBE2136830F0029BCC5 /* SlotData.c */,
				EB172CAE2136830C0029BCC5 /* TransformConstraint.c */,
				EB172CD1213683130029BCC5 /* TransformConstraintData.c */,
				EB172CC7213683100029BCC5 /* Triangulator.c */,
				EB172CB92136830E0029BCC5 /* VertexAttachment.c */,
				EB172CB12136830C0029BCC5 /* VertexEffect.c */,
			);
			name = ##NAME##;
			sourceTree = "<group>";
		};
/* End PBXGroup section */

/* Begin PBXHeadersBuildPhase section */
		5F9FAA9B15DD87E10039718F /* Headers */ = {
			isa = PBXHeadersBuildPhase;
			buildActionMask = 2147483647;
			files = (
				EB172CEA213683140029BCC5 /* Json.h in Headers */,
				EB172CEF213683140029BCC5 /* kvec.h in Headers */,
			);
			runOnlyForDeploymentPostprocessing = 0;
		};
/* End PBXHeadersBuildPhase section */

/* Begin PBXNativeTarget section */
		5F9FAA9C15DD87E10039718F /* ##NAME## */ = {
			isa = PBXNativeTarget;
			buildConfigurationList = 5F9FAAAA15DD87E20039718F /* Build configuration list for PBXNativeTarget "##NAME##" */;
			buildPhases = (
				5F9FAA9915DD87E10039718F /* Sources */,
				5F9FAA9A15DD87E10039718F /* Frameworks */,
				5F9FAA9B15DD87E10039718F /* Headers */,
			);
			buildRules = (
			);
			dependencies = (
			);
			name = ##NAME##;
			productName = ##NAME;
			productReference = 5F9FAA9D15DD87E20039718F /* lib##NAME##.a */;
			productType = "com.apple.product-type.library.static";
		};
/* End PBXNativeTarget section */

/* Begin PBXProject section */
		5F9FAA9415DD87E10039718F /* Project object */ = {
			isa = PBXProject;
			attributes = {
				LastUpgradeCheck = 0420;
				ORGANIZATIONNAME = "Gideros Mobile";
			};
			buildConfigurationList = 5F9FAA9715DD87E10039718F /* Build configuration list for PBXProject "##NAME##" */;
			compatibilityVersion = "Xcode 3.2";
			developmentRegion = English;
			hasScannedForEncodings = 0;
			knownRegions = (
				en,
			);
			mainGroup = 5F9FAA9215DD87E10039718F;
			productRefGroup = 5F9FAA9E15DD87E20039718F /* Products */;
			projectDirPath = "";
			projectRoot = "";
			targets = (
				5F9FAA9C15DD87E10039718F /* ##NAME## */,
			);
		};
/* End PBXProject section */

/* Begin PBXSourcesBuildPhase section */
		5F9FAA9915DD87E10039718F /* Sources */ = {
			isa = PBXSourcesBuildPhase;
			buildActionMask = 2147483647;
			files = (
				EB172CF8213683140029BCC5 /* EventData.c in Sources */,
				EB172CD8213683140029BCC5 /* Array.c in Sources */,
				EB172CE7213683140029BCC5 /* SlotData.c in Sources */,
				EB172CE5213683140029BCC5 /* PointAttachment.c in Sources */,
				EB172CE9213683140029BCC5 /* SkeletonBinary.c in Sources */,

			);
			runOnlyForDeploymentPostprocessing = 0;
		};
/* End PBXSourcesBuildPhase section */

/* Begin XCBuildConfiguration section */
		5F9FAAA815DD87E20039718F /* Debug */ = {
			isa = XCBuildConfiguration;
			buildSettings = {
				ALWAYS_SEARCH_USER_PATHS = NO;
				ARCHS = "$(ARCHS_STANDARD)";
				CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
				CLANG_CXX_LIBRARY = "libc++";
				CLANG_WARN_CONSTANT_CONVERSION = YES;
				CLANG_WARN_EMPTY_BODY = YES;
				CLANG_WARN_ENUM_CONVERSION = YES;
				CLANG_WARN_INT_CONVERSION = YES;
				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
				COPY_PHASE_STRIP = NO;
				GCC_C_LANGUAGE_STANDARD = gnu99;
				GCC_DYNAMIC_NO_PIC = NO;
				GCC_OPTIMIZATION_LEVEL = 0;
				GCC_PREPROCESSOR_DEFINITIONS = (
					"DEBUG=1",
					"$(inherited)",
				);
				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
				GCC_WARN_ABOUT_RETURN_TYPE = YES;
				GCC_WARN_UNINITIALIZED_AUTOS = YES;
				GCC_WARN_UNUSED_VARIABLE = YES;
				HEADER_SEARCH_PATHS = (
##INCLUDES##
				);
				IPHONEOS_DEPLOYMENT_TARGET = 5.0;
				ONLY_ACTIVE_ARCH = NO;
				SDKROOT = iphoneos;
			};
			name = Debug;
		};
		5F9FAAA915DD87E20039718F /* Release */ = {
			isa = XCBuildConfiguration;
			buildSettings = {
				ALWAYS_SEARCH_USER_PATHS = NO;
				ARCHS = "$(ARCHS_STANDARD)";
				CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
				CLANG_CXX_LIBRARY = "libc++";
				CLANG_WARN_CONSTANT_CONVERSION = YES;
				CLANG_WARN_EMPTY_BODY = YES;
				CLANG_WARN_ENUM_CONVERSION = YES;
				CLANG_WARN_INT_CONVERSION = YES;
				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
				COPY_PHASE_STRIP = YES;
				GCC_C_LANGUAGE_STANDARD = gnu99;
				GCC_WARN_ABOUT_RETURN_TYPE = YES;
				GCC_WARN_UNINITIALIZED_AUTOS = YES;
				GCC_WARN_UNUSED_VARIABLE = YES;
				HEADER_SEARCH_PATHS = (
##INCLUDES##
				);
				IPHONEOS_DEPLOYMENT_TARGET = 5.0;
				ONLY_ACTIVE_ARCH = NO;
				SDKROOT = iphoneos;
				VALIDATE_PRODUCT = YES;
			};
			name = Release;
		};
		5F9FAAAB15DD87E20039718F /* Debug */ = {
			isa = XCBuildConfiguration;
			buildSettings = {
				DSTROOT = /tmp/ogg.dst;
				GCC_PRECOMPILE_PREFIX_HEADER = YES;
				GCC_PREFIX_HEADER = "";
				HEADER_SEARCH_PATHS = (
##INCLUDES##
				);
				OTHER_LDFLAGS = "";
				PRODUCT_NAME = "$(TARGET_NAME)";
				SKIP_INSTALL = YES;
			};
			name = Debug;
		};
		5F9FAAAC15DD87E20039718F /* Release */ = {
			isa = XCBuildConfiguration;
			buildSettings = {
				DSTROOT = /tmp/ogg.dst;
				GCC_PRECOMPILE_PREFIX_HEADER = YES;
				GCC_PREFIX_HEADER = "";
				HEADER_SEARCH_PATHS = (
##INCLUDES##
				);
				OTHER_LDFLAGS = "";
				PRODUCT_NAME = "$(TARGET_NAME)";
				SKIP_INSTALL = YES;
			};
			name = Release;
		};
/* End XCBuildConfiguration section */

/* Begin XCConfigurationList section */
		5F9FAA9715DD87E10039718F /* Build configuration list for PBXProject "##NAME##" */ = {
			isa = XCConfigurationList;
			buildConfigurations = (
				5F9FAAA815DD87E20039718F /* Debug */,
				5F9FAAA915DD87E20039718F /* Release */,
			);
			defaultConfigurationIsVisible = 0;
			defaultConfigurationName = Release;
		};
		5F9FAAAA15DD87E20039718F /* Build configuration list for PBXNativeTarget "##NAME##" */ = {
			isa = XCConfigurationList;
			buildConfigurations = (
				5F9FAAAB15DD87E20039718F /* Debug */,
				5F9FAAAC15DD87E20039718F /* Release */,
			);
			defaultConfigurationIsVisible = 0;
			defaultConfigurationName = Release;
		};
/* End XCConfigurationList section */
	};
	rootObject = 5F9FAA9415DD87E10039718F /* Project object */;
}


  ]==]

  content = content:gsub("##NAME##", plugin.name.lower)
  dir = dir .. os.sep .. plugin.name.lower .. ".xcodeproj"
  createDirectory(dir)
  createFileWithContent(dir, "project.pbxproj", content)

  print("Finished creating ios project file")
end


------------------------------------------------------------------------------
------------------------------------------------------------------------------

local gmake = {}

gmake.desktop = function(plugin) return desktop.createFiles(plugin) end
gmake.android = function(plugin) return android.createFiles(plugin) end
gmake.win32 = function(plugin) return win32.createFiles(plugin) end
gmake.html5 = function(plugin) return html5.createFiles(plugin) end
gmake.winrt = function(plugin) return winrt.createFiles(plugin) end
gmake.ios = function(plugin) return ios.createFiles(plugin) end


-- get os dependant / or \ for path separator
os.sep = package.config:sub(1,1)

os.capture = function(cmd, raw)
  local f = assert(io.popen(cmd, 'r'))
  local s = assert(f:read('*a'))
  f:close()
  if raw then return s end
  s = string.gsub(s, '^%s+', '')
  s = string.gsub(s, '%s+$', '')
  s = string.gsub(s, '[\n\r]+', ' ')
  return s
end

local skeleton =
[==[
--
--    gmake definintion file, execute with gmake.lua
--

plugin = {}

plugin.name = {
  full = "Test Plugin",
  camel = "testPlugin"
}

plugin.desc = "Our lovely test plugin."

  -- available: "desktop", "android", "win32", "winrt", "html5", "ios"
plugin.targets = { "desktop", "android", "win32", "winrt", "html5", "ios" }

-- paths are relative to myplugin/source/common
plugin.sources =
{
  -- for vpath in Makefiles
  dirs = {
    "../../../../luabinding"
  },
  -- source files can have '_'s or '-'s but no other non-alphanumeric characters
  files =
  {
    "test_entry.cpp",
    "../../test-entry.cpp",
    "anotherfile.cpp",
    "../../../../luabinding/binder.cpp"
  }
}

plugin.headers =
{
  "anotherfile.h"
}

plugin.libs = {
  "lua",
  "gideros",
  "gvfs"
}

plugin.includes =
{
  -- relative to myplugin/source/common
  "../../../../Sdk/include",
  "../../../../Sdk/include/gideros",
  "../../../../2dsg",
  "../../../../2dsg/gfxbackends",
  "../../../../libgideros",
  "../../../../libgid/include",
  "../../../../luabinding",
  "../../../../lua/src"
}


return plugin
]==]

------------------------------------------------------------------------------
------------------------------------------------------------------------------
--
local main = function(args)
  print(docs.header) -- print cool docs.header (TODO: reduce superfluous comments)

  -- process command line arguments
  if args[1] ~= nil then
    for i = 1, #args do
      local option = args[i]:sub(1, 2)

      if     option == "-h" then
        print(docs.help)
        return

      elseif option == "-c" then
        print("Do you want to create a new skeleton plugin.def.lua file in this directory? (y/n)")
        local res = io.read()
        if res:match("^[Yy]$") then
          local file = io.open("plugin.def.lua", "r")
          if file then
            print("\nplugin.def.lua exists, please check file and delete manually if you really want to overwrite.\n")
            return
          end
          file = io.open("plugin.def.lua", "w")
          file:write(skeleton)
          file:close()
          print("\nplugin.def.lua written. Now edit the file with the name, description and source files used")
          print("in your plugin.\n")
        else
          print("Exiting.")
        end
        return

      else
        print("Option \"" .. option .. "\" not recognised.\n")
        print(docs.body)
        print(docs.help)
        return

      end
    end
  end

  local listing = os.capture("ls", true)
  local def_file = listing:match("(%w-%.def%.lua)")
  if def_file then
    print("Plugin definition file found: " .. def_file)
  else
    print("Plugin definition file not found.")
    print("Run gmake with -c option to create a skeleton .def file.\n")
    print(docs.body)
    print(docs.help)
    return
  end
  local name_no_ext = def_file:match("^(%w+)")
  local plugin = require(name_no_ext)
  plugin.name.lower = plugin.name.camel:lower()

  local gplugin_header = [[
<plugin
    name="##NAME##"
    description="##DESC##"
>
]]
  gplugin_header = gplugin_header:gsub("##NAME##", plugin.name.full)
  gplugin_header = gplugin_header:gsub("##DESC##", plugin.desc)
  createFileWithContent(".", plugin.name.lower .. ".gplugin", gplugin_header .. "\n")

  for k, v in ipairs(plugin.targets) do
    print(gmake[v](plugin))
  end

  -- finalise gplugin file
  appendToFile(".", plugin.name.lower .. ".gplugin", "\n</plugin>")

  createDirectory("source" .. os.sep .. "common")
  print("\nBuild files for plugin \"" .. plugin.name.full .. "\" created.\n")
end

main({...})


