0
我對Ruby有很少的經驗,我試圖構建一個簡單的自制公式。我有以下結構構建一個C++公式爲自制軟件
.
├── Makefile
└── test.cpp
0 directories, 2 files
和一個簡單的測試項目,然後我有以下.rb
公式文件
class Testbrew < Formula
desc ""
homepage ""
url ""
version ""
head ""
sha256 ""
def install
# system "make"
# system("g++ -std=c++14 -O3 test.cpp -o testbrew")
system "g++", "-std=c++14",
"-O3",
"-Wall",
"-Werror",
"-Wextra",
"-pedantic",
"-Wvla",
"test.cpp",
"-o testbrew"
bin.install "testbrew"
ohai("Done!")
end
end
這裏的混亂的部分是前兩個評論system
工作線安裝包但第三不,爲什麼?如果我嘗試第三行我得到的錯誤
==> g++ -std=c++14 -O3 -Wall -Werror -Wextra -pedantic -Wvla test.cpp -o testbrew
Error: No such file or directory - testbrew
另外,作爲一個後續,是否有某些事情,該函數調用system()
不允許用戶做什麼?即是否存在任何安全限制(例如使用ptrace
)?
'system'不會知道你的'bash_profile'的,所以也許'testbrew'不獲取添加到'PATH'喜歡經常做。也許嘗試傳遞絕對路徑。請參閱http://stackoverflow.com/questions/28555822/how-do-i-make-rubys-system-call-aware-of-my-bash-profile-aliases –
@maxple但那麼第二個'系統( )'在同樣的情況下致電工作?第二個工作正常,'bin.install'能夠將它複製到所需的目錄 – Curious
dunno。祝你好運 –