Skip to content
This repository has been archived by the owner on Oct 8, 2019. It is now read-only.

Commit

Permalink
v1.3 add OS X support and upgrade Qt4 to Qt5
Browse files Browse the repository at this point in the history
  • Loading branch information
Menci committed Feb 18, 2016
1 parent bba3237 commit 1a58425
Show file tree
Hide file tree
Showing 48 changed files with 247 additions and 85 deletions.
Binary file removed Psapi.Lib
Binary file not shown.
43 changes: 22 additions & 21 deletions addcompilerwizard.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "crossplatformhelper.h"
#include "addcompilerwizard.h"
#include "ui_addcompilerwizard.h"
#include "compiler.h"
Expand All @@ -12,7 +13,7 @@ AddCompilerWizard::AddCompilerWizard(QWidget *parent) :
ui->bytecodeFileExtensions->setValidator(new QRegExpValidator(QRegExp("(\\w+;)*\\w+"), this));
ui->javaMemoryLimit->setValidator(new QIntValidator(64, 2048, this));

#ifdef Q_OS_LINUX
#ifdef LEMON_OS_UNIX
if (QFileInfo("/usr/bin/gcc").exists())
ui->gccPath->setText("/usr/bin/gcc");
if (QFileInfo("/usr/bin/g++").exists())
Expand Down Expand Up @@ -249,12 +250,12 @@ void AddCompilerWizard::compilerTypeChanged()

void AddCompilerWizard::selectCompilerLocation()
{
#ifdef Q_OS_WIN32
#ifdef LEMON_OS_WIN32
QString location = QFileDialog::getOpenFileName(this, tr("Select Compiler\'s Location"),
QDir::rootPath(), tr("Executable files (*.exe)"));
#endif

#ifdef Q_OS_LINUX
#ifdef LEMON_OS_UNIX
QString location = QFileDialog::getOpenFileName(this, tr("Select Compiler\'s Location"),
QDir::rootPath(), tr("Executable files (*.*)"));
#endif
Expand All @@ -266,12 +267,12 @@ void AddCompilerWizard::selectCompilerLocation()

void AddCompilerWizard::selectInterpreterLocation()
{
#ifdef Q_OS_WIN32
#ifdef LEMON_OS_WIN32
QString location = QFileDialog::getOpenFileName(this, tr("Select Interpreter\'s Location"),
QDir::rootPath(), tr("Executable files (*.exe)"));
#endif

#ifdef Q_OS_LINUX
#ifdef LEMON_OS_UNIX
QString location = QFileDialog::getOpenFileName(this, tr("Select Interpreter\'s Location"),
QDir::rootPath(), tr("Executable files (*.*)"));
#endif
Expand All @@ -283,12 +284,12 @@ void AddCompilerWizard::selectInterpreterLocation()

void AddCompilerWizard::selectGccPath()
{
#ifdef Q_OS_WIN32
#ifdef LEMON_OS_WIN32
QString location = QFileDialog::getOpenFileName(this, tr("Select Compiler\'s Location"),
QDir::rootPath(), "gcc (gcc.exe)");
#endif

#ifdef Q_OS_LINUX
#ifdef LEMON_OS_UNIX
QString location = QFileDialog::getOpenFileName(this, tr("Select Compiler\'s Location"),
QDir::rootPath(), "gcc (gcc)");
#endif
Expand All @@ -300,12 +301,12 @@ void AddCompilerWizard::selectGccPath()

void AddCompilerWizard::selectGppPath()
{
#ifdef Q_OS_WIN32
#ifdef LEMON_OS_WIN32
QString location = QFileDialog::getOpenFileName(this, tr("Select Compiler\'s Location"),
QDir::rootPath(), "g++ (g++.exe)");
#endif

#ifdef Q_OS_LINUX
#ifdef LEMON_OS_UNIX
QString location = QFileDialog::getOpenFileName(this, tr("Select Compiler\'s Location"),
QDir::rootPath(), "g++ (g++)");
#endif
Expand All @@ -317,12 +318,12 @@ void AddCompilerWizard::selectGppPath()

void AddCompilerWizard::selectFpcPath()
{
#ifdef Q_OS_WIN32
#ifdef LEMON_OS_WIN32
QString location = QFileDialog::getOpenFileName(this, tr("Select Compiler\'s Location"),
QDir::rootPath(), "fpc (fpc.exe)");
#endif

#ifdef Q_OS_LINUX
#ifdef LEMON_OS_UNIX
QString location = QFileDialog::getOpenFileName(this, tr("Select Compiler\'s Location"),
QDir::rootPath(), "fpc (fpc)");
#endif
Expand All @@ -334,12 +335,12 @@ void AddCompilerWizard::selectFpcPath()

void AddCompilerWizard::selectFbcPath()
{
#ifdef Q_OS_WIN32
#ifdef LEMON_OS_WIN32
QString location = QFileDialog::getOpenFileName(this, tr("Select Compiler\'s Location"),
QDir::rootPath(), "fbc (fbc.exe)");
#endif

#ifdef Q_OS_LINUX
#ifdef LEMON_OS_UNIX
QString location = QFileDialog::getOpenFileName(this, tr("Select Compiler\'s Location"),
QDir::rootPath(), "fbc (fbc)");
#endif
Expand All @@ -351,12 +352,12 @@ void AddCompilerWizard::selectFbcPath()

void AddCompilerWizard::selectJavacPath()
{
#ifdef Q_OS_WIN32
#ifdef LEMON_OS_WIN32
QString location = QFileDialog::getOpenFileName(this, tr("Select Compiler\'s Location"),
QDir::rootPath(), "javac (javac.exe)");
#endif

#ifdef Q_OS_LINUX
#ifdef LEMON_OS_UNIX
QString location = QFileDialog::getOpenFileName(this, tr("Select Compiler\'s Location"),
QDir::rootPath(), "javac (javac)");
#endif
Expand All @@ -368,12 +369,12 @@ void AddCompilerWizard::selectJavacPath()

void AddCompilerWizard::selectJavaPath()
{
#ifdef Q_OS_WIN32
#ifdef LEMON_OS_WIN32
QString location = QFileDialog::getOpenFileName(this, tr("Select Interpreter\'s Location"),
QDir::rootPath(), "java (java.exe)");
#endif

#ifdef Q_OS_LINUX
#ifdef LEMON_OS_UNIX
QString location = QFileDialog::getOpenFileName(this, tr("Select Interpreter\'s Location"),
QDir::rootPath(), "java (java)");
#endif
Expand All @@ -385,12 +386,12 @@ void AddCompilerWizard::selectJavaPath()

void AddCompilerWizard::selectPythonPath()
{
#ifdef Q_OS_WIN32
#ifdef LEMON_OS_WIN32
QString location = QFileDialog::getOpenFileName(this, tr("Select Interpreter\'s Location"),
QDir::rootPath(), "python (python.exe)");
#endif

#ifdef Q_OS_LINUX
#ifdef LEMON_OS_UNIX
QString location = QFileDialog::getOpenFileName(this, tr("Select Interpreter\'s Location"),
QDir::rootPath(), "python (python)");
#endif
Expand Down Expand Up @@ -427,7 +428,7 @@ void AddCompilerWizard::accept()
} else {
compiler->addConfiguration("default", "-o %s %s.*", "");
}
#ifdef Q_OS_WIN32
#ifdef LEMON_OS_WIN32
QProcessEnvironment environment;
QString path = QFileInfo(ui->gccPath->text()).absolutePath();
path.replace('/', QDir::separator());
Expand All @@ -447,7 +448,7 @@ void AddCompilerWizard::accept()
} else {
compiler->addConfiguration("default", "-o %s %s.*", "");
}
#ifdef Q_OS_WIN32
#ifdef LEMON_OS_WIN32
QProcessEnvironment environment;
QString path = QFileInfo(ui->gppPath->text()).absolutePath();
path.replace('/', QDir::separator());
Expand Down
2 changes: 2 additions & 0 deletions addcompilerwizard.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <QtCore>
#include <QtGui>
#include <QWizard>
#include <QMessageBox>
#include <QFileDialog>

namespace Ui {
class AddCompilerWizard;
Expand Down
3 changes: 2 additions & 1 deletion addtestcaseswizard.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/***************************************************************************
This file is part of Project Lemon
Copyright (C) 2011 Zhipeng Jia
Copyright (C) 2016 Menci
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -207,7 +208,7 @@ QStringList AddTestCasesWizard::getMatchedPart(const QString &str, const QString
for (int pos = 0, i = 0; pos < pattern.length(); i ++, pos ++) {
if (pos + 2 < pattern.length()) {
if (pattern[pos] == '<' && pattern[pos+1].isDigit() && pattern[pos+1] != '0' && pattern[pos+2] == '>') {
int index = pattern[pos+1].toAscii() - 49;
int index = pattern[pos+1].toLatin1() - 49;
QString regExp = ui->argumentList->item(index, 1)->text();
for (int j = i; j < str.length(); j ++) {
if (QRegExp(regExp).exactMatch(str.mid(i, j - i + 1))) {
Expand Down
2 changes: 2 additions & 0 deletions addtestcaseswizard.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/***************************************************************************
This file is part of Project Lemon
Copyright (C) 2011 Zhipeng Jia
Copyright (C) 2016 Menci
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -22,6 +23,7 @@
#include <QtCore>
#include <QtGui>
#include <QWizard>
#include <QMessageBox>

namespace Ui {
class AddTestCasesWizard;
Expand Down
10 changes: 6 additions & 4 deletions advancedcompilersettingsdialog.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/***************************************************************************
This file is part of Project Lemon
Copyright (C) 2011 Zhipeng Jia
Copyright (C) 2016 Menci
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -16,6 +17,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
***************************************************************************/

#include "crossplatformhelper.h"
#include "advancedcompilersettingsdialog.h"
#include "ui_advancedcompilersettingsdialog.h"
#include "environmentvariablesdialog.h"
Expand Down Expand Up @@ -195,12 +197,12 @@ void AdvancedCompilerSettingsDialog::interpreterLocationChanged()

void AdvancedCompilerSettingsDialog::selectCompilerLocation()
{
#ifdef Q_OS_WIN32
#ifdef LEMON_OS_WIN32
QString location = QFileDialog::getOpenFileName(this, tr("Select Compiler\'s Location"),
QDir::rootPath(), tr("Executable files (*.exe)"));
#endif

#ifdef Q_OS_LINUX
#ifdef LEMON_OS_UNIX
QString location = QFileDialog::getOpenFileName(this, tr("Select Compiler\'s Location"),
QDir::rootPath(), tr("Executable files (*.*)"));
#endif
Expand All @@ -212,12 +214,12 @@ void AdvancedCompilerSettingsDialog::selectCompilerLocation()

void AdvancedCompilerSettingsDialog::selectInterpreterLocation()
{
#ifdef Q_OS_WIN32
#ifdef LEMON_OS_WIN32
QString location = QFileDialog::getOpenFileName(this, tr("Select Interpreter\'s Location"),
QDir::rootPath(), tr("Executable files (*.exe)"));
#endif

#ifdef Q_OS_LINUX
#ifdef LEMON_OS_UNIX
QString location = QFileDialog::getOpenFileName(this, tr("Select Interpreter\'s Location"),
QDir::rootPath(), tr("Executable files (*.*)"));
#endif
Expand Down
3 changes: 3 additions & 0 deletions advancedcompilersettingsdialog.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/***************************************************************************
This file is part of Project Lemon
Copyright (C) 2011 Zhipeng Jia
Copyright (C) 2016 Menci
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -22,6 +23,8 @@
#include <QtCore>
#include <QtGui>
#include <QDialog>
#include <QMessageBox>
#include <QFileDialog>

class Compiler;

Expand Down
6 changes: 4 additions & 2 deletions assignmentthread.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/***************************************************************************
This file is part of Project Lemon
Copyright (C) 2011 Zhipeng Jia
Copyright (C) 2016 Menci
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -16,6 +17,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
***************************************************************************/

#include "crossplatformhelper.h"
#include "assignmentthread.h"
#include "judgingthread.h"
#include "settings.h"
Expand Down Expand Up @@ -156,10 +158,10 @@ bool AssignmentThread::traditionalTaskPrepare()
}

if (compilerList[i]->getCompilerType() == Compiler::Typical) {
#ifdef Q_OS_WIN32
#ifdef LEMON_OS_WIN32
executableFile = task->getSourceFileName() + ".exe";
#endif
#ifdef Q_OS_LINUX
#ifdef LEMON_OS_UNIX
executableFile = task->getSourceFileName();
#endif
interpreterFlag = false;
Expand Down
21 changes: 21 additions & 0 deletions clean
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
#
# Project Lemon - A tiny judging environment for OI contest
# Copyright (C) 2016 Menci
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

make clean
rm -rf *.o moc_* ui_* *.lib *.Lib Makefile* watcher_unix
2 changes: 2 additions & 0 deletions compilersettings.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/***************************************************************************
This file is part of Project Lemon
Copyright (C) 2011 Zhipeng Jia
Copyright (C) 2016 Menci
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -22,6 +23,7 @@
#include <QtCore>
#include <QtGui>
#include <QWidget>
#include <QMessageBox>

namespace Ui {
class CompilerSettings;
Expand Down
6 changes: 4 additions & 2 deletions contest.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/***************************************************************************
This file is part of Project Lemon
Copyright (C) 2011 Zhipeng Jia
Copyright (C) 2016 Menci
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -17,6 +18,7 @@
***************************************************************************/

#include <QMessageBox>
#include "crossplatformhelper.h"
#include "contest.h"
#include "task.h"
#include "testcase.h"
Expand Down Expand Up @@ -145,10 +147,10 @@ void Contest::clearPath(const QString &curDir)
QStringList fileList = dir.entryList(QDir::Files);
for (int i = 0; i < fileList.size(); i ++) {
if (! dir.remove(fileList[i])) {
#ifdef Q_OS_WIN32
#ifdef LEMON_OS_WIN32
QProcess::execute(QString("attrib -R \"") + curDir + fileList[i] + "\"");
#endif
#ifdef Q_OS_LINUX
#ifdef LEMON_OS_UNIX
QProcess::execute(QString("chmod +w \"") + curDir + fileList[i] + "\"");
#endif
dir.remove(fileList[i]);
Expand Down
25 changes: 25 additions & 0 deletions crossplatformhelper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/***************************************************************************
This file is part of Project Lemon
Copyright (C) 2016 Menci
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***************************************************************************/

#ifdef __APPLE__
# define LEMON_OS_UNIX
#elif __linux__
# define LEMON_OS_LINUX
#elif _WIN32
# define LEMON_OS_WIN32
#endif
Loading

0 comments on commit 1a58425

Please sign in to comment.