XCode 'Run Script' step to create directory and copy file is failing - xcode4

I have the following custom script step during my build:
mkdir -p "${CONTENTS_FOLDER_PATH}/Frameworks"
cp "${SRCROOT}/testing.1.dylib" "${CONTENTS_FOLDER_PATH}/Frameworks"
The script runs successfully, but when I check the bundle the Frameworks directory does not exist.
Should not not work as I expect? (Frameworks folder created with the testing.1.dylib in it).
Edit: Added screenshot of the runscript.

How about trying the following:
dst=${CONFIGURATION_BUILD_DIR}/${CONTENTS_FOLDER_PATH}/Frameworks
mkdir -p "${dst}"
cp "..." "$dst"
(I found your example and adapted it as above to copy a dylib into the 'Frameworks' folder of my framework).

Related

Node Server missing css

I have a small node backend application used to: simple database operations, calling external services, and building emails. To build those templates I'm using Handlebars. Every email includes its own HTML and CSS files. In the development process, those files are available in runtime. But in the production build not. I noticed that the build command only touches *.js files. All other files are not built, and not visible in the build folder in the final step. In fact on production, only emails don't work. How to force node build command to compile also CSS, HTML files.
package.json build command:
"build": "babel src -d build",
build output:
src/constants/errorMessages.js -> build/constants/errorMessages.js
src/constants/index.js -> build/constants/index.js
src/index.js -> build/index.js
src/lib/email.js -> build/lib/email.js
src/lib/emailBuilder/index.js -> build/lib/emailBuilder/index.js
src/lib/index.js -> build/lib/index.js
src/lib/mongo.js -> build/lib/mongo.js
src/lib/responses.js -> build/lib/responses.js
src/resolvers/index.js -> build/resolvers/index.js
src/resolvers/message.js -> build/resolvers/message.js
src/resolvers/product.js -> build/resolvers/product.js
src/resolvers/stripe.js -> build/resolvers/stripe.js
src/sessionsObserver.js -> build/sessionsObserver.js
As you see there are not *.css | *.html files here.
I've found workaround. After build process im picking by bash script all HTML, CSS files and copy them to demanded directories:
#!/usr/bin/env bash
# strict mode http://redsymbol.net/articles/unofficial-bash-strict-mode/
echo "Running build script"
rm -rf build
# compile is an alias to classic build
npm run compile
# create directories for HTML and CSS files
mkdir ./build/lib/emailBuilder/templates
mkdir ./build/lib/emailBuilder/styles
# Find and copy HTML templates
for FILE in $(find ./src -name '*.html'); do
cp $FILE ./build/lib/emailBuilder/templates
done
# Find and copy styles
for FILE in $(find ./src -name '*.css'); do
cp $FILE ./build/lib/emailBuilder/styles
done

Rscript to use renv environment

