diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..b35a8f1 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "ceevlang"] + path = ceevlang + url = https://sauce.nxi.no/dahrub/ceevlang.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 0528c6f..276a7c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,8 +18,19 @@ execute_process( set(CMAKE_CXX_STANDARD 17) find_package(SDL2 REQUIRED) include_directories(${SDL2_INCLUDE_DIRS}) -add_executable(ceev src/ceev.cc src/ceev.h src/colors.cc src/colors.h) -target_link_libraries(ceev ${SDL2_LIBRARIES}) + +# Global lib config +add_executable(${PROJECT_NAME} src/ceev.cc src/ceev.h) +find_package(ceev REQUIRED) +include_directories(${ceev_INCLUDE_DIRS}) +target_link_libraries(${PROJECT_NAME} ${ceev_LIBRARIES}) +#endconfig + +# Local lib config +# add_executable(${PROJECT_NAME} src/ceev.cc src/ceev.h src/colors.cc src/colors.h) +# endconfig + +target_link_libraries(${PROJECT_NAME} ${SDL2_LIBRARIES}) target_compile_definitions(${PROJECT_NAME} PRIVATE "-DGIT_COMMIT_HASH=\"${GIT_COMMIT_HASH}\"") @@ -28,3 +39,5 @@ string(REPLACE "\n" "\\n" GIT_COMMIT_MSG "${GIT_COMMIT_MSG}") target_compile_definitions(${PROJECT_NAME} PRIVATE "-DGIT_COMMIT_MSG=\"${GIT_COMMIT_MSG}\"") + +install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) diff --git a/ceevlang b/ceevlang new file mode 160000 index 0000000..b8d5dd5 --- /dev/null +++ b/ceevlang @@ -0,0 +1 @@ +Subproject commit b8d5dd56730f7f8465e418a39a1c31d1fa67daac diff --git a/src/ceev.cc b/src/ceev.cc index c21b16b..9af90bc 100644 --- a/src/ceev.cc +++ b/src/ceev.cc @@ -1,5 +1,4 @@ #include "ceev.h" - int usage() { std::cout << "Usage:"; std::cout << "\n\t"; @@ -82,14 +81,16 @@ static std::string query_author() { return author; } -struct config_data get_config() { +struct config_data get_config(bool ignore_err = false) { fs::path config_path = fs::current_path(); std::string line; struct config_data data; std::ifstream config(config_path / ".ceev" / CONFIG_FILENAME); if (!config) { - std::cerr << bg_red(bold("ERROR")) << ": Could not open config\n"; - std::cerr << "Run `ceev init' to create a new project." << std::endl; + if (!ignore_err) { + std::cerr << bg_red(bold("ERROR")) << ": Could not open config\n"; + std::cerr << "Run `ceev init' to create a new project." << std::endl; + } return data; } while (std::getline(config, line)) { @@ -190,6 +191,8 @@ int devel(std::deque args) { return devel_roadmap(); if (a1 == "sdl2") return devel_sdl2(args); + if (a1 == "lang") + return 1; std::string kw; if (a1.substr(0, 2) == "--") { @@ -222,13 +225,15 @@ int devel_help() { std::cout << "Get info about the latest commit."; // ceev devel sdl2 std::cout << "\n*\t"; - std::cout << GET_PROGRAM_NAME() << " devel " << cyan("sdl2") << "\n"; + std::cout << GET_PROGRAM_NAME() << " devel " << cyan("sdl2") << " <" + << bright_green("--use-defaults") << "/" << bright_green("-D") + << ">\n"; std::cout << "\t\t"; std::cout << "Tests of SDL2"; // ceev devel --help std::cout << "\n*\t"; - std::cout << GET_PROGRAM_NAME() << " devel " << cyan("--help") << "/" - << cyan("-h") << "\n"; + std::cout << GET_PROGRAM_NAME() << " devel " << bright_green("--help") << "/" + << bright_green("-h") << "\n"; std::cout << "\t\t"; std::cout << "This help page."; std::cout << std::endl; @@ -256,24 +261,30 @@ int devel_roadmap() { return 0; } int devel_sdl2(std::deque args) { - struct config_data data = get_config(); - if (data.name == "" && - (args.empty() || args[0] != "--use-defaults" || args[0] != "-D")) { + struct config_data data; + if (!args.empty() && (args[0] == "--use-defaults" || args[0] == "-D")) { + data.name = "CeeV"; + data.version = __ceev_version; + data.author = "User"; + data.email = "user@example.org"; + } else + data = get_config(); + if (data.name == "") return 1; - } const int SCREEN_WIDTH = 640; const int SCREEN_HEIGHT = 480; SDL_Window *window = nullptr; SDL_Surface *screen_surface = nullptr; SDL_Surface *img_surface = nullptr; - return 0; if (SDL_Init(SDL_INIT_VIDEO) < 0) { std::cerr << bg_red(bold("ERROR")) << ": SDL could not initialize! SDL_Error: " << SDL_GetError() << std::endl; return 1; } - window = SDL_CreateWindow(data.name.c_str(), SDL_WINDOWPOS_UNDEFINED, + std::string name = data.name + " version " + data.version + " by " + + data.author + " <" + data.email + ">"; + window = SDL_CreateWindow(name.c_str(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN); if (window == nullptr) { @@ -311,9 +322,6 @@ int main(int argc, char **argv) { for (int i = 1; i < argc; i++) args.push_back(std::string(argv[i])); std::string a1 = std::string(args[0]); - // XXX: Is this really needed? - std::transform(a1.begin(), a1.end(), a1.begin(), - [](unsigned char c) { return std::tolower(c); }); args.pop_front(); if (a1 == "init") { return create_fs(args); @@ -335,8 +343,6 @@ int main(int argc, char **argv) { return show_help(); } if (a1.substr(0, 1) == "-") { - // TODO: Although not yet needed, add support for multiparams, like `ceev - // -hv' True, that doesn't make sense, that's why it's not yet needed. kw = a1.substr(1); if (kw == "v") return show_version(); diff --git a/src/ceev.h b/src/ceev.h index f368b7b..aeb2c10 100644 --- a/src/ceev.h +++ b/src/ceev.h @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -10,7 +11,7 @@ #include #include -#include "colors.h" +/* #include "colors.h" */ #ifndef __ceev_version #define __ceev_version "0.1.1-devel" @@ -32,7 +33,6 @@ #ifdef __GLIBC__ #define GET_PROGRAM_NAME() program_invocation_short_name #else -#include #define GET_PROGRAM_NAME() getprogname() #endif diff --git a/src/colors.cc b/src/colors.cc deleted file mode 100644 index 14616db..0000000 --- a/src/colors.cc +++ /dev/null @@ -1,37 +0,0 @@ -#include "colors.h" - -std::string black(std::string input) {return "\x1b[30m" + input + "\x1b[0m";} -std::string red(std::string input) {return "\x1b[31m" + input + "\x1b[0m";} -std::string green(std::string input) {return "\x1b[32m" + input + "\x1b[0m";} -std::string yellow(std::string input) {return "\x1b[33m" + input + "\x1b[0m";} -std::string blue(std::string input) {return "\x1b[34m" + input + "\x1b[0m";} -std::string magenta(std::string input) {return "\x1b[35m" + input + "\x1b[0m";} -std::string cyan(std::string input) {return "\x1b[36m" + input + "\x1b[0m";} -std::string white(std::string input) {return "\x1b[37m" + input + "\x1b[0m";} -std::string bright_black(std::string input) {return "\x1b[90m" + input + "\x1b[0m";} -std::string bright_red(std::string input) {return "\x1b[91m" + input + "\x1b[0m";} -std::string bright_green(std::string input) {return "\x1b[92m" + input + "\x1b[0m";} -std::string bright_yellow(std::string input) {return "\x1b[93m" + input + "\x1b[0m";} -std::string bright_blue(std::string input) {return "\x1b[94m" + input + "\x1b[0m";} -std::string bright_magenta(std::string input) {return "\x1b[95m" + input + "\x1b[0m";} -std::string bright_cyan(std::string input) {return "\x1b[96m" + input + "\x1b[0m";} -std::string bright_white(std::string input) {return "\x1b[97m" + input + "\x1b[0m";} -std::string bg_black(std::string input) {return "\x1b[40m" + input + "\x1b[0m";} -std::string bg_red(std::string input) {return "\x1b[41m" + input + "\x1b[0m";} -std::string bg_green(std::string input) {return "\x1b[42m" + input + "\x1b[0m";} -std::string bg_yellow(std::string input) {return "\x1b[43m" + input + "\x1b[0m";} -std::string bg_blue(std::string input) {return "\x1b[44m" + input + "\x1b[0m";} -std::string bg_magenta(std::string input) {return "\x1b[45m" + input + "\x1b[0m";} -std::string bg_cyan(std::string input) {return "\x1b[46m" + input + "\x1b[0m";} -std::string bg_white(std::string input) {return "\x1b[47m" + input + "\x1b[0m";} -std::string bg_bright_black(std::string input) {return "\x1b[100m" + input + "\x1b[0m";} -std::string bg_bright_red(std::string input) {return "\x1b[101m" + input + "\x1b[0m";} -std::string bg_bright_green(std::string input) {return "\x1b[102m" + input + "\x1b[0m";} -std::string bg_bright_yellow(std::string input) {return "\x1b[103m" + input + "\x1b[0m";} -std::string bg_bright_blue(std::string input) {return "\x1b[104m" + input + "\x1b[0m";} -std::string bg_bright_magenta(std::string input) {return "\x1b[105m" + input + "\x1b[0m";} -std::string bg_bright_cyan(std::string input) {return "\x1b[106m" + input + "\x1b[0m";} -std::string bg_bright_white(std::string input) {return "\x1b[107m" + input + "\x1b[0m";} -std::string bold(std::string input) {return "\x1b[1m" + input + "\x1b[0m";} -std::string underline(std::string input) {return "\x1b[4m" + input + "\x1b[0m";} -std::string reverse(std::string input) {return "\x1b[7m" + input + "\x1b[0m";} \ No newline at end of file diff --git a/src/colors.h b/src/colors.h deleted file mode 100644 index d177240..0000000 --- a/src/colors.h +++ /dev/null @@ -1,39 +0,0 @@ -#pragma once - -#include - -std::string black(std::string input); -std::string red(std::string input); -std::string green(std::string input); -std::string yellow(std::string input); -std::string blue(std::string input); -std::string magenta(std::string input); -std::string cyan(std::string input); -std::string white(std::string input); -std::string bright_black(std::string input); -std::string bright_red(std::string input); -std::string bright_green(std::string input); -std::string bright_yellow(std::string input); -std::string bright_blue(std::string input); -std::string bright_magenta(std::string input); -std::string bright_cyan(std::string input); -std::string bright_white(std::string input); -std::string bg_black(std::string input); -std::string bg_red(std::string input); -std::string bg_green(std::string input); -std::string bg_yellow(std::string input); -std::string bg_blue(std::string input); -std::string bg_magenta(std::string input); -std::string bg_cyan(std::string input); -std::string bg_white(std::string input); -std::string bg_bright_black(std::string input); -std::string bg_bright_red(std::string input); -std::string bg_bright_green(std::string input); -std::string bg_bright_yellow(std::string input); -std::string bg_bright_blue(std::string input); -std::string bg_bright_magenta(std::string input); -std::string bg_bright_cyan(std::string input); -std::string bg_bright_white(std::string input); -std::string bold(std::string input); -std::string underline(std::string input); -std::string reverse(std::string input); \ No newline at end of file