Блог пользователя slycelote

Автор slycelote, 9 лет назад, По-английски

Like CHelper for Java, caide automates certain common tasks that you do during programming competitions: parsing, running and debugging problem tests, inlining library code. It currently supports C++ and C# programming languages. The list of supported online judges is here.

Download here. You can also install VS extension directly from Visual Studio.

Documentation:

Codelite and command line caide in Linux: (full size)

Codelite in Windows: (full size)

Visual Studio:

  • Проголосовать: нравится
  • +36
  • Проголосовать: не нравится

»
9 лет назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

How to install it on Linux?

  • »
    »
    9 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Simply unpack the executable and put it in your PATH.

    • »
      »
      »
      9 лет назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      I've unpacked to many directories from PATH.

      After packing I checked using terminal;

      When I write caide in terminal as usual user, it returns

      bash: /bin/caide: Permission denied
      

      If I write as root user, it returns

      sudo: caide: command not found
      
      • »
        »
        »
        »
        9 лет назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        Make sure it's executable (sudo chmod +x /bin/caide)

      • »
        »
        »
        »
        9 лет назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        this can happen when you're trying to run 32-bit application under 64-bit system. Type ldd caide and install all the missing libraries.

»
9 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

will it work in visual studio express 2013 ?

»
9 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Added a 64-bit Linux build.

»
9 лет назад, # |
  Проголосовать: нравится +5 Проголосовать: не нравится

It seems that Caide does not work with C++11 feature =delete. Caide removes unused declaration of constructor but remains attributes of this declaration.

For example, in solution file we have

class Test {
public:
	Test(int n) : n(n) {}
private:
	Test() = delete;
	int n;
};

void solve(istream& in, ostream& out) {
	Test a(1000);
}

Caide converts it to submission.cpp:

class Test {
public:
	Test(int n) : n(n) {}
private:
	 = delete;
	int n;
};

void solve(istream& in, ostream& out) {
	Test a(1000);
}

Compiler fails on file submission.cpp with error error C2059: syntax error : '='.

Is it possible to fix it?

»
9 лет назад, # |
Rev. 3   Проголосовать: нравится +5 Проголосовать: не нравится

Another bug is removing method that is called from destructor (in case if destructor is not called explicitly).

Because the code is rather huge, I put it on Pastebin: http://pastebin.com/CRQDgguM. The first two cases are failed, the last one worked fine, but it is not convenient to write in such way during coding.

»
9 лет назад, # |
  Проголосовать: нравится +5 Проголосовать: не нравится

To continue reporting streak just want to mention strange thing (not a bug actually).

I bet lots of participants have some defines like

#ifdef _WIN32
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif

to make their code work under different environment.

Caide inliner module removes this ifdef and you need to fix you submission.cpp file manually. It is not very convenient to repeat this process every time. Is there any opportunity to tell inliner not to remove this ifdef?

  • »
    »
    9 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    There is a setting keep_macros in caide.ini file which you can use for this.

    • »
      »
      »
      9 лет назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      Hmm, it does not seem to work properly.

      I have platform-specific ifdef:

      #ifdef _WIN32
      #define LLD "%I64d"
      #else
      #define LLD "%lld"
      #endif
      

      In the submission.cpp I get the next:

      #ifdef _WIN32
      #else
      #define LLD "%lld"
      #endif
      

      Probably I am mistaken, but for me it seems that Caide removes that part of ifdef that should be choosen by compiler on my computer (so I have defined _WIN32 and this part is removed). I expected both parts to remain unchanged.

»
9 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

can i get (caide) for VS 2015 ??!

»
9 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Caide 2.1 changes:

  • Visual Studio 2015 support
  • CodeChef and Codeforces fix
  • Several improvements in C++ inliner
  • Better cross-distro compatibility for Linux builds
»
9 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

