|
|
|
@ -519,7 +519,7 @@
|
|
|
|
|
" my_compiler = [\"Windows\", \"GCC\", [\"cmd\", \"/c\", \"gcc\", f\"{filename_base}.cpp\"]]\n", |
|
|
|
|
"\n", |
|
|
|
|
" if not my_compiler:\n", |
|
|
|
|
" my_compiler=[my_platform, \"Unknown\", []]\n", |
|
|
|
|
" my_compiler=[my_platform, \"Unavailable\", []]\n", |
|
|
|
|
" \n", |
|
|
|
|
" elif my_platform == \"Linux\":\n", |
|
|
|
|
" if os.path.isfile(\"./simple\"):\n", |
|
|
|
@ -538,7 +538,7 @@
|
|
|
|
|
" my_compiler = [\"Linux\", \"CLang\", [\"clang\", f\"{filename_base}.cpp\", \"-o\", f\"{filename_base}\"]]\n", |
|
|
|
|
" \n", |
|
|
|
|
" if not my_compiler:\n", |
|
|
|
|
" my_compiler=[my_platform, \"Unknown\", []]\n", |
|
|
|
|
" my_compiler=[my_platform, \"Unavailable\", []]\n", |
|
|
|
|
"\n", |
|
|
|
|
" elif my_platform == \"Darwin\":\n", |
|
|
|
|
" if os.path.isfile(\"./simple\"):\n", |
|
|
|
@ -549,12 +549,12 @@
|
|
|
|
|
" my_compiler = [\"Linux\", \"CLang\", [\"clang++\", \"-Ofast\", \"-std=c++17\", \"-march=armv8.5-a\", \"-mtune=apple-m1\", \"-mcpu=apple-m1\", \"-o\", f\"{filename_base}\", f\"{filename_base}.cpp\"]]\n", |
|
|
|
|
"\n", |
|
|
|
|
" if not my_compiler:\n", |
|
|
|
|
" my_compiler=[my_platform, \"Unknown\", []]\n", |
|
|
|
|
" my_compiler=[my_platform, \"Unavailable\", []]\n", |
|
|
|
|
"\n", |
|
|
|
|
" if my_compiler:\n", |
|
|
|
|
" return my_compiler\n", |
|
|
|
|
" else:\n", |
|
|
|
|
" return [\"Unknown\", \"Unknown\", []]\n" |
|
|
|
|
" return [\"Unknown\", \"Unavailable\", []]\n" |
|
|
|
|
] |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
@ -576,14 +576,13 @@
|
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
"cell_type": "code", |
|
|
|
|
"execution_count": null, |
|
|
|
|
"execution_count": 107, |
|
|
|
|
"id": "77f3ab5d-fcfb-4d3f-8728-9cacbf833ea6", |
|
|
|
|
"metadata": {}, |
|
|
|
|
"outputs": [], |
|
|
|
|
"source": [ |
|
|
|
|
"def execute_cpp(code):\n", |
|
|
|
|
" write_output(code)\n", |
|
|
|
|
" print(f\"DEBUG. execute_cpp. compiler_cmd[2]=\\\"{compiler_cmd[2]}\\\"\")\n", |
|
|
|
|
" try:\n", |
|
|
|
|
" compile_result = subprocess.run(compiler_cmd[2], check=True, text=True, capture_output=True)\n", |
|
|
|
|
" run_cmd = [\"./optimized\"]\n", |
|
|
|
@ -786,7 +785,10 @@
|
|
|
|
|
" convert = gr.Button(\"Convert code\")\n", |
|
|
|
|
" with gr.Row():\n", |
|
|
|
|
" python_run = gr.Button(\"Run Python\")\n", |
|
|
|
|
" cpp_run = gr.Button(\"Run C++\")\n", |
|
|
|
|
" if not compiler_cmd[1] == \"Unavailable\":\n", |
|
|
|
|
" cpp_run = gr.Button(\"Run C++\")\n", |
|
|
|
|
" else:\n", |
|
|
|
|
" cpp_run = gr.Button(\"No compiler to run C++\", interactive=False)\n", |
|
|
|
|
" with gr.Row():\n", |
|
|
|
|
" python_out = gr.TextArea(label=\"Python result:\", elem_classes=[\"python\"])\n", |
|
|
|
|
" cpp_out = gr.TextArea(label=\"C++ result:\", elem_classes=[\"cpp\"])\n", |
|
|
|
|