add getDirectoryPath

This commit is contained in:
Syping 2019-10-18 18:26:38 +02:00
parent e1c5e46af5
commit be98a790e5
8 changed files with 93 additions and 13 deletions

View file

@ -7,7 +7,7 @@
!define COPYRIGHT "Copyright © 2018-2019 Syping"
!define DESCRIPTION "LuaEngine Runtime and Compiler"
!define INSTALLER_NAME "luaengine_setup.exe"
!define MAIN_APP_RUNTIME "LuaEngine.exe"
!define MAIN_APP_RUNTIME "luaengine.exe"
!define MAIN_APP_COMPILER "luaenginec.exe"
!define INSTALL_TYPE "SetShellVarContext all"
!define REG_ROOT "HKLM"
@ -102,7 +102,7 @@ ${INSTALL_TYPE}
SetOverwrite ifnewer
SetOutPath "$INSTDIR"
File "LuaEngine.dll"
File "LuaEngine.exe"
File "luaengine.exe"
File "luaenginec.exe"
File "LuaEngineGui.dll"
File "LuaEngineIO.dll"
@ -114,8 +114,6 @@ File "/opt/windev/qt64d-latest/bin/Qt5Core.dll"
File "/opt/windev/qt64d-latest/bin/Qt5Gui.dll"
File "/opt/windev/qt64d-latest/bin/Qt5Svg.dll"
File "/opt/windev/qt64d-latest/bin/Qt5Widgets.dll"
SetOutPath "$INSTDIR\sstubs"
File "windows.le"
SetOutPath "$INSTDIR\imageformats"
File "/opt/windev/qt64d-latest/plugins/imageformats/qgif.dll"
File "/opt/windev/qt64d-latest/plugins/imageformats/qicns.dll"
@ -128,6 +126,10 @@ File "/opt/windev/qt64d-latest/plugins/imageformats/qwbmp.dll"
File "/opt/windev/qt64d-latest/plugins/imageformats/qwebp.dll"
SetOutPath "$INSTDIR\platforms"
File "/opt/windev/qt64d-latest/plugins/platforms/qwindows.dll"
SetOutPath "$INSTDIR\scripts"
File "luaenginert.lea"
SetOutPath "$INSTDIR\sstubs"
File "windows.le"
SetOutPath "$INSTDIR\styles"
File "/opt/windev/qt64d-latest/plugins/styles/qcleanlooksstyle.dll"
File "/opt/windev/qt64d-latest/plugins/styles/qplastiquestyle.dll"
@ -143,7 +145,7 @@ WriteUninstaller "$INSTDIR\uninstall.exe"
!ifdef REG_START_MENU
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
CreateDirectory "$SMPROGRAMS\$SM_Folder"
CreateShortCut "$SMPROGRAMS\$SM_Folder\${APP_NAME}.lnk" "$INSTDIR\${MAIN_APP_RUNTIME}"
CreateShortCut "$SMPROGRAMS\$SM_Folder\${APP_NAME}.lnk" "$INSTDIR\${MAIN_APP_RUNTIME} $INSTDIR\scripts\luaenginert.lea"
CreateShortCut "$SMPROGRAMS\$SM_Folder\${APP_NAME} Compiler.lnk" "$INSTDIR\${MAIN_APP_COMPILER}"
CreateShortCut "$SMPROGRAMS\$SM_Folder\Uninstall ${APP_NAME}.lnk" "$INSTDIR\uninstall.exe"
@ -156,7 +158,8 @@ CreateShortCut "$SMPROGRAMS\$SM_Folder\${APP_NAME} Website.lnk" "$INSTDIR\${APP_
!ifndef REG_START_MENU
CreateDirectory "$SMPROGRAMS\LuaEngine"
CreateShortCut "$SMPROGRAMS\LuaEngine\${APP_NAME}.lnk" "$INSTDIR\${MAIN_APP_RUNTIME}"
CreateShortCut "$SMPROGRAMS\LuaEngine\${APP_NAME}.lnk" "$INSTDIR\${MAIN_APP_RUNTIME} $INSTDIR\scripts\luaenginert.lea"
CreateShortCut "$SMPROGRAMS\$SM_Folder\${APP_NAME} Compiler.lnk" "$INSTDIR\${MAIN_APP_COMPILER}"
CreateShortCut "$SMPROGRAMS\LuaEngine\Uninstall ${APP_NAME}.lnk" "$INSTDIR\uninstall.exe"
!ifdef WEB_SITE
@ -184,7 +187,7 @@ SectionEnd
Section Uninstall
${INSTALL_TYPE}
Delete "$INSTDIR\LuaEngine.dll"
Delete "$INSTDIR\LuaEngine.exe"
Delete "$INSTDIR\luaengine.exe"
Delete "$INSTDIR\luaenginec.exe"
Delete "$INSTDIR\LuaEngineGui.dll"
Delete "$INSTDIR\LuaEngineIO.dll"
@ -196,7 +199,6 @@ Delete "$INSTDIR\Qt5Core.dll"
Delete "$INSTDIR\Qt5Gui.dll"
Delete "$INSTDIR\Qt5Svg.dll"
Delete "$INSTDIR\Qt5Widgets.dll"
Delete "$INSTDIR\sstubs\windows.le"
Delete "$INSTDIR\imageformats\qgif.dll"
Delete "$INSTDIR\imageformats\qicns.dll"
Delete "$INSTDIR\imageformats\qico.dll"
@ -207,6 +209,8 @@ Delete "$INSTDIR\imageformats\qtiff.dll"
Delete "$INSTDIR\imageformats\qwbmp.dll"
Delete "$INSTDIR\imageformats\qwebp.dll"
Delete "$INSTDIR\platforms\qwindows.dll"
Delete "$INSTDIR\scripts\luaenginert.lea"
Delete "$INSTDIR\sstubs\windows.le"
Delete "$INSTDIR\styles\qcleanlooksstyle.dll"
Delete "$INSTDIR\styles\qplastiquestyle.dll"
Delete "$INSTDIR\styles\qwindowsvistastyle.dll"
@ -245,7 +249,7 @@ RmDir "$SMPROGRAMS\LuaEngine"
DeleteRegKey ${REG_ROOT} "${REG_APP_RUNTIME}"
DeleteRegKey ${REG_ROOT} "${REG_APP_COMPILER}"
DeleteRegKey ${REG_ROOT} "${REG_ENVIRONMENT}\${REG_ENV_RUNTIME}"
DeleteRegValue ${REG_ROOT} "${REG_ENV_RUNTIME}" "${REG_ENVIRONMENT}"
DeleteRegKey ${REG_ROOT} "${UNINSTALL_PATH}"
SectionEnd

