Linux Windows 的“制作”命令 - 可能的选项?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16755641/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"Make" command for Windows - possible options?
提问by User093203920
I am trying to setup Derby.js for Node on my Windows Machine. According to the Derby.js setup instructions, in order to use coffescript, I must do the following:
我正在尝试在我的 Windows 机器上为 Node 设置 Derby.js。根据 Derby.js 设置说明,为了使用 coffescript,我必须执行以下操作:
$ cd ~
$ derby new --coffee first-project
$ cd first-project
$ make
This worked, up until the "make" portion, which obviously requires a make program. I downloaded a make.exe file that is supposed to get it going, but it tells me that it can't find the file. I opened the make-file in a text editor to see if the path it pointed to exists, and it does. I'm wondering if it has to reference the path to the file differently since its located on windows and is being run through the command prompt? Does anyone know what I might be able to do? All I can think of is setting it up on a VM of linux, and then copying the files over, but it's a bit of a pain to do.
这一直有效,直到“make”部分,这显然需要一个 make 程序。我下载了一个应该可以运行的 make.exe 文件,但它告诉我它找不到该文件。我在文本编辑器中打开 make-file 以查看它指向的路径是否存在,并且确实存在。我想知道它是否必须以不同的方式引用文件路径,因为它位于 Windows 上并且正在通过命令提示符运行?有谁知道我能做什么?我能想到的就是在Linux的VM上设置它,然后将文件复制过来,但这有点麻烦。
采纳答案by steveha
As you found, a stand-alone make
wasn't enough; you needed Cygwin.
正如您所发现的,单机make
是不够的;你需要 Cygwin。
make
is a program that interprets a makefile and executes the commands in the makefile. But, what are those commands? If you look at your makefile you will see UNIX-style commands that are available in Linux, Mac OS X, or Cygwin but are not available in an off-the-shelf Windows system. Thus, simply grabbing a make
wasn't enough.
make
是一个解释生成文件并执行生成文件中命令的程序。但是,那些命令是什么?如果您查看您的 makefile,您将看到 UNIX 风格的命令,这些命令在 Linux、Mac OS X 或 Cygwin 中可用,但在现成的 Windows 系统中不可用。因此,仅仅抓住一个make
是不够的。
回答by User093203920
So I ended up downloading Cygwin and used the "make" system that came with it. It worked perfectly! I honestly have no idea why the GnuWin32 "make" command didn't work, but I suppose this would be helpful to those who encounter the same issue in the future.
所以我最终下载了 Cygwin 并使用了它附带的“make”系统。它工作得很好!老实说,我不知道为什么 GnuWin32“make”命令不起作用,但我想这对将来遇到相同问题的人会有所帮助。
回答by icktoofay
回答by ian0411
If you are looking for possible options, I actually have one which will utilize PowerShell. “Make” executes commands in the makefile so that is why I used PowerShell to accomplish similar tasks. However, be warned that I only did this for my Django project. Read below if this interests you and here is the sample:
如果您正在寻找可能的选项,我实际上有一个将使用PowerShell 的选项。“Make”执行 makefile 中的命令,这就是我使用 PowerShell 来完成类似任务的原因。但是,请注意,我只为我的 Django 项目执行了此操作。如果您对此感兴趣,请阅读以下内容,这是示例:
- Created a PowerShell file something like initial.ps1.
- Insert contents that you see or expect in the makefile. Here is the example I used for my Django project:
- 创建了一个类似于 initial.ps1 的 PowerShell 文件。
- 插入您在 makefile 中看到或期望的内容。这是我用于 Django 项目的示例:
# Bypass the execution policy (do this if needed)
Set-ExecutionPolicy RemoteSigned
# Setup variables
$proj = "proj"
$app = "app"
# Starting Virtual Environment
virtualenv $proj
cd .$proj
.\Scripts\activate
# Install project
pip install --upgrade pip
pip install django
# Starting app
django-admin startproject $app
cd .$app
# Build the project and the app
python .\manage.py makemigrations
python .\manage.py migrate
python .\manage.py createsuperuser
- Open CMD and run the ps1.
- 打开CMD并运行ps1。
This is very handy at least for me so I don't need to type all those commands over and over when creating new projects. Hope this helps.
这至少对我来说非常方便,所以我不需要在创建新项目时一遍又一遍地键入所有这些命令。希望这可以帮助。