Compare commits
4 Commits
6103225969
...
2.1.0
| Author | SHA1 | Date | |
|---|---|---|---|
| 4d3f2801f2 | |||
| 63c47e1f95 | |||
| bdb56768be | |||
| 8bcd70a943 |
@@ -0,0 +1,12 @@
|
|||||||
|
executable = lagueirto
|
||||||
|
source = main.cpp
|
||||||
|
|
||||||
|
windows:
|
||||||
|
@echo off
|
||||||
|
g++ $(source) -O3 -o "$(executable).exe"
|
||||||
|
|
||||||
|
macos:
|
||||||
|
clang++ $(source) -O3 -o "$(executable)"
|
||||||
|
|
||||||
|
linux:
|
||||||
|
g++ $(source) -O3 -o "$(executable)"
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
@echo off
|
||||||
|
|
||||||
|
REM Comprobar parámetro
|
||||||
|
IF "%1"=="" (
|
||||||
|
echo Uso: build_windows.bat ^<PARAMETRO^>
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
set PARAM=%1
|
||||||
|
|
||||||
|
echo Obteniendo última versión...
|
||||||
|
git pull || exit /b 1
|
||||||
|
|
||||||
|
echo Compilando windows...
|
||||||
|
g++ main.cpp -O3 -o lagueirto.exe || exit /b 1
|
||||||
|
|
||||||
|
echo Creando paquetes...
|
||||||
|
|
||||||
|
REM Crear ZIP release con mini.exe + DLLs
|
||||||
|
tar -a -c -f lagueirto_%PARAM%_win32-x64.zip lagueirto.exe || exit /b 1
|
||||||
|
|
||||||
|
echo Paquetes generados:
|
||||||
|
echo lagueirto_%PARAM%_win32-x64.zip
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
#if [ -z "$1" ]; then
|
||||||
|
# echo "Uso: $0 <PARAMETRO>"
|
||||||
|
# exit 1
|
||||||
|
#fi
|
||||||
|
|
||||||
|
# Leer versión desde version.h
|
||||||
|
VERSION=$(grep '#define LAGUEIRTO_VERSION' version.h | sed 's/.*"\(.*\)".*/\1/')
|
||||||
|
echo "Versión detectada: $VERSION"
|
||||||
|
|
||||||
|
#PARAM=$1
|
||||||
|
|
||||||
|
# Datos Windows
|
||||||
|
WIN_USER="raimon"
|
||||||
|
WIN_HOST="192.168.1.53"
|
||||||
|
WIN_PATH_SSH="C:\Users\raimon\dev\lagueirto"
|
||||||
|
WIN_PATH_SCP="C:/Users/Raimon/dev/lagueirto"
|
||||||
|
|
||||||
|
echo "=== Compilando Linux ==="
|
||||||
|
g++ main.cpp -O3 -o lagueirto
|
||||||
|
|
||||||
|
echo "=== Empaquetando Linux ==="
|
||||||
|
tar -czf lagueirto_v${VERSION}_linux.tar.gz lagueirto
|
||||||
|
|
||||||
|
echo "=== Ejecutando build remoto Windows ==="
|
||||||
|
ssh ${WIN_USER}@${WIN_HOST} "cd ${WIN_PATH_SSH} && do_release.bat v${VERSION}"
|
||||||
|
|
||||||
|
echo "=== Copiando ZIPs desde Windows ==="
|
||||||
|
scp ${WIN_USER}@${WIN_HOST}:"${WIN_PATH_SCP}/lagueirto_v${VERSION}_win32-x64.zip" .
|
||||||
|
|
||||||
|
echo "=== Build completado correctamente ==="
|
||||||
|
echo "Generados:"
|
||||||
|
echo " lagueirto_v${VERSION}_linux.tar.gz"
|
||||||
|
echo " lagueirto_v${VERSION}_win32-x64.zip"
|
||||||
+3
-4
@@ -1,5 +1,4 @@
|
|||||||
libs = -lSDL2 -lSDL2_mixer
|
cppflags = -O3
|
||||||
cppflags = -D DEBUG -g
|
executable = lagueirto
|
||||||
executable = thepool_debug
|
sourcepath = .
|
||||||
sourcepath = source
|
|
||||||
buildpath = build
|
buildpath = build
|
||||||
|
|||||||
@@ -7,8 +7,12 @@
|
|||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <thread>
|
||||||
|
#include <mutex>
|
||||||
|
#include <queue>
|
||||||
|
#include <condition_variable>
|
||||||
|
|
||||||
#define VERSION "2.0.1"
|
#include "version.h"
|
||||||
|
|
||||||
std::string libs = "";
|
std::string libs = "";
|
||||||
std::string cppflags = "";
|
std::string cppflags = "";
|
||||||
@@ -16,19 +20,23 @@ std::string executable = "out";
|
|||||||
std::string source_path = "";
|
std::string source_path = "";
|
||||||
std::vector<std::string> source_paths;
|
std::vector<std::string> source_paths;
|
||||||
std::string build_path = "";
|
std::string build_path = "";
|
||||||
|
std::string compiler = "g++";
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
std::string folder_char = "\\";
|
std::string folder_char = "\\";
|
||||||
#else
|
#else
|
||||||
std::string folder_char = "/";
|
std::string folder_char = "/";
|
||||||
#endif
|
#endif
|
||||||
|
std::string loaded_section = "";
|
||||||
|
|
||||||
std::vector<std::string> exclude;
|
std::vector<std::string> exclude;
|
||||||
std::vector<std::string> keys = {"libs", "cppflags", "executable", "sourcepath", "buildpath", "exclude"};
|
std::vector<std::string> keys = {"libs", "cppflags", "executable", "sourcepath", "buildpath", "exclude", "compiler"};
|
||||||
enum tokens {LIBS, CPPFLAGS, EXECUTABLE, SOURCEPATH, BUILDPATH, EXCLUDE};
|
enum tokens {LIBS, CPPFLAGS, EXECUTABLE, SOURCEPATH, BUILDPATH, EXCLUDE, COMPILER};
|
||||||
|
|
||||||
bool must_link = false;
|
bool must_link = false;
|
||||||
bool must_recompile_all = false;
|
bool must_recompile_all = false;
|
||||||
|
|
||||||
|
std::mutex progress_mtx;
|
||||||
|
|
||||||
struct FileInfo {
|
struct FileInfo {
|
||||||
std::string filename;
|
std::string filename;
|
||||||
std::filesystem::file_time_type time;
|
std::filesystem::file_time_type time;
|
||||||
@@ -174,7 +182,7 @@ bool loadLagueirtoFile(const std::string §ion_to_load)
|
|||||||
if (rest == "default") found_default = true;
|
if (rest == "default") found_default = true;
|
||||||
if (section_to_load.empty() && rest == "default") active = true;
|
if (section_to_load.empty() && rest == "default") active = true;
|
||||||
else active = (current_section == section_to_load);
|
else active = (current_section == section_to_load);
|
||||||
|
if (active) loaded_section = current_section;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,6 +202,7 @@ bool loadLagueirtoFile(const std::string §ion_to_load)
|
|||||||
else if (key == "sourcepath") source_path = value;
|
else if (key == "sourcepath") source_path = value;
|
||||||
else if (key == "buildpath") build_path = value;
|
else if (key == "buildpath") build_path = value;
|
||||||
else if (key == "exclude") exclude = split(value);
|
else if (key == "exclude") exclude = split(value);
|
||||||
|
else if (key == "compiler") compiler = value;
|
||||||
}
|
}
|
||||||
return !(found_any_section && section_to_load.empty() && !found_default);
|
return !(found_any_section && section_to_load.empty() && !found_default);
|
||||||
}
|
}
|
||||||
@@ -334,7 +343,7 @@ bool MustRecompile(FileInfo file) {
|
|||||||
void Recompile(std::string source_file) {
|
void Recompile(std::string source_file) {
|
||||||
std::string object_file = build_path + folder_char + std::filesystem::path(source_file).stem().string() + ".o";
|
std::string object_file = build_path + folder_char + std::filesystem::path(source_file).stem().string() + ".o";
|
||||||
must_link = true;
|
must_link = true;
|
||||||
std::string command = "g++ " + source_file + " " + cppflags + " -c -o " + object_file;
|
std::string command = compiler + " " + source_file + " " + cppflags + " -c -o " + object_file;
|
||||||
//std::cout << command << std::endl;
|
//std::cout << command << std::endl;
|
||||||
|
|
||||||
if (system(command.c_str()) != 0) {
|
if (system(command.c_str()) != 0) {
|
||||||
@@ -428,9 +437,79 @@ void processCommand(std::string arg) {
|
|||||||
if (arg == "-r") must_recompile_all = true;
|
if (arg == "-r") must_recompile_all = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void parallel_compile(int thread_count)
|
||||||
|
{
|
||||||
|
std::queue<std::string> work;
|
||||||
|
std::mutex mtx;
|
||||||
|
std::condition_variable cv;
|
||||||
|
bool done = false;
|
||||||
|
|
||||||
|
// Omplim la cua amb els arxius que necessiten recompilarse
|
||||||
|
for (auto &file : cpp_files) {
|
||||||
|
if (MustRecompile(file)) {
|
||||||
|
work.push(file.filename);
|
||||||
|
must_link = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::atomic<int> completed = 0;
|
||||||
|
int total = work.size();
|
||||||
|
progress_bar(0);
|
||||||
|
|
||||||
|
auto worker = [&]() {
|
||||||
|
while (true) {
|
||||||
|
std::string job;
|
||||||
|
|
||||||
|
// Extraure treball
|
||||||
|
{
|
||||||
|
std::unique_lock<std::mutex> lock(mtx);
|
||||||
|
cv.wait(lock, [&]() { return !work.empty() || done; });
|
||||||
|
|
||||||
|
if (work.empty()) return; // ja no hi ha res més que fer
|
||||||
|
|
||||||
|
job = work.front();
|
||||||
|
work.pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compilar
|
||||||
|
Recompile(job);
|
||||||
|
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(progress_mtx);
|
||||||
|
int done_now = ++completed;
|
||||||
|
progress_bar(100 * done_now / total);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Llançar threads
|
||||||
|
std::vector<std::thread> threads;
|
||||||
|
for (int i = 0; i < thread_count; i++)
|
||||||
|
threads.emplace_back(worker);
|
||||||
|
|
||||||
|
// Notificar als threads
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(mtx);
|
||||||
|
done = true;
|
||||||
|
}
|
||||||
|
cv.notify_all();
|
||||||
|
|
||||||
|
// Esperem a que acaben
|
||||||
|
for (auto &t : threads)
|
||||||
|
t.join();
|
||||||
|
|
||||||
|
progress_bar(100);
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
std::cout << "Lagueirto v" << VERSION << std::endl;
|
std::cout << " _ _ _ " << std::endl;
|
||||||
|
std::cout << "| | __ _ __ _ _ _ ___(_)_ __| |_ ___ " << std::endl;
|
||||||
|
std::cout << "| |/ _` |/ _` | | | |/ _ \\ | '__| __/ _ \\ " << std::endl;
|
||||||
|
std::cout << "| | (_| | (_| | |_| | __/ | | | || (_) |" << std::endl;
|
||||||
|
std::cout << "|_|\\__,_|\\__, |\\__,_|\\___|_|_| \\__\\___/ " << std::endl;
|
||||||
|
std::cout << " |___/ v" << LAGUEIRTO_VERSION << std::endl;
|
||||||
|
|
||||||
std::string configuration_to_use;
|
std::string configuration_to_use;
|
||||||
for (int i = 1; i < argc; ++i)
|
for (int i = 1; i < argc; ++i)
|
||||||
@@ -445,14 +524,29 @@ int main(int argc, char *argv[])
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string last_config_file = build_path + folder_char + "last_config";
|
||||||
|
if (!std::filesystem::exists(last_config_file)) {
|
||||||
|
must_recompile_all = true;
|
||||||
|
} else {
|
||||||
|
std::ifstream in(last_config_file);
|
||||||
|
if (in) {
|
||||||
|
std::string word;
|
||||||
|
in >> word;
|
||||||
|
if (word != loaded_section) must_recompile_all = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (must_recompile_all) {
|
if (must_recompile_all) {
|
||||||
std::cout << "remove: '" << build_path << "'" << std::endl;
|
std::cout << "remove: '" << build_path << "'" << std::endl;
|
||||||
std::filesystem::remove_all(build_path);
|
std::filesystem::remove_all(build_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!std::filesystem::is_directory(build_path)) std::filesystem::create_directory(build_path);
|
||||||
|
std::ofstream out(last_config_file);
|
||||||
|
if (out) out << loaded_section;
|
||||||
|
|
||||||
std::chrono::steady_clock::time_point begin_all = std::chrono::steady_clock::now();
|
std::chrono::steady_clock::time_point begin_all = std::chrono::steady_clock::now();
|
||||||
|
|
||||||
if (!std::filesystem::is_directory(build_path)) std::filesystem::create_directory(build_path);
|
|
||||||
source_paths = split(source_path);
|
source_paths = split(source_path);
|
||||||
|
|
||||||
// Recopilem tots els arxius cpp i capçaleres
|
// Recopilem tots els arxius cpp i capçaleres
|
||||||
@@ -517,19 +611,25 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
//print_file_tree(0, cpp_files);
|
//print_file_tree(0, cpp_files);
|
||||||
|
|
||||||
int i = 0;
|
int threads = std::thread::hardware_concurrency();
|
||||||
int total = cpp_files.size();
|
//printf("threads: %i\n", threads);
|
||||||
progress_bar(0);
|
if (threads == 0) threads = 4; // fallback
|
||||||
for (auto& file : cpp_files) {
|
|
||||||
if (MustRecompile(file)) Recompile(file.filename);
|
parallel_compile(threads);
|
||||||
progress_bar(100*float(float(i)/float(total)));
|
|
||||||
i++;
|
// int i = 0;
|
||||||
}
|
// int total = cpp_files.size();
|
||||||
progress_bar(100);
|
// progress_bar(0);
|
||||||
std::cout << std::endl;
|
// for (auto& file : cpp_files) {
|
||||||
|
// if (MustRecompile(file)) Recompile(file.filename);
|
||||||
|
// progress_bar(100*float(float(i)/float(total)));
|
||||||
|
// i++;
|
||||||
|
// }
|
||||||
|
// progress_bar(100);
|
||||||
|
// std::cout << std::endl;
|
||||||
|
|
||||||
if (must_link) {
|
if (must_link) {
|
||||||
std::string command = "g++ " + build_path + folder_char + "*.o " + libs + " -o " + executable;
|
std::string command = compiler + " " + build_path + folder_char + "*.o " + libs + " -o " + executable;
|
||||||
//std::cout << command << std::endl;
|
//std::cout << command << std::endl;
|
||||||
std::cout << "Linking..."; fflush(stdout);
|
std::cout << "Linking..."; fflush(stdout);
|
||||||
if (system(command.c_str()) != 0) {
|
if (system(command.c_str()) != 0) {
|
||||||
|
|||||||
Executable
+55
@@ -0,0 +1,55 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
#if [ -z "$1" ]; then
|
||||||
|
# echo "Uso: $0 <PARAMETRO>"
|
||||||
|
# exit 1
|
||||||
|
#fi
|
||||||
|
|
||||||
|
#GITEA_TOKEN=""
|
||||||
|
|
||||||
|
if [ -z "$GITEA_TOKEN" ]; then
|
||||||
|
echo "ERROR: Debes exportar GITEA_TOKEN"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Leer versión desde version.h
|
||||||
|
VERSION=$(grep '#define LAGUEIRTO_VERSION' version.h | sed 's/.*"\(.*\)".*/\1/')
|
||||||
|
echo "Versión detectada: $VERSION"
|
||||||
|
|
||||||
|
#PARAM=$1
|
||||||
|
API="https://gitea.sustancia.synology.me/api/v1"
|
||||||
|
REPO="JailDoctor/lagueirto"
|
||||||
|
|
||||||
|
echo "=== Creando release ${VERSION} en Gitea ==="
|
||||||
|
|
||||||
|
RELEASE_ID=$(curl -s -X POST "${API}/repos/${REPO}/releases" \
|
||||||
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{
|
||||||
|
\"tag_name\": \"${VERSION}\",
|
||||||
|
\"name\": \"Release ${VERSION}\",
|
||||||
|
\"draft\": false,
|
||||||
|
\"prerelease\": false
|
||||||
|
}" | jq -r '.id')
|
||||||
|
|
||||||
|
if [ "$RELEASE_ID" = "null" ]; then
|
||||||
|
echo "ERROR: No se pudo crear el release"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Release creado con ID: $RELEASE_ID"
|
||||||
|
|
||||||
|
echo "=== Subiendo artefactos ==="
|
||||||
|
|
||||||
|
for f in lagueirto_v${VERSION}_linux.tar.gz \
|
||||||
|
lagueirto_v${VERSION}_win32-x64.zip
|
||||||
|
do
|
||||||
|
echo "Subiendo $f..."
|
||||||
|
curl -s -X POST \
|
||||||
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
|
-F "attachment=@${f}" \
|
||||||
|
"${API}/repos/${REPO}/releases/${RELEASE_ID}/assets" > /dev/null
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "=== Publicación completada ==="
|
||||||
Reference in New Issue
Block a user