View file

@ -16,13 +16,13 @@ LuaEngine Windows:
- cp -Rf src/luaenginegui/release/LuaEngineGui.dll ${CI_PROJECT_DIR}/
- cp -Rf src/luaengineio/release/LuaEngineIO.dll ${CI_PROJECT_DIR}/
- cp -Rf src/luaengineos/release/LuaEngineOS.dll ${CI_PROJECT_DIR}/
- cp -Rf src/luaengine/release/LuaEngine.exe ${CI_PROJECT_DIR}/
- cp -Rf src/luaengine/release/luaengine.exe ${CI_PROJECT_DIR}/
- cp -Rf src/luaenginec/release/luaenginec.exe ${CI_PROJECT_DIR}/
- cd ${CI_PROJECT_DIR}
artifacts:
paths:
- "LuaEngine.dll"
- "LuaEngine.exe"
- "luaengine.exe"
- "luaenginec.exe"
- "LuaEngineGui.dll"
- "LuaEngineIO.dll"

60
scripts/luaenginert.lea Normal file
View file

@ -0,0 +1,60 @@
#!/usr/bin/env luaengine
--[[
******************************************************************************
* luaengine LuaEngine Runtime
* Copyright (C) 2019 Syping
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************
--]]
local mainWindow
local scriptLineEdit
function main()
mainWindow = createMainWindow("LuaEngine Runtime")
local mainLayout = createLayout(VerticalLayout, mainWindow)
createLabel("<strong>LuaEngine Runtime</strong>", mainLayout)
local scriptLayout = createLayout(HorizontalLayout, mainLayout)
createLabel("Script:", scriptLayout)
scriptLineEdit = createLineEdit("", scriptLayout)
setWidgetReadOnly(scriptLineEdit)
local scriptToolButton = createToolButton("...", scriptLayout)
connect(scriptToolButton, "clicked()", "scriptButtonPressed")
createSpacerItem(SizePolicyMinimum, SizePolicyExpanding, mainLayout)
local buttonLayout = createLayout(HorizontalLayout, mainLayout)
createSpacerItem(SizePolicyExpanding, SizePolicyMinimum, buttonLayout)
local runButton = createPushButton("&Run", buttonLayout)
connect(runButton, "clicked()", "runScript")
setWidgetSize(mainWindow, 300, 0)
setWidgetFixed(mainWindow, true)
showWidget(mainWindow, ShowDefault)
return GuiExecuted
end
function scriptButtonPressed()
local filePath = showFileDialog(OpenFileDialog, "Select LuaEngine script...", "LuaEngine scripts (*.lua *.lea)", mainWindow)
if (filePath ~= nil) then
setWidgetText(scriptLineEdit, filePath)
end
end
function runScript()
executeProcess(_LuaEngineRT, getWidgetText(scriptLineEdit), true)
end

