diff options
| author | ruki <[email protected]> | 2019-09-20 00:32:22 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-09-19 21:14:14 +0800 |
| commit | a838d8561e98342ed2c793c239f495357e4179c1 (patch) | |
| tree | 28bf94e58940f00433249c3d98f9ebfc6929ad88 | |
| parent | 5fa580d86834bf0d762c62626a576419724fe5c7 (diff) | |
add template files
10 files changed, 145 insertions, 6 deletions
diff --git a/xmake/actions/create/main.lua b/xmake/actions/create/main.lua index ffa31bb10..987d36b16 100644 --- a/xmake/actions/create/main.lua +++ b/xmake/actions/create/main.lua @@ -80,16 +80,24 @@ function _create_project_or_files(language, templateid, targetname) os.cd(projectdir) -- create project + local filedirs = {} local sourcedir = path.join(tempinst:scriptdir(), "project") if os.isdir(sourcedir) then - os.cp(path.join(sourcedir, "*"), projectdir) + for _, filedir in ipairs(os.filedirs(path.join(sourcedir, "*"))) do + os.cp(filedir, projectdir) + table.insert(filedirs, path.relative(filedir, sourcedir)) + end os.cp(path.join(os.programdir(), "scripts", "gitignore"), path.join(projectdir, ".gitignore")) + table.insert(filedirs, ".gitignore") end -- create files sourcedir = path.join(tempinst:scriptdir(), "files") if os.isdir(sourcedir) then - os.cp(path.join(sourcedir, "*"), projectdir) + for _, filedir in ipairs(os.filedirs(path.join(sourcedir, "*"))) do + os.cp(filedir, projectdir) + table.insert(filedirs, path.relative(filedir, sourcedir)) + end end -- get the builtin variables @@ -110,6 +118,17 @@ function _create_project_or_files(language, templateid, targetname) if after_create then after_create(tempinst, {targetname = targetname}) end + + -- trace + for _, filedir in ipairs(filedirs) do + if os.isdir(filedir) then + for _, file in ipairs(os.files(path.join(filedir, "**"))) do + print(" > %s", file) + end + else + print(" > %s", filedir) + end + end end -- main @@ -119,10 +138,10 @@ function main() os.cd(os.workingdir()) -- the target name - local targetname = option.get("target") or option.get("name") or path.basename(project.directory()) or "demo" + local targetname = option.get("target") or path.basename(project.directory()) or "demo" -- trace - cprint("${bright}create %s ...", targetname) + cprint("${bright}create %s files ...", targetname) -- create project or files from template _create_project_or_files(option.get("language"), option.get("template"), targetname) diff --git a/xmake/actions/create/xmake.lua b/xmake/actions/create/xmake.lua index 26157adc9..2c152c34f 100644 --- a/xmake/actions/create/xmake.lua +++ b/xmake/actions/create/xmake.lua @@ -38,8 +38,7 @@ task("create") -- options , options = { - {'n', "name", "kv", nil, "The project name." } - , {'l', "language", "kv", "c", "The project language" + {'l', "language", "kv", "c", "The project language" -- show the description of all languages , function () diff --git a/xmake/templates/c++/qt.mainwindow.files/files/mainwindowtest.cpp b/xmake/templates/c++/qt.mainwindow.files/files/mainwindowtest.cpp new file mode 100644 index 000000000..7982227fe --- /dev/null +++ b/xmake/templates/c++/qt.mainwindow.files/files/mainwindowtest.cpp @@ -0,0 +1,14 @@ +#include "mainwindowtest.h"
+#include "ui_mainwindowtest.h"
+
+MainWindowTest::MainWindowTest(QWidget *parent) :
+ QMainWindow(parent),
+ ui(new Ui::MainWindowTest)
+{
+ ui->setupUi(this);
+}
+
+MainWindowTest::~MainWindowTest()
+{
+ delete ui;
+}
diff --git a/xmake/templates/c++/qt.mainwindow.files/files/mainwindowtest.h b/xmake/templates/c++/qt.mainwindow.files/files/mainwindowtest.h new file mode 100644 index 000000000..53977f29c --- /dev/null +++ b/xmake/templates/c++/qt.mainwindow.files/files/mainwindowtest.h @@ -0,0 +1,22 @@ +#ifndef MAINWINDOWTEST_H
+#define MAINWINDOWTEST_H
+
+#include <QMainWindow>
+
+namespace Ui {
+class MainWindowTest;
+}
+
+class MainWindowTest : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ explicit MainWindowTest(QWidget *parent = nullptr);
+ ~MainWindowTest();
+
+private:
+ Ui::MainWindowTest *ui;
+};
+
+#endif // MAINWINDOWTEST_H
diff --git a/xmake/templates/c++/qt.mainwindow.files/files/mainwindowtest.ui b/xmake/templates/c++/qt.mainwindow.files/files/mainwindowtest.ui new file mode 100644 index 000000000..a231da10d --- /dev/null +++ b/xmake/templates/c++/qt.mainwindow.files/files/mainwindowtest.ui @@ -0,0 +1,24 @@ +<ui version="4.0">
+ <author/>
+ <comment/>
+ <exportmacro/>
+ <class>MainWindowTest</class>
+ <widget class="QMainWindow" name="MainWindowTest">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>800</width>
+ <height>600</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MainWindow</string>
+ </property>
+ <widget class="QMenuBar" name="menubar"/>
+ <widget class="QWidget" name="centralwidget"/>
+ <widget class="QStatusBar" name="statusbar"/>
+ </widget>
+ <pixmapfunction/>
+ <connections/>
+</ui>
diff --git a/xmake/templates/c++/qt.mainwindow.files/template.lua b/xmake/templates/c++/qt.mainwindow.files/template.lua new file mode 100644 index 000000000..9e586ed7b --- /dev/null +++ b/xmake/templates/c++/qt.mainwindow.files/template.lua @@ -0,0 +1,2 @@ +template("qt.mainwindow.files") + diff --git a/xmake/templates/c++/qt.widget.files/files/widgettest.cpp b/xmake/templates/c++/qt.widget.files/files/widgettest.cpp new file mode 100644 index 000000000..67d190c93 --- /dev/null +++ b/xmake/templates/c++/qt.widget.files/files/widgettest.cpp @@ -0,0 +1,14 @@ +#include "widgettest.h"
+#include "ui_widgettest.h"
+
+WidgetTest::WidgetTest(QWidget *parent) :
+ QWidget(parent),
+ ui(new Ui::WidgetTest)
+{
+ ui->setupUi(this);
+}
+
+WidgetTest::~WidgetTest()
+{
+ delete ui;
+}
diff --git a/xmake/templates/c++/qt.widget.files/files/widgettest.h b/xmake/templates/c++/qt.widget.files/files/widgettest.h new file mode 100644 index 000000000..8eee1e716 --- /dev/null +++ b/xmake/templates/c++/qt.widget.files/files/widgettest.h @@ -0,0 +1,22 @@ +#ifndef WIDGETTEST_H
+#define WIDGETTEST_H
+
+#include <QWidget>
+
+namespace Ui {
+class WidgetTest;
+}
+
+class WidgetTest : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit WidgetTest(QWidget *parent = nullptr);
+ ~WidgetTest();
+
+private:
+ Ui::WidgetTest *ui;
+};
+
+#endif // WIDGETTEST_H
diff --git a/xmake/templates/c++/qt.widget.files/files/widgettest.ui b/xmake/templates/c++/qt.widget.files/files/widgettest.ui new file mode 100644 index 000000000..72b8737bb --- /dev/null +++ b/xmake/templates/c++/qt.widget.files/files/widgettest.ui @@ -0,0 +1,21 @@ +<ui version="4.0">
+ <author/>
+ <comment/>
+ <exportmacro/>
+ <class>WidgetTest</class>
+ <widget class="QWidget" name="WidgetTest">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ </widget>
+ <pixmapfunction/>
+ <connections/>
+</ui>
diff --git a/xmake/templates/c++/qt.widget.files/template.lua b/xmake/templates/c++/qt.widget.files/template.lua new file mode 100644 index 000000000..bc9180e74 --- /dev/null +++ b/xmake/templates/c++/qt.widget.files/template.lua @@ -0,0 +1,2 @@ +template("qt.widget.files") + |
