profile
viewpoint
Dmitry Kozhevnikov fastasturtle @JetBrains St-Petersburg, Russia CLion developer

fastasturtle/basicDemo 0

Sample project to demo basic CLion features.

fastasturtle/Catch 0

A modern, C++-native, header-only, test framework for unit-tests, TDD and BDD - using C++98, C++03, C++11, C++14 and later

fastasturtle/clion-cppcheck 0

:ballot_box_with_check: cppcheck plugin for CLion

fastasturtle/clion_bugs 0

Simple project to reproduce some CLion bugs

fastasturtle/Disk-Inventory-X 0

Fork of Disk Inventory X (http://www.derlien.com/) with the correct volume size formatting

Pull request review commentJetBrains/clion-custom-defined-compiler-examples

Tasking VX for TriCore compiler support added - script only

+output_filename = "custom-compiler-tasking-generated.yaml"+tasking_install_folder = "C:\\Program Files\\TASKING\\TriCore v6.3r1"+tasking_platform_suffix = ["51", "arm", "mcs", "pcp", "tc"]  # TriCore, ARM++c_additional_compile_switches = "--iso=99"  # example, may be empty++cpp_additional_compile_switches = "--c++=11"  # example, may be empty++import os, subprocess, tempfile, re

I'd expect imports on the top

elmot

comment created time in a month

PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentJetBrains/clion-custom-defined-compiler-examples

Tasking VX for TriCore compiler support added - script only

+output_filename = "custom-compiler-tasking-generated.yaml"+tasking_install_folder = "C:\\Program Files\\TASKING\\TriCore v6.3r1"+tasking_platform_suffix = ["51", "arm", "mcs", "pcp", "tc"]  # TriCore, ARM++c_additional_compile_switches = "--iso=99"  # example, may be empty++cpp_additional_compile_switches = "--c++=11"  # example, may be empty++import os, subprocess, tempfile, re+++def extract_defines(compiler_bin, src_name):+    result = subprocess.run([compiler_bin, "-El", src_name], stderr=subprocess.STDOUT, stdout=subprocess.PIPE)+    if result.returncode != 0:+        return None+    all_defines = result.stdout.splitlines()

I'd decode here instead of b'...': result.stdout.decode('utf-8').splitlines()

elmot

comment created time in a month

Pull request review commentJetBrains/clion-custom-defined-compiler-examples

Tasking VX for TriCore compiler support added - script only

+output_filename = "custom-compiler-tasking-generated.yaml"+tasking_install_folder = "C:\\Program Files\\TASKING\\TriCore v6.3r1"+tasking_platform_suffix = ["51", "arm", "mcs", "pcp", "tc"]  # TriCore, ARM++c_additional_compile_switches = "--iso=99"  # example, may be empty++cpp_additional_compile_switches = "--c++=11"  # example, may be empty++import os, subprocess, tempfile, re+++def extract_defines(compiler_bin, src_name):+    result = subprocess.run([compiler_bin, "-El", src_name], stderr=subprocess.STDOUT, stdout=subprocess.PIPE)+    if result.returncode != 0:+        return None+    all_defines = result.stdout.splitlines()+    filtered_defines = filter(lambda s: s.split()[1] not in [b'__FILE__', b'__LINE__', b'__DATE__', b'__TIME__', ],+                              all_defines)+    str_defines = b'\n'.join(filtered_defines).decode("ascii")+    return str_defines+++with open(output_filename, "wt") as yaml_file:+    open("__empty.c", "wt")

Something like this is probably more convenient (don't need the "finally" block), and more robust:

with tempfile.NamedTemporaryFile(suffix=".c") as fc, tempfile.NamedTemporaryFile(suffix=".cpp") as fcpp:
   .. extrat_defines(... fc.name ...)
elmot

comment created time in a month

PullRequestReviewEvent
PullRequestReviewEvent
more