Does Clojure have a configuration file similar to ~/.clisprc.lisp? - configuration

On my platform, I need to add (set! *compile-path* (str *compile-path* ":.")) in order for (compile) to find my scripts. I'd prefer not to have to type that every time I want to compile something.

The easiest way to handle setting your "compile path" in Clojure is to use a build tool like Leiningen or Cake to manage your project. Using these tools, you get an idiomatic project structure, all your source code automatically on the compile/class path, and nice command-line tools to handle dependency retrieval, running unit tests and building your projects.
Here are some of the basic command-line tasks defined by Leiningen, and thus available to you in any project:
classpath Show the classpath of the current project.
clean Remove compiled artifacts and jars from project.
compile Compile Clojure source into .class files.
deps Download all dependencies and place them in the :library-path.
help Display a list of tasks or help for a given task.
install Install the current project or download the project specified.
interactive Enter interactive shell for calling tasks without relaunching JVM.
jar Package up all the project's files into a jar file.
javac Compile Java source files.
new Create a new project skeleton.
plugin Manage user-level plugins.
pom Write a pom.xml file to disk for Maven interop.
repl Start a repl session either with the current project or standalone.
run Run a -main function with optional command-line arguments.
swank Launch swank server for Emacs to connect.
test Run the project's tests.
test! Run a project's tests after cleaning and fetching dependencies.
uberjar Package up all the project's files and dependencies into a jar file.
So you start a new project by running lein new <name of project>, which generates a standard directory structure for a Clojure project. After you've written your code, you can run lein compile to simply compile your Clojure source, or you can go right to lein jar to package your code as a Jar file. For an executable jar that includes the Clojure language and all dependencies necessary to run your program, use lein uberjar instead.
If you don't use these tools, then you need to manage the classpath manually, to include where you store your dependency jars and where your source code lives. I highly recommend using one of the above-mentioned build tools.

You can specify -i when running Clojure to have it evaluate a file when starting up.
Below is the script I use to run Clojure as an example:
#!/bin/bash
# GUI mode
if [ "$1" != "--no-fork" ]; then
gnome-terminal -t Clojure -x $0 --no-fork $* &
exit
fi
shift
breakchars="(){}[],^%$##\"\";:''|\\"
if [ -f project.clj ]; then
lein repl
else
rlwrap --remember -c -b "$breakchars" \
java -Djava.ext.dirs=$HOME/.clojure clojure.main \
-i $HOME/.clojurerc --repl
fi

Leiningen will load ~/.lein/init.clj every time it launches. In addition, you can add a :repl-init key to your project.clj files to have that namespace loaded in each repl. Clojure is really not meant to be used standalone without any supporting tools, so calling (compile [...]) on your own is almost never the right answer.

In Clojure this is managed at the Java level (classpath etc) rather than having a .rc file. When I first started programming in Clojure I had a bash script that I would run, but now I use Leiningen.

Related

How to make a HTML build from raylib

I am a beginner programmer and I was wondering how I would make an HTML build from raylib. I tried looking at the GitHub https://github.com/raysan5/raylib/wiki/Working-for-Web-(HTML5) I couldn't understand it. would you be able to write a simple step-by-step tutorial for me. please
For the very beginning you have to install emscripten SDK. As stated at the site "Emscripten is a complete compiler toolchain to WebAssembly, using LLVM, with a special focus on speed, size, and the Web platform."
Installation steps are prety easy:
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
git pull
./emsdk install latest
./emsdk activate latest
source ./emsdk_env.sh
After this steps you will have emscripten installed into the directory you've cloned it.
Then, you need to compile raylib itself to be usable in Web:
Go to the raylib/src directory and open Makefile, find where EMSDK_PATH variable is being defined and edit it accordingly to your setup. If you downloaded emscripten into /home/user/emsdk directory then put it in there:
EMSDK_PATH ?= /home/user/emsdk
Fix PYTHON_PATH definition as well.
then launch execute make:
make -e PLATFORM=PLATFORM_WEB -B
Notice -e option. That option allows to propagate and override environment variables to makefile.
Generated libraylib.a is placed in raylib\src\libraylib.a directory.
After that you can cd into raylib/examples/, fix Makefile as described above and launch make -e PLATFORM=PLATFORM_WEB -B again.
After that you would be able to start python3 -m http.server in that directory, navigate to http://0.0.0.0:8000/ in your browser and see examples.