View file

@ -17,7 +17,6 @@
QT += widgets
TARGET = luaengine
win32: TARGET = LuaEngine
CONFIG += c++11
VERSION = 0.1

View file

@ -43,6 +43,7 @@ int main(int argc, char *argv[])
}
if (arguments.length() >= 2) {
QVariant rtPath = arguments.first();
arguments.removeFirst();
QFile luaScript(arguments.first().toString());
if (!luaScript.open(QIODevice::ReadOnly)) {
@ -60,6 +61,7 @@ int main(int argc, char *argv[])
LuaEngineGui luaEngineGui;
LuaEngineIO::pushClass(&luaEngineGui);
LuaEngineOS::pushClass(&luaEngineGui);
luaEngineGui.pushVariant("_LuaEngineRT", rtPath);
luaEngineGui.executeLuaScript(luaScript.readAll());
if (luaEngineGui.executeLuaFunction("main", arguments, true)) {

View file

@ -54,7 +54,7 @@ int main(int argc, char *argv[])
}
#else
{
QFile executable(a.arguments().at(0));
QFile executable(a.arguments().first());
if (executable.open(QIODevice::ReadOnly)) {
qint64 executableSize = executable.size();
executable.seek(executableSize - 6);

View file

@ -18,6 +18,7 @@
#include "LuaEngineIO.h"
#include <QDirIterator>
#include <QTextStream>
#include <QFileInfo>
#include <QString>
#include <QObject>
#include <QFile>
@ -38,6 +39,7 @@ void LuaEngineIO::pushClass(lua_State *L_p)
{
// Directory
pushFunction(L_p, "directoryListFiles", directoryListFiles);
pushFunction(L_p, "getDirectoryPath", getDirectoryPath);
// File
pushFunction(L_p, "linkFile", linkFile);
@ -102,6 +104,18 @@ int LuaEngineIO::linkFile(lua_State *L_p)
return 1;
}
int LuaEngineIO::getDirectoryPath(lua_State *L_p)
{
if (getArgumentCount(L_p) >= 1) {
QFileInfo fileInfo(getVariant(L_p, 1).toString());
if (fileInfo.exists()) {
pushVariant(L_p, fileInfo.absoluteDir().absolutePath());
return 1;
}
}
return 0;
}
QString LuaEngineIO::nameForPointer(void *pointer)
{
QString nameStorage;

View file

@ -32,6 +32,7 @@ public:
static void pushClass(LuaEngine *luaEngine);
static int directoryListFiles(lua_State *L_p);
static int linkFile(lua_State *L_p);
static int getDirectoryPath(lua_State *L_p);
private:
lua_State *L;