-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: embed own source and refactor build a bit
- Loading branch information
Showing
8 changed files
with
125 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/bin/bash | ||
|
||
dst=src/embed_source.c | ||
|
||
[ -r src/assets.h ] || { | ||
>&2 echo "Build must generate src/assets.h first" | ||
exit 1 | ||
} | ||
|
||
[ -r src/assets.c ] || { | ||
>&2 echo "Build must generate src/assets.c first" | ||
exit 1 | ||
} | ||
|
||
command -v xxd > /dev/null || { | ||
>&2 echo "Error not found: xxd binary not installed" | ||
exit 1 | ||
} | ||
|
||
set -e | ||
#set -x | ||
|
||
name=cjit_source | ||
[ -r ${dst} ] && exit 0 | ||
|
||
mkdir -p pristine && cd pristine | ||
rm -rf ${name}* | ||
if [ -r ../.git/config ]; then | ||
git clone ../ ${name} | ||
rm -rf ${name}/.git* | ||
else | ||
rsync -rax ../ --exclude pristine ${name} | ||
fi | ||
|
||
tar --format ustar -czf ../${name}.tar.gz ${name} | ||
cd - | ||
echo "// Embedded: $path" > $dst | ||
echo "// source generated by cjit/build/embed-path.sh" >> $dst | ||
echo "// `date`" >> $dst | ||
echo "// ${name}" >> $dst | ||
mv ${name}.tar.gz ${name} | ||
xxd -i ${name} >> $dst | ||
rm -f ${name} | ||
|
||
# must be constant variables in stack | ||
# sed inplace is not portable | ||
if [[ "$OSTYPE" == "darwin"* ]]; then | ||
sed -i'' -e 's/unsigned char/const char/' $dst | ||
sed -i'' -e 's/unsigned int/const unsigned int/' $dst | ||
else | ||
sed -i -e 's/unsigned char/const char/' $dst | ||
sed -i -e 's/unsigned int/const unsigned int/' $dst | ||
fi | ||
|
||
# xxd already converts dots in underscores | ||
varname=`echo $name | sed 's/\./_/g'` | ||
|
||
# generate assets in source for extract_assets(char *tmpdir) | ||
echo >> src/assets.h | ||
echo "extern char *${varname};" >> src/assets.h | ||
echo "extern unsigned int ${varname}_len;" >> src/assets.h | ||
echo >> src/assets.h | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters