{"id":4857,"date":"2022-08-07T10:35:08","date_gmt":"2022-08-07T08:35:08","guid":{"rendered":"https:\/\/www.pschatzmann.ch\/home\/?p=4857"},"modified":"2022-08-07T11:40:12","modified_gmt":"2022-08-07T09:40:12","slug":"symlinks-and-git","status":"publish","type":"post","link":"https:\/\/www.pschatzmann.ch\/home\/2022\/08\/07\/symlinks-and-git\/","title":{"rendered":"Symlinks and Git"},"content":{"rendered":"<p>I converted some Audio C++ libraries into <strong>Arduino Libraries<\/strong> and used <strong>symlinks<\/strong> which point to the original file locations to make sure that Arduino can find all relevant files. This approach was working fine in <strong>OSX and Linux<\/strong>. Unfortunately this seems to create <strong>problems in Windows<\/strong>, so I decided to change the approach a little bit and replace the symlinks just with regular files that contain a regular <strong>#include<\/strong>.<\/p>\n<p>To convert all files manually would have been too tedious, so I used the following simple Python program.<\/p>\n<pre><code>import os\nfrom pathlib import Path\n\ndef prefix(path):\n    n = path.count(\"\/\")\n    if n==1:\n        return \"..\/\"\n    if n==2:\n        return \"..\/..\/\"\n    if n==3:\n        return \"..\/..\/..\/\"\n    if n==4:\n        return \"..\/..\/..\/..\/\"\n\ndef replace(path, newPath):\n    # delete file\n    os.unlink(path)\n    # create new file\n    content = \"#pragma once\\n\/\/ link to original location\\n#include \\\"\"+prefix(path)+newPath+\"\\\"\\n\\n\"\n    with open(path, \"w\") as text_file:\n        text_file.write(content)\n\nworking_dir = os.getcwd()+\"\/\"\nfor path, currentDirectory, files in os.walk(\"src\"):\n    for file in files:\n        p = os.path.join(path, file);\n        if (Path(p).is_symlink()):\n            linkedPath = str(os.path.realpath(p)).replace(working_dir,\"\")\n            print(p + \" -&gt;\" + linkedPath);\n            replace(p, linkedPath)\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I converted some Audio C++ libraries into Arduino Libraries and used symlinks which point to the original file locations to make sure that Arduino can find all relevant files. This approach was working fine in OSX and Linux. Unfortunately this seems to create problems in Windows, so I decided to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1192,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[20],"tags":[],"class_list":["post-4857","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-arduino"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Symlinks and Git - Phil Schatzmann<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.pschatzmann.ch\/home\/2022\/08\/07\/symlinks-and-git\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Symlinks and Git - Phil Schatzmann\" \/>\n<meta property=\"og:description\" content=\"I converted some Audio C++ libraries into Arduino Libraries and used symlinks which point to the original file locations to make sure that Arduino can find all relevant files. This approach was working fine in OSX and Linux. Unfortunately this seems to create problems in Windows, so I decided to [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pschatzmann.ch\/home\/2022\/08\/07\/symlinks-and-git\/\" \/>\n<meta property=\"og:site_name\" content=\"Phil Schatzmann\" \/>\n<meta property=\"article:published_time\" content=\"2022-08-07T08:35:08+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-08-07T09:40:12+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2020\/03\/github.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"720\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"pschatzmann\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"pschatzmann\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/08\\\/07\\\/symlinks-and-git\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/08\\\/07\\\/symlinks-and-git\\\/\"},\"author\":{\"name\":\"pschatzmann\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\"},\"headline\":\"Symlinks and Git\",\"datePublished\":\"2022-08-07T08:35:08+00:00\",\"dateModified\":\"2022-08-07T09:40:12+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/08\\\/07\\\/symlinks-and-git\\\/\"},\"wordCount\":90,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\"},\"image\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/08\\\/07\\\/symlinks-and-git\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/github.jpg\",\"articleSection\":[\"Arduino\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/08\\\/07\\\/symlinks-and-git\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/08\\\/07\\\/symlinks-and-git\\\/\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/08\\\/07\\\/symlinks-and-git\\\/\",\"name\":\"Symlinks and Git - Phil Schatzmann\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/08\\\/07\\\/symlinks-and-git\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/08\\\/07\\\/symlinks-and-git\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/github.jpg\",\"datePublished\":\"2022-08-07T08:35:08+00:00\",\"dateModified\":\"2022-08-07T09:40:12+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/08\\\/07\\\/symlinks-and-git\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/08\\\/07\\\/symlinks-and-git\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/08\\\/07\\\/symlinks-and-git\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/github.jpg\",\"contentUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/github.jpg\",\"width\":1280,\"height\":720},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/08\\\/07\\\/symlinks-and-git\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Symlinks and Git\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#website\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/\",\"name\":\"Phil Schatzmann Consulting\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\",\"name\":\"pschatzmann\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/pschatzmann.png\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/pschatzmann.png\",\"contentUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/pschatzmann.png\",\"width\":305,\"height\":305,\"caption\":\"pschatzmann\"},\"logo\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/pschatzmann.png\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Symlinks and Git - Phil Schatzmann","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.pschatzmann.ch\/home\/2022\/08\/07\/symlinks-and-git\/","og_locale":"en_US","og_type":"article","og_title":"Symlinks and Git - Phil Schatzmann","og_description":"I converted some Audio C++ libraries into Arduino Libraries and used symlinks which point to the original file locations to make sure that Arduino can find all relevant files. This approach was working fine in OSX and Linux. Unfortunately this seems to create problems in Windows, so I decided to [&hellip;]","og_url":"https:\/\/www.pschatzmann.ch\/home\/2022\/08\/07\/symlinks-and-git\/","og_site_name":"Phil Schatzmann","article_published_time":"2022-08-07T08:35:08+00:00","article_modified_time":"2022-08-07T09:40:12+00:00","og_image":[{"width":1280,"height":720,"url":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2020\/03\/github.jpg","type":"image\/jpeg"}],"author":"pschatzmann","twitter_card":"summary_large_image","twitter_misc":{"Written by":"pschatzmann","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/08\/07\/symlinks-and-git\/#article","isPartOf":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/08\/07\/symlinks-and-git\/"},"author":{"name":"pschatzmann","@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1"},"headline":"Symlinks and Git","datePublished":"2022-08-07T08:35:08+00:00","dateModified":"2022-08-07T09:40:12+00:00","mainEntityOfPage":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/08\/07\/symlinks-and-git\/"},"wordCount":90,"commentCount":0,"publisher":{"@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1"},"image":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/08\/07\/symlinks-and-git\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2020\/03\/github.jpg","articleSection":["Arduino"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.pschatzmann.ch\/home\/2022\/08\/07\/symlinks-and-git\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/08\/07\/symlinks-and-git\/","url":"https:\/\/www.pschatzmann.ch\/home\/2022\/08\/07\/symlinks-and-git\/","name":"Symlinks and Git - Phil Schatzmann","isPartOf":{"@id":"https:\/\/www.pschatzmann.ch\/home\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/08\/07\/symlinks-and-git\/#primaryimage"},"image":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/08\/07\/symlinks-and-git\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2020\/03\/github.jpg","datePublished":"2022-08-07T08:35:08+00:00","dateModified":"2022-08-07T09:40:12+00:00","breadcrumb":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/08\/07\/symlinks-and-git\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pschatzmann.ch\/home\/2022\/08\/07\/symlinks-and-git\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/08\/07\/symlinks-and-git\/#primaryimage","url":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2020\/03\/github.jpg","contentUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2020\/03\/github.jpg","width":1280,"height":720},{"@type":"BreadcrumbList","@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/08\/07\/symlinks-and-git\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pschatzmann.ch\/home\/"},{"@type":"ListItem","position":2,"name":"Symlinks and Git"}]},{"@type":"WebSite","@id":"https:\/\/www.pschatzmann.ch\/home\/#website","url":"https:\/\/www.pschatzmann.ch\/home\/","name":"Phil Schatzmann Consulting","description":"","publisher":{"@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.pschatzmann.ch\/home\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1","name":"pschatzmann","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/08\/pschatzmann.png","url":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/08\/pschatzmann.png","contentUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/08\/pschatzmann.png","width":305,"height":305,"caption":"pschatzmann"},"logo":{"@id":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/08\/pschatzmann.png"}}]}},"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts\/4857","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/comments?post=4857"}],"version-history":[{"count":7,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts\/4857\/revisions"}],"predecessor-version":[{"id":4864,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts\/4857\/revisions\/4864"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/media\/1192"}],"wp:attachment":[{"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/media?parent=4857"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/categories?post=4857"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/tags?post=4857"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}