Giter Site home page Giter Site logo

wsjcpp-core's Introduction

wsjcpp

Build Status License: MIT Docker Pulls Github Stars Github Stars Github Forks Total alerts Language grade: C/C++ deepcode

Yet another... C++ Source Package Manager

Official site: https://wsjcpp.org/

Get for work

Use a docker

Docker:

$ docker pull sea5kg/wsjcpp:latest
$ docker run -it --rm \
    -v `pwd`/.:/root/project \
    sea5kg/wsjcpp:latest \
    bash
root@8b93098b8a07:~/project#

Now you can call wsjcpp inside a container For exit, just enter exit command after this container will be destroed.

Install to MacOS

$ brew tap wsjcpp/wsjcpp
$ brew install wsjcpp

Install on Ubuntu from ppa

$ sudo add-apt-repository ppa:sea5kg/wsjcpp
$ sudo apt-get update
$ sudo apt-get install wsjcpp

Build and install in Ubuntu/Debian

$ sudo apt install cmake make g++ pkg-config libcurl4-openssl-dev git-core
$ git clone https://github.com/wsjcpp/wsjcpp /tmp/wsjcpp.git
$ cd /tmp/wsjcpp.git
$ ./build_simple.sh
$ sudo cp -r /tmp/wsjcpp.git /bin/wsjcpp

More package managers for c++

Here

Basic usage

Init new project / package

Inside with your folder project

$ wsjcpp init .
$ chmod +x build_simple.sh
$ chmod +x unit-tests.wsjcpp/build_simple.sh

If you already have a project and want integrate to you project please look here: TODO

On this step will be generated different files, like (only if files not exists):

  • src.wsjcpp/CMakeLists.txt
  • src.wsjcpp/wsjcpp_core/* <- sample of package (core always required)
  • unit-tests.wsjcpp/* <- folder for unit-tests
  • src/main.cpp
  • .wsjcpp/* <- temporary folder
  • CMakeLists.txt
  • build_simple.sh
  • .gitignore
  • ...

Install packages

You can find on github package what a need you here (for example) https://github.com/topics/wsjcpp

And next command you can install package:

$ wsjcpp install https://github.com/wsjcpp/wsjcpp-print-tree:master

Also you can change 'master' to specific version or branch

After downloading wsjcpp will be automaticly update file: src.wsjcpp/CMakeLists.txt

Upgrade package

$ wsjcpp list 

  Dependencies: 
  * 'wsjcpp-core:v0.0.8' (https://github.com/wsjcpp/wsjcpp-core:master -> ./src.wsjcpp/wsjcpp_core)
  * 'wsjcpp-print-tree:v0.0.1' (https://github.com/wsjcpp/wsjcpp-print-tree:master -> ./src.wsjcpp/wsjcpp_print_tree)

$ wsjcpp reinstall wsjcpp-print-tree

Uninstall package

$ wsjcpp uninstall https://github.com/wsjcpp/wsjcpp-print-tree:master

Unit-tests

Create a new unit-test

$ wsjcpp unit-tests create SomeTest "Tesing some"

Will be created new files:

  • unit-tests.wsjcpp/src/unit_test_init_package.h
  • unit-tests.wsjcpp/src/unit_test_init_package.cpp

Also will be automaticly updated unit-tests.wsjcpp/CMakeLists.txt

For build and run unit-tests:

$ cd unit-tests.wsjcpp
$ ./build_simple.sh
$ ./unit-tests

P.S. For testing you package - you need define distribution files (for automaticly include to unit-tests.wsjcpp/CMakeLists.txt)

Specify distribution files from your package for uses your package

Add to distribution

$ wsjcpp distribution add src/your_source_file.h
$ wsjcpp distribution add src/your_source_file.cpp

Will be updated section 'distribution' in wsjcpp.yml

distribution:
  - source-file: "src/your_source_file.h"
    target-file: "your_source_file.h"
    type: "source-code"
  - source-file: "src/your_source_file.cpp"
    target-file: "your_source_file.cpp"
    type: "source-code"

Remove from distribution

$ wsjcpp distribution remove src/your_source_file.cpp

Manual changed wsjcpp.yml

For update automaticly generated files:

$ wsjcpp update

For building

wsjcpp prepare file 'build_simple.sh' for easy building

$ ./build_simple.sh

Build docker image

$ docker build -t sea5kg/wsjcpp:latest .

wsjcpp-core's People

Contributors

keimashikai avatar sea-kg avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

wsjcpp-core's Issues

Rename currentTime_milliseconds to getCurrentTimeMilliseconds

  • Rename currentTime_milliseconds to getCurrentTimeInMilliseconds
  • Rename currentTime_seconds to getCurrentTimeInSeconds
  • Rename currentTime_forFilename to getCurrentTimeForFilename
  • Rename currentTime_logformat to getCurrentTimeWothLogFormat
  • Rename threadId to getThreadId

Add setFilePermissions(filename) and getFilePermissions(filename);

Ex.

#include <sys/stat.h>
#include <stdio.h>

if (chmod(sNewFilepath.c_str(), S_IRWXU|S_IRWXG) != 0) {
    std::cout << "ERROR. Could not change permissions for. " << std::endl;
} else {
    struct stat info;
    stat(sNewFilepath.c_str(), &info);
    printf("after chmod(), permissions are: %08x\n", info.st_mode);
}

UnitTests: improve compare counter

  1. If never call method compare - so test is failed - test must call once or more 'compare'
  2. print compare counter like
[OK] UnitTestYamlParserComments: Test passed (compares: 30).

Improve commands for unit-tests

must be also short

Now:

Help:
 './unit-tests' - run all unit-tests
 './unit-tests help' - print this help
 './unit-tests list' - print list of unit-tests
 './unit-tests run <TestName>' - run single unit-test

Improve to:

Help:
 './unit-tests' - run all unit-tests
 './unit-tests --help|h' - print this help
 './unit-tests --version|v' - print this help
 './unit-tests list|ls' - print list of unit-tests
 './unit-tests run|r <TestName>' - run single unit-test

Add new 'extractDirpath'

Something like this:

std::string sDir = sFileTo.substr(0, sFileTo.length() - WsjcppCore::extractFilename(sFileTo).length());

Implement getEnv

Must use std::getenv

bool getEnv(const std::string &sName, std::string &sValue);

Redesign for unit-tests

bool bTestSuccess = true;

TestResult testResult;
testResult.failed("reason"); 
  1. To some nice object which can change state only to false no more for example struct
  2. Define this object in constructor of class WsjcppUnitTestBase
  3. remove from compare
  4. Add template compareT("sowhat", const T &aleft, const T &aright);
  5. from method run remove 'return' users must use TestSuccess Object for results
  6. add method getResult

New function convertCammelCaseToSnakCase

// ---------------------------------------------------------------------
std::string WsjcppPackageManager::normalizeUnitTestName(const std::string &sUnitTestName, bool bSilent) {
    std::string sRet = ""; 
    for (int i = 0; i < sUnitTestName.size(); i++) {
        char c = sUnitTestName[i];
        if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9')) {
            sRet += c;
        } else {
            if (!bSilent) {
                WsjcppLog::warn(TAG, std::string("Ignored symbol in UnitTest Name '") + c + "'");
            }
        }
    }
    return sRet;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.