How to use it for windows ?

  • »
    »
    9 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    If you use Visual Studio, simply install VsCaide extension. If you want to use the command line application, see README

    • »
      »
      »
      9 лет назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      I am using code lite at the moment , how to install for that?

      • »
        »
        »
        »
        9 лет назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        First, make sure you use latest Codelite version. Then see "Codelite" section here. There is no plugin for Codelite, so you'll have to parse problems / switch between them from command line. The rest (compiling, running) can be done inside the IDE. Let me know if you have any questions.

»
9 лет назад, # |
  Проголосовать: нравится +8 Проголосовать: не нравится

First of all, thank you very much for this awesome tool.

Second, after the most recent update to VS2015 the following needs to be added to clang_options in caide.ini: -D__EDG__,

»
9 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

I published 2.2 release. This release contains improvements in C++ inliner. In particular, unused namespaces and comments attached to unused declarations are now removed. Make sure to have -fparse-all-comments clang option in your caide.ini file.

Note: If you use latest release of VS 2015, you need to add the clang option -D__EDG__ in your caide.ini file. Thanks to Jacob for catching this.

Also, in light of recent cin/scanf fiasco, I'd like to remind that you can configure caide to use printf/scanf, fast I/O or any other kind of I/O. All you have to do is modify the signature of solve function and make corresponding changes in 3 template files: main_template.cpp, solution_template.cpp and test_template.cpp (the last one is quite large but you're interested only in runTest function). A sample implementation for printf/scanf is here: https://github.com/slycelote/caide/tree/release/libcaide/doc/samples/cstyle-io

»
8 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Another VS update broke the extension again... A hack to fix this is to add -D__is_assignable=__is_nothrow_assignable to clang_options config entry.

»
8 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

caide version 2.3 is out with support for Visual Studio 2017 and fixes in HackerRank and CodeChef parsers.

»
8 лет назад, # |
  Проголосовать: нравится +5 Проголосовать: не нравится

Hi. I was looking for a C++ code inliner, and found this one. I built it for Mac and looks like it's working, but I have some questions.

First, I parsed some problem and manually entered the correct sample output. But after I compile and run it, it outputs

Running test case1
...correct output goes here...

Results summary
_______________
Outcome	Count
Error	1

case1: Testwasnotrun

Why error and Testwasnotrun?

The more general question is how to use it in conjunction with some IDE? It would be convenient to use CMake to create a project with one target for every problem. Is there a way to configure problemID to be just one letter, not including any contest details? And what's the expected workflow for problems that cannot be parsed?

  • »
    »
    8 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    I built it for Mac and looks like it's working

    It's surprising that it compiles out of the box, I didn't expect that :) If you could upload the Mac build somewhere, it would help other users.

    Why error and Testwasnotrun?

    That's puzzling, especially the lack of spaces. Can you send me a zip archive of your caide directory right after you do that?

    how to use it in conjunction with some IDE?

    Right now there is Codelite support, as described in the README. You still have to use terminal to switch between problems and create new ones, but the rest should be possible to do within Codelite.

    It would be convenient to use CMake

    Yes, it is in my plans, but no ETA yet. I've added a Github issue for it here

    Is there a way to configure problemID to be just one letter

    Not at the moment, I've added a Github issue here

    what's the expected workflow for problems that cannot be parsed?

    You can create a code skeleton for the problem with caide problem A, and then create in/out files manually. Checkout caide problem -h.

»
7 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Thanks for the amazing tool!
I am not able to parse tasks through CHelper in Chrome. I read many forums but all in vain. It would be great if u could explain how I can do parsing.
Thanks :)

  • »
    »
    7 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Which page are you parsing? Do you use VsCaide or command line tool? What are the error messages?

    • »
      »
      »
      7 лет назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      I tried parsing Codeforces questions but did not succeed.
      I use VsCaide and there are no error messages. It just does not parse task!!

      Also, I get the following error when I parse the problem with its URL:
      Unable to start program 'C:\Users\Dishant\Desktop\VisualSolution\cf859A\Debug\cf859A.exe'.

      I am a beginner and am pretty sure might be missing something silly!! Sorry for the trouble!

      • »
        »
        »
        »
        7 лет назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        Please send screenshots and a zipped copy of your solution's folder in a private message.