How do I execute a command using RScript myfile.R so that it uses the renv environment of the project/directory it's in, NOT my default environment?
There are a couple ways:
Ensure your working directory is set to the root of your renv project, and that the renv project's auto-loader is active. (You can set up the auto-loader by calling renv::activate() from R in that project.)
In your script, explicitly call renv::load("/path/to/project") to load the requested project.
If neither of these methods suffice, please file an issue at https://github.com/rstudio/renv/issues.
I recently had a similar problem but the answer by #kevin-ushey was insufficient. Here's the background. I need to be able to run Rscript from any directory (Because I had several statistical models which were to be called from a Docker file, forcing a Docker file to have WORKDIR many times is just too cumbersome when you have long files with several Rscript calls. Moreover, some of these models are called several times in different bash files, making it cumbersome to cd to the directory before every Rscript call). We needed something akin to conda activate where any Rscript call would just use the activated 'renv environment' by default, regardless of what your working directory is. Here's a dummy example:
Install renv with install.packages('renv').
Create dummy folder with a dummy script containing the beepr library (just for the sake of the example) and initialize the renv environment:
mkdir ~/renv_test/
cd ~/renv_test/
echo "library(beepr); print('success')" >> test.R
Rscript -e "renv::init()"
Create a Docker image with the code below:
FROM rocker/r-base
ENV PROJ_ROOT='/usr/local/src/renv_test'
ENV RENV_DIR='/usr/local/.renv/'
COPY . $PROJ_ROOT
# Copy the projects renv infrastructure to RENV_DIR and remove all traces of renv from PROJ_ROOT
RUN mkdir -p $RENV_DIR/renv/ && \
cp $PROJ_ROOT/renv.lock $RENV_DIR && \
cp $PROJ_ROOT/renv/activate.R $RENV_DIR/renv/ && \
echo "source('renv/activate.R')" >> $RENV_DIR/.Rprofile && \
cd $RENV_DIR && \
Rscript -e "renv::restore()" && \
cd $PROJ_ROOT && Rscript -e "renv::deactivate()" && \
rm -rf renv/ renv.lock
# Set RENV_DIR's restore library as the default library
RUN echo $(cd $RENV_DIR && Rscript -e "cat(paste0('R_LIBS=', renv::paths\$library()), sep = '\n')") >> $HOME/.Renviron
# Run any script from any directory as if you had 'renv activated'
CMD Rscript $PROJ_ROOT/test.R
Here's a summary of the approach:
Copy the project to the docker image
Copy the renv infrastructure to a separate folder (here ~/.renv/) and restore the project there.
Eliminate all traces of renv from the project folder (this is so we don't mess up the path of the library if for some reason we execute a script from the root of this project).
Edit .Renviron so that it contains the restored library path in ~/.renv as the default library. This ensures that any new R session will use that library as the first option.
Execute any R scripts located in the project folder without having to cd or WORKDIR (docker) to the project folder.
If you build and run the previous Docker image, you should get a success statement even though we never cd to the project folder:
docker build -t renv_test .
docker run renv_test
[1] "success"
I believe a simpler way than the above answers:
Rscript -e 'renv::run("/path/to/myscript.R")'
It will pick up the renv environment from the base path. You can also specify the environment using the project parameter.

External configuration of Project_Version in gpr file

With gnatpro 19.1, I'm trying to add gnathub to my project and am wondering how to set dynamically Project_Version as in:
package Dashboard is
for Project_Version use #git --describe --tags#; -- this needs to be updated.
end Dashboard;
I can't think of any simple way to do it.
A solution would be to use a Makefile that would configure a .gpr.in file but it seems contrived to change my whole buildchain just to add a version to the sonar config.
A simple, not automated solution, is to call the project with another switch:
gnathub -P Foo.gpr --plugins sonar-config,sonar-scanner\
--targs:sonar-scanner -Dsonar.projectVersion=$(git describe --tags)
But this is not really usable.
Similar question is to add the option -Dsonar.branch.name=$(git branch). AFAICT, the package Dashboard, as per the documentation has no Switch switch.
Is there any solution other than passing the extra arguments or forking gnatdashboard?
The best solution seems to reside in automating this configuration with a tool like Make.
For example, one can define the following Makefile:
# This target runs all the plugins listed
# in the section Dashboard.plugins of your project’s gpr
# sonar-config and sonar-scanner shall not be listed therein.
analyzes:
gnathub -P project
# This uses gnathub API to get the object dir where sonar-config file will be generated
OBJECT_DIR = $(shell gnathub -P project --exec object_dir.py 2>/dev/null | tail -n 1)
SONAR_PROPERTIES = $(OBJECT_DIR)/gnathub/sonar/sonar-project.properties
PROJECT_VERSION = $(shell git describe --tags)
BRANCH_NAME = $(shell git rev-parse --abbrev-ref HEAD)
# Uses gnathub to generate sonar properties file.
# Replaces the projectVersion and add branch name
# (notice that, on sonar, the branch name shall not be specified on your "master" branch)
$(SONAR_PROPERTIES): analyzes
gnathub -P project --plugins sonar-config --incremental
#sed -i "s/\(sonar.projectVersion = \).*/\1$(PROJECT_VERSION)/" $#
ifneq ($(BRANCH_NAME), master)
#echo "sonar.branch.name = $(BRANCH_NAME)" >> $#
endif
sonar: $(SONAR_PROPERTIES)
gnathub -P project --plugins sonar-scanner --incremental
.PHONY: sonar analyzes
Where object_dir.py is:
#!/usr/bin/env python
import GNAThub;
print (GNAThub.Project.object_dir());
Then:
$make sonar
Would run the analyzes and update them with the correct version and branch name (if necessary) to the SonarQube server.

Symlink dotfiles

I am having trouble symlinking dotfiles. I have a folder in my home directory ~/dotfiles which I have synced to a github repo. I am trying to take my .vimrc file in ~/dotfiles/.vimrc and create a symbolic link to put it at ~/.vimrc. To do this I type in
ln -s ~/dotfiles/.vimrc ~/.vimrc
But when I run that it says
ln: /Users/me/.vimrc: File exists
What am I doing wrong?
That error message means that you already have a file at ~/.vimrc, which ln is refusing to overwrite. Either delete the ~/.vimrc and run ln again or let ln delete it for you by passing the -f option:
ln -s -f ~/dotfiles/.vimrc ~/.vimrc
There is a better solution for managing dotfiles without using symlinks or any other tool, just a git repo initialized with --bare.
A bare repository is special in a way that they omit working directory, so you can create your repo anywhere and set the --work-tree=$HOME then you don't need to do any work to maintain it.
Approach
first thing to do is, create a bare repo
git init --bare $HOME/.dotfiles
To use this bare repo, you need to specify --git-dir=$HOME/.dotfiles/ and --work-tree=$HOME, better is to create an alias
alias dotfiles='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME
At this point, all your configuration files are being tracked, and you can easily use the newly registered dotfiles command to manage the repository, ex :-
# to check the status of the tracked and untracked files
dotfiles status
# to add a file
dotfiles commit .tmux.conf -m ".tmux.conf added"
# push new files or changes to the github
dotfiles push origin main
I also use this way to sync and store my dotfiles, see my dotfiles repository and can read at Storing dotfiles with Git where I wrote about managing for multiple devices.
How to symlink all dotfiles in a directory recursively
Have a dotfiles directory that is structured as to how they should be structured at $HOME
dotfiles_home=~/dotfiles/home # for example
cp -rsf "$dotfiles_home"/. ~
-r: Recursive, create the necessary directory for each file
-s: Create symlinks instead of copying
-f: Overwrite existing files (previously created symlinks, default .bashrc, etc)
/.: Make sure cp "copy" the contents of home instead of the home directory itself.
Tips
Just like ln, if you want no headache or drama, use an absolute path for the first argument like the example above.
Note
This only works with GNU cp (preinstalled in Ubuntu), not POSIX cp. Check your man cp, you can install GNU coreutils if needed.
Thanks
To this and this.

Docker dotnet image container do not allow me to rebuild after change

I am new to docker, and I am trying to set a container to aspnet development. I just run yo aspnet on a folder and run:
docker run -i -t -p 80:5000 -v "$(pwd):/app" -w "/app" microsoft/dotnet /bin/bash
After that, I run the following commands to prepare to environment:
dotnet restore
dotnet build
dotnet run --server.urls http://*:5000
When I do some change to anything in the directory, even to a cshtml file, the changes do not reflect. If I try to stop the server and rerun it, I receive the error:
/usr/share/dotnet/dotnet compile-csc #/app/obj/Debug/netcoreapp1.0/dotnet-compile.rsp returned Exit Code 1
/app/error CS2012: Cannot open '/app/bin/Debug/netcoreapp1.0/app.dll' for writing -- 'Could not find a part of the path
'/app/bin/Debug/netcoreapp1.0/app.dll'.'
Compilation failed.
I could notice that I cannot delete the app.dll file from the bin folder. When I try to delete it, it gives me the following error:
rm -R bin
rm: cannot remove 'bin/Debug/netcoreapp1.0/app.dll': No such file or directory
But, if I enter the folder, the file is there with 0kb size.
Do you know what am I missing to allow me to rebuild the app without need to restart the container?

Resources