summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2019-08-24 11:07:15 +0800
committerruki <[email protected]>2019-08-24 11:07:15 +0800
commitbb5306699e625775cc115720ef1818c8697b467a (patch)
tree7ed9f2a5d22437812b4b6795afe827b5753fef36
parent216839989f150af359ad63143f5b0593f500cd56 (diff)
improve bcsave
-rw-r--r--.appveyor.yml6
-rw-r--r--.travis.yml6
-rwxr-xr-xscripts/archive-all.sh4
-rwxr-xr-xscripts/makeself/build-runfile.sh6
-rw-r--r--xmake/modules/private/utils/bcsave.lua19
5 files changed, 14 insertions, 27 deletions
diff --git a/.appveyor.yml b/.appveyor.yml
index 8eae878e7..d6001b892 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -50,11 +50,7 @@ build_script:
- ps: Copy-Item -Force .\core\build\xmake.exe $(Get-Command xmake).Path
- ps: (Get-Command xmake).FileVersionInfo.ProductVersion
# use bitcodes
- - ps: xmake l private.utils.bcsave -x 'scripts/**|templates/**' -o bcxmake xmake
- - ps: Copy-item xmake\scripts bcxmake/scripts -Recurse
- - ps: Copy-item xmake\templates bcxmake/templates -Recurse
- - ps: Remove-Item xmake -Recurse
- - ps: Rename-Item bcxmake xmake
+ - ps: xmake l private.utils.bcsave -x 'scripts/**|templates/**' xmake
- ps: (Get-Command xmake).FileVersionInfo.ProductVersion
after_build:
diff --git a/.travis.yml b/.travis.yml
index 22f5b363e..7d73bc777 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -29,11 +29,7 @@ script:
- export XMAKE_PROGRAM_DIR=~/.local/share/xmake
- cp core/build/xmake "$XMAKE_PROGRAM_DIR" || sudo cp core/build/xmake "$XMAKE_PROGRAM_DIR"
- xmake --version
- - xmake l private.utils.bcsave -x 'scripts/**|templates/**' -o bcxmake xmake
- - mv xmake/scripts bcxmake/scripts
- - mv xmake/templates bcxmake/templates
- - rm -rf xmake
- - mv bcxmake xmake
+ - xmake l private.utils.bcsave -x 'scripts/**|templates/**' xmake
- xmake --version
- travis_wait 60 xmake lua -v -D tests/run.lua
- scripts/archive-all.sh
diff --git a/scripts/archive-all.sh b/scripts/archive-all.sh
index bd663ca19..144c68f92 100755
--- a/scripts/archive-all.sh
+++ b/scripts/archive-all.sh
@@ -18,9 +18,9 @@ git submodule foreach git clean -dfX
# copy files to tmpdir/xmake
mkdir -p $tmpdir/xmake/scripts
cd $tmpdir/repo || exit
-xmake l -v private.utils.bcsave -x 'scripts/**|templates/**' -o bcxmake xmake || exit
+xmake l -v private.utils.bcsave -x 'scripts/**|templates/**' xmake || exit
cp -r ./core $tmpdir/xmake
-mv bcxmake $tmpdir/xmake/xmake
+cp -r ./xmake $tmpdir/xmake/xmake
cp ./scripts/get.sh $tmpdir/xmake/scripts
cp ./*.md $tmpdir/xmake
cp makefile $tmpdir/xmake
diff --git a/scripts/makeself/build-runfile.sh b/scripts/makeself/build-runfile.sh
index 471f6700e..45fa2ccd2 100755
--- a/scripts/makeself/build-runfile.sh
+++ b/scripts/makeself/build-runfile.sh
@@ -20,10 +20,8 @@ git submodule foreach git clean -dfX
# copy files to tmpdir/xmake
mkdir -p $tmpdir/xmake/scripts
cd $tmpdir/repo || exit
-xmake l -v private.utils.bcsave -x 'scripts/**|templates/**' -o bcxmake xmake || exit
-mv xmake/scripts bcxmake/scripts
-mv xmake/templates bcxmake/templates
-mv bcxmake $tmpdir/xmake/xmake
+xmake l -v private.utils.bcsave -x 'scripts/**|templates/**' xmake || exit
+cp -r ./xmake $tmpdir/xmake/xmake
cp -r ./core $tmpdir/xmake
cp ./scripts/get.sh $tmpdir/xmake/scripts
cp ./*.md $tmpdir/xmake
diff --git a/xmake/modules/private/utils/bcsave.lua b/xmake/modules/private/utils/bcsave.lua
index 528b3ec91..2ae3ae430 100644
--- a/xmake/modules/private/utils/bcsave.lua
+++ b/xmake/modules/private/utils/bcsave.lua
@@ -34,13 +34,10 @@ local options =
-- save lua files to bitcode files in the given directory
function save(sourcedir, outputdir, opt)
- -- check
- assert(outputdir, "no output directory!")
-
-- init source directory and options
opt = opt or {}
sourcedir = path.absolute(sourcedir or os.programdir())
- outputdir = path.absolute(outputdir)
+ outputdir = outputdir and path.absolute(outputdir) or sourcedir
assert(os.isdir(sourcedir), "%s not found!", sourcedir)
-- trace
@@ -54,13 +51,14 @@ function save(sourcedir, outputdir, opt)
if opt.excludedirs then
pattern = pattern .. "|" .. opt.excludedirs
end
+ local override = (outputdir == sourcedir)
for _, luafile in ipairs(os.files(pattern)) do
-- get relative lua file path to decrease bitcode file size (without strip)
luafile = path.relative(luafile, sourcedir)
-- get bitcode file path
- local bcfile = path.join(outputdir, luafile)
+ local bcfile = override and os.tmpfile() or path.join(outputdir, luafile)
-- generate bitcode file
bcsave(luafile, bcfile, {strip = opt.strip})
@@ -71,6 +69,11 @@ function save(sourcedir, outputdir, opt)
total_lua = total_lua + luasize
total_bc = total_bc + bcsize
vprint("generating %s (%d => %d)..", luafile, luasize, bcsize)
+
+ -- override?
+ if override then
+ os.cp(bcfile, luafile)
+ end
end
os.cd(oldir)
@@ -87,12 +90,6 @@ function main(...)
, ""
, "Usage: xmake l private.utils.bcsave [options]")
- -- check outputdir
- if not opt.outputdir then
- opt.help()
- raise("please set output directory!")
- end
-
-- save bitcode files
save(opt.sourcedir, opt.outputdir, opt)
end