SC Code
SC is a C based meta/programming language/environment
Status: Pre-Alpha
Brought to you by:
timon37
######### Major parts: ##### Main binaries/plugins/scripts: scedit_v2 the SC source code editor (also can be used as a processor) scproc the SC source code processor, used for running meta-code on files SCP the SC to C printer, used for compiling and for diff visualization in git sccomp a bash script that facilitates compilation (uses SCP) scdiff diff SC source code scpatch patch SC source code clang-c2sc plugin to clang, for translating C to SC (mainly used for headers) scmerge bash script which uses scdiff & scpatch to optimistically merge (things will fail horribly and potentially silently on any conflicts) ######### Compiling stuff from nothing git submodule init git submodule update ###### libjit dependency nix-shell # if running on nixos cd dep-src/libjit ./bootstrap ./configure --prefix="$(realpath "$PWD/../../dep")" make -j12 install ###### libconfuse dependency nix-shell # if running on nixos cd dep-src/libconfuse #potentially also below libtoolize command: # libtoolize --force ./autogen.sh ./configure --prefix="$(realpath "$PWD/../../dep")" make -j12 install ###### 64bit linux full dev setup ### Update: ### Instead of the instructions below you can use the setup_full script ### However it is advised to ispect it first in case of stupid mistakes etc... There are two relevant install paths: "local" and "system/global" (except I keep it in my ~/bin/sc where ~/bin/sc/bin/ is added to my PATH env) I use these 5 build folders (to play around with the editor you only need the first step): build-boot for bootstrapping to the "system/global" path build-sys for installing to the "system/global" path build for installing to the local dst folder (subdir of SC repo) build-dst same as above but using the tools from dst instead of system build-bootdst for bootstrapping into the dst folder ### build-boot # so first decide on a "global/system" install prefix, I use: PREFIX="$HOME/bin/sc" COMMON="-GNinja -DCMAKE_BUILD_TYPE:string=RELWITHDEBINFO -DKeyMap:string=dvorakqwerty -DOPT_GIT2:bool=1 -DOPT_HEAVY_TESTS:bool=1 -DOPT_OBSTACK:bool=1" mkdir build-boot cd build-boot cmake .. $COMMON -DCMAKE_INSTALL_PREFIX:path=$PREFIX -DOPT_BOOTSTRAP:bool=1 ninja install # now you should have the tools and headers installed, but to open libsc/SCE.sc # you'll still need to set some extra environment variables # if you used the same PREFIX as me just do the following from the repository folder source e # if not just modify SC_ROOT in that file to your PREFIX # then you can do: scedit_v2 libsc/SCE.sc ### build-sys # note: ehm I'm not sure but if you run into trouble try this from a terminal that doesn't have the variables from e set mkdir build-sys cd build-sys cmake .. $COMMON -DCMAKE_INSTALL_PREFIX:path=$PREFIX -DSC_ROOT:path=$PREFIX ninja install # now you're self-hosted, but in a somewhat dangerous way which is why for developing SC you'll want two more folders mkdir build cd build cmake .. $COMMON -DCMAKE_INSTALL_PREFIX:path=../dst -DSC_ROOT:path=$PREFIX ninja install cd .. mkdir build-dst cd build-dst cmake .. $COMMON -DCMAKE_INSTALL_PREFIX:path=../dst -DSC_ROOT:path="$(readlink -f ../dst)" ninja install ###### 32bit linux or other OSes sorry out of luck for now ###### howto compile sc files # theres's a few ways actually, the simplest is just print the file to .c and compile that SCP file.sc > file.sc.c gcc file.sc.c # for big files you cane use the script below to print the file into smaller chunks detect changes and recompile as needed sccomp -- file.sc -I/home/bin/sc/include ###### generate SC system-headers ./gen_include /usr/include/stdio.h ##### git SC integration #add to .git/config: [diff "sc"] textconv = sc print -v [merge "sc"] name = scmerge driver = sc merge %O %B %A %P recursive = binary #add to .gitattributes: *.sc diff=sc merge=sc *.sh diff=sc merge=sc *.scp diff=sc merge=sc *.shp diff=sc merge=sc ###### clang-c2sc (for translating C to SC) most likely clang versions to work is 3.8 (maybe 3.1, 2.8, or others just try and see) note: you'll quickly come to hate this, i'm doin it on an as needed basis so you might have to add support for some more AST classes #on nixos make sure to do this in: nom-shell clang.nix cd clang-c2sc mkdir build cd build cmake .. -DCMAKE_BUILD_TYPE=RELWITHDEBINFO make # now you have the plugin c2sc.so in clang-c2sc/build/lib # and you can run it like this: clang -cc1 -load clang-c2sc/build/lib/c2sc.so -plugin c2sc file.c &> out_log the SC output is written into OUT.sc if the out_log contains any "error:" then expect the OUT.sc file to be broken usually the errors will be missing .h files so you will probably have to add flags and paths like -I/usr/include look into the gen_include script for hints of what to do you can give additional c2sc specific options like -fnc-imp or -type-imp like this: -plugin-arg-c2sc -fnc-imp -plugin-arg-c2sc -type-imp these options control if the translator will include everything or just the stuff that originates from the source file Alternatively it may be necessary to run e.g. more like this: clang++ -Xclang -load -Xclang clang-c2sc/build/lib/c2sc.so -Xclang -plugin -Xclang c2sc file.cpp clang++ -Xclang -load -Xclang clang-c2sc/build/lib/c2sc.so -Xclang -plugin -Xclang c2sc -Xclang -plugin-arg-c2sc -Xclang -fnc-imp -Xclang -plugin-arg-c2sc -Xclang -type-imp file.cpp #btw I think clang is a bit stupid... and seriously lacks docs (not that gcc is much better;p) ###### gcc sc frontend ## DEPRECATED I've only used 4.4.3 for now no idea if other versions are compatible ln -s ../../scgcc gcc-4.4.3/gcc/sc mkdir gcc-build cd gcc-build ../gcc-4.4.3/configure --prefix=~/bin/sc/ --enable-languages=c,sc i generally add a lot more options based on my default system gcc -v, though some stuff like cloog tends to fail, you should not include all the prefix modifiers, and it's best to compile just c and sc then run make, you can use -j6 or whatever but it can fail at some point if it does just run make without -j for a moment after 10 seconds or more you can ctrl+c it and run make -j6 again make install