[{"data":1,"prerenderedAt":328},["Reactive",2],{"content-query-Cnh35jouAT":3},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"body":10,"_type":323,"_id":324,"_source":325,"_file":326,"_extension":327},"/docs/dev/shader-sdk-mac","dev",false,"","Shader SDK (MAC)","In this tutorial we will show how to setup Beam Shader SDK on Mac OS",{"type":11,"children":12,"toc":315},"root",[13,21,26,43,50,55,60,70,75,80,91,96,105,111,139,148,153,158,171,177,185,190,199,208,219,224,233,242,250,259,266,271,277,282,291,296,305,310],{"type":14,"tag":15,"props":16,"children":18},"element","h1",{"id":17},"shader-sdk-mac",[19],{"type":20,"value":8},"text",{"type":14,"tag":22,"props":23,"children":24},"p",{},[25],{"type":20,"value":9},{"type":14,"tag":22,"props":27,"children":28},{},[29,31,41],{"type":20,"value":30},"The Shader SDK's current version can be characterized as an ",{"type":14,"tag":32,"props":33,"children":34},"em",{},[35],{"type":14,"tag":36,"props":37,"children":38},"strong",{},[39],{"type":20,"value":40},"early developer preview",{"type":20,"value":42},", with a high possibility of encountering unusual issues and bugs.",{"type":14,"tag":44,"props":45,"children":47},"h3",{"id":46},"prerequisites",[48],{"type":20,"value":49},"Prerequisites",{"type":14,"tag":22,"props":51,"children":52},{},[53],{"type":20,"value":54},"You will  need a Python 3.x installed and available in the path (check by typing 'python' in the command line)",{"type":14,"tag":22,"props":56,"children":57},{},[58],{"type":20,"value":59},"In addition, you will need XCode Command line tools. The command to install those is:",{"type":14,"tag":22,"props":61,"children":62},{},[63],{"type":14,"tag":64,"props":65,"children":67},"code",{"className":66},[],[68],{"type":20,"value":69},"xcode-select --install",{"type":14,"tag":22,"props":71,"children":72},{},[73],{"type":20,"value":74},"But please consult with official documentation for more details.",{"type":14,"tag":22,"props":76,"children":77},{},[78],{"type":20,"value":79},"You will also need the following packages (I used brew to install those):",{"type":14,"tag":22,"props":81,"children":82},{},[83,89],{"type":14,"tag":64,"props":84,"children":86},{"className":85},[],[87],{"type":20,"value":88},"brew install openssl cmake ninja",{"type":20,"value":90},"\\",{"type":14,"tag":22,"props":92,"children":93},{},[94],{"type":20,"value":95},"Also, set the OPENSSL_ROOT_DIR environment variable as follows:",{"type":14,"tag":22,"props":97,"children":98},{},[99],{"type":14,"tag":64,"props":100,"children":102},{"className":101},[],[103],{"type":20,"value":104},"export OPENSSL_ROOT_DIR=\"/usr/local/opt/openssl@1.1\"",{"type":14,"tag":44,"props":106,"children":108},{"id":107},"building-shader-sdk",[109],{"type":20,"value":110},"Building Shader SDK",{"type":14,"tag":112,"props":113,"children":114},"ol",{},[115,129,134],{"type":14,"tag":116,"props":117,"children":118},"li",{},[119,121],{"type":20,"value":120},"Clone Shader SDK repository from here: ",{"type":14,"tag":122,"props":123,"children":127},"a",{"href":124,"rel":125},"https://github.com/BeamMW/shader-sdk",[126],"nofollow",[128],{"type":20,"value":124},{"type":14,"tag":116,"props":130,"children":131},{},[132],{"type":20,"value":133},"Open the Terminal application",{"type":14,"tag":116,"props":135,"children":136},{},[137],{"type":20,"value":138},"Change directory to the location of the shader-sdk and run:",{"type":14,"tag":22,"props":140,"children":141},{},[142],{"type":14,"tag":64,"props":143,"children":145},{"className":144},[],[146],{"type":20,"value":147},"./shade init",{"type":14,"tag":22,"props":149,"children":150},{},[151],{"type":20,"value":152},"This will operation will install and build all the necessary components.",{"type":14,"tag":22,"props":154,"children":155},{},[156],{"type":20,"value":157},"Here comes a small song and dance part that has to do with the fact that shader-sdk is still very raw",{"type":14,"tag":112,"props":159,"children":160},{},[161,166],{"type":14,"tag":116,"props":162,"children":163},{},[164],{"type":20,"value":165},"Inside the shader-sdk folder create a 'bin' folder",{"type":14,"tag":116,"props":167,"children":168},{},[169],{"type":20,"value":170},"Copy shader-sdk/build/host/beam/bvm/sid_generator/generate-sid to the newly created bin folder",{"type":14,"tag":44,"props":172,"children":174},{"id":173},"creating-a-new-shader-project",[175],{"type":20,"value":176},"Creating a new Shader Project",{"type":14,"tag":112,"props":178,"children":179},{},[180],{"type":14,"tag":116,"props":181,"children":182},{},[183],{"type":20,"value":184},"Open a Terminal and create a new folder for your Shader project. We will use 'vault' in our example",{"type":14,"tag":22,"props":186,"children":187},{},[188],{"type":20,"value":189},"2. Set the following environment variables to point to the location of you shader-sdk and wasi-sdk:",{"type":14,"tag":22,"props":191,"children":192},{},[193],{"type":14,"tag":64,"props":194,"children":196},{"className":195},[],[197],{"type":20,"value":198},"export BEAM_SHADER_SDK=~/Code/shader-sdk",{"type":14,"tag":22,"props":200,"children":201},{},[202],{"type":14,"tag":64,"props":203,"children":205},{"className":204},[],[206],{"type":20,"value":207},"export WASI_SDK_PREFIX=~/Code/shader-sdk/wasi-sdk-14.0",{"type":14,"tag":22,"props":209,"children":210},{},[211,213],{"type":20,"value":212},"3. Run the following command: ",{"type":14,"tag":64,"props":214,"children":216},{"className":215},[],[217],{"type":20,"value":218},"shade create_project \u003Cproject name>",{"type":14,"tag":22,"props":220,"children":221},{},[222],{"type":20,"value":223},"In our case:",{"type":14,"tag":22,"props":225,"children":226},{},[227],{"type":14,"tag":64,"props":228,"children":230},{"className":229},[],[231],{"type":20,"value":232},"~/Code/shader-sdk/shade create_project vault",{"type":14,"tag":22,"props":234,"children":235},{},[236],{"type":14,"tag":64,"props":237,"children":239},{"className":238},[],[240],{"type":20,"value":241},"Here comes another issue. Your Mac is very likely to warn you about the fact that generate-sid application was not created by a certified developer",{"type":14,"tag":22,"props":243,"children":244},{},[245],{"type":14,"tag":246,"props":247,"children":249},"img",{"alt":7,"src":248},".gitbook/assets/Screen%20Shot%202022-11-19%20at%2014.27.00%20(1).png",[],{"type":14,"tag":22,"props":251,"children":252},{},[253],{"type":14,"tag":64,"props":254,"children":256},{"className":255},[],[257],{"type":20,"value":258},"To avoid this you will need to allow running this script anyway from the Settings -> Security & Privacy dialogue and then rerunning the command",{"type":14,"tag":22,"props":260,"children":261},{},[262],{"type":14,"tag":246,"props":263,"children":265},{"alt":7,"src":264},".gitbook/assets/Screen%20Shot%202022-11-19%20at%2014.27.55.png",[],{"type":14,"tag":22,"props":267,"children":268},{},[269],{"type":20,"value":270},"This will initialize the structure of the Shader project",{"type":14,"tag":44,"props":272,"children":274},{"id":273},"building-the-shader-project",[275],{"type":20,"value":276},"Building the Shader Project",{"type":14,"tag":22,"props":278,"children":279},{},[280],{"type":20,"value":281},"Inside the project folder run the following command:",{"type":14,"tag":22,"props":283,"children":284},{},[285],{"type":14,"tag":64,"props":286,"children":288},{"className":287},[],[289],{"type":20,"value":290},"cmake -G \"Ninja\" -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=$WASI_SDK_PREFIX/share/cmake/wasi-sdk.cmake -DCMAKE_SYSROOT=$WASI_SDK_PREFIX/share/wasi-sysroot -DWASI_SDK_PREFIX=$WASI_SDK_PREFIX -DCMAKE_CXX_COMPILER_FORCED=True -DCMAKE_C_COMPILER_FORCED=True -DCMAKE_SYSTEM_NAME=\"WASI\"",{"type":14,"tag":22,"props":292,"children":293},{},[294],{"type":20,"value":295},"Then run:",{"type":14,"tag":22,"props":297,"children":298},{},[299],{"type":14,"tag":64,"props":300,"children":302},{"className":301},[],[303],{"type":20,"value":304},"ninja",{"type":14,"tag":22,"props":306,"children":307},{},[308],{"type":20,"value":309},"And the .wasm files with compiled contracts will be generated in the /shaders folder",{"type":14,"tag":22,"props":311,"children":312},{},[313],{"type":20,"value":314},"Now you are ready to start coding your Shader!",{"title":7,"searchDepth":316,"depth":316,"links":317},2,[318,320,321,322],{"id":46,"depth":319,"text":49},3,{"id":107,"depth":319,"text":110},{"id":173,"depth":319,"text":176},{"id":273,"depth":319,"text":276},"markdown","docs:docs:dev:shader-sdk-mac.md","docs","docs/dev/shader-sdk-mac.md","md",1777630727840]