»
7 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

In the Visual Studio 2017 Community Edition i have installed VsCaide extension..... But When I build a solution it is showing build errors...... 499 errors its showing...... cmath, cerno etc....... Can you fix it ?

  • »
    »
    7 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Please make sure you installed Windows Universal CRT SDK via VS 2017 installer. If it still doesn't work, send me a zip archive of the whole directory.

    • »
      »
      »
      7 лет назад, # ^ |
      Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

      I already have installed Windows 10 SDK (10.0.15063.0) for Desktop C++ x86 and x64

      Windows 10 SDK (10.0.15063.0) for UWP: C#, VB, JS

      Windows 10 SDK (10.0.15063.0) for UWP: C++

      Windows 8.1 SDK

      but can't find the Windows Universal CRT SDK that you mentioned above....

      • »
        »
        »
        »
        7 лет назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        It's under Individual Components tab, section "Compilers, build tools and runtimes" in the installer.

»
7 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

how to solve this problem https://imgur.com/a/ur5ej ?

»
6 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

is any one here using this tool with visual studio 2017 and work with it properly, i need his help in guiding me !!

»
6 лет назад, # |
Rev. 2   Проголосовать: нравится +3 Проголосовать: не нравится

YouTube Tutorial on how to use VsCaide: https://youtu.be/qNKBdqifxpU

»
6 лет назад, # |
  Проголосовать: нравится +12 Проголосовать: не нравится

New in version 2.4:

  • Support Competitive Companion browser extension for problem parsing.
  • Better test editing GUI in VsCaide, see new screenshot (thanks to @Predelnik)
  • Autodetect latest Windows SDK in vcxproj template, removing the need to install Universal SDK (thanks to @aybassiouny)
  • Update bundled MinGW headers: in particular, fixes missing std::to_string.
  • -std=c++14 is now default, -std=c++1z is available for C++17 support
  • Bug fixes in C++ inliner
  • Improve automated detection of compilation flags when system headers are used.

Download from github here. Visual Studio extension will be published to the marketplace soon.

  • »
    »
    6 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Somehow after the update I am having troubles with creating solution in VsCaide.

    The problem I am getting is "caide.exe: g++: readCreateProcessWithExitCode: does not exist (No such file or directory)"

    • »
      »
      »
      6 лет назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится
      1. Could you try downloading the command line executable and running caide init from an empty directory?
      2. Do you have g++ in your PATH?
      • »
        »
        »
        »
        6 лет назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        Apparently g++ was in the path before, but then disappeared.

        I’ve added it back, and then everything worked again.

    • »
      »
      »
      6 лет назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      I'll publish a fix soon.

»
6 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Can you port it over to Sublime Text 3 because many competitive programmers use a lightweight ide like sublime text instead of Visual Studio

  • »
    »
    6 лет назад, # ^ |
    Rev. 3   Проголосовать: нравится 0 Проголосовать: не нравится

    I created github issues for VSCode and Sublime Text, but I don't plan to work on them (at least until I see enough interest). Please note that most functionality is implemented in a command line executable, which means that:

    1. It should be easy to create plugins for extensible editors like VSCode, Sublime Text, vim, emacs etc by wrapping calls to that executable. (In case anyone wants to give it a try...)
    2. The value of such plugins is not so big because you can do everything from command line anyway. For example, I use the following Makefile, so I can generate submission code and run tests with a single make test-debug. I also use the following config for vim-fswitch to quickly switch between sample input/output files:
    nnoremap <silent> <leader>f :FSHere<CR>
    augroup vimrc
        autocmd BufEnter *.in  let b:fswitchdst = 'out' | let b:fswitchlocs = '.'
        autocmd BufEnter *.out let b:fswitchdst = 'in'  | let b:fswitchlocs = '.'
    augroup END
    
