summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2018-01-27 00:26:03 +0800
committerruki <[email protected]>2018-01-27 00:26:03 +0800
commit25f2dfa8baa7121817dd1d614bfd15dc2cb12f00 (patch)
treefe1376b8689e4ba908dc4f82d68782b99474d52a
parentaeae3a633365811cdc138b537942ef12e2218fd0 (diff)
add os.filesize and modify changelogs
-rw-r--r--CHANGELOG.md44
-rw-r--r--core/src/xmake/machine.c2
-rw-r--r--core/src/xmake/makefile1
-rw-r--r--core/src/xmake/os/filesize.c57
-rw-r--r--xmake/core/sandbox/modules/interpreter/os.lua1
-rw-r--r--xmake/core/sandbox/modules/os.lua1
6 files changed, 78 insertions, 28 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 419da7f1c..18dbff03e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,24 +2,12 @@
## master (unreleased)
-### Changes
-
-* Improve to search the root project directory
-* Improve to detect vs environment
-* Upgrade luajit to 2.1.0-beta3
-* Support to run xmake on linux (arm, arm64)
-* Improve to generate vs201x project plugin
-
-### Bugs fixed
-
-* Fix `xmake f --cross` error
-
-## v2.1.9
-
### New features
* Add `del_files()` api to delete files in the files list
* Add `rule()`, `add_rules()` api to implement the custom build rule and improve `add_files("src/*.md", {rule = "markdown"})`
+* Add `os.filesize()` api
+* Add `core.ui.xxx` cui components
### Changes
@@ -29,12 +17,18 @@
* Improve the checking errors tips
* Improve `add_cxflags` .., force to set flags without auto checking: `add_cxflags("-DTEST", {force = true})`
* Improve `add_files`, add force block to force to set flags without auto checking: `add_files("src/*.c", {force = {cxflags = "-DTEST"}})`
+* Improve to search the root project directory
+* Improve to detect vs environment
+* Upgrade luajit to 2.1.0-beta3
+* Support to run xmake on linux (arm, arm64)
+* Improve to generate vs201x project plugin
### Bugs fixed
* Fix complation dependence
* [#151](https://github.com/tboox/xmake/issues/151): Fix `os.nuldev()` for gcc on mingw
* [#150](https://github.com/tboox/xmake/issues/150): Fix the command line string limitation for `ar.exe`
+* Fix `xmake f --cross` error
## v2.1.8
@@ -425,24 +419,12 @@
## master (开发中)
-### 改进
-
-* 改进搜索工程根目录策略
-* 改进vs环境探测,支持加密文件系统下vs环境的探测
-* 升级luajit到最新2.1.0-beta3
-* 增加对linux/arm, arm64的支持,可以在arm linux上运行xmake
-* 改进vs201x工程生成插件,更好的includedirs设置支持
-
-## Bugs修复
-
-* 修复`xmake f --cross`无法配置问题
-
-## v2.1.9
-
### 新特性
* 添加`del_files()`接口去从已添加的文件列表中移除一些文件
* 添加`rule()`, `add_rules()`接口实现自定义构建规则,并且改进`add_files("src/*.md", {rule = "markdown"})`
+* 添加`os.filesize()`接口
+* 添加`core.ui.xxx`等cui组件模块,实现终端可视化界面,用于实现跟用户进行短暂的交互
### 改进
@@ -452,12 +434,18 @@
* 改进检测错误提示
* 改进`add_cxflags`等flags api的设置,添加force参数,来禁用自动检测和映射,强制设置选项:`add_cxflags("-DTEST", {force = true})`
* 改进`add_files`的flags设置,添加force域,用于设置不带自动检测和映射的原始flags:`add_files("src/*.c", {force = {cxflags = "-DTEST"}})`
+* 改进搜索工程根目录策略
+* 改进vs环境探测,支持加密文件系统下vs环境的探测
+* 升级luajit到最新2.1.0-beta3
+* 增加对linux/arm, arm64的支持,可以在arm linux上运行xmake
+* 改进vs201x工程生成插件,更好的includedirs设置支持
## Bugs修复
* 修复依赖修改编译和链接问题
* [#151](https://github.com/tboox/xmake/issues/151): 修复`os.nuldev()`在mingw上传入gcc时出现问题
* [#150](https://github.com/tboox/xmake/issues/150): 修复windows下ar.exe打包过长obj列表参数,导致失败问题
+* 修复`xmake f --cross`无法配置问题
## v2.1.8
diff --git a/core/src/xmake/machine.c b/core/src/xmake/machine.c
index 02bf760e7..d35631a1c 100644
--- a/core/src/xmake/machine.c
+++ b/core/src/xmake/machine.c
@@ -77,6 +77,7 @@ tb_int_t xm_os_rename(lua_State* lua);
tb_int_t xm_os_exists(lua_State* lua);
tb_int_t xm_os_setenv(lua_State* lua);
tb_int_t xm_os_getenv(lua_State* lua);
+tb_int_t xm_os_filesize(lua_State* lua);
tb_int_t xm_os_emptydir(lua_State* lua);
tb_int_t xm_os_strerror(lua_State* lua);
tb_int_t xm_os_getwinsize(lua_State* lua);
@@ -165,6 +166,7 @@ static luaL_Reg const g_os_functions[] =
, { "getenv", xm_os_getenv }
, { "emptydir", xm_os_emptydir }
, { "strerror", xm_os_strerror }
+, { "filesize", xm_os_filesize }
, { "getwinsize", xm_os_getwinsize}
, { "versioninfo", xm_os_versioninfo}
#ifndef TB_CONFIG_OS_WINDOWS
diff --git a/core/src/xmake/makefile b/core/src/xmake/makefile
index a8afcd30d..5c11d0a62 100644
--- a/core/src/xmake/makefile
+++ b/core/src/xmake/makefile
@@ -35,6 +35,7 @@ xmake_C_FILES += \
os/getenv \
os/emptydir \
os/strerror \
+ os/filesize \
os/getwinsize \
os/versioninfo \
os/uid \
diff --git a/core/src/xmake/os/filesize.c b/core/src/xmake/os/filesize.c
new file mode 100644
index 000000000..c8c3fcfe6
--- /dev/null
+++ b/core/src/xmake/os/filesize.c
@@ -0,0 +1,57 @@
+/*!The Make-like Build Utility based on Lua
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Copyright (C) 2015 - 2018, TBOOX Open Source Group.
+ *
+ * @author ruki
+ * @file filesize.c
+ *
+ */
+
+/* //////////////////////////////////////////////////////////////////////////////////////
+ * trace
+ */
+#define TB_TRACE_MODULE_NAME "filesize"
+#define TB_TRACE_MODULE_DEBUG (0)
+
+/* //////////////////////////////////////////////////////////////////////////////////////
+ * includes
+ */
+#include "prefix.h"
+
+/* //////////////////////////////////////////////////////////////////////////////////////
+ * implementation
+ */
+tb_int_t xm_os_filesize(lua_State* lua)
+{
+ // check
+ tb_assert_and_check_return_val(lua, 0);
+
+ // get the path
+ tb_char_t const* path = luaL_checkstring(lua, 1);
+ tb_check_return_val(path, 0);
+
+ // done os.filesize(path)
+ tb_file_info_t info = {0};
+ if (tb_file_info(path, &info) && (info.type == TB_FILE_TYPE_FILE))
+ lua_pushinteger(lua, (lua_Integer)info.size);
+ else lua_pushinteger(lua, 0);
+
+ // ok
+ return 1;
+}
diff --git a/xmake/core/sandbox/modules/interpreter/os.lua b/xmake/core/sandbox/modules/interpreter/os.lua
index 3ec2cf120..abb45d36d 100644
--- a/xmake/core/sandbox/modules/interpreter/os.lua
+++ b/xmake/core/sandbox/modules/interpreter/os.lua
@@ -43,6 +43,7 @@ sandbox_os.isfile = os.isfile
sandbox_os.exists = os.exists
sandbox_os.curdir = os.curdir
sandbox_os.tmpdir = os.tmpdir
+sandbox_os.filesize = os.filesize
sandbox_os.programdir = os.programdir
sandbox_os.programfile = os.programfile
sandbox_os.projectdir = os.projectdir
diff --git a/xmake/core/sandbox/modules/os.lua b/xmake/core/sandbox/modules/os.lua
index 338dc35c2..ad6c60e0a 100644
--- a/xmake/core/sandbox/modules/os.lua
+++ b/xmake/core/sandbox/modules/os.lua
@@ -52,6 +52,7 @@ sandbox_os.getenv = os.getenv
sandbox_os.setenv = os.setenv
sandbox_os.addenv = os.addenv
sandbox_os.emptydir = os.emptydir
+sandbox_os.filesize = os.filesize
sandbox_os.workingdir = os.workingdir
sandbox_os.programdir = os.programdir
sandbox_os.programfile = os.programfile