<commit_before>local app 		= require('app')
local utils 	= require('util')
local path  	= require('path')
local fs  		= require('fs')
local zlib  	= require('zlib')
local json  	= require('json')

local exec      = require('child_process').exec

local copy  	= fs.copyfileSync
local cwd		= process.cwd()
local join  	= path.join

-------------------------------------------------------------------------------
-- copy

local platform = os.platform()
local arch = os.arch()

-------------------------------------------------------------------------------
-- 

local exports = {}

local copy_files

--[[
复制文件或目录，相当于 `cp -rf`
@param source {String} 源文件
@param target {String} 目标文件
--]]
function copy_files(source, target)
	if (not source) or (not target) then
		return
	end

	local join  = path.join
	fs.mkdirpSync(target)

	local files = fs.readdirSync(source)
    if (not files) then 
    	return 
    end

    for i = 1, #files do
        local name = files[i]
        if (name:sub(1, 1) ~= ".") then
            local stat = fs.statSync(join(source, name))
            if (not stat) then
            	console.log(source, name)
            end

            if (stat.type == 'file') then
            	copy(join(source, name), join(target, name))

            elseif (stat.type == 'directory') then
            	copy_files(join(source, name), join(target, name))
            end
        end
    end
end 

local xcopy = copy_files

local function get_make_board()
    -- 只有 linux 下支持交叉编译
	local target = fs.readFileSync('build/target') or 'local'
	return target:trim()
end

local function get_make_target()
	local board = get_make_board()
	if (board ~= "local") then
		return board .. "-linux"
	end

	return arch .. "-" .. platform
end

local function get_make_version()
	local version = process.version
	version = version:trim()
	return version
end

local sdk = {}

function sdk.build_common_sdk(target, packageInfo)
	local sdkPath  = sdk.get_sdk_build_path(target, packageInfo.type)
	local nodePath = join(sdkPath, "usr/local/lnode")

	local mkdir = fs.mkdirpSync
	mkdir(join(nodePath, "lib"))

	local board = get_make_board()

	-- copy lib files
	local buildPath  = join(cwd, "build", board)

	local libs = packageInfo.libs or {}
	for _, file in ipairs(libs) do
		local destFile = join(nodePath, 'lib', file)
		copy(join(buildPath,  file), destFile)
	end

	-- copy modules lua files
	local visionPath = join(cwd, "modules")
	--xcopy(visionPath, join(nodePath, "lib"))

	local files = fs.readdirSync(visionPath)
	if (files) then
		for i = 1, #files do
			local name = files[i]
			local luaPath = join(visionPath, name, "lua")
			console.log(luaPath)

			if (fs.existsSync(luaPath)) then
				xcopy(luaPath, join(nodePath, "lib", name))
			end
		end
	end

	-- copy app files
	mkdir(join(nodePath, "app"))
	local applications = packageInfo.applications or {}
	for _, key in ipairs(applications) do
		local file =  key
		xcopy(join(cwd, "app", file),  join(nodePath , "app", file))
	end

	if (packageInfo.type ~= 'patch') then
		mkdir(join(nodePath, "bin"))
		mkdir(join(nodePath, "conf"))
		mkdir(join(nodePath, "lua"))
<commit_msg>remove app in sdk<commit_after>local app 		= require('app')
local utils 	= require('util')
local path  	= require('path')
local fs  		= require('fs')
local zlib  	= require('zlib')
local json  	= require('json')

local exec      = require('child_process').exec

local copy  	= fs.copyfileSync
local cwd		= process.cwd()
local join  	= path.join

-------------------------------------------------------------------------------
-- copy

local platform = os.platform()
local arch = os.arch()

-------------------------------------------------------------------------------
-- 

local exports = {}

local copy_files

--[[
复制文件或目录，相当于 `cp -rf`
@param source {String} 源文件
@param target {String} 目标文件
--]]
function copy_files(source, target)
	if (not source) or (not target) then
		return
	end

	local join  = path.join
	fs.mkdirpSync(target)

	local files = fs.readdirSync(source)
    if (not files) then 
    	return 
    end

    for i = 1, #files do
        local name = files[i]
        if (name:sub(1, 1) ~= ".") then
            local stat = fs.statSync(join(source, name))
            if (not stat) then
            	console.log(source, name)
            end

            if (stat.type == 'file') then
            	copy(join(source, name), join(target, name))

            elseif (stat.type == 'directory') then
            	copy_files(join(source, name), join(target, name))
            end
        end
    end
end 

local xcopy = copy_files

local function get_make_board()
    -- 只有 linux 下支持交叉编译
	local target = fs.readFileSync('build/target') or 'local'
	return target:trim()
end

local function get_make_target()
	local board = get_make_board()
	if (board ~= "local") then
		return board .. "-linux"
	end

	return arch .. "-" .. platform
end

local function get_make_version()
	local version = process.version
	version = version:trim()
	return version
end

local sdk = {}

function sdk.build_common_sdk(target, packageInfo)
	local sdkPath  = sdk.get_sdk_build_path(target, packageInfo.type)
	local nodePath = join(sdkPath, "usr/local/lnode")

	local mkdir = fs.mkdirpSync
	mkdir(join(nodePath, "lib"))

	local board = get_make_board()

	-- copy lib files
	local buildPath  = join(cwd, "build", board)

	local libs = packageInfo.libs or {}
	for _, file in ipairs(libs) do
		local destFile = join(nodePath, 'lib', file)
		copy(join(buildPath,  file), destFile)
	end

	-- copy modules lua files
	local visionPath = join(cwd, "modules")
	--xcopy(visionPath, join(nodePath, "lib"))

	local files = fs.readdirSync(visionPath)
	if (files) then
		for i = 1, #files do
			local name = files[i]
			local luaPath = join(visionPath, name, "lua")
			console.log(luaPath)

			if (fs.existsSync(luaPath)) then
				xcopy(luaPath, join(nodePath, "lib", name))
			end
		end
	end

	if (packageInfo.type ~= 'patch') then
		mkdir(join(nodePath, "bin"))
		mkdir(join(nodePath, "lua"))

{'fraction_non_alphanumeric': 0.17422474158052684, 'fraction_numerical': 0.001333777925975325, 'mean_word_length': 2.5602373887240355, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7104936', 'n_tokens_mistral': 2078, 'n_tokens_neox': 1981, 'n_words': 553}