🔧 build: 修改 makefile
parent
3818bdcad8
commit
841999c589
@ -1,19 +0,0 @@
|
|||||||
Copyright (C) 2010-2013 nsf <no.smile.face@gmail.com>
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
||||||
@ -1,2 +0,0 @@
|
|||||||
*.o
|
|
||||||
*.so
|
|
||||||
@ -1,26 +1,30 @@
|
|||||||
PROJECT = rc4
|
SKYNET_ROOT ?= ../../skynet
|
||||||
SRC = .
|
include $(SKYNET_ROOT)/platform.mk
|
||||||
INC = -I. -I/usr/local/include
|
|
||||||
|
|
||||||
CC = gcc
|
|
||||||
CC_FLAGS = -O2 -fPIC $(INC) -Wall -Wextra -c
|
|
||||||
|
|
||||||
SRC_C = $(foreach dir, $(SRC), $(wildcard $(dir)/*.c))
|
PLAT ?= none
|
||||||
OBJ_C = $(patsubst %.c, %.o, $(SRC_C))
|
|
||||||
OBJ = $(OBJ_C)
|
|
||||||
|
|
||||||
.PHONY : all
|
TARGET = ../../luaclib/rc4.so
|
||||||
all: $(PROJECT).so
|
|
||||||
|
|
||||||
$(PROJECT).so: $(OBJ)
|
ifeq ($(PLAT), macosx)
|
||||||
ld -shared $(OBJ) -o $(PROJECT).so
|
CFLAGS = -g -O2 -dynamiclib -Wl,-undefined,dynamic_lookup
|
||||||
ifdef OUTPUT
|
else
|
||||||
cp -f $(PROJECT).so $(OUTPUT)
|
ifeq ($(PLAT), linux)
|
||||||
|
CFLAGS = -g -O2 -shared -fPIC
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
LUA_LIB ?= $(SKYNET_ROOT)/3rd/lua/
|
||||||
|
LUA_INC ?= $(SKYNET_ROOT)/3rd/lua/
|
||||||
|
SKYNET_SRC ?= $(SKYNET_ROOT)/skynet-src
|
||||||
|
|
||||||
|
SRC = .
|
||||||
|
|
||||||
|
.PHONY: all clean
|
||||||
|
|
||||||
|
all: $(TARGET)
|
||||||
|
|
||||||
$(OBJ_C) : %.o : %.c
|
$(TARGET): $(foreach dir, $(SRC), $(wildcard $(dir)/*.c))
|
||||||
$(CC) $(CC_FLAGS) -o $@ $<
|
$(CC) $(CFLAGS) $(SHARED) -I$(LUA_INC) -I$(SKYNET_SRC) $^ -o $@
|
||||||
|
|
||||||
.PHONY : clean
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(PROJECT).so $(OBJ)
|
rm -f *.o $(TARGET)
|
||||||
@ -1,81 +1,93 @@
|
|||||||
-- sample for termfx
|
-- sample for termfx
|
||||||
-- Gunnar Zötl <gz@tset.de>, 2014-2015
|
-- Gunnar Zötl <gz@tset.de>, 2014-2015
|
||||||
-- Released under the terms of the MIT license. See file LICENSE for details.
|
-- Released under the terms of the MIT license. See file LICENSE for details.
|
||||||
|
|
||||||
tfx = require "termfx"
|
tfx = require "termfx"
|
||||||
|
|
||||||
tfx.init()
|
tfx.init()
|
||||||
|
|
||||||
function makespr(s, fg, bg)
|
function makespr(s, fg, bg)
|
||||||
local c = "-:+=%ZXH#"
|
local c = "-:+=%ZXH#"
|
||||||
local spr = tfx.newbuffer(s, s/2)
|
local spr = tfx.newbuffer(s, s / 2)
|
||||||
spr:attributes(fg, bg)
|
spr:attributes(fg, bg)
|
||||||
for y=1, s/2 do
|
for y = 1, s / 2 do
|
||||||
for x=1, s do
|
for x = 1, s do
|
||||||
local lx, ly = (x-0.5)/s, (2*y-1)/s
|
local lx, ly = (x - 0.5) / s, (2 * y - 1) / s
|
||||||
local v = math.floor((math.sin(lx*math.pi) + math.sin(ly*math.pi)) / 2 * #c)
|
local v = math.floor((math.sin(lx * math.pi) + math.sin(ly * math.pi)) / 2 * #c)
|
||||||
local ch = string.sub(c, v, v)
|
local ch = string.sub(c, v, v)
|
||||||
spr:setcell(x, y, ch)
|
spr:setcell(x, y, ch)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return spr
|
return spr
|
||||||
end
|
end
|
||||||
|
|
||||||
tfx.outputmode(tfx.output.NORMAL)
|
tfx.outputmode(tfx.output.NORMAL)
|
||||||
|
|
||||||
ok, err = pcall(function()
|
ok, err = pcall(function()
|
||||||
local sprites = {}
|
local sprites = {}
|
||||||
local blit2screen = true
|
local blit2screen = true
|
||||||
|
|
||||||
for i=1, 5 do
|
for i = 1, 5 do
|
||||||
sprites[i] = makespr(2^(i+2), i+1, tfx.color.BLACK)
|
sprites[i] = makespr(2 ^ (i + 2), i + 1, tfx.color.BLACK)
|
||||||
end
|
end
|
||||||
|
|
||||||
local snum = 1
|
local snum = 1
|
||||||
local spr = sprites[snum]
|
local spr = sprites[snum]
|
||||||
local sw, sh = spr:width(), spr:height()
|
local sw, sh = spr:width(), spr:height()
|
||||||
local x, y = 1-sw, 1-sh
|
local x, y = 1 - sw, 1 - sh
|
||||||
local xo, yo = 1, 1
|
local xo, yo = 1, 1
|
||||||
local fw, fh = tfx.width(), tfx.height()
|
local fw, fh = tfx.width(), tfx.height()
|
||||||
local target = tfx.newbuffer(fw - 2, fh - 2)
|
local target = tfx.newbuffer(fw - 2, fh - 2)
|
||||||
local w, h = target:width(), target:height()
|
local w, h = target:width(), target:height()
|
||||||
|
|
||||||
|
repeat
|
||||||
|
|
||||||
repeat
|
if blit2screen then
|
||||||
|
tfx.clear(tfx.color.WHITE, tfx.color.BLACK)
|
||||||
if blit2screen then
|
tfx.blit(x, y, spr)
|
||||||
tfx.clear(tfx.color.WHITE, tfx.color.BLACK)
|
else
|
||||||
tfx.blit(x, y, spr)
|
tfx.clear(tfx.color.WHITE, tfx.color.RED)
|
||||||
else
|
target:clear(tfx.color.WHITE, tfx.color.BLACK)
|
||||||
tfx.clear(tfx.color.WHITE, tfx.color.RED)
|
target:blit(x, y, spr)
|
||||||
target:clear(tfx.color.WHITE, tfx.color.BLACK)
|
tfx.blit(2, 2, target)
|
||||||
target:blit(x, y, spr)
|
end
|
||||||
tfx.blit(2, 2, target)
|
|
||||||
end
|
|
||||||
|
|
||||||
x = x + xo
|
x = x + xo
|
||||||
if x > w or x < 1-sw then xo = -xo end
|
if x > w or x < 1 - sw then
|
||||||
y = y + yo
|
xo = -xo
|
||||||
if y > h or y < 1-sh then yo = -yo end
|
end
|
||||||
|
y = y + yo
|
||||||
|
if y > h or y < 1 - sh then
|
||||||
|
yo = -yo
|
||||||
|
end
|
||||||
|
|
||||||
tfx.printat(1, tfx.height(), "print 1.."..#sprites.." for sprite size, t to toggle blit to screen or buffer, q to quit")
|
tfx.printat(1, tfx.height(),
|
||||||
tfx.printat(1, 1, "Current size: "..snum.." ("..spr:width().."x"..spr:height()..")")
|
"print 1.." .. #sprites .. " for sprite size, t to toggle blit to screen or buffer, q to quit")
|
||||||
|
tfx.printat(1, 1, "Current size: " .. snum .. " (" .. spr:width() .. "x" .. spr:height() .. ")")
|
||||||
|
|
||||||
tfx.present()
|
tfx.present()
|
||||||
evt = tfx.pollevent(333)
|
evt = tfx.pollevent(333)
|
||||||
snum = evt and tonumber(evt.char) or snum
|
snum = evt and tonumber(evt.char) or snum
|
||||||
if snum >= 1 and snum <= #sprites then
|
if snum >= 1 and snum <= #sprites then
|
||||||
spr = sprites[snum]
|
spr = sprites[snum]
|
||||||
sw, sh = spr:width(), spr:height()
|
sw, sh = spr:width(), spr:height()
|
||||||
if x < 1-sw then x = 1-sw xo = 1 end
|
if x < 1 - sw then
|
||||||
if y < 1-sh then y = 1-sh yo = 1 end
|
x = 1 - sw
|
||||||
end
|
xo = 1
|
||||||
|
end
|
||||||
if evt and evt.char == 't' then
|
if y < 1 - sh then
|
||||||
blit2screen = not blit2screen
|
y = 1 - sh
|
||||||
end
|
yo = 1
|
||||||
|
end
|
||||||
until evt and evt.type == "key" and evt.char == "q"
|
end
|
||||||
|
|
||||||
|
if evt and evt.char == 't' then
|
||||||
|
blit2screen = not blit2screen
|
||||||
|
end
|
||||||
|
|
||||||
|
until evt and evt.type == "key" and evt.char == "q"
|
||||||
end)
|
end)
|
||||||
|
|
||||||
tfx.shutdown()
|
tfx.shutdown()
|
||||||
if not ok then print("Error: "..err) end
|
if not ok then
|
||||||
|
print("Error: " .. err)
|
||||||
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue