Skip to content

Commit

Permalink
Build emake as part of release. (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
fundies committed Apr 9, 2020
1 parent be5cd58 commit 94e0653
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 26 deletions.
64 changes: 45 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,33 @@
cmake_minimum_required(VERSION 3.11)
cmake_minimum_required(VERSION 3.14)
project(RadialGM)

include(CMakeDependentOption)

option(RGM_ENABLE_GRPC_SERVER "Enable the GRPC client plugin for compilation and code analysis." ON)
option(RGM_BUILD_EMAKE "Build Emake and the compiler." ON)

# FIXME: MSVC dynamic linking requires US TO DLLEXPORT our funcs
# since we currently don't, I'm force disabling the option on MSVC
cmake_dependent_option(RGM_BUILD_STATIC "Build static libs." ON "MSVC" OFF)

if (RGM_BUILD_STATIC)
set(LIB_TYPE STATIC)
else()
set(LIB_TYPE SHARED)
endif()

if (CMAKE_BUILD_TYPE MATCHES "Debug")
set(EXE "RadialGM-Debug")
add_definitions(-DRGM_DEBUG)
else()
set(EXE "RadialGM")
endif()

set(EXE_DESCRIPTION "ENIGMA IDE")

project(RadialGM)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
SET(CMAKE_SKIP_BUILD_RPATH ON)
set(CMAKE_INSTALL_RPATH $ORIGIN)

# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
Expand All @@ -28,7 +45,7 @@ set(CMAKE_AUTOUIC_SEARCH_PATHS "${CMAKE_CURRENT_SOURCE_DIR}/Dialogs")

# Include ENIGMA things
set(ENIGMA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Submodules/enigma-dev)
include_directories("${CMAKE_BINARY_DIR}/Submodules/enigma-dev/CommandLine/libEGM/libProtocols" "${ENIGMA_DIR}/CommandLine/libEGM")
include_directories("${CMAKE_BINARY_DIR}/Submodules/enigma-dev/shared/protos/" "${ENIGMA_DIR}/CommandLine/libEGM" "${ENIGMA_DIR}/shared")

# Populate a CMake variable with the sources
set(RGM_SOURCES
Expand Down Expand Up @@ -164,9 +181,6 @@ if (RGM_ENABLE_GRPC_SERVER)
set(RGM_HEADERS ${RGM_HEADERS} Plugins/ServerPlugin.h)
endif()


set(CMAKE_INSTALL_RPATH "${ENIGMA_DIR}")

# Tell CMake to create the RadialGM executable
add_executable(${EXE} WIN32 ${RGM_UI} ${RGM_HEADERS} ${RGM_SOURCES} ${EDITOR_SOURCES} ${RGM_RC})

Expand Down Expand Up @@ -240,9 +254,11 @@ find_package(Qt5 COMPONENTS Core Widgets Gui PrintSupport Multimedia REQUIRED)
target_link_libraries(${EXE} PRIVATE Qt5::Core Qt5::Widgets Qt5::Gui Qt5::PrintSupport Qt5::Multimedia)

# LibProto
add_subdirectory(Submodules/enigma-dev/shared)
add_subdirectory(Submodules/enigma-dev/shared/protos)
add_subdirectory(Submodules/enigma-dev/CommandLine/libEGM)
add_dependencies(${EXE} "EGM")
target_link_libraries(${EXE} PRIVATE "EGM" "Protocols")
target_link_libraries(${EXE} PRIVATE "EGM" "Protocols" "ENIGMAShared")

# Find FreeType
find_package(Freetype REQUIRED)
Expand Down Expand Up @@ -270,19 +286,27 @@ if(WIN32)
target_link_libraries(${EXE} PRIVATE Ws2_32 Wtsapi32 Wldap32 Crypt32 Winmm Userenv Netapi32 version Dwmapi Imm32)
endif(WIN32)

install(TARGETS ${EXE} RUNTIME DESTINATION .)

if(MSVC)
# Default MSVC warnings are overkill. Set to Lvl 2
target_compile_options(${EXE} PRIVATE /W1)
target_compile_options("EGM" PRIVATE /W1)
target_compile_options("Protocols" PRIVATE /W1)
# Default MSVC warnings are overkill. Set to Lvl 2
target_compile_options(${EXE} PRIVATE /W1)
endif()

if (RGM_BUILD_EMAKE)
add_subdirectory(Submodules/enigma-dev/CompilerSource)
add_subdirectory(Submodules/enigma-dev/CommandLine/emake)
if (CMAKE_BUILD_TYPE MATCHES "Debug")
set(CLI_TARGET "emake-debug")
else()
set(CLI_TARGET "emake")
endif()
add_dependencies(${EXE} ${CLI_TARGET})
endif()

install(TARGETS "Protocols" DESTINATION .)
install(TARGETS "EGM" DESTINATION .)
install(TARGETS ${EXE} RUNTIME DESTINATION .)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${EXE}.dir/Debug/${EXE}.pdb" DESTINATION . OPTIONAL)

set(APPS "${CMAKE_INSTALL_PREFIX}/${EXE}${CMAKE_EXECUTABLE_SUFFIX}")
set(RGM_APP "${CMAKE_INSTALL_PREFIX}/${EXE}${CMAKE_EXECUTABLE_SUFFIX}")
set(EMAKE_APP "${CMAKE_INSTALL_PREFIX}/${CLI_TARGET}${CMAKE_EXECUTABLE_SUFFIX}")

if (MSVC)
file(TO_CMAKE_PATH ${VCPKG_ROOT} VCPKG_ROOT)
Expand All @@ -293,7 +317,8 @@ file(TO_CMAKE_PATH ${VCPKG_ROOT} VCPKG_ROOT)
endif()
else()
set(LIBS "${CMAKE_INSTALL_PREFIX}/${CMAKE_SHARED_LIBRARY_PREFIX}EGM${CMAKE_SHARED_LIBRARY_SUFFIX}"
"${CMAKE_INSTALL_PREFIX}/${CMAKE_SHARED_LIBRARY_PREFIX}Protocols${CMAKE_SHARED_LIBRARY_SUFFIX}")
"${CMAKE_INSTALL_PREFIX}/${CMAKE_SHARED_LIBRARY_PREFIX}Protocols${CMAKE_SHARED_LIBRARY_SUFFIX}"
"${CMAKE_INSTALL_PREFIX}/${CMAKE_SHARED_LIBRARY_PREFIX}ENIGMAShared${CMAKE_SHARED_LIBRARY_SUFFIX}")
endif()

if (WIN32)
Expand All @@ -314,7 +339,8 @@ if (WIN32)

install(CODE "
include(BundleUtilities)
fixup_bundle(\"${APPS}\" \"${LIBS}\" \"${SEARCH_PATHS}\")
execute_process(COMMAND windeployqt.exe ${WINDEPLOY_ARGS} ${APPS})
fixup_bundle(\"${RGM_APP}\" \"${LIBS}\" \"${SEARCH_PATHS}\")
fixup_bundle(\"${EMAKE_APP}\" \"${LIBS}\" \"${SEARCH_PATHS}\")
execute_process(COMMAND windeployqt.exe ${WINDEPLOY_ARGS} ${RGM_APP})
")
endif()
68 changes: 62 additions & 6 deletions Plugins/ServerPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,31 +242,87 @@ void CompilerClient::UpdateLoop(void* got_tag, bool ok) {
ServerPlugin::ServerPlugin(MainWindow& mainWindow) : RGMPlugin(mainWindow) {
// create a new child process for us to launch an emake server
process = new QProcess(this);

connect(process, &QProcess::errorOccurred, [&](QProcess::ProcessError error) {
qDebug() << "QProcess error: " << error << endl;
});
connect(process, &QProcess::readyReadStandardOutput, [&]() {
emit LogOutput(process->readAllStandardOutput());
});
connect(process, &QProcess::readyReadStandardError, [&]() {
emit LogOutput(process->readAllStandardError());
});

#ifdef _WIN32
//TODO: Make all this stuff configurable in IDE
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();

// FIXME: this is just an approximate guess on how to get emake running outside a msys shell and currently causes emake to crash
QString msysPath;
if (!env.contains("MSYS_ROOT")) {
msysPath = env.value("SystemDrive", "C:") + "/msys64";
qDebug().noquote() << "Environmental variable \"MSYS_ROOT\" is not set defaulting MSYS path to: " + msysPath;
} else msysPath = env.value("MSYS_ROOT");

env.insert("PATH", env.value("PATH") + ";" + msysPath + "/usr/bin;" + msysPath + "/mingw64/bin");
process->setProcessEnvironment(env);
#endif

// look for an executable file that looks like emake in some common directories
QList<QString> searchPaths = {QDir::currentPath(), "./enigma-dev", "../RadialGM/Submodules/enigma-dev"};
QFileInfo emakeFileInfo(QFile("emake"));
QList<QString> searchPaths = {QDir::currentPath(), "./enigma-dev", "../enigma-dev", "../RadialGM/Submodules/enigma-dev"};
#ifndef RGM_DEBUG
QString emakeName = "emake";
#else
QString emakeName = "emake-debug";
#endif

QFileInfo emakeFileInfo;
foreach (auto path, searchPaths) {
const QDir dir(path);
QDir::Filters filters = QDir::Filter::Executable | QDir::Filter::Files;
// we use a wildcard because we want it to find emake.exe on Windows
auto entryList = dir.entryInfoList(QStringList({"emake","emake.exe"}), filters, QDir::SortFlag::NoSort);
auto entryList = dir.entryInfoList(QStringList({emakeName, emakeName + ".exe"}), filters, QDir::SortFlag::NoSort);
if (!entryList.empty()) {
emakeFileInfo = entryList.first();
break;
}
}

if (emakeFileInfo.filePath().isEmpty()) {
qDebug() << "Error: Failed to locate emake. Compiling and syntax check will not work.\n" << "Search Paths:\n" << searchPaths;
return;
}

QFileInfo enigmaFileInfo;
foreach (auto path, searchPaths) {
const QDir dir(path);
QDir::Filters filters = QDir::Filter::AllEntries;
auto entryList = dir.entryInfoList(QStringList({"ENIGMAsystem"}), filters, QDir::SortFlag::NoSort);
if (!entryList.empty()) {
enigmaFileInfo = entryList.first();
break;
}
}

if (enigmaFileInfo.filePath().isEmpty()) {
qDebug() << "Error: Failed to locate ENIGMA sources. Compiling and syntax check will not work.\n" << "Search Paths:\n" << searchPaths;
return;
}

// use the closest matching emake file we found and launch it in a child process
qDebug() << emakeFileInfo.absoluteFilePath();
qDebug() << "Using emake exe at: " << emakeFileInfo.absolutePath();
qDebug() << "Using ENIGMA sources at: " << enigmaFileInfo.absolutePath();
process->setWorkingDirectory(emakeFileInfo.absolutePath());
QString program = emakeFileInfo.fileName();
QStringList arguments;
arguments << "--server"
<< "-e"
<< "Paths"
<< "-r"
<< "--quiet";
<< "--quiet"
<< "--enigma-root"
<< enigmaFileInfo.absolutePath();

qDebug() << "Running: " << program << " " << arguments;

process->start(program, arguments);
process->waitForStarted();
Expand Down
2 changes: 1 addition & 1 deletion Submodules/enigma-dev
Submodule enigma-dev updated 99 files
+1 −1 .travis.yml
+112 −0 CommandLine/emake/CMakeLists.txt
+1 −1 CommandLine/emake/EnigmaCallbacks.cpp
+34 −115 CommandLine/emake/EnigmaPlugin.cpp
+1 −24 CommandLine/emake/EnigmaPlugin.hpp
+15 −9 CommandLine/emake/Main.cpp
+3 −6 CommandLine/emake/Makefile
+8 −1 CommandLine/emake/OptionsParser.cpp
+2 −0 CommandLine/emake/OptionsParser.hpp
+21 −41 CommandLine/libEGM/CMakeLists.txt
+2 −2 CommandLine/libEGM/Makefile
+1 −1 CommandLine/libEGM/gmk.cpp
+3 −2 CommandLine/testing/GitHub-ImageDiff.sh
+43 −0 CompilerSource/CMakeLists.txt
+1 −1 CompilerSource/CompileEGMf.cbp
+1 −1 CompilerSource/JDI/src/API/AST.cpp
+1 −1 CompilerSource/JDI/src/API/context.cpp
+1 −1 CompilerSource/JDI/src/Storage/arg_key.cpp
+1 −1 CompilerSource/JDI/src/Storage/references.cpp
+1 −1 CompilerSource/JDI/src/System/lex_buffer.cpp
+5 −5 CompilerSource/JDI/src/System/lex_cpp.cpp
+5 −5 CompilerSource/JDI/src/System/macros.cpp
+2 −6 CompilerSource/Makefile
+2 −2 CompilerSource/backend/GameData.cpp
+3 −1 CompilerSource/compiler/compile.cpp
+32 −0 CompilerSource/enigma.h
+1 −1 CompilerSource/frontend.cpp
+1 −1 CompilerSource/gcc_interface/gcc_backend.cpp
+1 −1 CompilerSource/languages/lang_CPP.cpp
+14 −7 CompilerSource/main.cpp
+1 −1 CompilerSource/parser/object_storage.cpp
+1 −1 CompilerSource/parser/object_storage.h
+1 −1 CompilerSource/parser/parser.cpp
+1 −1 CompilerSource/parser/parser_components.cpp
+1 −1 CompilerSource/parser/parser_components.h
+5 −5 CompilerSource/settings-parse/crawler.cpp
+4 −2 CompilerSource/settings-parse/parse_ide_settings.cpp
+1 −1 CompilerSource/settings.h
+1 −1 CompilerSource/standalone_main.cpp
+3 −5 ENIGMAsystem/SHELL/Audio_Systems/DirectSound/DSsystem.cpp
+0 −24 ENIGMAsystem/SHELL/Bridges/SDL-Win32/handle.cpp
+1 −4 ENIGMAsystem/SHELL/Bridges/Win32-Direct3D11/graphics_bridge.cpp
+1 −3 ENIGMAsystem/SHELL/Bridges/Win32-Direct3D9/graphics_bridge.cpp
+5 −6 ENIGMAsystem/SHELL/Bridges/Win32/WINDOWShandle.h
+17 −8 ENIGMAsystem/SHELL/Bridges/xlib-OpenGL/graphics_bridge.cpp
+1 −0 ENIGMAsystem/SHELL/Bridges/xlib-OpenGL1/Makefile
+13 −0 ENIGMAsystem/SHELL/Bridges/xlib-OpenGL1/attribs.cpp
+1 −0 ENIGMAsystem/SHELL/Bridges/xlib-OpenGL3/Makefile
+16 −0 ENIGMAsystem/SHELL/Bridges/xlib-OpenGL3/attribs.cpp
+2 −2 ENIGMAsystem/SHELL/Graphics_Systems/OpenGLES3/std.cpp
+0 −2 ENIGMAsystem/SHELL/Makefile
+5 −0 ENIGMAsystem/SHELL/Platforms/General/PFmain.h
+0 −1 ENIGMAsystem/SHELL/Platforms/General/PFwindow.cpp
+4 −7 ENIGMAsystem/SHELL/Platforms/General/PFwindow.h
+39 −18 ENIGMAsystem/SHELL/Platforms/General/POSIX/shell.cpp
+51 −0 ENIGMAsystem/SHELL/Platforms/SDL/Android/Window.cpp
+36 −0 ENIGMAsystem/SHELL/Platforms/SDL/Cocoa/CocoaWindow.m
+62 −0 ENIGMAsystem/SHELL/Platforms/SDL/Cocoa/Window.cpp
+20 −5 ENIGMAsystem/SHELL/Platforms/SDL/Makefile
+62 −0 ENIGMAsystem/SHELL/Platforms/SDL/Win32/Window.cpp
+3 −1 ENIGMAsystem/SHELL/Platforms/SDL/Window.cpp
+1 −0 ENIGMAsystem/SHELL/Platforms/SDL/Window.h
+67 −0 ENIGMAsystem/SHELL/Platforms/SDL/xlib/Window.cpp
+0 −0 ENIGMAsystem/SHELL/Platforms/Win32/WINDOWShandle.cpp
+4 −6 ENIGMAsystem/SHELL/Platforms/Win32/WINDOWSmain.cpp
+13 −7 ENIGMAsystem/SHELL/Platforms/Win32/WINDOWSwindow.cpp
+8 −0 ENIGMAsystem/SHELL/Platforms/platforms_mandatory.h
+1 −1 ENIGMAsystem/SHELL/Platforms/xlib/XLIBicon.cpp
+21 −21 ENIGMAsystem/SHELL/Platforms/xlib/XLIBwindow.cpp
+2 −1 ENIGMAsystem/SHELL/Platforms/xlib/XLIBwindow.h
+1 −1 ENIGMAsystem/SHELL/Universal_System/Extensions/Asynchronous/About.ey
+15 −5 ENIGMAsystem/SHELL/Universal_System/Extensions/FileDropper/FileDropper.cpp
+1 −1 ENIGMAsystem/SHELL/Universal_System/Extensions/RegistrySpoof/registryspoof.cpp
+2 −2 ENIGMAsystem/SHELL/Universal_System/Extensions/libpng/Makefile
+1 −0 ENIGMAsystem/SHELL/Universal_System/Extensions/libpng/libpng-util.cpp
+0 −178 ENIGMAsystem/SHELL/Universal_System/darray.h
+6 −4 ENIGMAsystem/SHELL/Universal_System/image_formats.cpp
+1 −1 ENIGMAsystem/SHELL/Universal_System/image_formats.h
+1 −0 ENIGMAsystem/SHELL/Universal_System/rectpack.cpp
+5 −0 ENIGMAsystem/SHELL/Widget_Systems/GTK+/dialogs.cpp
+35 −5 ENIGMAsystem/SHELL/Widget_Systems/Win32/dialogs.cpp
+3 −5 ENIGMAsystem/SHELL/Widget_Systems/Win32/widgets.cpp
+2 −0 ENIGMAsystem/SHELL/Widget_Systems/widgets_mandatory.h
+4 −7 ENIGMAsystem/SHELL/Widget_Systems/xlib/Info/About.ey
+2 −0 ENIGMAsystem/SHELL/Widget_Systems/xlib/SDL/include.h
+20 −18 ENIGMAsystem/SHELL/Widget_Systems/xlib/kdialog.cpp
+20 −18 ENIGMAsystem/SHELL/Widget_Systems/xlib/zenity.cpp
+17 −12 Makefile
+1 −1 appveyor.yml
+19 −0 azure-pipelines.yml
+32 −0 shared/CMakeLists.txt
+10 −2 shared/Makefile
+0 −0 shared/darray.h
+0 −1 shared/event_reader/Makefile
+1 −1 shared/event_reader/event_parser.cpp
+0 −2 shared/eyaml/Makefile
+0 −9 shared/libpng-util/Makefile
+24 −32 shared/protos/CMakeLists.txt
+0 −1 shared/rectpacker/Makefile

0 comments on commit 94e0653

Please sign in to comment.