»
6 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Fixed in version 2.4.1:

  • An issue with initialization when a c++ compiler cannot be found.
  • Visual Studio 2019 compatibility for the extension
»
6 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Awesome job, I wish I had known about this tool earlier.

I've noticed a bug where the inliner removes code which is only used inside static_assert's:

using int2 = int;                             // this line is removed in submission.cpp
static_assert(is_same<int2, int>::value, ""); // this line is kept, resulting in a compile error
  • »
    »
    6 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Thanks johannesk. I created a bug here.

    Note that there are two ways to work around bugs. You can mark a declaration with /// caide keep comment to always keep it, or you can mark a member of a class with /// caide concept comment to keep it as long as the class is used. Something like this may be an acceptable workaround:

    struct Types {
        /// caide concept
        using int2 = int;
        static_assert(is_same<int2, int>::value, "");
    };
    
    • »
      »
      »
      6 лет назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      Thanks for the quick reply slycelote. Another inlining bug, this time with friend classes:

      template <typename T> struct A {}; // this is removed
      struct B { friend class A<int>; }; // the friend declaration is kept
      int main() { B b; } // only B is referenced
      

      (yes, I'm actually writing such code o.O)

      The workaround is perfectly fine for the time being, so it's not a big deal.

      • »
        »
        »
        »
        6 лет назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        Both will be fixed in the next version. BTW, keep these bug reports coming even if there's a workaround :)

»
5 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

I am trying to use caide with CHelper browser extension. It seems that for GCJ website this coupling doesn't work. On VS General Output window I can see the following message every attempt to parse a problem:

'gcj3' not supported
  • »
    »
    5 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Yeah, CHelper extension itself doesn't parse the problem, it just passes the contents of the webpage to whatever tool is listening, so parsing has to be implemented by the tool. I recommend using Competitive Companion.

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Version 2.5.0 is released on Github. I'll upload VS extension to the marketplace in a few days.

General
  • Default Competitive Companion port changed to 10043.
  • Fixes in CodeForces and CodeChef parsers
  • Fix incorrect parameter passthrough in default Topcoder test template
C++ inliner:
  • Update all builtin headers to latest versions (libstdc++ 10.1.0, MinGW 7.0, Clang 10.0). Allows using latest language and STL features.
  • Default language setting changed to C++17 (-std=c++17).
Visual Studio extension:
  • Drop compatibility with VS 2013 and VS 2015
  • Remove deprecation warning in VS 2019
  • Fix a regression when build output would go into the root directory of the disk
  • Double-clicking a caide solution will now properly activate Caide window.
  • Slightly better look in dark mode.
  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Hi, I am using Competitive Companion in conjunction with Caide (VS extension). Normally this setup works very well, and thanks so much for maintaining the Caide tool.

    However, I recently faced an issue when parsing any problem from Facebook Hacker Cup. I am getting the following error on Caide side: Could not parse input JSON: Error in $: key "result" not found

    I am not sure if this is a problem on the Caide side or in the Competitive Companion, so I'll just report it in both threads.

    • »
      »
      »
      4 года назад, # ^ |
      Rev. 3   Проголосовать: нравится 0 Проголосовать: не нравится

      Replying here as well for visibility to slycelote:
      Competitive Companion 2.18.0 sets the input type on parsed FHC problems to "regex" and passes along a "pattern". Caide 2.5.0 doesn't support this input type, and although it is a breaking change I am going to let it stay because it improves the quality of the extracted data and because most tools already work with it (all except for Caide it seems).

      The regex input type is supposed to read input from the last modified file matching the given pattern. Example implementations can be found for C++ in JHelper here and for Java in CHelper here.

      I would contribute this myself if I knew my way around FP languages, but since I don't I hope you (slycelote) could add support for it.

    • »
      »
      »
      4 года назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      Actually, I cannot reproduce the issue. Generated code reads from stdin, but there's no error.

      • »
        »
        »
        »
        4 года назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        Is there a way to log problem JSON completely?

        • »
          »
          »
          »
          »
          4 года назад, # ^ |
            Проголосовать: нравится 0 Проголосовать: не нравится

          Competitive Companion logs it to the browser's console if debug mode is enabled in settings.

        • »
          »
          »
          »
          »
          4 года назад, # ^ |
            Проголосовать: нравится 0 Проголосовать: не нравится

          Jacob, I published a beta build here. It has code template for "regex" file type and also logs JSON in Output window (General tab). Can you try it out (in a new VS solution)?

          • »
            »
            »
            »
            »
            »
            4 года назад, # ^ |
              Проголосовать: нравится 0 Проголосовать: не нравится

            I will try it out, but not earlier than next week. Thanks.

          • »
            »
            »
            »
            »
            »
            4 года назад, # ^ |
              Проголосовать: нравится 0 Проголосовать: не нравится

            In the upsolving the issue doesn't reproduce. I'll check today during the actual round using that build with JSON logging.

          • »
            »
            »
            »
            »
            »
            4 года назад, # ^ |
              Проголосовать: нравится 0 Проголосовать: не нравится

            That build worked like a charm, thanks.

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

New in version 2.6.0:

  • Drop support for 32-bit Windows
  • Support 'regex' problem type for Competitive Companion
  • Fix CodeChef contest parser
  • Automatic check for updates in the command line application (can be disabled via config)

VS extension will be published shortly.

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

New in version 2.7.0:

  • Allow overriding problem ID when parsing
  • Display runtime per test
  • Add verbose_test_report option to display results of all tests rather than just failed ones
  • Fix hanging HTTP server on Windows
  • »
    »
    3 года назад, # ^ |
      Проголосовать: нравится +1 Проголосовать: не нравится

    VisuaL studio doesn't show running time per test... :)

    • »
      »
      »
      3 года назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      Try recreating the solution

      • »
        »
        »
        »
        3 года назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        I did it 2 times, xdd... I use vs 2019, can u upload a youtube video regarding regarding the setup and etc... Sorry for my informalities (for instance using "u"). Cuz, caide was updated and there ain't any updated tutorials...

        • »
          »
          »
          »
          »
          3 года назад, # ^ |
            Проголосовать: нравится 0 Проголосовать: не нравится

          Are any of your tests failing? By default, only details of failed tests are displayed. You can use verbose_test_report option to display details for all tests. See docs here, that page is always up to date. And the video-tutorial here should still be relevant, there haven't been many changes since then.

»
3 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Does it support Kotlin? İf can you please add it

  • »
    »
    3 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Kotlin is currently not supported. If you could port solution/test templates in this directory to Kotlin, it could increase the chances of it being included)

»
3 года назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

New in version 2.8:

  • Add warning when a template was updated both upstream and by the user
  • Display input file in main template for regex type
  • Autogenerate class constructor in C++ TopCoder template
  • Visual Studio extension:
    • Avoid VS crashes
    • Use colors (mostly) consistent with selected theme.
»
3 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Any idea why: LINK : fatal error LNK1104: cannot open file 'C:\Home\Caide2021\cpplib\Debug\cpplib.lib'

»
3 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Added support for VS 2022.

»
3 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

New in 2.10:

  • LeetCode support.
  • C++ inliner:
    • Preserve Topcoder class constructor and solution method automatically.
    • Pull all include directives to the beginning of inlined file.
  • VS extension:
    • (Regression fix) Automatically archive problem when VS project is deleted.
    • Avoid errors when trying to delete directories locked by another program (e.g. file explorer) or VS itself.
    • Minor UI improvements.
»
2 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Can I use it on mac m1 pro chip ?