How do I make Octave see installed Shogun libraries in Ubuntu 16.04?

I copied the commands (from these instructions: http://www.shogun-toolbox.org/install#ubuntu) into the terminal and they seem to have worked, but there is no documentation on how to make Octave find the libraries. I have tried modshogun and init_shogun but Octave cannot find them. I do have the libraries in usr/lib, and I have put that directory on PATH. I have even set usr/lib as my working directory in Octave and that did not help. As far as I have found, there is no Shogun documentation on what to do at this point.
I have also tried compiling Shogun from source, but configure couldn't find GCC. Apparently, this is a known problem with newer versions of GCC. I decided to ask for help with the former method because at least I have the libraries with that.
Edit: I am following the instructions here http://www.shogun-toolbox.org/install#manual-basics
When i do cd build and then "cmake -DINTERFACE_OCTAVE=ON" it tells me there is no cmakelists.txt. There is one in in the above folder, but when I go to that directory and do "cmake -DINTERFACE_OCTAVE=ON" again, it tells me "Shogun can only be built with GPL codes if the source files are in /home/derose/shogun/src/shogun/src/gpl. Please download or disable with LICENSE_GPL_SHOGUN=OFF."
However, when I add -LICENSE_GPL_SHOGUN=OFF as an option, i get the error "CMake Error: The source directory "/home/derose/shogun/src/shogun/-LICENSE_GPL_SHOGUN=OFF" does not exist."
You've linked to the Ubuntu install instructions. From there
These currently do contain the C++ library and Python bindings..
No word that this would include the GNU Octave binding. See below on the same page:
The native C++ interface is always included. The cmake options for building interfaces are -DINTERFACE_PYTHON=ON -DINTERFACE_R .. etc. For example, replace the cmake step above by cmake -DINTERFACE_PYTHON=ON...
So you have to grab the source and fire up cmake with something like -DINTERFACE_OCTAVE=ON
Steps to build the bleeding edge of shogun (the github repo) and the Octave interface:
git clone https://github.com/shogun-toolbox/shogun && cd shogun
git submodule update --init
mkdir build && cd build
cmake .. -DINTERFACE_OCTAVE=ON
make -j4

should I recompile all clang project when I want to add a new checker in Clang StaticAnalyzer?

I follow the steps in the section Checker Registration
in the manual page of clang static analyzer one by one and can not find my checker from the output of the command
clang -cc1 -help | grep "analyzer"
So, I wonder if I should recompile the whole project? That is a burdensome job which I need almost several hours to compile it.
You should be using a build system like ninja or make when compiling llvm/clang. The build system automatically decides which parts need to be recompiled and which parts do not.
As an example, if you follow the steps to build clang here, step number 7 says to run the following commands:
mkdir build (in-tree build is not supported)
cd build
cmake -G "Unix Makefiles" ../llvm
make
From that point forward every time you make changes you only need to re-run the make command from your build folder and make will automatically compile anything that needs to be recompiled.
If you want slightly faster recompile times you can install the ninja build system and use cmake -G "Ninja" ../llvm when first building the project and use the ninja command instead of make from that point forward.

nuget package restore with MonoDevelop

I have a solution that is primarily developed in Visual Studio 2012. I would like to develop in MonoDevelop without major incompatibilities.
Thus far, I have installed mrward's nuget addin for MonoDevelop and things work if I manually add each package in packages.config through that interface. However, this is highly onerous. This addin doesn't have support for automated package restore as of this writing.
I downloaded nuget.exe from CodePlex ("NuGet command line utility", as it's labeled). I use a simple find/xargs combination to install all required packages:
find . -name packages.config | xargs -I '{}' mono nuget.exe install '{}'
This creates several dozen directories in the directory from which it is run instead of putting things under packages/ as expected, and it also doesn't touch the project files so MonoDevelop still thinks that it should be looking for package references in the directory from which MonoDevelop was started.
I therefore opened MonoDevelop from the working directory that contains all of these package folders, and I still get invalid references. I think this is probably because the project is looking for package_name/ reference, but the folders are name package_name.version/ in the working directory.
Any suggestions for a sane, simple way to interact with this solution? I'm next going to try modifying my shell command so that it automatically drops to project/packages and runs nuget from that directory.
Did you try using the -o command line parameter with NuGet.exe? You can use that to get the packages to install into a particular packages folder.
The NuGet addin for MonoDevelop supports package restore from version 0.6 or above. Right click your project and select Restore Packages. This will download all the packages defined in your packages.config for all projects in the solution. It uses NuGet.exe to do this.
Another way to get this working is to use the custom NuGet MSBuild target so the package restore happens at build time when using xbuild. It would require some manual editing of project files though. Under the covers the custom MSBuild target just uses NuGet.exe with a similar command line to what you have already just with the output directory option specified. So I would try the command line approach since that will be less work.
You would have to get the following files from the NuGet repository on codeplex:
NuGet.exe
NuGet.targets
NuGet.config
Put these in a directory somewhere. Typically these are put in a .nuget directory in the same directory as your solution file. Then you need to edit your project files to include the NuGet.targets file and also define the SolutionDir property. So something like this:
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" />
You will also need to enable package restore on your machine. You can do this using the NuGet addin for MonoDevelop in the Options dialog. Under Linux this is available from the Edit menu under Preferences. Then look in the NuGet - General options and there is a checkbox for enabling package restore.
There is an example project on GitHub created by Jonathan Channon which uses package restore and works when building with xbuild inside MonoDevelop. There is also an issue on GitHub about using NuGet restore on Linux which might be helpful.
Update: 2014-05-14: NuGet addin for MonoDevelop now supports package restore.

How to add path variable to job shell

I am setting up Jenkins to replace our current TeamCity CI build.
I have created a free-style software project so that I can execute a shell script.
The Shell script runs the mvn command.
But the build fails complaining that the 'mvn' command cannot be found.
I have figured that this is because Jenkins is running the build in a different shell, which does not have Maven on it's path.
My question is; how do I add the path so 'mvn' is found in my Shell script? I've looked around but can't spot where the right place might be.
Thanks for your time.
I solved this by exporting and setting the Path in the Jenkins Job configuration where you can enter shell commands. So I set the environments variable before I execute my Shell script, works a treat.
Some possible solutions:
You can call maven with an absolute path
You configure a global environment variable in the jenkins system settings with the absolute path to your maven instance, and use this in your script call (if you use the inline shell script, I don't know if those are substituted to a called script, you have to test)
You use a maven project and configure your maven instance in the jenkins system settings
ps.: Usually /bin/sh is chosen from Jenkins, if you want to switch to eg. bash, you can configure this in the jenkins system settings, in case you want to configure global environment variables.
You can use envInject plugin. It's very powerful.
I use it to install rbenv. And it can inject environment variables into your current job.
Another option to Dags suggestion is that if you're only using a single version of maven, on each slave server you could do either;
* add PATH=${PATH}:
* symlink mvn into /usr/bin with; sudo ln -s /usr/bin
I'm not at a Jenkins box at the moment, but I can find some more detailed examples if you'd like.
Jenkins is using sh by default and not bash.
This is my first time defining a jenkins maven job, and I also followed soem regular maven instructions (for running from command line...), and tried to update ~/.bashrc with M2_HOME, M2, PATH, but it didn't work because jenkins used sh and not bash. Then I found out that there is a simpler and better way built into jenkins.
After installing maven, I was supposed to configure my maven installation in jenkins.
To configure your maven installation in Jenkins:
login to jenkins web console
click Manage Jenkins --> Configure System
Under Maven, click the "Maven Installations..." button
a. Give it some name
b. and under MVN_HOME set the path to where you installed maven, for example "/usr/local/apache-maven/apache-maven-3.0.5"
Click Save button
Define a job with maven target
edit your job
Click "Add build step"
on Maven Version, enter the name you gave your maven installation (step #4 above)
set some goal like clean install