Skip to content

Commit

Permalink
Maybe get windows building (#3)
Browse files Browse the repository at this point in the history
* Update main.cpp

* Update build.yml

* Update main.cpp

* Update CMakeLists.txt

* Update MainMenu.cpp

* Update main.cpp

* Update CMakeLists.txt

* Update CMakeLists.txt

* Update CMakeLists.txt

* Update CMakeLists.txt
  • Loading branch information
JustDoom authored Dec 7, 2024
1 parent aa0ffe6 commit 0108aa5
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
- name: Collect executable and assets
run: |
mkdir -p output
cp build/Release/10SecondIntern.exe output/
cp build/Release/8ChocChip.exe output/
cp -r build/Release/assets output/
- name: Upload build artifacts
Expand Down
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ project(8ChocChip
LANGUAGES CXX
VERSION 0.1)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

#file(COPY assets DESTINATION ${CMAKE_BINARY_DIR})
#
#install(DIRECTORY assets DESTINATION ${CMAKE_INSTALL_PREFIX})
Expand All @@ -15,4 +18,4 @@ foreach(ASSET ${ASSETS})
endforeach()

add_subdirectory(dependencies)
add_subdirectory(src)
add_subdirectory(src)
2 changes: 1 addition & 1 deletion dependencies/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ endif()

add_subdirectory(sfml)
add_subdirectory(nativefiledialog)
add_subdirectory(libconfig)
add_subdirectory(libconfig)
23 changes: 14 additions & 9 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
#include <filesystem>
#include <iostream>
#include <thread>
#include <vector>
#include <unordered_map>
#include <string_view>
#include <fstream>

#include "sfml/Emulator.h"
#include "fstream"

#include "util/MiscUtil.h"

#include "sfml/MainMenu.h"

#include "libconfig.hh"

int main(int argc, char **argv) {
Expand All @@ -19,7 +19,7 @@ int main(int argc, char **argv) {
std::string_view arg = argv[i];
if (arg.rfind("--") != 0) continue; // TODO: Account for --longform or -sf (short form) commands. just needs a better command handler

std::string command = MiscUtil::toLowerCase(arg);
std::string command = MiscUtil::toLowerCase(std::string(arg));
if (command == "--rom") {
if (i + 1 < argc) {
return Emulator().launch(argv[++i]);
Expand All @@ -33,7 +33,13 @@ int main(int argc, char **argv) {
}
}

std::string configFilePath = (std::filesystem::path(std::filesystem::path(getenv("HOME")).string()) / ".8chocchip.cfg").string();
auto home = std::getenv("HOME");
if (!home) {
std::cerr << "HOME environment variable not set!" << std::endl;
return 1;
}

std::string configFilePath = (std::filesystem::path(home) / ".8chocchip.cfg").string();

std::vector<std::unique_ptr<std::thread>> windows;

Expand All @@ -45,7 +51,6 @@ int main(int argc, char **argv) {
config.readFile(configFilePath);

libconfig::Setting &settings = config.getRoot();

if (!settings.exists("directories")) {
settings.add("directories", libconfig::Setting::TypeArray);
}
Expand All @@ -71,7 +76,7 @@ int main(int argc, char **argv) {
}

// Add the file path to the romFiles entry
romFiles.find(&romDirectories.back())->second.emplace_back(romFile.path());
romFiles.find(&romDirectories.back())->second.emplace_back(romFile.path().string());
}
}
} else {
Expand All @@ -92,4 +97,4 @@ int main(int argc, char **argv) {
MainMenu menu(romFiles, romDirectories, windows, configFilePath);

return 0;
}
}
4 changes: 2 additions & 2 deletions src/sfml/MainMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ MainMenu::MainMenu(std::unordered_map<std::string *, std::vector<std::string>>&
}

// Add the file path to the romFiles entry
romFiles.find(&romDirectories.back())->second.emplace_back(file.path());
romFiles.find(&romDirectories.back())->second.emplace_back(file.path().string());

TextButton romButton(0, 25 * roms.size(), this->window.getSize().x, 25, file.path().filename().string(), &font);
roms.emplace(file.path().string(), romButton);
Expand Down Expand Up @@ -174,4 +174,4 @@ MainMenu::MainMenu(std::unordered_map<std::string *, std::vector<std::string>>&
start = std::chrono::high_resolution_clock::now();
}
}
}
}

0 comments on commit 0108aa5

Please sign in to comment.