-- -- GENie - Project generator tool -- https://github.com/bkaradzic/GENie#license -- local qbs = premake.qbs function qbs.generate_solution(sln) _p('/*') _p(' * QBS project file autogenerated by GENie') _p(' * https://github.com/bkaradzic/GENie') _p(' */') _p('') _p('import qbs') _p('') _p(0, 'Project {') _p(1, 'references: [') for prj in premake.solution.eachproject(sln) do _p(2, '"' .. prj.name .. '.qbs",') end _p(1, ']') _p(0, '}') end local function is_app(kind) if kind == "ConsoleApp" or kind == "WindowedApp" then return true end return false end function qbs.generate_user(sln) _p(0, '') _p(0, '') _p(0, '') _p(0, '') local startProject = 0 local idx = 0 for prj in premake.solution.eachproject(sln) do if is_app(prj.kind) then if sln.startproject == prj.name then startProject = idx end idx = idx + 1 end end _p(1, '') _p(2, 'ProjectExplorer.Project.Target.0') _p(2, '') _p(3, 'Desktop') _p(3, 'Desktop') local qbsguid = "" local qbsprofile = "" local qtcreatordir = "" if _OS == "windows" then qtcreatordir = path.join(os.getenv("APPDATA"), "QtProject/qtcreator") else qtcreatordir = path.join(os.getenv("HOME"), ".config/QtProject/qtcreator") end local file = io.open(path.join(qtcreatordir, "qbs.conf")) if file == nil then file = io.open(path.join(qtcreatordir, "qbs/1.6.0/qbs.conf")) end if file ~= nil then for line in file:lines() do if line == "[org]" then -- BK - Need to figure out how to extract kit associated profile name/guid... -- ~.config/QtProject/qtcreator/qbs.conf -- -- [org] -- qt-project\qbs\preferences\qtcreator\kit\%7B9926e565-8fc0-448d-9d5d-4b0293efd443%7D=qtc_Desktop_1bffddf2 -- local str = 'qt-project\\qbs\\preferences\\qtcreator\\kit\\%' local index = string.len(str)+1 for line in file:lines() do if index == string.find(line, '7B', index) then line = string.sub(line, index+2) qbsguid = string.sub(line, 1, 36) qbsprofile = string.sub(line, 41) --print(qbsguid, qbsprofile) break end end else -- ~/.config/QtProject/qtcreator/qbs/1.6.0/qbs.conf -- -- org.qt-project.qbs.preferences.qtcreator.kit.{d67ae030-7a33-43e0-850a-afe9e47fe5e1} -- qtc_Desktop_ee88281c local str = '\torg.qt-project.qbs.preferences.qtcreator.kit.' local index = string.len(str)+1 for line in file:lines() do if qbsguid == "" and index == string.find(line, '{', index) then line = string.sub(line, index+1) qbsguid = string.sub(line, 1, 36) elseif qbsguid ~= "" then qbsprofile = string.sub(line, 10, 29) --print(qbsguid, qbsprofile) break end end end break end io.close(file) end _p(3, '{%s}', qbsguid) _p(3, '0') _p(3, '0') _p(3, '%d', startProject) -- BuildConfiguration idx = 0 for _, cfgname in ipairs(sln.configurations) do -- cfg.objectsdir _p(3, '', idx) _p(4, 'build') _p(4, '') _p(5, '') _p(6, 'true') _p(6, '') _p(6, 'Qbs Build') _p(6, 'Qbs.BuildStep') _p(6, 'false') _p(6, '') _p(7, '%s', cfgname:lower()) _p(7, '%s', qbsprofile) _p(6, '') _p(5, '') _p(5, '1') _p(5, 'Build') _p(5, '') _p(5, 'ProjectExplorer.BuildSteps.Build') _p(4, '') _p(4, '') _p(5, '') _p(6, 'true') _p(6, '') _p(6, 'Qbs Clean') _p(6, 'Qbs.CleanStep') _p(6, 'true') _p(6, 'false') _p(6, 'false') _p(5, '') _p(5, '1') _p(5, 'Clean') _p(5, '') _p(5, 'ProjectExplorer.BuildSteps.Clean') _p(4, '') _p(4, '2') _p(4, 'false') _p(4, '') _p(4, '%s', cfgname) _p(4, '') _p(4, 'Qbs.QbsBuildConfiguration') _p(3, '') idx = idx + 1 end _p(3, '%d', idx) -- DeployConfiguration _p(3, '') _p(4, '') _p(5, '0') _p(5, 'Deploy') _p(5, '') _p(5, 'ProjectExplorer.BuildSteps.Deploy') _p(4, '') _p(4, '1') _p(4, 'Deploy locally') _p(4, 'Qbs Install') _p(4, 'Qbs.Deploy') _p(3, '') _p(3, '1') -- PluginSettings -- _p(3, '') -- RunConfiguration idx = 0 for prj in premake.solution.eachproject(sln) do if is_app(prj.kind) then -- _p(3, 'ProjectExplorer.Project.Target.%d', idx) _p(3, '', idx) if idx == startProject then _p(4, '2') else _p(4, '-1') end _p(4, '') _p(4, '%s', prj.name) _p(4, '') _p(4, 'Qbs.RunConfiguration:%s.%s---Qbs.RC.NameSeparator---%s', prj.name, qbsprofile, prj.name) _p(4, '') local cfg = premake.getconfig(prj, nil, nil) if cfg.debugdir ~= nil then _p(4, '%s', cfg.debugdir) else _p(4, '') end _p(3, '') idx = idx + 1 end end _p(3, '%d', idx) _p(2, '') _p(1, '') _p(1, '') _p(2, 'ProjectExplorer.Project.TargetCount') _p(2, '1') _p(1, '') _p(1, '') _p(2, 'Version') _p(2, '18') _p(1, '') _p(0, '') end