├── .editorconfig ├── .github └── workflows │ └── build.yml ├── .gitignore ├── LICENSE ├── README.md ├── build ├── gmake.darwin │ ├── Makefile │ └── genie.make ├── gmake.freebsd │ ├── Makefile │ └── genie.make ├── gmake.linux │ ├── Makefile │ └── genie.make └── gmake.windows │ ├── Makefile │ └── genie.make ├── docs └── scripting-reference.md ├── makefile ├── scripts ├── embed.lua ├── genie.lua └── release.lua ├── src ├── _manifest.lua ├── _premake_main.lua ├── actions │ ├── cmake │ │ ├── _cmake.lua │ │ ├── cmake_project.lua │ │ └── cmake_workspace.lua │ ├── example │ │ ├── _example.lua │ │ ├── example_project.lua │ │ └── example_solution.lua │ ├── jcdb │ │ ├── _jcdb.lua │ │ └── jcdb_solution.lua │ ├── make │ │ ├── _make.lua │ │ ├── make_cpp.lua │ │ ├── make_csharp.lua │ │ ├── make_solution.lua │ │ ├── make_swift.lua │ │ └── make_vala.lua │ ├── ninja │ │ ├── _ninja.lua │ │ ├── ninja_base.lua │ │ ├── ninja_cpp.lua │ │ ├── ninja_solution.lua │ │ ├── ninja_swift.lua │ │ └── ninja_swift_incremental.lua │ ├── vstudio │ │ ├── _vstudio.lua │ │ ├── vs2010.lua │ │ ├── vs2012.lua │ │ ├── vs2013.lua │ │ ├── vs2015.lua │ │ ├── vs2017.lua │ │ ├── vs2019.lua │ │ ├── vs2022.lua │ │ ├── vstudio_solution.lua │ │ ├── vstudio_vcxproj.lua │ │ └── vstudio_vcxproj_filters.lua │ └── xcode │ │ ├── _xcode.lua │ │ ├── xcode10.lua │ │ ├── xcode11.lua │ │ ├── xcode14.lua │ │ ├── xcode15.lua │ │ ├── xcode8.lua │ │ ├── xcode9.lua │ │ ├── xcode_common.lua │ │ ├── xcode_project.lua │ │ ├── xcode_scheme.lua │ │ └── xcode_workspace.lua ├── base │ ├── action.lua │ ├── api.lua │ ├── bake.lua │ ├── cmdline.lua │ ├── config.lua │ ├── globals.lua │ ├── help.lua │ ├── inspect.lua │ ├── io.lua │ ├── iter.lua │ ├── option.lua │ ├── os.lua │ ├── path.lua │ ├── premake.lua │ ├── profiler.lua │ ├── project.lua │ ├── set.lua │ ├── solution.lua │ ├── string.lua │ ├── table.lua │ ├── tree.lua │ └── validate.lua ├── host │ ├── lua-5.3.0 │ │ ├── Makefile │ │ ├── README │ │ ├── doc │ │ │ ├── contents.html │ │ │ ├── logo.gif │ │ │ ├── lua.1 │ │ │ ├── lua.css │ │ │ ├── luac.1 │ │ │ ├── manual.css │ │ │ ├── manual.html │ │ │ ├── osi-certified-72x60.png │ │ │ └── readme.html │ │ └── src │ │ │ ├── Makefile │ │ │ ├── lapi.c │ │ │ ├── lapi.h │ │ │ ├── lauxlib.c │ │ │ ├── lauxlib.h │ │ │ ├── lbaselib.c │ │ │ ├── lbitlib.c │ │ │ ├── lcode.c │ │ │ ├── lcode.h │ │ │ ├── lcorolib.c │ │ │ ├── lctype.c │ │ │ ├── lctype.h │ │ │ ├── ldblib.c │ │ │ ├── ldebug.c │ │ │ ├── ldebug.h │ │ │ ├── ldo.c │ │ │ ├── ldo.h │ │ │ ├── ldump.c │ │ │ ├── lfunc.c │ │ │ ├── lfunc.h │ │ │ ├── lgc.c │ │ │ ├── lgc.h │ │ │ ├── linit.c │ │ │ ├── liolib.c │ │ │ ├── llex.c │ │ │ ├── llex.h │ │ │ ├── llimits.h │ │ │ ├── lmathlib.c │ │ │ ├── lmem.c │ │ │ ├── lmem.h │ │ │ ├── loadlib.c │ │ │ ├── lobject.c │ │ │ ├── lobject.h │ │ │ ├── lopcodes.c │ │ │ ├── lopcodes.h │ │ │ ├── loslib.c │ │ │ ├── lparser.c │ │ │ ├── lparser.h │ │ │ ├── lprefix.h │ │ │ ├── lstate.c │ │ │ ├── lstate.h │ │ │ ├── lstring.c │ │ │ ├── lstring.h │ │ │ ├── lstrlib.c │ │ │ ├── ltable.c │ │ │ ├── ltable.h │ │ │ ├── ltablib.c │ │ │ ├── ltm.c │ │ │ ├── ltm.h │ │ │ ├── lua.c │ │ │ ├── lua.h │ │ │ ├── lua.hpp │ │ │ ├── luac.c │ │ │ ├── luaconf.h │ │ │ ├── lualib.h │ │ │ ├── lundump.c │ │ │ ├── lundump.h │ │ │ ├── lutf8lib.c │ │ │ ├── lvm.c │ │ │ ├── lvm.h │ │ │ ├── lzio.c │ │ │ └── lzio.h │ ├── os_chdir.c │ ├── os_copyfile.c │ ├── os_getcwd.c │ ├── os_is64bit.c │ ├── os_isdir.c │ ├── os_isfile.c │ ├── os_match.c │ ├── os_mkdir.c │ ├── os_pathsearch.c │ ├── os_rmdir.c │ ├── os_stat.c │ ├── os_ticks.c │ ├── os_uuid.c │ ├── path_getabsolute.c │ ├── path_getrelative.c │ ├── path_helpers.c │ ├── path_isabsolute.c │ ├── premake.c │ ├── premake.h │ ├── premake_main.c │ ├── scripts.c │ ├── string_endswith.c │ ├── string_hash.c │ └── version.h └── tools │ ├── dotnet.lua │ ├── gcc.lua │ ├── ghs.lua │ ├── msc.lua │ ├── ow.lua │ ├── snc.lua │ ├── swift.lua │ └── valac.lua └── tests ├── actions ├── make │ ├── test_make_escaping.lua │ ├── test_make_linking.lua │ ├── test_make_pch.lua │ ├── test_makesettings.lua │ └── test_wiidev.lua ├── test_clean.lua └── vstudio │ ├── cs2002 │ └── test_files.lua │ ├── cs2005 │ ├── projectelement.lua │ ├── projectsettings.lua │ ├── propertygroup.lua │ └── test_files.lua │ ├── sln2005 │ ├── dependencies.lua │ ├── header.lua │ ├── layout.lua │ ├── platforms.lua │ ├── projectplatforms.lua │ └── projects.lua │ ├── test_vs200x_vcproj.lua │ ├── test_vs200x_vcproj_linker.lua │ ├── test_vs2010_flags.lua │ ├── test_vs2010_project_kinds.lua │ ├── test_vs2010_vcxproj.lua │ ├── vc200x │ ├── debugdir.lua │ ├── header.lua │ ├── test_files.lua │ └── test_filters.lua │ └── vc2010 │ ├── test_config_props.lua │ ├── test_debugdir.lua │ ├── test_files.lua │ ├── test_filters.lua │ ├── test_header.lua │ ├── test_link_settings.lua │ ├── test_links.lua │ ├── test_output_props.lua │ ├── test_pch.lua │ └── test_project_refs.lua ├── baking └── test_merging.lua ├── base ├── test_action.lua ├── test_api.lua ├── test_baking.lua ├── test_config.lua ├── test_config_bug.lua ├── test_location.lua ├── test_os.lua ├── test_path.lua ├── test_premake_command.lua ├── test_table.lua └── test_tree.lua ├── folder ├── ok.lua └── ok.lua.2 ├── pepperfish_profiler.lua ├── premake4.lua ├── project ├── test_eachfile.lua └── test_vpaths.lua ├── stress ├── test ├── test.bat ├── test_dofile.lua ├── test_gmake_cpp.lua ├── test_gmake_cs.lua ├── test_keywords.lua ├── test_platforms.lua ├── test_premake.lua ├── test_project.lua ├── test_stress.lua ├── test_string.lua ├── test_targets.lua ├── testfx.lua └── tools └── test_gcc.lua /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = tab 5 | indent_size = 4 6 | end_of_line = lf 7 | max_line_length = 100 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | max_line_length = 80 14 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build and Upload Artifact 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - master 7 | push: 8 | branches: 9 | - master 10 | 11 | jobs: 12 | build: 13 | strategy: 14 | matrix: 15 | os: [ubuntu-latest, macos-latest, windows-latest] 16 | runs-on: ${{ matrix.os }} 17 | 18 | steps: 19 | - uses: actions/checkout@v2 20 | name: Checkout code 21 | 22 | - name: Install dependencies (Ubuntu) 23 | if: matrix.os == 'ubuntu-latest' 24 | run: | 25 | sudo apt-get update 26 | sudo apt-get install -y make 27 | shell: bash 28 | 29 | - name: Install dependencies (macOS) 30 | if: matrix.os == 'macos-latest' 31 | run: | 32 | brew install make 33 | shell: bash 34 | 35 | - name: Install dependencies (Windows) 36 | if: matrix.os == 'windows-latest' 37 | run: | 38 | choco install make 39 | shell: pwsh 40 | 41 | - name: Build project 42 | run: make 43 | shell: bash 44 | 45 | - name: Archive production artifacts (Linux) 46 | if: matrix.os == 'ubuntu-latest' 47 | uses: actions/upload-artifact@v4 48 | with: 49 | name: build-artifacts-linux 50 | path: bin/linux/genie 51 | 52 | - name: Archive production artifacts (macOS) 53 | if: matrix.os == 'macos-latest' 54 | uses: actions/upload-artifact@v4 55 | with: 56 | name: build-artifacts-macos 57 | path: bin/darwin/genie 58 | 59 | - name: Archive production artifacts (Windows) 60 | if: matrix.os == 'windows-latest' 61 | uses: actions/upload-artifact@v4 62 | with: 63 | name: build-artifacts-windows 64 | path: bin/windows/genie.exe 65 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .build 2 | bin 3 | build/*/obj 4 | src/host/scripts.c 5 | -------------------------------------------------------------------------------- /build/gmake.darwin/Makefile: -------------------------------------------------------------------------------- 1 | # GNU Make solution makefile autogenerated by GENie 2 | # Type "make help" for usage help 3 | 4 | ifndef config 5 | config=release 6 | endif 7 | export config 8 | 9 | PROJECTS := genie 10 | 11 | .PHONY: all clean help $(PROJECTS) 12 | 13 | all: $(PROJECTS) 14 | 15 | genie: 16 | @echo "==== Building genie ($(config)) ====" 17 | @${MAKE} --no-print-directory -C . -f genie.make 18 | 19 | clean: 20 | @${MAKE} --no-print-directory -C . -f genie.make clean 21 | 22 | help: 23 | @echo "Usage: make [config=name] [target]" 24 | @echo "" 25 | @echo "CONFIGURATIONS:" 26 | @echo " release" 27 | @echo " debug" 28 | @echo " releaseuniv32" 29 | @echo " debuguniv32" 30 | @echo "" 31 | @echo "TARGETS:" 32 | @echo " all (default)" 33 | @echo " clean" 34 | @echo " genie" 35 | @echo "" 36 | @echo "For more information, see https://github.com/bkaradzic/genie" 37 | -------------------------------------------------------------------------------- /build/gmake.freebsd/Makefile: -------------------------------------------------------------------------------- 1 | # GNU Make solution makefile autogenerated by GENie 2 | # Type "make help" for usage help 3 | 4 | ifndef config 5 | config=release 6 | endif 7 | export config 8 | 9 | PROJECTS := genie 10 | 11 | .PHONY: all clean help $(PROJECTS) 12 | 13 | all: $(PROJECTS) 14 | 15 | genie: 16 | @echo "==== Building genie ($(config)) ====" 17 | @${MAKE} --no-print-directory -C . -f genie.make 18 | 19 | clean: 20 | @${MAKE} --no-print-directory -C . -f genie.make clean 21 | 22 | help: 23 | @echo "Usage: make [config=name] [target]" 24 | @echo "" 25 | @echo "CONFIGURATIONS:" 26 | @echo " release" 27 | @echo " debug" 28 | @echo "" 29 | @echo "TARGETS:" 30 | @echo " all (default)" 31 | @echo " clean" 32 | @echo " genie" 33 | @echo "" 34 | @echo "For more information, see https://github.com/bkaradzic/genie" 35 | -------------------------------------------------------------------------------- /build/gmake.linux/Makefile: -------------------------------------------------------------------------------- 1 | # GNU Make solution makefile autogenerated by GENie 2 | # Type "make help" for usage help 3 | 4 | ifndef config 5 | config=release 6 | endif 7 | export config 8 | 9 | PROJECTS := genie 10 | 11 | .PHONY: all clean help $(PROJECTS) 12 | 13 | all: $(PROJECTS) 14 | 15 | genie: 16 | @echo "==== Building genie ($(config)) ====" 17 | @${MAKE} --no-print-directory -C . -f genie.make 18 | 19 | clean: 20 | @${MAKE} --no-print-directory -C . -f genie.make clean 21 | 22 | help: 23 | @echo "Usage: make [config=name] [target]" 24 | @echo "" 25 | @echo "CONFIGURATIONS:" 26 | @echo " release" 27 | @echo " debug" 28 | @echo "" 29 | @echo "TARGETS:" 30 | @echo " all (default)" 31 | @echo " clean" 32 | @echo " genie" 33 | @echo "" 34 | @echo "For more information, see https://github.com/bkaradzic/genie" 35 | -------------------------------------------------------------------------------- /build/gmake.windows/Makefile: -------------------------------------------------------------------------------- 1 | # GNU Make solution makefile autogenerated by GENie 2 | # Type "make help" for usage help 3 | 4 | ifndef config 5 | config=release 6 | endif 7 | export config 8 | 9 | PROJECTS := genie 10 | 11 | .PHONY: all clean help $(PROJECTS) 12 | 13 | all: $(PROJECTS) 14 | 15 | genie: 16 | @echo "==== Building genie ($(config)) ====" 17 | @${MAKE} --no-print-directory -C . -f genie.make 18 | 19 | clean: 20 | @${MAKE} --no-print-directory -C . -f genie.make clean 21 | 22 | help: 23 | @echo "Usage: make [config=name] [target]" 24 | @echo "" 25 | @echo "CONFIGURATIONS:" 26 | @echo " release" 27 | @echo " debug" 28 | @echo "" 29 | @echo "TARGETS:" 30 | @echo " all (default)" 31 | @echo " clean" 32 | @echo " genie" 33 | @echo "" 34 | @echo "For more information, see https://github.com/bkaradzic/genie" 35 | -------------------------------------------------------------------------------- /makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2011-2014 Branimir Karadzic. All rights reserved. 3 | # License: http://www.opensource.org/licenses/BSD-2-Clause 4 | # 5 | 6 | UNAME := $(shell uname) 7 | ifeq ($(UNAME),$(filter $(UNAME),Linux Darwin SunOS FreeBSD GNU/kFreeBSD NetBSD OpenBSD GNU)) 8 | ifeq ($(UNAME),$(filter $(UNAME),Darwin)) 9 | OS=darwin 10 | else 11 | ifeq ($(UNAME),$(filter $(UNAME),SunOS)) 12 | OS=solaris 13 | else 14 | ifeq ($(UNAME),$(filter $(UNAME),FreeBSD GNU/kFreeBSD NetBSD OpenBSD)) 15 | OS=bsd 16 | else 17 | OS=linux 18 | endif 19 | endif 20 | endif 21 | else 22 | OS=windows 23 | endif 24 | 25 | .PHONY: release 26 | 27 | GENIE=bin/$(OS)/genie 28 | PROJECT_TYPE?=gmake 29 | 30 | SILENT?=@ 31 | 32 | $(GENIE): 33 | $(SILENT) $(MAKE) -C build/$(PROJECT_TYPE).$(OS) 34 | 35 | all: $(SILENT) $(GENIE) 36 | 37 | clean: 38 | $(SILENT) $(MAKE) -C build/$(PROJECT_TYPE).$(OS) clean 39 | $(SILENT) -rm -rf bin 40 | 41 | projgen: 42 | $(SILENT) $(GENIE) --to=../build/$(PROJECT_TYPE).windows --os=windows $(PROJECT_TYPE) 43 | $(SILENT) $(GENIE) --to=../build/$(PROJECT_TYPE).linux --os=linux $(PROJECT_TYPE) 44 | $(SILENT) $(GENIE) --to=../build/$(PROJECT_TYPE).darwin --os=macosx --platform=universal32 $(PROJECT_TYPE) 45 | $(SILENT) $(GENIE) --to=../build/$(PROJECT_TYPE).freebsd --os=bsd $(PROJECT_TYPE) 46 | 47 | rebuild: 48 | $(SILENT) $(MAKE) -C build/$(PROJECT_TYPE).$(OS) clean all 49 | 50 | release-windows release-darwin: $(GENIE) 51 | $(GENIE) release 52 | $(SILENT) $(MAKE) -C build/$(PROJECT_TYPE).$(OS) clean all 53 | $(SILENT) git checkout src/host/version.h 54 | 55 | release-linux: $(GENIE) 56 | $(SILENT) $(GENIE) release 57 | $(SILENT) $(MAKE) -C build/$(PROJECT_TYPE).darwin clean all CC=arm64-apple-darwin24.1-clang CFLAGS="-arch arm64" LDFLAGS="-arch arm64" 58 | $(SILENT) $(MAKE) -C build/$(PROJECT_TYPE).linux clean all 59 | $(SILENT) $(MAKE) -C build/$(PROJECT_TYPE).windows clean all CC=x86_64-w64-mingw32-gcc 60 | $(SILENT) git checkout src/host/version.h 61 | 62 | release: release-$(OS) 63 | 64 | dist: release 65 | cp bin/linux/genie ../bx/tools/bin/linux/ 66 | cp bin/windows/genie.exe ../bx/tools/bin/windows/ 67 | cp bin/darwin/genie ../bx/tools/bin/darwin/ 68 | -------------------------------------------------------------------------------- /scripts/embed.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Embed the Lua scripts into src/host/scripts.c as static data buffers. 3 | -- I embed the actual scripts, rather than Lua bytecodes, because the 4 | -- bytecodes are not portable to different architectures, which causes 5 | -- issues in Mac OS X Universal builds. 6 | -- 7 | 8 | local scriptdir = path.getdirectory(_SCRIPT) 9 | 10 | local function stripfile(fname) 11 | local f = io.open(fname) 12 | local s = assert(f:read("*a")) 13 | f:close() 14 | 15 | -- strip tabs 16 | s = s:gsub("[\t]", "") 17 | 18 | -- strip any CRs 19 | s = s:gsub("[\r]", "") 20 | 21 | -- strip out comments 22 | s = s:gsub("\n%-%-[^\n]*", "") 23 | 24 | -- escape backslashes 25 | s = s:gsub("\\", "\\\\") 26 | 27 | -- strip duplicate line feeds 28 | s = s:gsub("\n+", "\n") 29 | 30 | -- strip out leading comments 31 | s = s:gsub("^%-%-\n", "") 32 | 33 | -- escape line feeds 34 | s = s:gsub("\n", "\\n") 35 | 36 | -- escape double quote marks 37 | s = s:gsub("\"", "\\\"") 38 | 39 | return s 40 | end 41 | 42 | 43 | local function writeline(out, s, continues) 44 | out:write("\t\"") 45 | out:write(s) 46 | out:write(iif(continues, "\"\n", "\",\n")) 47 | end 48 | 49 | 50 | local function writefile(out, fname, contents) 51 | local max = 1024 52 | 53 | out:write("\t/* " .. fname .. " */\n") 54 | 55 | -- break up large strings to fit in Visual Studio's string length limit 56 | local start = 1 57 | local len = contents:len() 58 | while start <= len do 59 | local n = len - start 60 | if n > max then n = max end 61 | local finish = start + n 62 | 63 | -- make sure I don't cut an escape sequence 64 | while contents:sub(finish, finish) == "\\" do 65 | finish = finish - 1 66 | end 67 | 68 | writeline(out, contents:sub(start, finish), finish < len) 69 | start = finish + 1 70 | end 71 | 72 | out:write("\n") 73 | end 74 | 75 | 76 | function doembed() 77 | -- load the manifest of script files 78 | scripts = dofile(path.join(scriptdir, "../src/_manifest.lua")) 79 | 80 | -- main script always goes at the end 81 | table.insert(scripts, "_premake_main.lua") 82 | 83 | -- open scripts.c and write the file header 84 | local out = io.open(path.join(scriptdir, "../src/host/scripts.c"), "w+b") 85 | out:write("/* Premake's Lua scripts, as static data buffers for release mode builds */\n") 86 | out:write("/* DO NOT EDIT - this file is autogenerated - see BUILD.txt */\n") 87 | out:write("/* To regenerate this file, run: premake4 embed */ \n\n") 88 | out:write("const char* builtin_scripts[] = {\n") 89 | 90 | for i,fn in ipairs(scripts) do 91 | print(fn) 92 | local s = stripfile(path.join(scriptdir,"../src/" .. fn)) 93 | writefile(out, fn, s) 94 | end 95 | 96 | out:write("\t0\n};\n"); 97 | out:close() 98 | end 99 | -------------------------------------------------------------------------------- /scripts/release.lua: -------------------------------------------------------------------------------- 1 | function dorelease() 2 | -- 3 | -- Helper function: runs a command (formatted, with optional arguments) and 4 | -- suppresses any output. Works on both Windows and POSIX. Might be a good 5 | -- candidate for a core function. 6 | -- 7 | local function exec(cmd, ...) 8 | cmd = string.format(cmd, ...) 9 | local z = os.execute(cmd .. " > output.log 2> error.log") 10 | os.remove("output.log") 11 | os.remove("error.log") 12 | return z 13 | end 14 | 15 | 16 | print("Updating version number...") 17 | 18 | local f = io.popen("git rev-list --count HEAD") 19 | local rev = string.match(f:read("*a"), ".*%S") 20 | f:close() 21 | f = io.popen("git log --format=format:%H -1") 22 | local sha1 = f:read("*a") 23 | f:close() 24 | io.output("src/host/version.h") 25 | io.write("#define VERSION " ..rev .. "\n") 26 | io.write("#define VERSION_STR \"version " ..rev .. " (commit " .. sha1 .. ")\"\n") 27 | io.close() 28 | 29 | 30 | print("Updating embedded scripts...") 31 | 32 | local z = exec(_PREMAKE_COMMAND .. " embed") 33 | if z ~= true then 34 | error("** Failed to update the embedded scripts", 0) 35 | end 36 | 37 | 38 | print("Generating project files...") 39 | 40 | exec(_PREMAKE_COMMAND .. " /to=../build/gmake.windows /os=windows gmake") 41 | exec(_PREMAKE_COMMAND .. " /to=../build/gmake.linux /os=linux gmake") 42 | exec(_PREMAKE_COMMAND .. " /to=../build/gmake.darwin /os=macosx /platform=universal32 gmake") 43 | 44 | print("") 45 | print( "Finished.") 46 | 47 | end 48 | -------------------------------------------------------------------------------- /src/_manifest.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- _manifest.lua 3 | -- Manage the list of built-in Premake scripts. 4 | -- Copyright (c) 2002-2011 Jason Perkins and the Premake project 5 | -- 6 | 7 | -- The master list of built-in scripts. Order is important! If you want to 8 | -- build a new script into Premake, add it to this list. 9 | 10 | return 11 | { 12 | -- core files 13 | "base/os.lua", 14 | "base/path.lua", 15 | "base/string.lua", 16 | "base/table.lua", 17 | "base/io.lua", 18 | "base/globals.lua", 19 | "base/action.lua", 20 | "base/option.lua", 21 | "base/tree.lua", 22 | "base/solution.lua", 23 | "base/project.lua", 24 | "base/config.lua", 25 | "base/bake.lua", 26 | "base/api.lua", 27 | "base/cmdline.lua", 28 | "base/inspect.lua", 29 | "base/profiler.lua", 30 | "tools/dotnet.lua", 31 | "tools/gcc.lua", 32 | "tools/ghs.lua", 33 | "tools/msc.lua", 34 | "tools/ow.lua", 35 | "tools/snc.lua", 36 | "tools/valac.lua", 37 | "tools/swift.lua", 38 | "base/validate.lua", 39 | "base/help.lua", 40 | "base/premake.lua", 41 | "base/iter.lua", 42 | "base/set.lua", 43 | 44 | -- CMake action 45 | "actions/cmake/_cmake.lua", 46 | "actions/cmake/cmake_workspace.lua", 47 | "actions/cmake/cmake_project.lua", 48 | 49 | -- GNU make action 50 | "actions/make/_make.lua", 51 | "actions/make/make_solution.lua", 52 | "actions/make/make_cpp.lua", 53 | "actions/make/make_csharp.lua", 54 | "actions/make/make_vala.lua", 55 | "actions/make/make_swift.lua", 56 | 57 | -- Visual Studio actions 58 | "actions/vstudio/_vstudio.lua", 59 | "actions/vstudio/vstudio_solution.lua", 60 | "actions/vstudio/vstudio_vcxproj.lua", 61 | "actions/vstudio/vstudio_vcxproj_filters.lua", 62 | "actions/vstudio/vs2010.lua", 63 | "actions/vstudio/vs2012.lua", 64 | "actions/vstudio/vs2013.lua", 65 | "actions/vstudio/vs2015.lua", 66 | "actions/vstudio/vs2017.lua", 67 | "actions/vstudio/vs2019.lua", 68 | "actions/vstudio/vs2022.lua", 69 | 70 | -- Xcode action 71 | "actions/xcode/_xcode.lua", 72 | "actions/xcode/xcode_common.lua", 73 | "actions/xcode/xcode_project.lua", 74 | "actions/xcode/xcode_scheme.lua", 75 | "actions/xcode/xcode_workspace.lua", 76 | "actions/xcode/xcode8.lua", 77 | "actions/xcode/xcode9.lua", 78 | "actions/xcode/xcode10.lua", 79 | "actions/xcode/xcode11.lua", 80 | "actions/xcode/xcode14.lua", 81 | "actions/xcode/xcode15.lua", 82 | 83 | -- ninja action 84 | "actions/ninja/_ninja.lua", 85 | "actions/ninja/ninja_base.lua", 86 | "actions/ninja/ninja_solution.lua", 87 | "actions/ninja/ninja_cpp.lua", 88 | "actions/ninja/ninja_swift.lua", 89 | "actions/ninja/ninja_swift_incremental.lua", 90 | 91 | -- jcdb action 92 | "actions/jcdb/_jcdb.lua", 93 | "actions/jcdb/jcdb_solution.lua", 94 | } 95 | -------------------------------------------------------------------------------- /src/actions/cmake/_cmake.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- _cmake.lua 3 | -- Define the CMake action(s). 4 | -- Copyright (c) 2015 Miodrag Milanovic 5 | -- 6 | 7 | premake.cmake = { } 8 | 9 | -- 10 | -- Register the "cmake" action 11 | -- 12 | 13 | newaction { 14 | trigger = "cmake", 15 | shortname = "CMake", 16 | description = "Generate CMake project files", 17 | valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib", "Bundle" }, 18 | valid_languages = { "C", "C++" }, 19 | valid_tools = { 20 | cc = { "gcc" }, 21 | }, 22 | onsolution = function(sln) 23 | premake.generate(sln, "CMakeLists.txt", premake.cmake.workspace) 24 | end, 25 | onproject = function(prj) 26 | premake.generate(prj, "%%/CMakeLists.txt", premake.cmake.project) 27 | end, 28 | oncleansolution = function(sln) 29 | premake.clean.file(sln, "CMakeLists.txt") 30 | end, 31 | oncleanproject = function(prj) 32 | premake.clean.file(prj, "%%/CMakeLists.txt") 33 | end 34 | } -------------------------------------------------------------------------------- /src/actions/cmake/cmake_workspace.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- _cmake.lua 3 | -- Define the CMake action(s). 4 | -- Copyright (c) 2015 Miodrag Milanovic 5 | -- 6 | 7 | function premake.cmake.workspace(sln) 8 | if (sln.location ~= _WORKING_DIR) then 9 | local name = string.format("%s/CMakeLists.txt", _WORKING_DIR) 10 | local f, err = io.open(name, "wb") 11 | if (not f) then 12 | error(err, 0) 13 | end 14 | f:write([[ 15 | # CMakeLists autogenerated by GENie 16 | project(GENie) 17 | cmake_minimum_required(VERSION 3.15) 18 | 19 | ######################################################################### 20 | 21 | # Set a default build type if none was specified 22 | # Source: https://blog.kitware.com/cmake-and-the-default-build-type/ 23 | set(default_build_type "Release") 24 | if(EXISTS "${CMAKE_SOURCE_DIR}/.git") 25 | set(default_build_type "Debug") 26 | endif() 27 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 28 | message(STATUS "Setting build type to '${default_build_type}' as none was specified.") 29 | set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE) 30 | # Set the possible values of build type for cmake-gui 31 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") 32 | endif() 33 | 34 | ######################################################################### 35 | ]]) 36 | if os.is("windows") then 37 | -- Add support for CMP0091, see https://cmake.org/cmake/help/latest/policy/CMP0091.html 38 | f:write('cmake_policy(SET CMP0091 NEW)\n') 39 | end 40 | f:write('add_subdirectory('.. path.getrelative(_WORKING_DIR, sln.location) ..')\n') 41 | f:close() 42 | end 43 | _p([[ 44 | # CMakeLists autogenerated by GENie 45 | cmake_minimum_required(VERSION 3.15) 46 | ]]) 47 | if os.is("windows") then 48 | -- Add support for CMP0091, see https://cmake.org/cmake/help/latest/policy/CMP0091.html 49 | _p('cmake_policy(SET CMP0091 NEW)') 50 | end 51 | for i,prj in ipairs(sln.projects) do 52 | local name = premake.esc(prj.name) 53 | _p('add_subdirectory(%s)', name) 54 | end 55 | end 56 | -------------------------------------------------------------------------------- /src/actions/example/example_project.lua: -------------------------------------------------------------------------------- 1 | -- An example project generator; see _example.lua for action description 2 | 3 | -- 4 | -- The project generation function, attached to the action in _example.lua. 5 | -- By now, premake.generate() has created the project file using the name 6 | -- provided in _example.lua, and redirected input to this new file. 7 | -- 8 | 9 | function premake.example.project(prj) 10 | -- If necessary, set an explicit line ending sequence 11 | -- io.eol = '\r\n' 12 | 13 | -- Let's start with a header 14 | _p('-- Example project file version 1.0') 15 | _p('Name: %s', prj.name) 16 | _p('Kind: %s', prj.kind) 17 | _p('Language: %s', prj.language) 18 | _p('ID: {%s}', prj.uuid) 19 | _p('') 20 | 21 | 22 | -- List the build configurations, and the settings for each 23 | for cfg in premake.eachconfig(prj) do 24 | _p('Configuration %s:', cfg.name) 25 | _p(1, 'Objects directory: %s', cfg.objectsdir) 26 | 27 | _p(1, 'Build target:') 28 | _p(2, 'Full path: %s', cfg.buildtarget.fullpath) 29 | _p(2, 'Directory: %s', cfg.buildtarget.directory) 30 | _p(2, 'Name: %s', cfg.buildtarget.name) 31 | _p(2, 'Base name: %s', cfg.buildtarget.basename) 32 | _p(2, 'Prefix: %s', cfg.buildtarget.prefix) 33 | _p(2, 'Suffix: %s', cfg.buildtarget.suffix) 34 | _p('') 35 | 36 | _p(1, 'Compiling:') 37 | _p(2, 'Defines: %s', table.concat(cfg.defines, ";")) 38 | _p(2, 'Include paths: %s', table.concat(cfg.includedirs, ";")) 39 | _p(2, 'Flags: %s', table.concat(cfg.flags, ", ")) 40 | if not cfg.flags.NoPCH and cfg.pchheader then 41 | _p(2, 'Precompiled header: %s (%s)', cfg.pchheader, cfg.pchsource) 42 | end 43 | _p(2, 'Options: %s', table.concat(cfg.buildoptions, " ")) 44 | _p('') 45 | 46 | _p(1, 'Linking:') 47 | _p(2, 'Library paths: %s', table.concat(cfg.libdirs, ";")) 48 | _p(2, 'Options: %s', table.concat(cfg.linkoptions, " ")) 49 | _p(2, 'Libraries: %s', table.concat(premake.getlinks(cfg, "all", "fullpath"))) 50 | _p('') 51 | 52 | if #cfg.prebuildcommands > 0 then 53 | _p(1, 'Prebuild commands:') 54 | for _, cmd in ipairs(cfg.prebuildcommands) do 55 | _p(2, cmd) 56 | end 57 | _p('') 58 | end 59 | 60 | if #cfg.prelinkcommands > 0 then 61 | _p(1, 'Prelink commands:') 62 | for _, cmd in ipairs(cfg.prelinkcommands) do 63 | _p(2, cmd) 64 | end 65 | _p('') 66 | end 67 | 68 | if #cfg.postbuildcommands > 0 then 69 | _p(1, 'Postbuild commands:') 70 | for _, cmd in ipairs(cfg.postbuildcommands) do 71 | _p(2, cmd) 72 | end 73 | _p('') 74 | end 75 | end 76 | 77 | 78 | -- List out the folders and files that make up the build 79 | local tr = premake.project.buildsourcetree(prj) 80 | premake.tree.sort(tr) 81 | premake.tree.traverse(tr, { 82 | onbranch = function(node, depth) 83 | _p(depth, path.getname(node.name) .. "/") 84 | end, 85 | 86 | onleaf = function(node, depth) 87 | _p(depth, path.getname(node.name)) 88 | end 89 | }) 90 | 91 | end 92 | -------------------------------------------------------------------------------- /src/actions/example/example_solution.lua: -------------------------------------------------------------------------------- 1 | -- An example solution generator; see _example.lua for action description 2 | 3 | -- 4 | -- The solution generation function, attached to the action in _example.lua. 5 | -- By now, premake.generate() has created the solution file using the name 6 | -- provided in _example.lua, and redirected input to this new file. 7 | -- 8 | 9 | function premake.example.solution(sln) 10 | -- If necessary, set an explicit line ending sequence 11 | -- io.eol = '\r\n' 12 | 13 | -- Let's start with a header 14 | _p('-- Example solution file version 1.0') 15 | _p('Name: %s', sln.name) 16 | _p('') 17 | 18 | 19 | -- List the build configurations 20 | for _, cfgname in ipairs(sln.configurations) do 21 | _p('Config: %s', cfgname) 22 | end 23 | _p('') 24 | 25 | 26 | -- List the projects contained by the solution, with some info on each 27 | for prj in premake.solution.eachproject(sln) do 28 | _p('Project: %s', prj.name) 29 | _p(1, 'Kind: %s', prj.kind) 30 | _p(1, 'Language: %s', prj.language) 31 | _p(1, 'ID: {%s}', prj.uuid) 32 | _p(1, 'Relative path: %s', path.getrelative(sln.location, prj.location)) 33 | 34 | -- List dependencies, if there are any 35 | local deps = premake.getdependencies(prj) 36 | if #deps > 0 then 37 | _p(1, 'Dependencies:') 38 | for _, depprj in ipairs(deps) do 39 | _p(2, '%s {%s}', depprj.name, depprj.uuid) 40 | end 41 | end 42 | 43 | _p('') 44 | end 45 | 46 | end 47 | -------------------------------------------------------------------------------- /src/actions/jcdb/_jcdb.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- _jcdb.lua 3 | -- Define the compile_commands.json action(s). 4 | -- Copyright (c) 2020 Johan Skoeld 5 | -- 6 | 7 | newaction { 8 | trigger = "jcdb", 9 | shortname = "compile_commands.json", 10 | description = "Generate a compile_commands.json file.", 11 | 12 | valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib", "Bundle" }, 13 | valid_languages = { "C", "C++" }, 14 | valid_tools = { cc = { "gcc" } }, 15 | 16 | onsolution = function(sln) 17 | local jsonpath = path.join(sln.location, "compile_commands.json") 18 | premake.generate(sln, jsonpath, premake.jcdb.generate) 19 | end, 20 | } 21 | 22 | -------------------------------------------------------------------------------- /src/actions/make/make_solution.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- make_solution.lua 3 | -- Generate a solution-level makefile. 4 | -- Copyright (c) 2002-2009 Jason Perkins and the Premake project 5 | -- 6 | 7 | function premake.make_solution(sln) 8 | -- create a shortcut to the compiler interface 9 | local cc = premake[_OPTIONS.cc] 10 | 11 | -- build a list of supported target platforms that also includes a generic build 12 | local platforms = premake.filterplatforms(sln, cc.platforms, "Native") 13 | 14 | -- write a header showing the build options 15 | _p('# %s solution makefile autogenerated by GENie', premake.action.current().shortname) 16 | _p('# Type "make help" for usage help') 17 | _p('') 18 | 19 | -- set a default configuration 20 | _p('ifndef config') 21 | _p(' config=%s', _MAKE.esc(premake.getconfigname(sln.configurations[1], platforms[1], true))) 22 | _p('endif') 23 | _p('export config') 24 | _p('') 25 | 26 | local projects = table.extract(sln.projects, "name") 27 | table.sort(projects) 28 | 29 | -- list the projects included in the solution 30 | _p('PROJECTS := %s', table.concat(_MAKE.esc(projects), " ")) 31 | _p('') 32 | _p('.PHONY: all clean help $(PROJECTS)') 33 | _p('') 34 | _p('all: $(PROJECTS)') 35 | _p('') 36 | 37 | -- write the project build rules 38 | for _, prj in ipairs(sln.projects) do 39 | _p('%s: %s', _MAKE.esc(prj.name), table.concat(_MAKE.esc(table.extract(premake.getdependencies(prj), "name")), " ")) 40 | if (not sln.messageskip) or (not table.contains(sln.messageskip, "SkipBuildingMessage")) then 41 | _p('\t@echo "==== Building %s ($(config)) ===="', prj.name) 42 | end 43 | _p('\t@${MAKE} --no-print-directory -C %s -f %s', _MAKE.esc(path.getrelative(sln.location, prj.location)), _MAKE.esc(_MAKE.getmakefilename(prj, true))) 44 | _p('') 45 | end 46 | 47 | -- clean rules 48 | _p('clean:') 49 | for _ ,prj in ipairs(sln.projects) do 50 | _p('\t@${MAKE} --no-print-directory -C %s -f %s clean', _MAKE.esc(path.getrelative(sln.location, prj.location)), _MAKE.esc(_MAKE.getmakefilename(prj, true))) 51 | end 52 | _p('') 53 | 54 | -- help rule 55 | _p('help:') 56 | _p(1,'@echo "Usage: make [config=name] [target]"') 57 | _p(1,'@echo ""') 58 | _p(1,'@echo "CONFIGURATIONS:"') 59 | 60 | local cfgpairs = { } 61 | for _, platform in ipairs(platforms) do 62 | for _, cfgname in ipairs(sln.configurations) do 63 | _p(1,'@echo " %s"', premake.getconfigname(cfgname, platform, true)) 64 | end 65 | end 66 | 67 | _p(1,'@echo ""') 68 | _p(1,'@echo "TARGETS:"') 69 | _p(1,'@echo " all (default)"') 70 | _p(1,'@echo " clean"') 71 | 72 | for _, prj in ipairs(sln.projects) do 73 | _p(1,'@echo " %s"', prj.name) 74 | end 75 | 76 | _p(1,'@echo ""') 77 | _p(1,'@echo "For more information, see https://github.com/bkaradzic/genie"') 78 | 79 | end 80 | -------------------------------------------------------------------------------- /src/actions/ninja/_ninja.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- GENie - Project generator tool 3 | -- https://github.com/bkaradzic/GENie#license 4 | -- 5 | 6 | premake.ninja = { } 7 | 8 | local p = premake 9 | 10 | newaction 11 | { 12 | -- Metadata for the command line and help system 13 | trigger = "ninja", 14 | shortname = "ninja", 15 | description = "Generate Ninja build files", 16 | module = "ninja", 17 | 18 | -- The capabilities of this action 19 | valid_kinds = {"ConsoleApp", "WindowedApp", "StaticLib", "SharedLib", "Bundle"}, 20 | valid_languages = {"C", "C++", "Swift"}, 21 | valid_tools = { 22 | cc = { "gcc" }, 23 | swift = { "swift" }, 24 | }, 25 | 26 | -- Solution and project generation logic 27 | onsolution = function(sln) 28 | io.eol = "\r\n" 29 | io.indent = "\t" 30 | io.escaper(p.ninja.esc) 31 | p.generate(sln, "Makefile", p.ninja.generate_solution) 32 | io.indent = " " 33 | p.ninja.generate_ninja_builds(sln) 34 | end, 35 | 36 | onproject = function(prj) 37 | io.eol = "\r\n" 38 | io.indent = " " 39 | io.escaper(p.ninja.esc) 40 | p.ninja.generate_project(prj) 41 | end, 42 | 43 | oncleansolution = function(sln) 44 | for _,name in ipairs(sln.configurations) do 45 | premake.clean.file(sln, p.ninja.get_solution_name(sln, name)) 46 | end 47 | end, 48 | 49 | oncleanproject = function(prj) 50 | -- TODO 51 | end, 52 | 53 | oncleantarget = function(prj) 54 | -- TODO 55 | end, 56 | } 57 | -------------------------------------------------------------------------------- /src/actions/vstudio/vs2010.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- vs2010.lua 3 | -- Baseline support for Visual Studio 2010. 4 | -- Copyright (c) 2013 Jason Perkins and the Premake project 5 | -- 6 | 7 | local vc2010 = premake.vstudio.vc2010 8 | local vstudio = premake.vstudio 9 | 10 | --- 11 | -- Register a command-line action for Visual Studio 2010. 12 | --- 13 | 14 | newaction 15 | { 16 | trigger = "vs2010", 17 | shortname = "Visual Studio 2010", 18 | description = "Generate Microsoft Visual Studio 2010 project files", 19 | os = "windows", 20 | 21 | valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib", "Bundle" }, 22 | 23 | valid_languages = { "C", "C++", "C#"}, 24 | 25 | valid_tools = { 26 | cc = { "msc" }, 27 | dotnet = { "msnet" }, 28 | }, 29 | 30 | onsolution = function(sln) 31 | premake.generate(sln, "%%.sln", vstudio.sln2005.generate) 32 | end, 33 | 34 | onproject = function(prj) 35 | if premake.isdotnetproject(prj) then 36 | premake.generate(prj, "%%.csproj", vstudio.cs2005.generate) 37 | premake.generate(prj, "%%.csproj.user", vstudio.cs2005.generate_user) 38 | else 39 | premake.generate(prj, "%%.vcxproj", premake.vs2010_vcxproj) 40 | premake.generate(prj, "%%.vcxproj.user", premake.vs2010_vcxproj_user) 41 | premake.generate(prj, "%%.vcxproj.filters", vstudio.vc2010.generate_filters) 42 | end 43 | end, 44 | 45 | oncleansolution = premake.vstudio.cleansolution, 46 | oncleanproject = premake.vstudio.cleanproject, 47 | oncleantarget = premake.vstudio.cleantarget, 48 | 49 | vstudio = { 50 | productVersion = "8.0.30703", 51 | solutionVersion = "11", 52 | targetFramework = "4.0", 53 | toolsVersion = "4.0", 54 | supports64bitEditContinue = false, 55 | intDirAbsolute = false, 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/actions/vstudio/vs2012.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- vs2012.lua 3 | -- Baseline support for Visual Studio 2012. 4 | -- Copyright (c) 2013 Jason Perkins and the Premake project 5 | -- 6 | 7 | premake.vstudio.vc2012 = {} 8 | local vc2012 = premake.vstudio.vc2012 9 | local vstudio = premake.vstudio 10 | 11 | 12 | --- 13 | -- Register a command-line action for Visual Studio 2012. 14 | --- 15 | 16 | newaction 17 | { 18 | trigger = "vs2012", 19 | shortname = "Visual Studio 2012", 20 | description = "Generate Microsoft Visual Studio 2012 project files", 21 | os = "windows", 22 | 23 | valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib", "Bundle" }, 24 | 25 | valid_languages = { "C", "C++", "C#"}, 26 | 27 | valid_tools = { 28 | cc = { "msc" }, 29 | dotnet = { "msnet" }, 30 | }, 31 | 32 | onsolution = function(sln) 33 | premake.generate(sln, "%%.sln", vstudio.sln2005.generate) 34 | end, 35 | 36 | onproject = function(prj) 37 | if premake.isdotnetproject(prj) then 38 | premake.generate(prj, "%%.csproj", vstudio.cs2005.generate) 39 | premake.generate(prj, "%%.csproj.user", vstudio.cs2005.generate_user) 40 | else 41 | premake.generate(prj, "%%.vcxproj", premake.vs2010_vcxproj) 42 | premake.generate(prj, "%%.vcxproj.user", premake.vs2010_vcxproj_user) 43 | premake.generate(prj, "%%.vcxproj.filters", vstudio.vc2010.generate_filters) 44 | end 45 | end, 46 | 47 | 48 | oncleansolution = premake.vstudio.cleansolution, 49 | oncleanproject = premake.vstudio.cleanproject, 50 | oncleantarget = premake.vstudio.cleantarget, 51 | 52 | vstudio = { 53 | solutionVersion = "12", 54 | targetFramework = "4.5", 55 | toolsVersion = "4.0", 56 | supports64bitEditContinue = false, 57 | intDirAbsolute = false, 58 | } 59 | } 60 | 61 | -------------------------------------------------------------------------------- /src/actions/vstudio/vs2013.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- vs2013.lua 3 | -- Baseline support for Visual Studio 2013. 4 | -- Copyright (c) 2013 Jason Perkins and the Premake project 5 | -- 6 | 7 | premake.vstudio.vc2013 = {} 8 | local vc2013 = premake.vstudio.vc2013 9 | local vstudio = premake.vstudio 10 | 11 | 12 | --- 13 | -- Register a command-line action for Visual Studio 2013. 14 | --- 15 | 16 | newaction 17 | { 18 | trigger = "vs2013", 19 | shortname = "Visual Studio 2013", 20 | description = "Generate Microsoft Visual Studio 2013 project files", 21 | os = "windows", 22 | 23 | valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib", "Bundle" }, 24 | 25 | valid_languages = { "C", "C++", "C#"}, 26 | 27 | valid_tools = { 28 | cc = { "msc" }, 29 | dotnet = { "msnet" }, 30 | }, 31 | 32 | onsolution = function(sln) 33 | premake.generate(sln, "%%.sln", vstudio.sln2005.generate) 34 | end, 35 | 36 | onproject = function(prj) 37 | if premake.isdotnetproject(prj) then 38 | premake.generate(prj, "%%.csproj", vstudio.cs2005.generate) 39 | premake.generate(prj, "%%.csproj.user", vstudio.cs2005.generate_user) 40 | else 41 | premake.vstudio.needAppxManifest = false 42 | premake.generate(prj, "%%.vcxproj", premake.vs2010_vcxproj) 43 | premake.generate(prj, "%%.vcxproj.user", premake.vs2010_vcxproj_user) 44 | premake.generate(prj, "%%.vcxproj.filters", vstudio.vc2010.generate_filters) 45 | 46 | if premake.vstudio.needAppxManifest then 47 | premake.generate(prj, "%%/Package.appxmanifest", premake.vs2010_appxmanifest) 48 | end 49 | end 50 | end, 51 | 52 | 53 | oncleansolution = premake.vstudio.cleansolution, 54 | oncleanproject = premake.vstudio.cleanproject, 55 | oncleantarget = premake.vstudio.cleantarget, 56 | 57 | vstudio = { 58 | solutionVersion = "12", 59 | targetFramework = "4.5", 60 | toolsVersion = "12.0", 61 | supports64bitEditContinue = false, 62 | intDirAbsolute = false, 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/actions/vstudio/vs2015.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- vs2015.lua 3 | -- Baseline support for Visual Studio 2015. 4 | -- 5 | 6 | premake.vstudio.vc2015 = {} 7 | local vc2015 = premake.vstudio.vc2015 8 | local vstudio = premake.vstudio 9 | 10 | 11 | --- 12 | -- Register a command-line action for Visual Studio 2015. 13 | --- 14 | 15 | newaction 16 | { 17 | trigger = "vs2015", 18 | shortname = "Visual Studio 2015", 19 | description = "Generate Microsoft Visual Studio 2015 project files", 20 | os = "windows", 21 | 22 | valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib", "Bundle" }, 23 | 24 | valid_languages = { "C", "C++", "C#" }, 25 | 26 | valid_tools = { 27 | cc = { "msc" }, 28 | dotnet = { "msnet" }, 29 | }, 30 | 31 | onsolution = function(sln) 32 | premake.generate(sln, "%%.sln", vstudio.sln2005.generate) 33 | end, 34 | 35 | onproject = function(prj) 36 | if premake.isdotnetproject(prj) then 37 | premake.generate(prj, "%%.csproj", vstudio.cs2005.generate) 38 | premake.generate(prj, "%%.csproj.user", vstudio.cs2005.generate_user) 39 | else 40 | premake.vstudio.needAppxManifest = false 41 | premake.generate(prj, "%%.vcxproj", premake.vs2010_vcxproj) 42 | premake.generate(prj, "%%.vcxproj.user", premake.vs2010_vcxproj_user) 43 | premake.generate(prj, "%%.vcxproj.filters", vstudio.vc2010.generate_filters) 44 | 45 | if premake.vstudio.needAppxManifest then 46 | premake.generate(prj, "%%/Package.appxmanifest", premake.vs2010_appxmanifest) 47 | end 48 | end 49 | end, 50 | 51 | 52 | oncleansolution = premake.vstudio.cleansolution, 53 | oncleanproject = premake.vstudio.cleanproject, 54 | oncleantarget = premake.vstudio.cleantarget, 55 | 56 | vstudio = { 57 | solutionVersion = "12", 58 | targetFramework = "4.5", 59 | toolsVersion = "14.0", 60 | windowsTargetPlatformVersion = "8.1", 61 | supports64bitEditContinue = true, 62 | intDirAbsolute = false, 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/actions/vstudio/vs2017.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- vs2015.lua 3 | -- Baseline support for Visual Studio 2017. 4 | -- 5 | 6 | premake.vstudio.vc2017 = {} 7 | local vc2017 = premake.vstudio.vc2017 8 | local vstudio = premake.vstudio 9 | 10 | 11 | --- 12 | -- Register a command-line action for Visual Studio 2017. 13 | --- 14 | 15 | newaction 16 | { 17 | trigger = "vs2017", 18 | shortname = "Visual Studio 2017", 19 | description = "Generate Microsoft Visual Studio 2017 project files", 20 | os = "windows", 21 | 22 | valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib", "Bundle" }, 23 | 24 | valid_languages = { "C", "C++", "C#" }, 25 | 26 | valid_tools = { 27 | cc = { "msc" }, 28 | dotnet = { "msnet" }, 29 | }, 30 | 31 | onsolution = function(sln) 32 | premake.generate(sln, "%%.sln", vstudio.sln2005.generate) 33 | end, 34 | 35 | onproject = function(prj) 36 | if premake.isdotnetproject(prj) then 37 | premake.generate(prj, "%%.csproj", vstudio.cs2005.generate) 38 | premake.generate(prj, "%%.csproj.user", vstudio.cs2005.generate_user) 39 | else 40 | premake.vstudio.needAppxManifest = false 41 | premake.generate(prj, "%%.vcxproj", premake.vs2010_vcxproj) 42 | premake.generate(prj, "%%.vcxproj.user", premake.vs2010_vcxproj_user) 43 | premake.generate(prj, "%%.vcxproj.filters", vstudio.vc2010.generate_filters) 44 | 45 | if premake.vstudio.needAppxManifest then 46 | premake.generate(prj, "%%/Package.appxmanifest", premake.vs2010_appxmanifest) 47 | end 48 | end 49 | end, 50 | 51 | 52 | oncleansolution = premake.vstudio.cleansolution, 53 | oncleanproject = premake.vstudio.cleanproject, 54 | oncleantarget = premake.vstudio.cleantarget, 55 | 56 | vstudio = { 57 | solutionVersion = "12", 58 | targetFramework = "4.5.2", 59 | toolsVersion = "15.0", 60 | windowsTargetPlatformVersion = "8.1", 61 | supports64bitEditContinue = true, 62 | intDirAbsolute = false, 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/actions/vstudio/vs2019.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- vs2015.lua 3 | -- Baseline support for Visual Studio 2019. 4 | -- 5 | 6 | premake.vstudio.vc2019 = {} 7 | local vc2019 = premake.vstudio.vc2019 8 | local vstudio = premake.vstudio 9 | 10 | 11 | --- 12 | -- Register a command-line action for Visual Studio 2019. 13 | --- 14 | 15 | newaction 16 | { 17 | trigger = "vs2019", 18 | shortname = "Visual Studio 2019", 19 | description = "Generate Microsoft Visual Studio 2019 project files", 20 | os = "windows", 21 | 22 | valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib", "Bundle" }, 23 | 24 | valid_languages = { "C", "C++", "C#" }, 25 | 26 | valid_tools = { 27 | cc = { "msc" }, 28 | dotnet = { "msnet" }, 29 | }, 30 | 31 | onsolution = function(sln) 32 | premake.generate(sln, "%%.sln", vstudio.sln2005.generate) 33 | end, 34 | 35 | onproject = function(prj) 36 | if premake.isdotnetproject(prj) then 37 | premake.generate(prj, "%%.csproj", vstudio.cs2005.generate) 38 | premake.generate(prj, "%%.csproj.user", vstudio.cs2005.generate_user) 39 | else 40 | premake.vstudio.needAppxManifest = false 41 | premake.generate(prj, "%%.vcxproj", premake.vs2010_vcxproj) 42 | premake.generate(prj, "%%.vcxproj.user", premake.vs2010_vcxproj_user) 43 | premake.generate(prj, "%%.vcxproj.filters", vstudio.vc2010.generate_filters) 44 | 45 | if premake.vstudio.needAppxManifest then 46 | premake.generate(prj, "%%/Package.appxmanifest", premake.vs2010_appxmanifest) 47 | end 48 | end 49 | end, 50 | 51 | 52 | oncleansolution = premake.vstudio.cleansolution, 53 | oncleanproject = premake.vstudio.cleanproject, 54 | oncleantarget = premake.vstudio.cleantarget, 55 | 56 | vstudio = { 57 | solutionVersion = "12", 58 | targetFramework = "4.7.2", 59 | toolsVersion = "16.0", 60 | windowsTargetPlatformVersion = "10.0", 61 | supports64bitEditContinue = true, 62 | intDirAbsolute = false, 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/actions/vstudio/vs2022.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- vs2022.lua 3 | -- Baseline support for Visual Studio 2022. 4 | -- 5 | 6 | premake.vstudio.vc2022 = {} 7 | local vc2022 = premake.vstudio.vc2022 8 | local vstudio = premake.vstudio 9 | 10 | 11 | --- 12 | -- Register a command-line action for Visual Studio 2022. 13 | --- 14 | 15 | newaction 16 | { 17 | trigger = "vs2022", 18 | shortname = "Visual Studio 2022", 19 | description = "Generate Microsoft Visual Studio 2022 project files", 20 | os = "windows", 21 | 22 | valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib", "Bundle" }, 23 | 24 | valid_languages = { "C", "C++", "C#" }, 25 | 26 | valid_tools = { 27 | cc = { "msc" }, 28 | dotnet = { "msnet" }, 29 | }, 30 | 31 | onsolution = function(sln) 32 | premake.generate(sln, "%%.sln", vstudio.sln2005.generate) 33 | end, 34 | 35 | onproject = function(prj) 36 | if premake.isdotnetproject(prj) then 37 | premake.generate(prj, "%%.csproj", vstudio.cs2005.generate) 38 | premake.generate(prj, "%%.csproj.user", vstudio.cs2005.generate_user) 39 | else 40 | premake.vstudio.needAppxManifest = false 41 | premake.generate(prj, "%%.vcxproj", premake.vs2010_vcxproj) 42 | premake.generate(prj, "%%.vcxproj.user", premake.vs2010_vcxproj_user) 43 | premake.generate(prj, "%%.vcxproj.filters", vstudio.vc2010.generate_filters) 44 | 45 | if premake.vstudio.needAppxManifest then 46 | premake.generate(prj, "%%/Package.appxmanifest", premake.vs2010_appxmanifest) 47 | end 48 | end 49 | end, 50 | 51 | 52 | oncleansolution = premake.vstudio.cleansolution, 53 | oncleanproject = premake.vstudio.cleanproject, 54 | oncleantarget = premake.vstudio.cleantarget, 55 | 56 | vstudio = { 57 | solutionVersion = "12", 58 | targetFramework = "4.7.2", 59 | toolsVersion = "16.0", 60 | windowsTargetPlatformVersion = "10.0", 61 | supports64bitEditContinue = true, 62 | intDirAbsolute = false, 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/actions/xcode/_xcode.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- _xcode.lua 3 | -- Define the Apple XCode action and support functions. 4 | -- Copyright (c) 2009 Jason Perkins and the Premake project 5 | -- 6 | 7 | premake.xcode = { } 8 | 9 | -- 10 | -- Verify only single target kind for Xcode project 11 | -- 12 | -- @param prj 13 | -- Project to be analyzed 14 | -- 15 | 16 | function premake.xcode.checkproject(prj) 17 | -- Xcode can't mix target kinds within a project 18 | local last 19 | for cfg in premake.eachconfig(prj) do 20 | if last and last ~= cfg.kind then 21 | error("Project '" .. prj.name .. "' uses more than one target kind; not supported by Xcode", 0) 22 | end 23 | last = cfg.kind 24 | end 25 | end 26 | 27 | -- 28 | -- Set default toolset 29 | -- 30 | 31 | premake.xcode.toolset = "macosx" 32 | -------------------------------------------------------------------------------- /src/actions/xcode/xcode11.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- xcode11.lua 3 | -- Define the Apple XCode 11.0 action and support functions. 4 | -- 5 | 6 | local premake = premake 7 | premake.xcode11 = { } 8 | 9 | local xcode = premake.xcode 10 | local xcode10 = premake.xcode10 11 | local xcode11 = premake.xcode11 12 | 13 | function xcode11.XCBuildConfiguration_Target(tr, target, cfg) 14 | local options = xcode10.XCBuildConfiguration_Target(tr, target, cfg) 15 | options.CODE_SIGN_IDENTITY = "-" 16 | return options 17 | end 18 | 19 | function xcode11.project(prj) 20 | local tr = xcode.buildprjtree(prj) 21 | xcode.Header(tr, 48) 22 | xcode.PBXBuildFile(tr) 23 | xcode.PBXContainerItemProxy(tr) 24 | xcode.PBXFileReference(tr,prj) 25 | xcode.PBXFrameworksBuildPhase(tr) 26 | xcode.PBXGroup(tr) 27 | xcode.PBXNativeTarget(tr) 28 | xcode.PBXProject(tr, "8.0") 29 | xcode.PBXReferenceProxy(tr) 30 | xcode.PBXResourcesBuildPhase(tr) 31 | xcode.PBXShellScriptBuildPhase(tr) 32 | xcode.PBXCopyFilesBuildPhase(tr) 33 | xcode.PBXSourcesBuildPhase(tr,prj) 34 | xcode.PBXVariantGroup(tr) 35 | xcode.PBXTargetDependency(tr) 36 | xcode.XCBuildConfiguration(tr, prj, { 37 | ontarget = xcode11.XCBuildConfiguration_Target, 38 | onproject = xcode10.XCBuildConfiguration_Project, 39 | }) 40 | xcode.XCBuildConfigurationList(tr) 41 | xcode.Footer(tr) 42 | end 43 | --]] 44 | 45 | 46 | -- 47 | -- xcode11 action 48 | -- 49 | 50 | newaction 51 | { 52 | trigger = "xcode11", 53 | shortname = "Xcode 11", 54 | description = "Generate Apple Xcode 11 project files", 55 | os = "macosx", 56 | 57 | valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib", "Bundle" }, 58 | 59 | valid_languages = { "C", "C++" }, 60 | 61 | valid_tools = { 62 | cc = { "gcc" }, 63 | }, 64 | 65 | valid_platforms = { Native = "Native" }, 66 | default_platform = "Native", 67 | 68 | onsolution = function(sln) 69 | premake.generate(sln, "%%.xcworkspace/contents.xcworkspacedata", xcode.workspace_generate) 70 | premake.generate(sln, "%%.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings", xcode.workspace_settings) 71 | premake.generate(sln, "%%.xcworkspace/xcshareddata/xcschemes/-ALL-.xcscheme", xcode.workspace_scheme) 72 | end, 73 | 74 | onproject = function(prj) 75 | premake.generate(prj, "%%.xcodeproj/project.pbxproj", xcode11.project) 76 | xcode.generate_schemes(prj, "%%.xcodeproj/xcshareddata/xcschemes") 77 | end, 78 | 79 | oncleanproject = function(prj) 80 | premake.clean.directory(prj, "%%.xcodeproj") 81 | premake.clean.directory(prj, "%%.xcworkspace") 82 | end, 83 | 84 | oncheckproject = xcode.checkproject, 85 | 86 | xcode = { 87 | iOSTargetPlatformVersion = nil, 88 | macOSTargetPlatformVersion = nil, 89 | tvOSTargetPlatformVersion = nil, 90 | }, 91 | } 92 | -------------------------------------------------------------------------------- /src/actions/xcode/xcode9.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- xcode9.lua 3 | -- Define the Apple XCode 9.0 action and support functions. 4 | -- 5 | 6 | local premake = premake 7 | premake.xcode9 = { } 8 | 9 | local xcode = premake.xcode 10 | local xcode8 = premake.xcode8 11 | local xcode9 = premake.xcode9 12 | 13 | function xcode9.XCBuildConfiguration_Project(tr, prj, cfg) 14 | local options = xcode8.XCBuildConfiguration_Project(tr, prj, cfg) 15 | 16 | if cfg.flags.Cpp17 then 17 | options.CLANG_CXX_LANGUAGE_STANDARD = "c++17" 18 | elseif cfg.flags.Cpp20 or cfg.flags.CppLatest then 19 | options.CLANG_CXX_LANGUAGE_STANDARD = "c++20" 20 | end 21 | 22 | return table.merge(options, { 23 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = "YES", 24 | CLANG_WARN_COMMA = "YES", 25 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = "YES", 26 | CLANG_WARN_OBJC_LITERAL_CONVERSION = "YES", 27 | CLANG_WARN_RANGE_LOOP_ANALYSIS = "YES", 28 | CLANG_WARN_STRICT_PROTOTYPES = "YES", 29 | }) 30 | end 31 | 32 | function xcode9.project(prj) 33 | local tr = xcode.buildprjtree(prj) 34 | xcode.Header(tr, 48) 35 | xcode.PBXBuildFile(tr) 36 | xcode.PBXContainerItemProxy(tr) 37 | xcode.PBXFileReference(tr,prj) 38 | xcode.PBXFrameworksBuildPhase(tr) 39 | xcode.PBXGroup(tr) 40 | xcode.PBXNativeTarget(tr) 41 | xcode.PBXProject(tr, "8.0") 42 | xcode.PBXReferenceProxy(tr) 43 | xcode.PBXResourcesBuildPhase(tr) 44 | xcode.PBXShellScriptBuildPhase(tr) 45 | xcode.PBXCopyFilesBuildPhase(tr) 46 | xcode.PBXSourcesBuildPhase(tr,prj) 47 | xcode.PBXVariantGroup(tr) 48 | xcode.PBXTargetDependency(tr) 49 | xcode.XCBuildConfiguration(tr, prj, { 50 | ontarget = xcode8.XCBuildConfiguration_Target, 51 | onproject = xcode9.XCBuildConfiguration_Project, 52 | }) 53 | xcode.XCBuildConfigurationList(tr) 54 | xcode.Footer(tr) 55 | end 56 | 57 | 58 | -- 59 | -- xcode9 action 60 | -- 61 | 62 | newaction 63 | { 64 | trigger = "xcode9", 65 | shortname = "Xcode 9", 66 | description = "Generate Apple Xcode 9 project files", 67 | os = "macosx", 68 | 69 | valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib", "Bundle" }, 70 | 71 | valid_languages = { "C", "C++" }, 72 | 73 | valid_tools = { 74 | cc = { "gcc" }, 75 | }, 76 | 77 | valid_platforms = { 78 | Native = "Native", 79 | x32 = "Native 32-bit", 80 | x64 = "Native 64-bit", 81 | Universal = "Universal", 82 | }, 83 | 84 | default_platform = "Native", 85 | 86 | onsolution = function(sln) 87 | premake.generate(sln, "%%.xcworkspace/contents.xcworkspacedata", xcode.workspace_generate) 88 | premake.generate(sln, "%%.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings", xcode.workspace_settings) 89 | premake.generate(sln, "%%.xcworkspace/xcshareddata/xcschemes/-ALL-.xcscheme", xcode.workspace_scheme) 90 | end, 91 | 92 | onproject = function(prj) 93 | premake.generate(prj, "%%.xcodeproj/project.pbxproj", xcode9.project) 94 | xcode.generate_schemes(prj, "%%.xcodeproj/xcshareddata/xcschemes") 95 | end, 96 | 97 | oncleanproject = function(prj) 98 | premake.clean.directory(prj, "%%.xcodeproj") 99 | premake.clean.directory(prj, "%%.xcworkspace") 100 | end, 101 | 102 | oncheckproject = xcode.checkproject, 103 | 104 | xcode = { 105 | iOSTargetPlatformVersion = nil, 106 | macOSTargetPlatformVersion = nil, 107 | tvOSTargetPlatformVersion = nil, 108 | }, 109 | } 110 | -------------------------------------------------------------------------------- /src/base/cmdline.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- cmdline.lua 3 | -- Functions to define and handle command line actions and options. 4 | -- Copyright (c) 2002-2011 Jason Perkins and the Premake project 5 | -- 6 | 7 | 8 | -- 9 | -- Built-in command line options 10 | -- 11 | 12 | newoption 13 | { 14 | trigger = "cc", 15 | value = "VALUE", 16 | description = "Choose a C/C++ compiler set", 17 | allowed = { 18 | { "gcc", "GNU GCC (gcc/g++)" }, 19 | { "ow", "OpenWatcom" }, 20 | { "ghs", "Green Hills Software" }, 21 | } 22 | } 23 | 24 | newoption 25 | { 26 | trigger = "dotnet", 27 | value = "VALUE", 28 | description = "Choose a .NET compiler set", 29 | allowed = { 30 | { "msnet", "Microsoft .NET (csc)" }, 31 | { "mono", "Novell Mono (mcs)" }, 32 | { "pnet", "Portable.NET (cscc)" }, 33 | } 34 | } 35 | 36 | newoption 37 | { 38 | trigger = "file", 39 | value = "FILE", 40 | description = "Read FILE as a Premake script; default is 'premake4.lua'" 41 | } 42 | 43 | newoption 44 | { 45 | trigger = "help", 46 | description = "Display this information" 47 | } 48 | 49 | newoption 50 | { 51 | trigger = "os", 52 | value = "VALUE", 53 | description = "Generate files for a different operating system", 54 | allowed = { 55 | { "bsd", "OpenBSD, NetBSD, or FreeBSD" }, 56 | { "linux", "Linux" }, 57 | { "macosx", "Apple Mac OS X" }, 58 | { "solaris", "Solaris" }, 59 | { "windows", "Microsoft Windows" }, 60 | } 61 | } 62 | 63 | newoption 64 | { 65 | trigger = "platform", 66 | value = "VALUE", 67 | description = "Add target architecture (if supported by action)", 68 | allowed = { 69 | { "x32", "32-bit" }, 70 | { "x64", "64-bit" }, 71 | { "universal", "Mac OS X Universal, 32- and 64-bit" }, 72 | { "universal32", "Mac OS X Universal, 32-bit only" }, 73 | { "universal64", "Mac OS X Universal, 64-bit only" }, 74 | { "ps3", "Playstation 3" }, 75 | { "orbis", "Playstation 4" }, 76 | { "xbox360", "Xbox 360" }, 77 | { "durango", "Xbox One" }, 78 | { "ARM", "ARM" }, 79 | { "ARM64", "ARM64" }, 80 | { "PowerPC", "PowerPC" }, 81 | { "nx32", "Nintendo Switch, 32-bit only" }, 82 | { "nx64", "Nintendo Switch, 64-bit only" }, 83 | { "gdk-desktop", "GDK Windows Desktop" }, 84 | { "gdk-xboxone", "GDK Xbox One" }, 85 | { "gdk-scarlett","GDK Xbox Scarlett" }, 86 | } 87 | } 88 | 89 | newoption 90 | { 91 | trigger = "scripts", 92 | value = "path", 93 | description = "Search for additional scripts on the given path" 94 | } 95 | 96 | newoption 97 | { 98 | trigger = "debug-profiler", 99 | description = "GENie script generation profiler." 100 | } 101 | 102 | newoption 103 | { 104 | trigger = "version", 105 | description = "Display version information" 106 | } 107 | -------------------------------------------------------------------------------- /src/base/config.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- configs.lua 3 | -- 4 | -- Functions for working with configuration objects (which can include 5 | -- projects and solutions). 6 | -- 7 | -- Copyright (c) 2008-2011 Jason Perkins and the Premake project 8 | -- 9 | 10 | premake.config = { } 11 | local config = premake.config 12 | 13 | 14 | -- 15 | -- Determine if a configuration represents a "debug" or "release" build. 16 | -- This controls the runtime library selected for Visual Studio builds 17 | -- (and might also be useful elsewhere). 18 | -- 19 | 20 | function premake.config.isdebugbuild(cfg) 21 | -- If any of the specific runtime flags are set 22 | if cfg.flags.DebugRuntime then 23 | return true 24 | end 25 | 26 | if cfg.flags.ReleaseRuntime then 27 | return false 28 | end 29 | 30 | -- If any of the optimize flags are set, it's a release a build 31 | if cfg.flags.Optimize or cfg.flags.OptimizeSize or cfg.flags.OptimizeSpeed then 32 | return false 33 | end 34 | 35 | -- If symbols are not defined, it's a release build 36 | if not cfg.flags.Symbols then 37 | return false 38 | end 39 | 40 | return true 41 | end 42 | 43 | 44 | -- 45 | -- Return an iterator over each file included in this configuration. 46 | -- 47 | 48 | function premake.config.eachfile(cfg) 49 | local i = 0 50 | local t = cfg.files 51 | return function () 52 | i = i + 1 53 | if (i <= #t) then 54 | local fcfg = cfg.__fileconfigs[t[i]] 55 | fcfg.vpath = premake.project.getvpath(cfg.project, fcfg.name) 56 | return fcfg 57 | end 58 | end 59 | end 60 | 61 | 62 | -- 63 | -- Determines if this configuration can be linked incrementally. 64 | -- 65 | 66 | function premake.config.isincrementallink(cfg) 67 | if cfg.kind == "StaticLib" then 68 | return false 69 | end 70 | return not config.islinkeroptimizedbuild(cfg.flags) and not cfg.flags.NoIncrementalLink 71 | end 72 | 73 | 74 | -- 75 | -- Determine if this configuration uses one of the optimize flags. 76 | -- 77 | 78 | function premake.config.isoptimizedbuild(flags) 79 | return flags.Optimize or flags.OptimizeSize or flags.OptimizeSpeed 80 | end 81 | 82 | 83 | -- 84 | -- Determine if this configuration uses one of the optimize flags. 85 | -- Optimized builds get different treatment, such as full linking 86 | -- instead of incremental. 87 | -- 88 | 89 | function premake.config.islinkeroptimizedbuild(flags) 90 | return config.isoptimizedbuild(flags) and not flags.NoOptimizeLink 91 | end 92 | 93 | 94 | -- 95 | -- Determines if this configuration uses edit and continue. 96 | -- 97 | 98 | function premake.config.iseditandcontinue(cfg) 99 | if cfg.flags.NoEditAndContinue 100 | or cfg.flags.Managed 101 | or (cfg.kind ~= "StaticLib" and not config.isincrementallink(cfg)) 102 | or config.islinkeroptimizedbuild(cfg.flags) then 103 | return false 104 | end 105 | return true 106 | end 107 | 108 | -------------------------------------------------------------------------------- /src/base/help.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- help.lua 3 | -- User help, displayed on /help option. 4 | -- Copyright (c) 2002-2008 Jason Perkins and the Premake project 5 | -- 6 | 7 | 8 | function premake.showhelp() 9 | 10 | -- display the basic usage 11 | printf("") 12 | printf("Usage: genie [options] action [arguments]") 13 | printf("") 14 | 15 | 16 | -- display all options 17 | printf("OPTIONS") 18 | printf("") 19 | for option in premake.option.each() do 20 | local trigger = option.trigger 21 | local description = option.description 22 | if (option.value) then trigger = trigger .. "=" .. option.value end 23 | if (option.allowed) then description = description .. "; one of:" end 24 | 25 | printf(" --%-15s %s", trigger, description) 26 | if (option.allowed) then 27 | for _, value in ipairs(option.allowed) do 28 | printf(" %-14s %s", value[1], value[2]) 29 | end 30 | end 31 | printf("") 32 | end 33 | 34 | -- display all actions 35 | printf("ACTIONS") 36 | printf("") 37 | for action in premake.action.each() do 38 | printf(" %-17s %s", action.trigger, action.description) 39 | end 40 | printf("") 41 | 42 | 43 | -- see more 44 | printf("For additional information, see https://github.com/bkaradzic/genie") 45 | 46 | end 47 | 48 | 49 | -------------------------------------------------------------------------------- /src/base/io.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- io.lua 3 | -- Additions to the I/O namespace. 4 | -- Copyright (c) 2008-2009 Jason Perkins and the Premake project 5 | -- 6 | 7 | io.eol = "\n" 8 | io.indent = "\t" 9 | io.indentLevel = 0 10 | 11 | -- default escaper function 12 | local function _escaper(v) return v end 13 | _esc = _escaper 14 | 15 | 16 | -- 17 | -- Prepare to capture the output from all subsequent calls to io.printf(), 18 | -- used for automated testing of the generators. Returns the previously 19 | -- captured text. 20 | -- 21 | 22 | function io.capture() 23 | local prev = io.captured 24 | io.captured = '' 25 | return prev 26 | end 27 | 28 | 29 | 30 | -- 31 | -- Returns the captured text and stops capturing, optionally restoring a 32 | -- previous capture. 33 | -- 34 | 35 | function io.endcapture(restore) 36 | local captured = io.captured 37 | io.captured = restore 38 | return captured 39 | end 40 | 41 | 42 | -- 43 | -- Open an overload of the io.open() function, which will create any missing 44 | -- subdirectories in the filename if "mode" is set to writeable. 45 | -- 46 | 47 | local builtin_open = io.open 48 | function io.open(fname, mode) 49 | if (mode) then 50 | if (mode:find("w")) then 51 | local dir = path.getdirectory(fname) 52 | ok, err = os.mkdir(dir) 53 | if (not ok) then 54 | error(err, 0) 55 | end 56 | end 57 | end 58 | return builtin_open(fname, mode) 59 | end 60 | 61 | 62 | 63 | -- 64 | -- A shortcut for printing formatted output to an output stream. 65 | -- 66 | 67 | function io.printf(msg, ...) 68 | local arg={...} 69 | if not io.eol then 70 | io.eol = "\n" 71 | end 72 | 73 | if not io.indent then 74 | io.indent = "\t" 75 | end 76 | 77 | if type(msg) == "number" then 78 | s = string.rep(io.indent, msg) .. string.format(table.unpack(arg)) 79 | else 80 | s = string.format(msg, table.unpack(arg)) 81 | end 82 | 83 | if io.captured then 84 | io.captured = io.captured .. s .. io.eol 85 | else 86 | io.write(s) 87 | io.write(io.eol) 88 | end 89 | end 90 | 91 | -- 92 | -- Write a formatted string to the exported file, after passing all 93 | -- arguments (except for the first, which is the formatting string) 94 | -- through io.esc(). 95 | -- 96 | 97 | function io.xprintf(msg, ...) 98 | local arg = {...} 99 | for i = 1, #arg do 100 | arg[i] = io.esc(arg[i]) 101 | end 102 | io.printf(msg, unpack(arg)) 103 | end 104 | 105 | -- 106 | -- Handle escaping of strings for various outputs 107 | -- 108 | 109 | function io.esc(value) 110 | if type(value) == "table" then 111 | local result = {} 112 | local n = #value 113 | for i = 1, n do 114 | table.insert(result, io.esc(value[i])) 115 | end 116 | return result 117 | end 118 | 119 | return _esc(value or "") 120 | end 121 | 122 | -- 123 | -- Set a new string escaping function 124 | -- 125 | 126 | function io.escaper(func) 127 | _esc = func or _escaper 128 | end 129 | 130 | -- 131 | -- Because I use io.printf() so often in the generators, create a terse shortcut 132 | -- for it. This saves me typing, and also reduces the size of the executable. 133 | -- 134 | 135 | _p = io.printf 136 | _x = io.xprintf 137 | -------------------------------------------------------------------------------- /src/base/iter.lua: -------------------------------------------------------------------------------- 1 | iter = {} 2 | 3 | -- sortByKeys iterates over the table where the keys are in sort order 4 | 5 | function iter.sortByKeys(arr, f) 6 | local a = table.keys(arr) 7 | table.sort(a, f) 8 | 9 | local i = 0 10 | return function() 11 | i = i + 1 12 | if a[i] ~= nil then 13 | return a[i], arr[a[i]] 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /src/base/option.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- option.lua 3 | -- Work with the list of registered options. 4 | -- Copyright (c) 2002-2009 Jason Perkins and the Premake project 5 | -- 6 | 7 | premake.option = { } 8 | 9 | 10 | -- 11 | -- The list of registered options. 12 | -- 13 | 14 | premake.option.list = { } 15 | 16 | 17 | -- 18 | -- Register a new option. 19 | -- 20 | -- @param opt 21 | -- The new option object. 22 | -- 23 | 24 | function premake.option.add(opt) 25 | -- some sanity checking 26 | local missing 27 | for _, field in ipairs({ "description", "trigger" }) do 28 | if (not opt[field]) then 29 | missing = field 30 | end 31 | end 32 | 33 | if (missing) then 34 | error("option needs a " .. missing, 3) 35 | end 36 | 37 | -- add it to the master list 38 | premake.option.list[opt.trigger] = opt 39 | end 40 | 41 | 42 | -- 43 | -- Retrieve an option by name. 44 | -- 45 | -- @param name 46 | -- The name of the option to retrieve. 47 | -- @returns 48 | -- The requested option, or nil if the option does not exist. 49 | -- 50 | 51 | function premake.option.get(name) 52 | return premake.option.list[name] 53 | end 54 | 55 | 56 | -- 57 | -- Iterator for the list of options. 58 | -- 59 | 60 | function premake.option.each() 61 | -- sort the list by trigger 62 | local keys = { } 63 | for _, option in pairs(premake.option.list) do 64 | table.insert(keys, option.trigger) 65 | end 66 | table.sort(keys) 67 | 68 | local i = 0 69 | return function() 70 | i = i + 1 71 | return premake.option.list[keys[i]] 72 | end 73 | end 74 | 75 | 76 | -- 77 | -- Validate a list of user supplied key/value pairs against the list of registered options. 78 | -- 79 | -- @param values 80 | -- The list of user supplied key/value pairs. 81 | -- @returns 82 | --- True if the list of pairs are valid, false and an error message otherwise. 83 | -- 84 | 85 | function premake.option.validate(values) 86 | for key, value in pairs(values) do 87 | -- does this option exist 88 | local opt = premake.option.get(key) 89 | if (not opt) then 90 | return false, "invalid option '" .. key .. "'" 91 | end 92 | 93 | -- does it need a value? 94 | if (opt.value and value == "") then 95 | return false, "no value specified for option '" .. key .. "'" 96 | end 97 | 98 | -- is the value allowed? 99 | if opt.allowed then 100 | local found = false 101 | for _, match in ipairs(opt.allowed) do 102 | if match[1] == value then 103 | found = true 104 | break 105 | end 106 | end 107 | if not found then 108 | return false, string.format("invalid value '%s' for option '%s'", value, key) 109 | end 110 | end 111 | end 112 | return true 113 | end 114 | -------------------------------------------------------------------------------- /src/base/premake.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- premake.lua 3 | -- High-level processing functions. 4 | -- Copyright (c) 2002-2009 Jason Perkins and the Premake project 5 | -- 6 | 7 | premake._filelevelconfig = false 8 | premake._checkgenerate = true 9 | 10 | -- 11 | -- Open a file for output, and call a function to actually do the writing. 12 | -- Used by the actions to generate solution and project files. 13 | -- 14 | -- @param obj 15 | -- A solution or project object; will be based to the callback function. 16 | -- @param filename 17 | -- The output filename; see the docs for premake.project.getfilename() 18 | -- for the expected format. 19 | -- @param callback 20 | -- The function responsible for writing the file, should take a solution 21 | -- or project as a parameters. 22 | -- 23 | 24 | function premake.generate(obj, filename, callback) 25 | local prev = io.capture() 26 | local abort = (callback(obj) == false) 27 | local new = io.endcapture(prev) 28 | 29 | if abort then 30 | premake.stats.num_skipped = premake.stats.num_skipped + 1 31 | return 32 | end 33 | 34 | filename = premake.project.getfilename(obj, filename) 35 | 36 | if (premake._checkgenerate) then 37 | local delta = false 38 | 39 | local f, err = io.open(filename, "rb") 40 | if (not f) then 41 | if string.find(err, "No such file or directory") then 42 | delta = true 43 | else 44 | error(err, 0) 45 | end 46 | else 47 | local existing = f:read("*all") 48 | if existing ~= new then 49 | delta = true 50 | end 51 | f:close() 52 | end 53 | 54 | if delta then 55 | printf("Generating %q", filename) 56 | local f, err = io.open(filename, "wb") 57 | if (not f) then 58 | error(err, 0) 59 | end 60 | 61 | f:write(new) 62 | f:close() 63 | 64 | premake.stats.num_generated = premake.stats.num_generated + 1 65 | else 66 | -- printf("Skipping %s as its contents would not change.", filename) 67 | premake.stats.num_skipped = premake.stats.num_skipped + 1 68 | end 69 | else 70 | printf("Generating %q", filename) 71 | 72 | local f, err = io.open(filename, "wb") 73 | if (not f) then 74 | error(err, 0) 75 | end 76 | 77 | f:write(new) 78 | f:close() 79 | premake.stats.num_generated = premake.stats.num_generated + 1 80 | end 81 | end 82 | 83 | 84 | -- 85 | -- Finds a valid premake build file in the specified directory 86 | -- Used by both the main genie process, and include commands 87 | -- 88 | -- @param dir 89 | -- The path in which to start looking for the script 90 | -- @param search_upwards 91 | -- When the script was not found in the specified directory, does the 92 | -- script need to look upwards in the file system 93 | -- 94 | 95 | function premake.findDefaultScript(dir, search_upwards) 96 | search_upwards = search_upwards or true 97 | 98 | local last = "" 99 | while dir ~= last do 100 | for _, name in ipairs({ "genie.lua", "solution.lua", "premake4.lua" }) do 101 | 102 | local script0 = dir .. "/" .. name 103 | if (os.isfile(script0)) then 104 | return dir, name 105 | end 106 | 107 | local script1 = dir .. "/scripts/" .. name 108 | if (os.isfile(script1)) then 109 | return dir .. "/scripts/", name 110 | end 111 | end 112 | 113 | last = dir 114 | dir = path.getabsolute(dir .. "/..") 115 | 116 | if dir == "." or not search_upwards then break end 117 | end 118 | 119 | return nil, nil 120 | end 121 | -------------------------------------------------------------------------------- /src/base/set.lua: -------------------------------------------------------------------------------- 1 | Set_mt = {} 2 | 3 | function Set(t) 4 | local set = {} 5 | for k, l in ipairs(t) do 6 | set[l] = true 7 | end 8 | setmetatable(set, Set_mt) 9 | return set 10 | end 11 | 12 | function Set_mt.union(a, b) 13 | local res = Set{} 14 | for k in pairs(a) do res[k] = true end 15 | for k in pairs(b) do res[k] = true end 16 | return res 17 | end 18 | 19 | function Set_mt.intersection(a, b) 20 | local res = Set{} 21 | for k in pairs(a) do 22 | res[k] = b[k] 23 | end 24 | return res 25 | end 26 | 27 | local function get_cache(a) 28 | if not rawget(a, "__cache") then 29 | rawset(a, "__cache", Set_mt.totable(a)) 30 | end 31 | return rawget(a, "__cache") 32 | end 33 | 34 | function Set_mt.len(a) 35 | return #get_cache(a) 36 | end 37 | 38 | function Set_mt.implode(a, sep) 39 | return table.concat(get_cache(a), sep) 40 | end 41 | 42 | function Set_mt.totable(a) 43 | local res = {} 44 | for k in pairs(a) do 45 | table.insert(res, k) 46 | end 47 | return res 48 | end 49 | 50 | function Set_mt.difference(a, b) 51 | if getmetatable(b) ~= Set_mt then 52 | if type(b) ~= "table" then 53 | error(type(b).." is not a Set or table") 54 | end 55 | b=Set(b) 56 | end 57 | 58 | local res = Set{} 59 | for k in pairs(a) do 60 | res[k] = not b[k] or nil 61 | end 62 | rawset(res, "__cache", nil) 63 | return res 64 | end 65 | 66 | function Set_mt.__index(a, i) 67 | if type(i) == "number" then 68 | return get_cache(a)[i] 69 | end 70 | return Set_mt[i] or rawget(a, i) 71 | end 72 | 73 | Set_mt.__add = Set_mt.union 74 | Set_mt.__mul = Set_mt.intersection 75 | Set_mt.__sub = Set_mt.difference 76 | Set_mt.__len = Set_mt.len 77 | Set_mt.__concat = Set_mt.implode -------------------------------------------------------------------------------- /src/base/string.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- string.lua 3 | -- Additions to Lua's built-in string functions. 4 | -- Copyright (c) 2002-2008 Jason Perkins and the Premake project 5 | -- 6 | 7 | 8 | -- 9 | -- Returns an array of strings, each of which is a substring of s 10 | -- formed by splitting on boundaries formed by `pattern`. 11 | -- 12 | 13 | function string.explode(s, pattern, plain) 14 | if (pattern == '') then return false end 15 | local pos = 0 16 | local arr = { } 17 | for st,sp in function() return s:find(pattern, pos, plain) end do 18 | table.insert(arr, s:sub(pos, st-1)) 19 | pos = sp + 1 20 | end 21 | table.insert(arr, s:sub(pos)) 22 | return arr 23 | end 24 | 25 | 26 | 27 | -- 28 | -- Find the last instance of a pattern in a string. 29 | -- 30 | 31 | function string.findlast(s, pattern, plain) 32 | local curr = 0 33 | local term = nil 34 | repeat 35 | local next, nextterm = s:find(pattern, curr + 1, plain) 36 | if (next) then 37 | curr = next 38 | term = nextterm 39 | end 40 | until (not next) 41 | if (curr > 0) then 42 | return curr, term 43 | end 44 | end 45 | 46 | 47 | 48 | -- 49 | -- Returns true if `haystack` starts with the sequence `needle`. 50 | -- 51 | 52 | function string.startswith(haystack, needle) 53 | return (haystack:find(needle, 1, true) == 1) 54 | end 55 | 56 | -- 57 | -- remove leading and trailing whitespace from string. 58 | -- 59 | 60 | function string.trim(s) 61 | return (s:gsub("^%s*(.-)%s*$", "%1")) 62 | end 63 | -------------------------------------------------------------------------------- /src/base/validate.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- validate.lua 3 | -- Tests to validate the run-time environment before starting the action. 4 | -- Copyright (c) 2002-2009 Jason Perkins and the Premake project 5 | -- 6 | 7 | 8 | -- 9 | -- Performs a sanity check of all of the solutions and projects 10 | -- in the session to be sure they meet some minimum requirements. 11 | -- 12 | 13 | function premake.checkprojects() 14 | local action = premake.action.current() 15 | 16 | for sln in premake.solution.each() do 17 | 18 | -- every solution must have at least one project 19 | if (#sln.projects == 0) then 20 | return nil, "solution '" .. sln.name .. "' needs at least one project" 21 | end 22 | 23 | -- every solution must provide a list of configurations 24 | if (#sln.configurations == 0) then 25 | return nil, "solution '" .. sln.name .. "' needs configurations" 26 | end 27 | 28 | for prj in premake.solution.eachproject(sln) do 29 | 30 | -- every project must have a language 31 | if (not prj.language) then 32 | return nil, "project '" ..prj.name .. "' needs a language" 33 | end 34 | 35 | -- and the action must support it 36 | if (action.valid_languages) then 37 | if (not table.contains(action.valid_languages, prj.language)) then 38 | return nil, "the " .. action.shortname .. " action does not support " .. prj.language .. " projects" 39 | end 40 | end 41 | 42 | for cfg in premake.eachconfig(prj) do 43 | 44 | -- every config must have a kind 45 | if (not cfg.kind) then 46 | return nil, "project '" ..prj.name .. "' needs a kind in configuration '" .. cfg.name .. "'" 47 | end 48 | 49 | -- and the action must support it 50 | if (action.valid_kinds) then 51 | if (not table.contains(action.valid_kinds, cfg.kind)) then 52 | return nil, "the " .. action.shortname .. " action does not support " .. cfg.kind .. " projects" 53 | end 54 | end 55 | 56 | end 57 | 58 | -- some actions have custom validation logic 59 | if action.oncheckproject then 60 | action.oncheckproject(prj) 61 | end 62 | 63 | end 64 | end 65 | return true 66 | end 67 | 68 | 69 | -- 70 | -- Check the specified tools (/cc, /dotnet, etc.) against the current action 71 | -- to make sure they are compatible and supported. 72 | -- 73 | 74 | function premake.checktools() 75 | local action = premake.action.current() 76 | if (not action.valid_tools) then 77 | return true 78 | end 79 | 80 | for tool, values in pairs(action.valid_tools) do 81 | if (_OPTIONS[tool]) then 82 | if (not table.contains(values, _OPTIONS[tool])) then 83 | return nil, "the " .. action.shortname .. " action does not support /" .. tool .. "=" .. _OPTIONS[tool] .. " (yet)" 84 | end 85 | else 86 | _OPTIONS[tool] = values[1] 87 | end 88 | end 89 | 90 | return true 91 | end 92 | -------------------------------------------------------------------------------- /src/host/lua-5.3.0/README: -------------------------------------------------------------------------------- 1 | 2 | This is Lua 5.3.0, released on 06 Jan 2015. 3 | 4 | For installation instructions, license details, and 5 | further information about Lua, see doc/readme.html. 6 | 7 | -------------------------------------------------------------------------------- /src/host/lua-5.3.0/doc/logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bkaradzic/GENie/bf3bf3f051a5f829e9f77d792c169ff866528f8d/src/host/lua-5.3.0/doc/logo.gif -------------------------------------------------------------------------------- /src/host/lua-5.3.0/doc/lua.1: -------------------------------------------------------------------------------- 1 | .TH LUA 1 "$Date: 2014/12/10 15:55:45 $" 2 | .SH NAME 3 | lua \- Lua interpreter 4 | .SH SYNOPSIS 5 | .B lua 6 | [ 7 | .I options 8 | ] 9 | [ 10 | .I script 11 | [ 12 | .I args 13 | ] 14 | ] 15 | .SH DESCRIPTION 16 | .B lua 17 | is the standalone Lua interpreter. 18 | It loads and executes Lua programs, 19 | either in textual source form or 20 | in precompiled binary form. 21 | (Precompiled binaries are output by 22 | .BR luac , 23 | the Lua compiler.) 24 | .B lua 25 | can be used as a batch interpreter and also interactively. 26 | .LP 27 | The given 28 | .I options 29 | are handled in order and then 30 | the Lua program in file 31 | .I script 32 | is loaded and executed. 33 | The given 34 | .I args 35 | are available to 36 | .I script 37 | as strings in a global table named 38 | .BR arg . 39 | If no options or arguments are given, 40 | then 41 | .B "\-v \-i" 42 | is assumed when the standard input is a terminal; 43 | otherwise, 44 | .B "\-" 45 | is assumed. 46 | .LP 47 | In interactive mode, 48 | .B lua 49 | prompts the user, 50 | reads lines from the standard input, 51 | and executes them as they are read. 52 | If the line contains an expression or list of expressions, 53 | then the line is evaluated and the results are printed. 54 | If a line does not contain a complete statement, 55 | then a secondary prompt is displayed and 56 | lines are read until a complete statement is formed or 57 | a syntax error is found. 58 | .LP 59 | At the very start, 60 | before even handling the command line, 61 | .B lua 62 | checks the contents of the environment variables 63 | .B LUA_INIT_5_3 64 | or 65 | .BR LUA_INIT , 66 | in that order. 67 | If the contents is of the form 68 | .RI '@ filename ', 69 | then 70 | .I filename 71 | is executed. 72 | Otherwise, the string is assumed to be a Lua statement and is executed. 73 | .SH OPTIONS 74 | .TP 75 | .BI \-e " stat" 76 | execute statement 77 | .IR stat . 78 | .TP 79 | .B \-i 80 | enter interactive mode after executing 81 | .IR script . 82 | .TP 83 | .BI \-l " name" 84 | execute the equivalent of 85 | .IB name =require(' name ') 86 | before executing 87 | .IR script . 88 | .TP 89 | .B \-v 90 | show version information. 91 | .TP 92 | .B \-E 93 | ignore environment variables. 94 | .TP 95 | .B \-\- 96 | stop handling options. 97 | .TP 98 | .B \- 99 | stop handling options and execute the standard input as a file. 100 | .SH "SEE ALSO" 101 | .BR luac (1) 102 | .br 103 | The documentation at lua.org, 104 | especially section 7 of the reference manual. 105 | .SH DIAGNOSTICS 106 | Error messages should be self explanatory. 107 | .SH AUTHORS 108 | R. Ierusalimschy, 109 | L. H. de Figueiredo, 110 | W. Celes 111 | .\" EOF 112 | -------------------------------------------------------------------------------- /src/host/lua-5.3.0/doc/lua.css: -------------------------------------------------------------------------------- 1 | html { 2 | background-color: #F8F8F8 ; 3 | } 4 | 5 | body { 6 | border: solid #a0a0a0 1px ; 7 | border-radius: 20px ; 8 | padding: 26px ; 9 | margin: 16px ; 10 | color: #000000 ; 11 | background-color: #FFFFFF ; 12 | font-family: Helvetica, Arial, sans-serif ; 13 | text-align: justify ; 14 | } 15 | 16 | h1, h2, h3, h4 { 17 | font-family: Verdana, Geneva, sans-serif ; 18 | font-weight: normal ; 19 | font-style: normal ; 20 | } 21 | 22 | h2 { 23 | padding-top: 0.4em ; 24 | padding-bottom: 0.4em ; 25 | padding-left: 0.8em ; 26 | padding-right: 0.8em ; 27 | background-color: #D0D0FF ; 28 | border-radius: 8px ; 29 | border: solid #a0a0a0 1px ; 30 | } 31 | 32 | h3 { 33 | padding-left: 0.5em ; 34 | border-left: solid #D0D0FF 1em ; 35 | } 36 | 37 | table h3 { 38 | padding-left: 0px ; 39 | border-left: none ; 40 | } 41 | 42 | a:link { 43 | color: #000080 ; 44 | background-color: inherit ; 45 | text-decoration: none ; 46 | } 47 | 48 | a:visited { 49 | background-color: inherit ; 50 | text-decoration: none ; 51 | } 52 | 53 | a:link:hover, a:visited:hover { 54 | color: #000080 ; 55 | background-color: #D0D0FF ; 56 | border-radius: 4px; 57 | } 58 | 59 | a:link:active, a:visited:active { 60 | color: #FF0000 ; 61 | } 62 | 63 | h1 a img { 64 | vertical-align: text-bottom ; 65 | } 66 | 67 | hr { 68 | border: 0 ; 69 | height: 1px ; 70 | color: #a0a0a0 ; 71 | background-color: #a0a0a0 ; 72 | display: none ; 73 | } 74 | 75 | table hr { 76 | display: block ; 77 | } 78 | 79 | :target { 80 | background-color: #F8F8F8 ; 81 | padding: 8px ; 82 | border: solid #a0a0a0 2px ; 83 | border-radius: 8px ; 84 | } 85 | 86 | .footer { 87 | color: gray ; 88 | font-size: x-small ; 89 | } 90 | 91 | input[type=text] { 92 | border: solid #a0a0a0 2px ; 93 | border-radius: 2em ; 94 | background-image: url('images/search.png') ; 95 | background-repeat: no-repeat ; 96 | background-position: 4px center ; 97 | padding-left: 20px ; 98 | height: 2em ; 99 | } 100 | 101 | pre.session { 102 | background-color: #F8F8F8 ; 103 | padding: 1em ; 104 | border-radius: 8px ; 105 | } 106 | -------------------------------------------------------------------------------- /src/host/lua-5.3.0/doc/manual.css: -------------------------------------------------------------------------------- 1 | h3 code { 2 | font-family: inherit ; 3 | font-size: inherit ; 4 | } 5 | 6 | pre, code { 7 | font-size: 12pt ; 8 | } 9 | 10 | span.apii { 11 | float: right ; 12 | font-family: inherit ; 13 | font-style: normal ; 14 | font-size: small ; 15 | color: gray ; 16 | } 17 | 18 | p+h1, ul+h1 { 19 | font-style: normal ; 20 | padding-top: 0.4em ; 21 | padding-bottom: 0.4em ; 22 | padding-left: 16px ; 23 | margin-left: -16px ; 24 | background-color: #D0D0FF ; 25 | border-radius: 8px ; 26 | border: solid #000080 1px ; 27 | } 28 | -------------------------------------------------------------------------------- /src/host/lua-5.3.0/doc/osi-certified-72x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bkaradzic/GENie/bf3bf3f051a5f829e9f77d792c169ff866528f8d/src/host/lua-5.3.0/doc/osi-certified-72x60.png -------------------------------------------------------------------------------- /src/host/lua-5.3.0/src/lapi.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lapi.h,v 2.8 2014/07/15 21:26:50 roberto Exp $ 3 | ** Auxiliary functions from Lua API 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lapi_h 8 | #define lapi_h 9 | 10 | 11 | #include "llimits.h" 12 | #include "lstate.h" 13 | 14 | #define api_incr_top(L) {L->top++; api_check(L->top <= L->ci->top, \ 15 | "stack overflow");} 16 | 17 | #define adjustresults(L,nres) \ 18 | { if ((nres) == LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; } 19 | 20 | #define api_checknelems(L,n) api_check((n) < (L->top - L->ci->func), \ 21 | "not enough elements in the stack") 22 | 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /src/host/lua-5.3.0/src/lcode.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lcode.h,v 1.63 2013/12/30 20:47:58 roberto Exp $ 3 | ** Code generator for Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lcode_h 8 | #define lcode_h 9 | 10 | #include "llex.h" 11 | #include "lobject.h" 12 | #include "lopcodes.h" 13 | #include "lparser.h" 14 | 15 | 16 | /* 17 | ** Marks the end of a patch list. It is an invalid value both as an absolute 18 | ** address, and as a list link (would link an element to itself). 19 | */ 20 | #define NO_JUMP (-1) 21 | 22 | 23 | /* 24 | ** grep "ORDER OPR" if you change these enums (ORDER OP) 25 | */ 26 | typedef enum BinOpr { 27 | OPR_ADD, OPR_SUB, OPR_MUL, OPR_MOD, OPR_POW, 28 | OPR_DIV, 29 | OPR_IDIV, 30 | OPR_BAND, OPR_BOR, OPR_BXOR, 31 | OPR_SHL, OPR_SHR, 32 | OPR_CONCAT, 33 | OPR_EQ, OPR_LT, OPR_LE, 34 | OPR_NE, OPR_GT, OPR_GE, 35 | OPR_AND, OPR_OR, 36 | OPR_NOBINOPR 37 | } BinOpr; 38 | 39 | 40 | typedef enum UnOpr { OPR_MINUS, OPR_BNOT, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr; 41 | 42 | 43 | #define getcode(fs,e) ((fs)->f->code[(e)->u.info]) 44 | 45 | #define luaK_codeAsBx(fs,o,A,sBx) luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx) 46 | 47 | #define luaK_setmultret(fs,e) luaK_setreturns(fs, e, LUA_MULTRET) 48 | 49 | #define luaK_jumpto(fs,t) luaK_patchlist(fs, luaK_jump(fs), t) 50 | 51 | LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx); 52 | LUAI_FUNC int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C); 53 | LUAI_FUNC int luaK_codek (FuncState *fs, int reg, int k); 54 | LUAI_FUNC void luaK_fixline (FuncState *fs, int line); 55 | LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n); 56 | LUAI_FUNC void luaK_reserveregs (FuncState *fs, int n); 57 | LUAI_FUNC void luaK_checkstack (FuncState *fs, int n); 58 | LUAI_FUNC int luaK_stringK (FuncState *fs, TString *s); 59 | LUAI_FUNC int luaK_intK (FuncState *fs, lua_Integer n); 60 | LUAI_FUNC void luaK_dischargevars (FuncState *fs, expdesc *e); 61 | LUAI_FUNC int luaK_exp2anyreg (FuncState *fs, expdesc *e); 62 | LUAI_FUNC void luaK_exp2anyregup (FuncState *fs, expdesc *e); 63 | LUAI_FUNC void luaK_exp2nextreg (FuncState *fs, expdesc *e); 64 | LUAI_FUNC void luaK_exp2val (FuncState *fs, expdesc *e); 65 | LUAI_FUNC int luaK_exp2RK (FuncState *fs, expdesc *e); 66 | LUAI_FUNC void luaK_self (FuncState *fs, expdesc *e, expdesc *key); 67 | LUAI_FUNC void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k); 68 | LUAI_FUNC void luaK_goiftrue (FuncState *fs, expdesc *e); 69 | LUAI_FUNC void luaK_goiffalse (FuncState *fs, expdesc *e); 70 | LUAI_FUNC void luaK_storevar (FuncState *fs, expdesc *var, expdesc *e); 71 | LUAI_FUNC void luaK_setreturns (FuncState *fs, expdesc *e, int nresults); 72 | LUAI_FUNC void luaK_setoneret (FuncState *fs, expdesc *e); 73 | LUAI_FUNC int luaK_jump (FuncState *fs); 74 | LUAI_FUNC void luaK_ret (FuncState *fs, int first, int nret); 75 | LUAI_FUNC void luaK_patchlist (FuncState *fs, int list, int target); 76 | LUAI_FUNC void luaK_patchtohere (FuncState *fs, int list); 77 | LUAI_FUNC void luaK_patchclose (FuncState *fs, int list, int level); 78 | LUAI_FUNC void luaK_concat (FuncState *fs, int *l1, int l2); 79 | LUAI_FUNC int luaK_getlabel (FuncState *fs); 80 | LUAI_FUNC void luaK_prefix (FuncState *fs, UnOpr op, expdesc *v, int line); 81 | LUAI_FUNC void luaK_infix (FuncState *fs, BinOpr op, expdesc *v); 82 | LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1, 83 | expdesc *v2, int line); 84 | LUAI_FUNC void luaK_setlist (FuncState *fs, int base, int nelems, int tostore); 85 | 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /src/host/lua-5.3.0/src/lctype.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lctype.c,v 1.12 2014/11/02 19:19:04 roberto Exp $ 3 | ** 'ctype' functions for Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #define lctype_c 8 | #define LUA_CORE 9 | 10 | #include "lprefix.h" 11 | 12 | 13 | #include "lctype.h" 14 | 15 | #if !LUA_USE_CTYPE /* { */ 16 | 17 | #include 18 | 19 | LUAI_DDEF const lu_byte luai_ctype_[UCHAR_MAX + 2] = { 20 | 0x00, /* EOZ */ 21 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0. */ 22 | 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 23 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 1. */ 24 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 25 | 0x0c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, /* 2. */ 26 | 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 27 | 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, /* 3. */ 28 | 0x16, 0x16, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 29 | 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 4. */ 30 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 31 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 5. */ 32 | 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x05, 33 | 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 6. */ 34 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 35 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 7. */ 36 | 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x00, 37 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 8. */ 38 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 39 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 9. */ 40 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 41 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a. */ 42 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 43 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b. */ 44 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 45 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* c. */ 46 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 47 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* d. */ 48 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 49 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* e. */ 50 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 51 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* f. */ 52 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 53 | }; 54 | 55 | #endif /* } */ 56 | -------------------------------------------------------------------------------- /src/host/lua-5.3.0/src/lctype.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lctype.h,v 1.12 2011/07/15 12:50:29 roberto Exp $ 3 | ** 'ctype' functions for Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lctype_h 8 | #define lctype_h 9 | 10 | #include "lua.h" 11 | 12 | 13 | /* 14 | ** WARNING: the functions defined here do not necessarily correspond 15 | ** to the similar functions in the standard C ctype.h. They are 16 | ** optimized for the specific needs of Lua 17 | */ 18 | 19 | #if !defined(LUA_USE_CTYPE) 20 | 21 | #if 'A' == 65 && '0' == 48 22 | /* ASCII case: can use its own tables; faster and fixed */ 23 | #define LUA_USE_CTYPE 0 24 | #else 25 | /* must use standard C ctype */ 26 | #define LUA_USE_CTYPE 1 27 | #endif 28 | 29 | #endif 30 | 31 | 32 | #if !LUA_USE_CTYPE /* { */ 33 | 34 | #include 35 | 36 | #include "llimits.h" 37 | 38 | 39 | #define ALPHABIT 0 40 | #define DIGITBIT 1 41 | #define PRINTBIT 2 42 | #define SPACEBIT 3 43 | #define XDIGITBIT 4 44 | 45 | 46 | #define MASK(B) (1 << (B)) 47 | 48 | 49 | /* 50 | ** add 1 to char to allow index -1 (EOZ) 51 | */ 52 | #define testprop(c,p) (luai_ctype_[(c)+1] & (p)) 53 | 54 | /* 55 | ** 'lalpha' (Lua alphabetic) and 'lalnum' (Lua alphanumeric) both include '_' 56 | */ 57 | #define lislalpha(c) testprop(c, MASK(ALPHABIT)) 58 | #define lislalnum(c) testprop(c, (MASK(ALPHABIT) | MASK(DIGITBIT))) 59 | #define lisdigit(c) testprop(c, MASK(DIGITBIT)) 60 | #define lisspace(c) testprop(c, MASK(SPACEBIT)) 61 | #define lisprint(c) testprop(c, MASK(PRINTBIT)) 62 | #define lisxdigit(c) testprop(c, MASK(XDIGITBIT)) 63 | 64 | /* 65 | ** this 'ltolower' only works for alphabetic characters 66 | */ 67 | #define ltolower(c) ((c) | ('A' ^ 'a')) 68 | 69 | 70 | /* two more entries for 0 and -1 (EOZ) */ 71 | LUAI_DDEC const lu_byte luai_ctype_[UCHAR_MAX + 2]; 72 | 73 | 74 | #else /* }{ */ 75 | 76 | /* 77 | ** use standard C ctypes 78 | */ 79 | 80 | #include 81 | 82 | 83 | #define lislalpha(c) (isalpha(c) || (c) == '_') 84 | #define lislalnum(c) (isalnum(c) || (c) == '_') 85 | #define lisdigit(c) (isdigit(c)) 86 | #define lisspace(c) (isspace(c)) 87 | #define lisprint(c) (isprint(c)) 88 | #define lisxdigit(c) (isxdigit(c)) 89 | 90 | #define ltolower(c) (tolower(c)) 91 | 92 | #endif /* } */ 93 | 94 | #endif 95 | 96 | -------------------------------------------------------------------------------- /src/host/lua-5.3.0/src/ldebug.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldebug.h,v 2.12 2014/11/10 14:46:05 roberto Exp $ 3 | ** Auxiliary functions from Debug Interface module 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ldebug_h 8 | #define ldebug_h 9 | 10 | 11 | #include "lstate.h" 12 | 13 | 14 | #define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1) 15 | 16 | #define getfuncline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : -1) 17 | 18 | #define resethookcount(L) (L->hookcount = L->basehookcount) 19 | 20 | /* Active Lua function (given call info) */ 21 | #define ci_func(ci) (clLvalue((ci)->func)) 22 | 23 | 24 | LUAI_FUNC l_noret luaG_typeerror (lua_State *L, const TValue *o, 25 | const char *opname); 26 | LUAI_FUNC l_noret luaG_concaterror (lua_State *L, const TValue *p1, 27 | const TValue *p2); 28 | LUAI_FUNC l_noret luaG_opinterror (lua_State *L, const TValue *p1, 29 | const TValue *p2, 30 | const char *msg); 31 | LUAI_FUNC l_noret luaG_tointerror (lua_State *L, const TValue *p1, 32 | const TValue *p2); 33 | LUAI_FUNC l_noret luaG_ordererror (lua_State *L, const TValue *p1, 34 | const TValue *p2); 35 | LUAI_FUNC l_noret luaG_runerror (lua_State *L, const char *fmt, ...); 36 | LUAI_FUNC l_noret luaG_errormsg (lua_State *L); 37 | LUAI_FUNC void luaG_traceexec (lua_State *L); 38 | 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/host/lua-5.3.0/src/ldo.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldo.h,v 2.21 2014/10/25 11:50:46 roberto Exp $ 3 | ** Stack and Call structure of Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ldo_h 8 | #define ldo_h 9 | 10 | 11 | #include "lobject.h" 12 | #include "lstate.h" 13 | #include "lzio.h" 14 | 15 | 16 | #define luaD_checkstack(L,n) if (L->stack_last - L->top <= (n)) \ 17 | luaD_growstack(L, n); else condmovestack(L); 18 | 19 | 20 | #define incr_top(L) {L->top++; luaD_checkstack(L,0);} 21 | 22 | #define savestack(L,p) ((char *)(p) - (char *)L->stack) 23 | #define restorestack(L,n) ((TValue *)((char *)L->stack + (n))) 24 | 25 | 26 | /* type of protected functions, to be ran by 'runprotected' */ 27 | typedef void (*Pfunc) (lua_State *L, void *ud); 28 | 29 | LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name, 30 | const char *mode); 31 | LUAI_FUNC void luaD_hook (lua_State *L, int event, int line); 32 | LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults); 33 | LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults, 34 | int allowyield); 35 | LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, 36 | ptrdiff_t oldtop, ptrdiff_t ef); 37 | LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult); 38 | LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize); 39 | LUAI_FUNC void luaD_growstack (lua_State *L, int n); 40 | LUAI_FUNC void luaD_shrinkstack (lua_State *L); 41 | 42 | LUAI_FUNC l_noret luaD_throw (lua_State *L, int errcode); 43 | LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud); 44 | 45 | #endif 46 | 47 | -------------------------------------------------------------------------------- /src/host/lua-5.3.0/src/lfunc.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lfunc.h,v 2.14 2014/06/19 18:27:20 roberto Exp $ 3 | ** Auxiliary functions to manipulate prototypes and closures 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lfunc_h 8 | #define lfunc_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | #define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \ 15 | cast(int, sizeof(TValue)*((n)-1))) 16 | 17 | #define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \ 18 | cast(int, sizeof(TValue *)*((n)-1))) 19 | 20 | 21 | /* test whether thread is in 'twups' list */ 22 | #define isintwups(L) (L->twups != L) 23 | 24 | 25 | /* 26 | ** Upvalues for Lua closures 27 | */ 28 | struct UpVal { 29 | TValue *v; /* points to stack or to its own value */ 30 | lu_mem refcount; /* reference counter */ 31 | union { 32 | struct { /* (when open) */ 33 | UpVal *next; /* linked list */ 34 | int touched; /* mark to avoid cycles with dead threads */ 35 | } open; 36 | TValue value; /* the value (when closed) */ 37 | } u; 38 | }; 39 | 40 | #define upisopen(up) ((up)->v != &(up)->u.value) 41 | 42 | 43 | LUAI_FUNC Proto *luaF_newproto (lua_State *L); 44 | LUAI_FUNC CClosure *luaF_newCclosure (lua_State *L, int nelems); 45 | LUAI_FUNC LClosure *luaF_newLclosure (lua_State *L, int nelems); 46 | LUAI_FUNC void luaF_initupvals (lua_State *L, LClosure *cl); 47 | LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); 48 | LUAI_FUNC void luaF_close (lua_State *L, StkId level); 49 | LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); 50 | LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, 51 | int pc); 52 | 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /src/host/lua-5.3.0/src/linit.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: linit.c,v 1.38 2015/01/05 13:48:33 roberto Exp $ 3 | ** Initialization of libraries for lua.c and other clients 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #define linit_c 9 | #define LUA_LIB 10 | 11 | /* 12 | ** If you embed Lua in your program and need to open the standard 13 | ** libraries, call luaL_openlibs in your program. If you need a 14 | ** different set of libraries, copy this file to your project and edit 15 | ** it to suit your needs. 16 | ** 17 | ** You can also *preload* libraries, so that a later 'require' can 18 | ** open the library, which is already linked to the application. 19 | ** For that, do the following code: 20 | ** 21 | ** luaL_getsubtable(L, LUA_REGISTRYINDEX, "_PRELOAD"); 22 | ** lua_pushcfunction(L, luaopen_modname); 23 | ** lua_setfield(L, -2, modname); 24 | ** lua_pop(L, 1); // remove _PRELOAD table 25 | */ 26 | 27 | #include "lprefix.h" 28 | 29 | 30 | #include 31 | 32 | #include "lua.h" 33 | 34 | #include "lualib.h" 35 | #include "lauxlib.h" 36 | 37 | 38 | /* 39 | ** these libs are loaded by lua.c and are readily available to any Lua 40 | ** program 41 | */ 42 | static const luaL_Reg loadedlibs[] = { 43 | {"_G", luaopen_base}, 44 | {LUA_LOADLIBNAME, luaopen_package}, 45 | {LUA_COLIBNAME, luaopen_coroutine}, 46 | {LUA_TABLIBNAME, luaopen_table}, 47 | {LUA_IOLIBNAME, luaopen_io}, 48 | {LUA_OSLIBNAME, luaopen_os}, 49 | {LUA_STRLIBNAME, luaopen_string}, 50 | {LUA_MATHLIBNAME, luaopen_math}, 51 | {LUA_UTF8LIBNAME, luaopen_utf8}, 52 | {LUA_DBLIBNAME, luaopen_debug}, 53 | #if defined(LUA_COMPAT_BITLIB) 54 | {LUA_BITLIBNAME, luaopen_bit32}, 55 | #endif 56 | {NULL, NULL} 57 | }; 58 | 59 | 60 | LUALIB_API void luaL_openlibs (lua_State *L) { 61 | const luaL_Reg *lib; 62 | /* "require" functions from 'loadedlibs' and set results to global table */ 63 | for (lib = loadedlibs; lib->func; lib++) { 64 | luaL_requiref(L, lib->name, lib->func, 1); 65 | lua_pop(L, 1); /* remove lib */ 66 | } 67 | } 68 | 69 | -------------------------------------------------------------------------------- /src/host/lua-5.3.0/src/llex.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: llex.h,v 1.78 2014/10/29 15:38:24 roberto Exp $ 3 | ** Lexical Analyzer 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef llex_h 8 | #define llex_h 9 | 10 | #include "lobject.h" 11 | #include "lzio.h" 12 | 13 | 14 | #define FIRST_RESERVED 257 15 | 16 | 17 | #if !defined(LUA_ENV) 18 | #define LUA_ENV "_ENV" 19 | #endif 20 | 21 | 22 | /* 23 | * WARNING: if you change the order of this enumeration, 24 | * grep "ORDER RESERVED" 25 | */ 26 | enum RESERVED { 27 | /* terminal symbols denoted by reserved words */ 28 | TK_AND = FIRST_RESERVED, TK_BREAK, 29 | TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION, 30 | TK_GOTO, TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT, 31 | TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE, 32 | /* other terminal symbols */ 33 | TK_IDIV, TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, 34 | TK_SHL, TK_SHR, 35 | TK_DBCOLON, TK_EOS, 36 | TK_FLT, TK_INT, TK_NAME, TK_STRING 37 | }; 38 | 39 | /* number of reserved words */ 40 | #define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1)) 41 | 42 | 43 | typedef union { 44 | lua_Number r; 45 | lua_Integer i; 46 | TString *ts; 47 | } SemInfo; /* semantics information */ 48 | 49 | 50 | typedef struct Token { 51 | int token; 52 | SemInfo seminfo; 53 | } Token; 54 | 55 | 56 | /* state of the lexer plus state of the parser when shared by all 57 | functions */ 58 | typedef struct LexState { 59 | int current; /* current character (charint) */ 60 | int linenumber; /* input line counter */ 61 | int lastline; /* line of last token 'consumed' */ 62 | Token t; /* current token */ 63 | Token lookahead; /* look ahead token */ 64 | struct FuncState *fs; /* current function (parser) */ 65 | struct lua_State *L; 66 | ZIO *z; /* input stream */ 67 | Mbuffer *buff; /* buffer for tokens */ 68 | Table *h; /* to avoid collection/reuse strings */ 69 | struct Dyndata *dyd; /* dynamic structures used by the parser */ 70 | TString *source; /* current source name */ 71 | TString *envn; /* environment variable name */ 72 | char decpoint; /* locale decimal point */ 73 | } LexState; 74 | 75 | 76 | LUAI_FUNC void luaX_init (lua_State *L); 77 | LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, 78 | TString *source, int firstchar); 79 | LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l); 80 | LUAI_FUNC void luaX_next (LexState *ls); 81 | LUAI_FUNC int luaX_lookahead (LexState *ls); 82 | LUAI_FUNC l_noret luaX_syntaxerror (LexState *ls, const char *s); 83 | LUAI_FUNC const char *luaX_token2str (LexState *ls, int token); 84 | 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /src/host/lua-5.3.0/src/lmem.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lmem.c,v 1.89 2014/11/02 19:33:33 roberto Exp $ 3 | ** Interface to Memory Manager 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #define lmem_c 8 | #define LUA_CORE 9 | 10 | #include "lprefix.h" 11 | 12 | 13 | #include 14 | 15 | #include "lua.h" 16 | 17 | #include "ldebug.h" 18 | #include "ldo.h" 19 | #include "lgc.h" 20 | #include "lmem.h" 21 | #include "lobject.h" 22 | #include "lstate.h" 23 | 24 | 25 | 26 | /* 27 | ** About the realloc function: 28 | ** void * frealloc (void *ud, void *ptr, size_t osize, size_t nsize); 29 | ** ('osize' is the old size, 'nsize' is the new size) 30 | ** 31 | ** * frealloc(ud, NULL, x, s) creates a new block of size 's' (no 32 | ** matter 'x'). 33 | ** 34 | ** * frealloc(ud, p, x, 0) frees the block 'p' 35 | ** (in this specific case, frealloc must return NULL); 36 | ** particularly, frealloc(ud, NULL, 0, 0) does nothing 37 | ** (which is equivalent to free(NULL) in ISO C) 38 | ** 39 | ** frealloc returns NULL if it cannot create or reallocate the area 40 | ** (any reallocation to an equal or smaller size cannot fail!) 41 | */ 42 | 43 | 44 | 45 | #define MINSIZEARRAY 4 46 | 47 | 48 | void *luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elems, 49 | int limit, const char *what) { 50 | void *newblock; 51 | int newsize; 52 | if (*size >= limit/2) { /* cannot double it? */ 53 | if (*size >= limit) /* cannot grow even a little? */ 54 | luaG_runerror(L, "too many %s (limit is %d)", what, limit); 55 | newsize = limit; /* still have at least one free place */ 56 | } 57 | else { 58 | newsize = (*size)*2; 59 | if (newsize < MINSIZEARRAY) 60 | newsize = MINSIZEARRAY; /* minimum size */ 61 | } 62 | newblock = luaM_reallocv(L, block, *size, newsize, size_elems); 63 | *size = newsize; /* update only when everything else is OK */ 64 | return newblock; 65 | } 66 | 67 | 68 | l_noret luaM_toobig (lua_State *L) { 69 | luaG_runerror(L, "memory allocation error: block too big"); 70 | } 71 | 72 | 73 | 74 | /* 75 | ** generic allocation routine. 76 | */ 77 | void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) { 78 | void *newblock; 79 | global_State *g = G(L); 80 | size_t realosize = (block) ? osize : 0; 81 | lua_assert((realosize == 0) == (block == NULL)); 82 | #if defined(HARDMEMTESTS) 83 | if (nsize > realosize && g->gcrunning) 84 | luaC_fullgc(L, 1); /* force a GC whenever possible */ 85 | #endif 86 | newblock = (*g->frealloc)(g->ud, block, osize, nsize); 87 | if (newblock == NULL && nsize > 0) { 88 | api_check( nsize > realosize, 89 | "realloc cannot fail when shrinking a block"); 90 | luaC_fullgc(L, 1); /* try to free some memory... */ 91 | newblock = (*g->frealloc)(g->ud, block, osize, nsize); /* try again */ 92 | if (newblock == NULL) 93 | luaD_throw(L, LUA_ERRMEM); 94 | } 95 | lua_assert((nsize == 0) == (newblock == NULL)); 96 | g->GCdebt = (g->GCdebt + nsize) - realosize; 97 | return newblock; 98 | } 99 | 100 | -------------------------------------------------------------------------------- /src/host/lua-5.3.0/src/lmem.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lmem.h,v 1.43 2014/12/19 17:26:14 roberto Exp $ 3 | ** Interface to Memory Manager 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lmem_h 8 | #define lmem_h 9 | 10 | 11 | #include 12 | 13 | #include "llimits.h" 14 | #include "lua.h" 15 | 16 | 17 | /* 18 | ** This macro reallocs a vector 'b' from 'on' to 'n' elements, where 19 | ** each element has size 'e'. In case of arithmetic overflow of the 20 | ** product 'n'*'e', it raises an error (calling 'luaM_toobig'). Because 21 | ** 'e' is always constant, it avoids the runtime division MAX_SIZET/(e). 22 | ** 23 | ** (The macro is somewhat complex to avoid warnings: The 'sizeof' 24 | ** comparison avoids a runtime comparison when overflow cannot occur. 25 | ** The compiler should be able to optimize the real test by itself, but 26 | ** when it does it, it may give a warning about "comparison is always 27 | ** false due to limited range of data type"; the +1 tricks the compiler, 28 | ** avoiding this warning but also this optimization.) 29 | */ 30 | #define luaM_reallocv(L,b,on,n,e) \ 31 | (((sizeof(n) >= sizeof(size_t) && cast(size_t, (n)) + 1 > MAX_SIZET/(e)) \ 32 | ? luaM_toobig(L) : cast_void(0)) , \ 33 | luaM_realloc_(L, (b), (on)*(e), (n)*(e))) 34 | 35 | /* 36 | ** Arrays of chars do not need any test 37 | */ 38 | #define luaM_reallocvchar(L,b,on,n) \ 39 | cast(char *, luaM_realloc_(L, (b), (on)*sizeof(char), (n)*sizeof(char))) 40 | 41 | #define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0) 42 | #define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0) 43 | #define luaM_freearray(L, b, n) luaM_realloc_(L, (b), (n)*sizeof(*(b)), 0) 44 | 45 | #define luaM_malloc(L,s) luaM_realloc_(L, NULL, 0, (s)) 46 | #define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t))) 47 | #define luaM_newvector(L,n,t) \ 48 | cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t))) 49 | 50 | #define luaM_newobject(L,tag,s) luaM_realloc_(L, NULL, tag, (s)) 51 | 52 | #define luaM_growvector(L,v,nelems,size,t,limit,e) \ 53 | if ((nelems)+1 > (size)) \ 54 | ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e))) 55 | 56 | #define luaM_reallocvector(L, v,oldn,n,t) \ 57 | ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t)))) 58 | 59 | LUAI_FUNC l_noret luaM_toobig (lua_State *L); 60 | 61 | /* not to be called directly */ 62 | LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, 63 | size_t size); 64 | LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size, 65 | size_t size_elem, int limit, 66 | const char *what); 67 | 68 | #endif 69 | 70 | -------------------------------------------------------------------------------- /src/host/lua-5.3.0/src/lprefix.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lprefix.h,v 1.2 2014/12/29 16:54:13 roberto Exp $ 3 | ** Definitions for Lua code that must come before any other header file 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lprefix_h 8 | #define lprefix_h 9 | 10 | 11 | /* 12 | ** Allows POSIX/XSI stuff 13 | */ 14 | #if !defined(LUA_USE_C89) /* { */ 15 | 16 | #if !defined(_XOPEN_SOURCE) 17 | #define _XOPEN_SOURCE 600 18 | #elif _XOPEN_SOURCE == 0 19 | #undef _XOPEN_SOURCE /* use -D_XOPEN_SOURCE=0 to undefine it */ 20 | #endif 21 | 22 | /* 23 | ** Allows manipulation of large files in gcc and some other compilers 24 | */ 25 | #if !defined(LUA_32BITS) && !defined(_FILE_OFFSET_BITS) 26 | #define _LARGEFILE_SOURCE 1 27 | #define _FILE_OFFSET_BITS 64 28 | #endif 29 | 30 | #endif /* } */ 31 | 32 | 33 | /* 34 | ** Windows stuff 35 | */ 36 | #if defined(_WIN32) /* { */ 37 | 38 | #if !defined(_CRT_SECURE_NO_WARNINGS) 39 | #define _CRT_SECURE_NO_WARNINGS /* avoid warnings about ISO C functions */ 40 | #endif 41 | 42 | #endif /* } */ 43 | 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /src/host/lua-5.3.0/src/lstring.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lstring.h,v 1.56 2014/07/18 14:46:47 roberto Exp $ 3 | ** String table (keep all strings handled by Lua) 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lstring_h 8 | #define lstring_h 9 | 10 | #include "lgc.h" 11 | #include "lobject.h" 12 | #include "lstate.h" 13 | 14 | 15 | #define sizelstring(l) (sizeof(union UTString) + ((l) + 1) * sizeof(char)) 16 | #define sizestring(s) sizelstring((s)->len) 17 | 18 | #define sizeludata(l) (sizeof(union UUdata) + (l)) 19 | #define sizeudata(u) sizeludata((u)->len) 20 | 21 | #define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ 22 | (sizeof(s)/sizeof(char))-1)) 23 | 24 | 25 | /* 26 | ** test whether a string is a reserved word 27 | */ 28 | #define isreserved(s) ((s)->tt == LUA_TSHRSTR && (s)->extra > 0) 29 | 30 | 31 | /* 32 | ** equality for short strings, which are always internalized 33 | */ 34 | #define eqshrstr(a,b) check_exp((a)->tt == LUA_TSHRSTR, (a) == (b)) 35 | 36 | 37 | LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed); 38 | LUAI_FUNC int luaS_eqlngstr (TString *a, TString *b); 39 | LUAI_FUNC void luaS_resize (lua_State *L, int newsize); 40 | LUAI_FUNC void luaS_remove (lua_State *L, TString *ts); 41 | LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s); 42 | LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); 43 | LUAI_FUNC TString *luaS_new (lua_State *L, const char *str); 44 | 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/host/lua-5.3.0/src/ltable.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltable.h,v 2.20 2014/09/04 18:15:29 roberto Exp $ 3 | ** Lua tables (hash) 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ltable_h 8 | #define ltable_h 9 | 10 | #include "lobject.h" 11 | 12 | 13 | #define gnode(t,i) (&(t)->node[i]) 14 | #define gval(n) (&(n)->i_val) 15 | #define gnext(n) ((n)->i_key.nk.next) 16 | 17 | 18 | /* 'const' to avoid wrong writings that can mess up field 'next' */ 19 | #define gkey(n) cast(const TValue*, (&(n)->i_key.tvk)) 20 | 21 | #define wgkey(n) (&(n)->i_key.nk) 22 | 23 | #define invalidateTMcache(t) ((t)->flags = 0) 24 | 25 | 26 | /* returns the key, given the value of a table entry */ 27 | #define keyfromval(v) \ 28 | (gkey(cast(Node *, cast(char *, (v)) - offsetof(Node, i_val)))) 29 | 30 | 31 | LUAI_FUNC const TValue *luaH_getint (Table *t, lua_Integer key); 32 | LUAI_FUNC void luaH_setint (lua_State *L, Table *t, lua_Integer key, 33 | TValue *value); 34 | LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key); 35 | LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key); 36 | LUAI_FUNC TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key); 37 | LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key); 38 | LUAI_FUNC Table *luaH_new (lua_State *L); 39 | LUAI_FUNC void luaH_resize (lua_State *L, Table *t, unsigned int nasize, 40 | unsigned int nhsize); 41 | LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, unsigned int nasize); 42 | LUAI_FUNC void luaH_free (lua_State *L, Table *t); 43 | LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key); 44 | LUAI_FUNC int luaH_getn (Table *t); 45 | 46 | 47 | #if defined(LUA_DEBUG) 48 | LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key); 49 | LUAI_FUNC int luaH_isdummy (Node *n); 50 | #endif 51 | 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /src/host/lua-5.3.0/src/ltm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltm.h,v 2.21 2014/10/25 11:50:46 roberto Exp $ 3 | ** Tag methods 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ltm_h 8 | #define ltm_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | /* 15 | * WARNING: if you change the order of this enumeration, 16 | * grep "ORDER TM" and "ORDER OP" 17 | */ 18 | typedef enum { 19 | TM_INDEX, 20 | TM_NEWINDEX, 21 | TM_GC, 22 | TM_MODE, 23 | TM_LEN, 24 | TM_EQ, /* last tag method with fast access */ 25 | TM_ADD, 26 | TM_SUB, 27 | TM_MUL, 28 | TM_MOD, 29 | TM_POW, 30 | TM_DIV, 31 | TM_IDIV, 32 | TM_BAND, 33 | TM_BOR, 34 | TM_BXOR, 35 | TM_SHL, 36 | TM_SHR, 37 | TM_UNM, 38 | TM_BNOT, 39 | TM_LT, 40 | TM_LE, 41 | TM_CONCAT, 42 | TM_CALL, 43 | TM_N /* number of elements in the enum */ 44 | } TMS; 45 | 46 | 47 | 48 | #define gfasttm(g,et,e) ((et) == NULL ? NULL : \ 49 | ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e])) 50 | 51 | #define fasttm(l,et,e) gfasttm(G(l), et, e) 52 | 53 | #define ttypename(x) luaT_typenames_[(x) + 1] 54 | #define objtypename(x) ttypename(ttnov(x)) 55 | 56 | LUAI_DDEC const char *const luaT_typenames_[LUA_TOTALTAGS]; 57 | 58 | 59 | LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename); 60 | LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, 61 | TMS event); 62 | LUAI_FUNC void luaT_init (lua_State *L); 63 | 64 | LUAI_FUNC void luaT_callTM (lua_State *L, const TValue *f, const TValue *p1, 65 | const TValue *p2, TValue *p3, int hasres); 66 | LUAI_FUNC int luaT_callbinTM (lua_State *L, const TValue *p1, const TValue *p2, 67 | StkId res, TMS event); 68 | LUAI_FUNC void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2, 69 | StkId res, TMS event); 70 | LUAI_FUNC int luaT_callorderTM (lua_State *L, const TValue *p1, 71 | const TValue *p2, TMS event); 72 | 73 | 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /src/host/lua-5.3.0/src/lua.hpp: -------------------------------------------------------------------------------- 1 | // lua.hpp 2 | // Lua header files for C++ 3 | // <> not supplied automatically because Lua also compiles as C++ 4 | 5 | extern "C" { 6 | #include "lua.h" 7 | #include "lualib.h" 8 | #include "lauxlib.h" 9 | } 10 | -------------------------------------------------------------------------------- /src/host/lua-5.3.0/src/lualib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lualib.h,v 1.44 2014/02/06 17:32:33 roberto Exp $ 3 | ** Lua standard libraries 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lualib_h 9 | #define lualib_h 10 | 11 | #include "lua.h" 12 | 13 | 14 | 15 | LUAMOD_API int (luaopen_base) (lua_State *L); 16 | 17 | #define LUA_COLIBNAME "coroutine" 18 | LUAMOD_API int (luaopen_coroutine) (lua_State *L); 19 | 20 | #define LUA_TABLIBNAME "table" 21 | LUAMOD_API int (luaopen_table) (lua_State *L); 22 | 23 | #define LUA_IOLIBNAME "io" 24 | LUAMOD_API int (luaopen_io) (lua_State *L); 25 | 26 | #define LUA_OSLIBNAME "os" 27 | LUAMOD_API int (luaopen_os) (lua_State *L); 28 | 29 | #define LUA_STRLIBNAME "string" 30 | LUAMOD_API int (luaopen_string) (lua_State *L); 31 | 32 | #define LUA_UTF8LIBNAME "utf8" 33 | LUAMOD_API int (luaopen_utf8) (lua_State *L); 34 | 35 | #define LUA_BITLIBNAME "bit32" 36 | LUAMOD_API int (luaopen_bit32) (lua_State *L); 37 | 38 | #define LUA_MATHLIBNAME "math" 39 | LUAMOD_API int (luaopen_math) (lua_State *L); 40 | 41 | #define LUA_DBLIBNAME "debug" 42 | LUAMOD_API int (luaopen_debug) (lua_State *L); 43 | 44 | #define LUA_LOADLIBNAME "package" 45 | LUAMOD_API int (luaopen_package) (lua_State *L); 46 | 47 | 48 | /* open all previous libraries */ 49 | LUALIB_API void (luaL_openlibs) (lua_State *L); 50 | 51 | 52 | 53 | #if !defined(lua_assert) 54 | #define lua_assert(x) ((void)0) 55 | #endif 56 | 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /src/host/lua-5.3.0/src/lundump.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lundump.h,v 1.44 2014/06/19 18:27:20 roberto Exp $ 3 | ** load precompiled Lua chunks 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lundump_h 8 | #define lundump_h 9 | 10 | #include "llimits.h" 11 | #include "lobject.h" 12 | #include "lzio.h" 13 | 14 | 15 | /* data to catch conversion errors */ 16 | #define LUAC_DATA "\x19\x93\r\n\x1a\n" 17 | 18 | #define LUAC_INT 0x5678 19 | #define LUAC_NUM cast_num(370.5) 20 | 21 | #define MYINT(s) (s[0]-'0') 22 | #define LUAC_VERSION (MYINT(LUA_VERSION_MAJOR)*16+MYINT(LUA_VERSION_MINOR)) 23 | #define LUAC_FORMAT 0 /* this is the official format */ 24 | 25 | /* load one chunk; from lundump.c */ 26 | LUAI_FUNC LClosure* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, 27 | const char* name); 28 | 29 | /* dump one chunk; from ldump.c */ 30 | LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, 31 | void* data, int strip); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/host/lua-5.3.0/src/lvm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lvm.h,v 2.34 2014/08/01 17:24:02 roberto Exp $ 3 | ** Lua virtual machine 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lvm_h 8 | #define lvm_h 9 | 10 | 11 | #include "ldo.h" 12 | #include "lobject.h" 13 | #include "ltm.h" 14 | 15 | 16 | #if !defined(LUA_NOCVTN2S) 17 | #define cvt2str(o) ttisnumber(o) 18 | #else 19 | #define cvt2str(o) 0 /* no conversion from numbers to strings */ 20 | #endif 21 | 22 | 23 | #if !defined(LUA_NOCVTS2N) 24 | #define cvt2num(o) ttisstring(o) 25 | #else 26 | #define cvt2num(o) 0 /* no conversion from strings to numbers */ 27 | #endif 28 | 29 | 30 | #define tonumber(o,n) \ 31 | (ttisfloat(o) ? (*(n) = fltvalue(o), 1) : luaV_tonumber_(o,n)) 32 | 33 | #define tointeger(o,i) \ 34 | (ttisinteger(o) ? (*(i) = ivalue(o), 1) : luaV_tointeger_(o,i)) 35 | 36 | #define intop(op,v1,v2) l_castU2S(l_castS2U(v1) op l_castS2U(v2)) 37 | 38 | #define luaV_rawequalobj(t1,t2) luaV_equalobj(NULL,t1,t2) 39 | 40 | 41 | LUAI_FUNC int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2); 42 | LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r); 43 | LUAI_FUNC int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r); 44 | LUAI_FUNC int luaV_tonumber_ (const TValue *obj, lua_Number *n); 45 | LUAI_FUNC int luaV_tointeger_ (const TValue *obj, lua_Integer *p); 46 | LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key, 47 | StkId val); 48 | LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key, 49 | StkId val); 50 | LUAI_FUNC void luaV_finishOp (lua_State *L); 51 | LUAI_FUNC void luaV_execute (lua_State *L); 52 | LUAI_FUNC void luaV_concat (lua_State *L, int total); 53 | LUAI_FUNC lua_Integer luaV_div (lua_State *L, lua_Integer x, lua_Integer y); 54 | LUAI_FUNC lua_Integer luaV_mod (lua_State *L, lua_Integer x, lua_Integer y); 55 | LUAI_FUNC lua_Integer luaV_shiftl (lua_Integer x, lua_Integer y); 56 | LUAI_FUNC void luaV_objlen (lua_State *L, StkId ra, const TValue *rb); 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /src/host/lua-5.3.0/src/lzio.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.c,v 1.36 2014/11/02 19:19:04 roberto Exp $ 3 | ** Buffered streams 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #define lzio_c 8 | #define LUA_CORE 9 | 10 | #include "lprefix.h" 11 | 12 | 13 | #include 14 | 15 | #include "lua.h" 16 | 17 | #include "llimits.h" 18 | #include "lmem.h" 19 | #include "lstate.h" 20 | #include "lzio.h" 21 | 22 | 23 | int luaZ_fill (ZIO *z) { 24 | size_t size; 25 | lua_State *L = z->L; 26 | const char *buff; 27 | lua_unlock(L); 28 | buff = z->reader(L, z->data, &size); 29 | lua_lock(L); 30 | if (buff == NULL || size == 0) 31 | return EOZ; 32 | z->n = size - 1; /* discount char being returned */ 33 | z->p = buff; 34 | return cast_uchar(*(z->p++)); 35 | } 36 | 37 | 38 | void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) { 39 | z->L = L; 40 | z->reader = reader; 41 | z->data = data; 42 | z->n = 0; 43 | z->p = NULL; 44 | } 45 | 46 | 47 | /* --------------------------------------------------------------- read --- */ 48 | size_t luaZ_read (ZIO *z, void *b, size_t n) { 49 | while (n) { 50 | size_t m; 51 | if (z->n == 0) { /* no bytes in buffer? */ 52 | if (luaZ_fill(z) == EOZ) /* try to read more */ 53 | return n; /* no more input; return number of missing bytes */ 54 | else { 55 | z->n++; /* luaZ_fill consumed first byte; put it back */ 56 | z->p--; 57 | } 58 | } 59 | m = (n <= z->n) ? n : z->n; /* min. between n and z->n */ 60 | memcpy(b, z->p, m); 61 | z->n -= m; 62 | z->p += m; 63 | b = (char *)b + m; 64 | n -= m; 65 | } 66 | return 0; 67 | } 68 | 69 | /* ------------------------------------------------------------------------ */ 70 | char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n) { 71 | if (n > buff->buffsize) { 72 | if (n < LUA_MINBUFFER) n = LUA_MINBUFFER; 73 | luaZ_resizebuffer(L, buff, n); 74 | } 75 | return buff->buffer; 76 | } 77 | 78 | 79 | -------------------------------------------------------------------------------- /src/host/lua-5.3.0/src/lzio.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.h,v 1.30 2014/12/19 17:26:14 roberto Exp $ 3 | ** Buffered streams 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lzio_h 9 | #define lzio_h 10 | 11 | #include "lua.h" 12 | 13 | #include "lmem.h" 14 | 15 | 16 | #define EOZ (-1) /* end of stream */ 17 | 18 | typedef struct Zio ZIO; 19 | 20 | #define zgetc(z) (((z)->n--)>0 ? cast_uchar(*(z)->p++) : luaZ_fill(z)) 21 | 22 | 23 | typedef struct Mbuffer { 24 | char *buffer; 25 | size_t n; 26 | size_t buffsize; 27 | } Mbuffer; 28 | 29 | #define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0) 30 | 31 | #define luaZ_buffer(buff) ((buff)->buffer) 32 | #define luaZ_sizebuffer(buff) ((buff)->buffsize) 33 | #define luaZ_bufflen(buff) ((buff)->n) 34 | 35 | #define luaZ_buffremove(buff,i) ((buff)->n -= (i)) 36 | #define luaZ_resetbuffer(buff) ((buff)->n = 0) 37 | 38 | 39 | #define luaZ_resizebuffer(L, buff, size) \ 40 | ((buff)->buffer = luaM_reallocvchar(L, (buff)->buffer, \ 41 | (buff)->buffsize, size), \ 42 | (buff)->buffsize = size) 43 | 44 | #define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0) 45 | 46 | 47 | LUAI_FUNC char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n); 48 | LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, 49 | void *data); 50 | LUAI_FUNC size_t luaZ_read (ZIO* z, void *b, size_t n); /* read next n bytes */ 51 | 52 | 53 | 54 | /* --------- Private Part ------------------ */ 55 | 56 | struct Zio { 57 | size_t n; /* bytes still unread */ 58 | const char *p; /* current position in buffer */ 59 | lua_Reader reader; /* reader function */ 60 | void *data; /* additional data */ 61 | lua_State *L; /* Lua state (for reader) */ 62 | }; 63 | 64 | 65 | LUAI_FUNC int luaZ_fill (ZIO *z); 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /src/host/os_chdir.c: -------------------------------------------------------------------------------- 1 | /** 2 | * \file os_chdir.c 3 | * \brief Change the current working directory. 4 | * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project 5 | */ 6 | 7 | #include "premake.h" 8 | 9 | 10 | int os_chdir(lua_State* L) 11 | { 12 | int z; 13 | const char* path = luaL_checkstring(L, 1); 14 | 15 | #if PLATFORM_WINDOWS 16 | z = SetCurrentDirectory(path); 17 | #else 18 | z = !chdir(path); 19 | #endif 20 | 21 | if (!z) 22 | { 23 | lua_pushnil(L); 24 | lua_pushfstring(L, "unable to switch to directory '%s'", path); 25 | return 2; 26 | } 27 | else 28 | { 29 | lua_pushboolean(L, 1); 30 | return 1; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/host/os_copyfile.c: -------------------------------------------------------------------------------- 1 | /** 2 | * \file os_copyfile.c 3 | * \brief Copy a file from one location to another. 4 | * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project 5 | */ 6 | 7 | #include 8 | #include "premake.h" 9 | 10 | int os_copyfile(lua_State* L) 11 | { 12 | int z; 13 | const char* src = luaL_checkstring(L, 1); 14 | const char* dst = luaL_checkstring(L, 2); 15 | 16 | #if PLATFORM_WINDOWS 17 | z = CopyFile(src, dst, FALSE); 18 | #else 19 | lua_pushfstring(L, "cp %s %s", src, dst); 20 | z = (system(lua_tostring(L, -1)) == 0); 21 | #endif 22 | 23 | if (!z) 24 | { 25 | lua_pushnil(L); 26 | lua_pushfstring(L, "unable to copy file to '%s'", dst); 27 | return 2; 28 | } 29 | else 30 | { 31 | lua_pushboolean(L, 1); 32 | return 1; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/host/os_getcwd.c: -------------------------------------------------------------------------------- 1 | /** 2 | * \file os_getcwd.c 3 | * \brief Retrieve the current working directory. 4 | * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project 5 | */ 6 | 7 | #include "premake.h" 8 | 9 | int os_getcwd(lua_State* L) 10 | { 11 | char buffer[0x4000]; 12 | char* ch; 13 | int result; 14 | 15 | #if PLATFORM_WINDOWS 16 | result = (GetCurrentDirectory(0x4000, buffer) != 0); 17 | #else 18 | result = (getcwd(buffer, 0x4000) != 0); 19 | #endif 20 | 21 | if (!result) 22 | return 0; 23 | 24 | /* convert to platform-neutral directory separators */ 25 | for (ch = buffer; *ch != '\0'; ++ch) 26 | { 27 | if (*ch == '\\') *ch = '/'; 28 | } 29 | 30 | lua_pushstring(L, buffer); 31 | return 1; 32 | } 33 | 34 | 35 | -------------------------------------------------------------------------------- /src/host/os_is64bit.c: -------------------------------------------------------------------------------- 1 | /** 2 | * \file os_is64bit.c 3 | * \brief Native code-side checking for a 64-bit architecture. 4 | * \author Copyright (c) 2011 Jason Perkins and the Premake project 5 | */ 6 | 7 | #include "premake.h" 8 | 9 | int os_is64bit(lua_State* L) 10 | { 11 | // If this code returns true, then the platform is 64-bit. If it 12 | // returns false, the platform might still be 64-bit, but more 13 | // checking will need to be done on the Lua side of things. 14 | #if PLATFORM_WINDOWS 15 | typedef BOOL (WINAPI* WowFuncSig)(HANDLE, PBOOL); 16 | WowFuncSig func = (WowFuncSig)GetProcAddress(GetModuleHandle(TEXT("kernel32")), "IsWow64Process"); 17 | if (func) 18 | { 19 | BOOL isWow = FALSE; 20 | if (func(GetCurrentProcess(), &isWow)) 21 | { 22 | lua_pushboolean(L, isWow); 23 | return 1; 24 | } 25 | } 26 | #endif 27 | 28 | lua_pushboolean(L, 0); 29 | return 1; 30 | } 31 | -------------------------------------------------------------------------------- /src/host/os_isdir.c: -------------------------------------------------------------------------------- 1 | /** 2 | * \file os_isdir.c 3 | * \brief Returns true if the specified directory exists. 4 | * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project 5 | */ 6 | 7 | #include 8 | #include 9 | #include "premake.h" 10 | 11 | 12 | int os_isdir(lua_State* L) 13 | { 14 | struct stat buf; 15 | const char* path = luaL_checkstring(L, 1); 16 | 17 | /* empty path is equivalent to ".", must be true */ 18 | if (strlen(path) == 0) 19 | { 20 | lua_pushboolean(L, 1); 21 | } 22 | else if (stat(path, &buf) == 0) 23 | { 24 | lua_pushboolean(L, buf.st_mode & S_IFDIR); 25 | } 26 | else 27 | { 28 | lua_pushboolean(L, 0); 29 | } 30 | 31 | return 1; 32 | } 33 | 34 | 35 | -------------------------------------------------------------------------------- /src/host/os_isfile.c: -------------------------------------------------------------------------------- 1 | /** 2 | * \file os_isfile.c 3 | * \brief Returns true if the given file exists on the file system. 4 | * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project 5 | */ 6 | 7 | #include 8 | #include "premake.h" 9 | 10 | 11 | int os_isfile(lua_State* L) 12 | { 13 | const char* filename = luaL_checkstring(L, 1); 14 | lua_pushboolean(L, do_isfile(filename)); 15 | return 1; 16 | } 17 | 18 | 19 | int do_isfile(const char* filename) 20 | { 21 | struct stat buf; 22 | if (stat(filename, &buf) == 0) 23 | { 24 | return ((buf.st_mode & S_IFDIR) == 0); 25 | } 26 | else 27 | { 28 | return 0; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/host/os_mkdir.c: -------------------------------------------------------------------------------- 1 | /** 2 | * \file os_mkdir.c 3 | * \brief Create a subdirectory. 4 | * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project 5 | */ 6 | 7 | #include 8 | #include "premake.h" 9 | 10 | 11 | int os_mkdir(lua_State* L) 12 | { 13 | int z; 14 | const char* path = luaL_checkstring(L, 1); 15 | 16 | #if PLATFORM_WINDOWS 17 | z = CreateDirectory(path, NULL); 18 | #else 19 | z = (mkdir(path, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) == 0); 20 | #endif 21 | 22 | if (!z) 23 | { 24 | lua_pushnil(L); 25 | lua_pushfstring(L, "unable to create directory '%s'", path); 26 | return 2; 27 | } 28 | else 29 | { 30 | lua_pushboolean(L, 1); 31 | return 1; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/host/os_pathsearch.c: -------------------------------------------------------------------------------- 1 | /** 2 | * \file os_pathsearch.c 3 | * \brief Locates a file, given a set of search paths. 4 | * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project 5 | * 6 | * \note This function is required by the bootstrapping code; it must be 7 | * implemented here in the host and not scripted. 8 | */ 9 | 10 | #include 11 | #include "premake.h" 12 | 13 | 14 | int os_pathsearch(lua_State* L) 15 | { 16 | int i; 17 | for (i = 2; i <= lua_gettop(L); ++i) 18 | { 19 | const char* path; 20 | 21 | if (lua_isnil(L, i)) 22 | continue; 23 | 24 | path = luaL_checkstring(L, i); 25 | do 26 | { 27 | const char* split; 28 | 29 | /* look for the closest path separator ; or : */ 30 | /* can't use : on windows because it breaks on C:\path */ 31 | const char* semi = strchr(path, ';'); 32 | #if !defined(PLATFORM_WINDOWS) && !defined(PLATFORM_OS2) 33 | const char* full = strchr(path, ':'); 34 | #else 35 | const char* full = NULL; 36 | #endif 37 | 38 | if (!semi) 39 | { 40 | split = full; 41 | } 42 | else if (!full) 43 | { 44 | split = semi; 45 | } 46 | else 47 | { 48 | split = (semi < full) ? semi : full; 49 | } 50 | 51 | /* push this piece of the full search string onto the stack */ 52 | if (split) 53 | { 54 | lua_pushlstring(L, path, split - path); 55 | } 56 | else 57 | { 58 | lua_pushstring(L, path); 59 | } 60 | 61 | /* keep an extra copy around, so I can return it if I have a match */ 62 | lua_pushvalue(L, -1); 63 | 64 | /* append the filename to make the full test path */ 65 | lua_pushstring(L, "/"); 66 | lua_pushvalue(L, 1); 67 | lua_concat(L, 3); 68 | 69 | /* test it - if it exists return the path */ 70 | if (do_isfile(lua_tostring(L, -1))) 71 | { 72 | lua_pop(L, 1); 73 | return 1; 74 | } 75 | 76 | /* no match, set up the next try */ 77 | lua_pop(L, 2); 78 | path = (split) ? split + 1 : NULL; 79 | } 80 | while (path); 81 | } 82 | 83 | return 0; 84 | } 85 | -------------------------------------------------------------------------------- /src/host/os_rmdir.c: -------------------------------------------------------------------------------- 1 | /** 2 | * \file os_rmdir.c 3 | * \brief Remove a subdirectory. 4 | * \author Copyright (c) 2002-2013 Jason Perkins and the Premake project 5 | */ 6 | 7 | #include 8 | #include "premake.h" 9 | 10 | 11 | int os_rmdir(lua_State* L) 12 | { 13 | int z; 14 | const char* path = luaL_checkstring(L, 1); 15 | 16 | #if PLATFORM_WINDOWS 17 | z = RemoveDirectory(path); 18 | #else 19 | z = (0 == rmdir(path)); 20 | #endif 21 | 22 | if (!z) 23 | { 24 | lua_pushnil(L); 25 | lua_pushfstring(L, "unable to remove directory '%s'", path); 26 | return 2; 27 | } 28 | else 29 | { 30 | lua_pushboolean(L, 1); 31 | return 1; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/host/os_stat.c: -------------------------------------------------------------------------------- 1 | /** 2 | * \file os_stat.c 3 | * \brief Retrieve information about a file. 4 | * \author Copyright (c) 2011 Jason Perkins and the Premake project 5 | */ 6 | 7 | #include "premake.h" 8 | #include 9 | #include 10 | 11 | int os_stat(lua_State* L) 12 | { 13 | struct stat s; 14 | 15 | const char* filename = luaL_checkstring(L, 1); 16 | if (stat(filename, &s) != 0) 17 | { 18 | lua_pushnil(L); 19 | switch (errno) 20 | { 21 | case EACCES: 22 | lua_pushfstring(L, "'%s' could not be accessed", filename); 23 | break; 24 | case ENOENT: 25 | lua_pushfstring(L, "'%s' was not found", filename); 26 | break; 27 | default: 28 | lua_pushfstring(L, "An unknown error %d occured while accessing '%s'", errno, filename); 29 | break; 30 | } 31 | return 2; 32 | } 33 | 34 | 35 | lua_newtable(L); 36 | 37 | lua_pushstring(L, "mtime"); 38 | lua_pushinteger(L, (lua_Integer)s.st_mtime); 39 | lua_settable(L, -3); 40 | 41 | lua_pushstring(L, "size"); 42 | lua_pushnumber(L, s.st_size); 43 | lua_settable(L, -3); 44 | 45 | return 1; 46 | } 47 | -------------------------------------------------------------------------------- /src/host/os_ticks.c: -------------------------------------------------------------------------------- 1 | /** 2 | * \file os_ticks.c 3 | * \brief Return the system tick counter (in microsecond units). 4 | */ 5 | 6 | #include 7 | #include "premake.h" 8 | 9 | // Epochs used by Windows and Unix time APIs. These adjustments, 10 | // when added to the time value returned by the OS, will yield 11 | // the number of microsecond intervals since Jan 1, year 1. 12 | #define TICK_EPOCH_WINDOWS ((lua_Integer)0x0701ce1722770000) 13 | #define TICK_EPOCH_UNIX ((lua_Integer)0x00dcbffeff2bc000) 14 | 15 | #define TICKS_PER_SECOND ((lua_Integer)1000000) 16 | 17 | int os_ticks(lua_State* L) 18 | { 19 | lua_Integer ticks = 0; 20 | 21 | #if PLATFORM_WINDOWS 22 | FILETIME fileTimeUtc; 23 | GetSystemTimeAsFileTime(&fileTimeUtc); 24 | ticks = 25 | TICK_EPOCH_WINDOWS 26 | + ((lua_Integer)fileTimeUtc.dwHighDateTime << 32 27 | | (lua_Integer)fileTimeUtc.dwLowDateTime); 28 | ticks /= (lua_Integer)10; 29 | #else 30 | struct timeval tp; 31 | if (gettimeofday(&tp, NULL) == 0) { 32 | ticks = 33 | TICK_EPOCH_UNIX 34 | + (lua_Integer)tp.tv_sec * TICKS_PER_SECOND 35 | + (lua_Integer)tp.tv_usec; 36 | } 37 | #endif 38 | 39 | lua_pushinteger(L, ticks); 40 | return 1; 41 | } 42 | -------------------------------------------------------------------------------- /src/host/os_uuid.c: -------------------------------------------------------------------------------- 1 | /** 2 | * \file os_uuid.c 3 | * \brief Create a new UUID. 4 | * \author Copyright (c) 2002-2012 Jason Perkins and the Premake project 5 | */ 6 | 7 | #include "premake.h" 8 | 9 | #if PLATFORM_WINDOWS 10 | #include 11 | #endif 12 | 13 | 14 | /* 15 | * Pull off the four lowest bytes of a value and add them to my array, 16 | * without the help of the determinately sized C99 data types that 17 | * are not yet universally supported. 18 | */ 19 | static void add(unsigned char* bytes, int offset, unsigned long value) 20 | { 21 | int i; 22 | for (i = 0; i < 4; ++i) 23 | { 24 | bytes[offset++] = (unsigned char)(value & 0xff); 25 | value >>= 8; 26 | } 27 | } 28 | 29 | 30 | int os_uuid(lua_State* L) 31 | { 32 | char uuid[38]; 33 | unsigned char bytes[16]; 34 | 35 | /* If a name argument is supplied, build the UUID from that. For speed we 36 | * are using a simple DBJ2 hashing function; if this isn't sufficient we 37 | * can switch to a full RFC 4122 §4.3 implementation later. */ 38 | const char* name = luaL_optstring(L, 1, NULL); 39 | if (name != NULL) 40 | { 41 | add(bytes, 0, do_hash(name, 0)); 42 | add(bytes, 4, do_hash(name, 'L')); 43 | add(bytes, 8, do_hash(name, 'u')); 44 | add(bytes, 12, do_hash(name, 'a')); 45 | } 46 | 47 | /* If no name is supplied, try to build one properly */ 48 | else 49 | { 50 | #if PLATFORM_WINDOWS 51 | CoCreateGuid((GUID*)bytes); 52 | #elif PLATFORM_OS2 53 | int i; 54 | for (i = 0; i < 16; i++) 55 | bytes[i] = (unsigned char)gethrtime(); 56 | #else 57 | int result; 58 | 59 | /* not sure how to get a UUID here, so I fake it */ 60 | FILE* rnd = fopen("/dev/urandom", "rb"); 61 | result = fread(bytes, 16, 1, rnd); 62 | fclose(rnd); 63 | if (!result) 64 | { 65 | return 0; 66 | } 67 | #endif 68 | } 69 | 70 | sprintf(uuid, "%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X", 71 | bytes[0], bytes[1], bytes[2], bytes[3], 72 | bytes[4], bytes[5], 73 | bytes[6], bytes[7], 74 | bytes[8], bytes[9], 75 | bytes[10], bytes[11], bytes[12], bytes[13], bytes[14], bytes[15]); 76 | 77 | lua_pushstring(L, uuid); 78 | return 1; 79 | } 80 | -------------------------------------------------------------------------------- /src/host/path_getabsolute.c: -------------------------------------------------------------------------------- 1 | /** 2 | * \file path_getabsolute.c 3 | * \brief Calculate the absolute path from a relative path 4 | */ 5 | 6 | #include "premake.h" 7 | 8 | int path_getabsolute(lua_State *L) 9 | { 10 | const char *path = luaL_checkstring(L, -1); 11 | char buffer[PATH_BUFSIZE]; 12 | get_absolute_path(path, buffer, PATH_BUFSIZE); 13 | lua_pushstring(L, buffer); 14 | return 1; 15 | } 16 | -------------------------------------------------------------------------------- /src/host/path_getrelative.c: -------------------------------------------------------------------------------- 1 | /** 2 | * \file path_getrelative.c 3 | * \brief Calculate the relative path from src to dest 4 | */ 5 | 6 | #include "premake.h" 7 | 8 | int path_getrelative(lua_State *L) 9 | { 10 | const char *src = luaL_checkstring(L, -2); 11 | const char *dst = luaL_checkstring(L, -1); 12 | char buffer[PATH_BUFSIZE]; 13 | get_relative_path(src, dst, buffer, PATH_BUFSIZE); 14 | lua_pushstring(L, buffer); 15 | return 1; 16 | } 17 | -------------------------------------------------------------------------------- /src/host/path_isabsolute.c: -------------------------------------------------------------------------------- 1 | /** 2 | * \file path_isabsolute.c 3 | * \brief Determines if a path is absolute or relative. 4 | * \author Copyright (c) 2002-2009 Jason Perkins and the Premake project 5 | */ 6 | 7 | #include "premake.h" 8 | 9 | int path_isabsolute(lua_State* L) 10 | { 11 | const char* path = luaL_checkstring(L, -1); 12 | if (is_absolute_path(path)) { 13 | lua_pushboolean(L, 1); 14 | return 1; 15 | } 16 | 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /src/host/premake.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file premake.h 3 | * \brief Program-wide constants and definitions. 4 | * \author Copyright (c) 2002-2011 Jason Perkins and the Premake project 5 | */ 6 | 7 | #define lua_c 8 | #include "lua.h" 9 | #include "lauxlib.h" 10 | #include "lualib.h" 11 | 12 | 13 | /* Identify the current platform I'm not sure how to reliably detect 14 | * Windows but since it is the most common I use it as the default */ 15 | #if defined(__linux__) || defined(__GNU__) 16 | #define PLATFORM_LINUX (1) 17 | #define PLATFORM_STRING "linux" 18 | #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) 19 | #define PLATFORM_BSD (1) 20 | #define PLATFORM_STRING "bsd" 21 | #elif defined(__sun__) || defined(__svr4__) 22 | #define PLATFORM_SOLARIS (1) 23 | #define PLATFORM_STRING "solaris" 24 | #elif defined(__APPLE__) && defined(__MACH__) 25 | #define PLATFORM_MACOSX (1) 26 | #define PLATFORM_STRING "macosx" 27 | #elif defined(__OS2__) 28 | #define PLATFORM_OS2 (1) 29 | #define PLATFORM_STRING "os2" 30 | #else 31 | #define PLATFORM_WINDOWS (1) 32 | #define PLATFORM_STRING "windows" 33 | #endif 34 | 35 | 36 | /* Pull in platform-specific headers required by built-in functions */ 37 | #if PLATFORM_WINDOWS 38 | #define WIN32_LEAN_AND_MEAN 39 | #include 40 | #else 41 | #include 42 | #include 43 | #endif 44 | 45 | 46 | /* A success return code */ 47 | #define OKAY (0) 48 | 49 | 50 | /* Bootstrapping helper functions */ 51 | unsigned long do_hash(const char* str, int seed); 52 | int do_isfile(const char* filename); 53 | 54 | 55 | /* Path helper functions */ 56 | #define PATH_BUFSIZE 0x4000 57 | int is_absolute_path(const char * path); 58 | char *get_relative_path(const char src[], const char dst[], char *buffer, int bufsize); 59 | char *get_absolute_path(const char path[], char *buffer, int bufsize); 60 | 61 | 62 | /* Built-in functions */ 63 | int path_isabsolute(lua_State* L); 64 | int path_getabsolute(lua_State *L); 65 | int path_getrelative(lua_State *L); 66 | int os_chdir(lua_State* L); 67 | int os_copyfile(lua_State* L); 68 | int os_getcwd(lua_State* L); 69 | int os_getversion(lua_State* L); 70 | int os_is64bit(lua_State* L); 71 | int os_isdir(lua_State* L); 72 | int os_isfile(lua_State* L); 73 | int os_matchdone(lua_State* L); 74 | int os_matchisfile(lua_State* L); 75 | int os_matchname(lua_State* L); 76 | int os_matchnext(lua_State* L); 77 | int os_matchstart(lua_State* L); 78 | int os_mkdir(lua_State* L); 79 | int os_pathsearch(lua_State* L); 80 | int os_rmdir(lua_State* L); 81 | int os_stat(lua_State* L); 82 | int os_ticks(lua_State* L); 83 | int os_uuid(lua_State* L); 84 | int string_endswith(lua_State* L); 85 | 86 | 87 | /* Engine interface */ 88 | int premake_init(lua_State* L); 89 | int premake_locate(lua_State* L, const char* argv0); 90 | int premake_execute(lua_State* L, int argc, const char** argv); 91 | 92 | -------------------------------------------------------------------------------- /src/host/premake_main.c: -------------------------------------------------------------------------------- 1 | /** 2 | * \file premake_main.c 3 | * \brief Program entry point. 4 | * \author Copyright (c) 2002-2012 Jason Perkins and the Premake project 5 | */ 6 | 7 | #include "premake.h" 8 | 9 | int main(int argc, const char** argv) 10 | { 11 | lua_State* L; 12 | int z = OKAY; 13 | 14 | L = luaL_newstate(); 15 | luaL_openlibs(L); 16 | z = premake_init(L); 17 | 18 | /* push the location of the Premake executable */ 19 | premake_locate(L, argv[0]); 20 | lua_setglobal(L, "_PREMAKE_COMMAND"); 21 | 22 | if (z == OKAY) 23 | { 24 | z = premake_execute(L, argc, argv); 25 | } 26 | 27 | lua_close(L); 28 | return z; 29 | } 30 | -------------------------------------------------------------------------------- /src/host/string_endswith.c: -------------------------------------------------------------------------------- 1 | /** 2 | * \file string_endswith.c 3 | * \brief Determines if a string ends with the given sequence. 4 | * \author Copyright (c) 2002-2009 Jason Perkins and the Premake project 5 | */ 6 | 7 | #include "premake.h" 8 | #include 9 | 10 | 11 | int string_endswith(lua_State* L) 12 | { 13 | const char* haystack = luaL_optstring(L, 1, NULL); 14 | const char* needle = luaL_optstring(L, 2, NULL); 15 | 16 | if (haystack && needle) 17 | { 18 | int hlen = (int)strlen(haystack); 19 | int nlen = (int)strlen(needle); 20 | if (hlen >= nlen) 21 | { 22 | lua_pushboolean(L, strcmp(haystack + hlen - nlen, needle) == 0); 23 | return 1; 24 | } 25 | } 26 | 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /src/host/string_hash.c: -------------------------------------------------------------------------------- 1 | /** 2 | * \file string_hash.c 3 | * \brief Computes a hash value for a string. 4 | * \author Copyright (c) 2012 Jason Perkins and the Premake project 5 | */ 6 | 7 | #include "premake.h" 8 | #include 9 | 10 | 11 | int string_hash(lua_State* L) 12 | { 13 | const char* str = luaL_checkstring(L, 1); 14 | lua_pushnumber(L, (lua_Number)do_hash(str, 0)); 15 | return 1; 16 | } 17 | 18 | 19 | unsigned long do_hash(const char* str, int seed) 20 | { 21 | /* DJB2 hashing; see http://www.cse.yorku.ca/~oz/hash.html */ 22 | 23 | unsigned long hash = 5381; 24 | 25 | if (seed != 0) { 26 | hash = hash * 33 + seed; 27 | } 28 | 29 | while (*str) { 30 | hash = hash * 33 + (*str); 31 | str++; 32 | } 33 | 34 | return hash; 35 | } 36 | -------------------------------------------------------------------------------- /src/host/version.h: -------------------------------------------------------------------------------- 1 | #define VERSION 1181 2 | #define VERSION_STR "version 1181 (commit 29e6832fdf3b106c0906d288c8ced6c0761b8985)" 3 | -------------------------------------------------------------------------------- /src/tools/dotnet.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- dotnet.lua 3 | -- Interface for the C# compilers, all of which are flag compatible. 4 | -- Copyright (c) 2002-2009 Jason Perkins and the Premake project 5 | -- 6 | 7 | 8 | premake.dotnet = { } 9 | premake.dotnet.namestyle = "windows" 10 | 11 | 12 | -- 13 | -- Translation of Premake flags into CSC flags 14 | -- 15 | 16 | local flags = 17 | { 18 | FatalWarning = "/warnaserror", 19 | Optimize = "/optimize", 20 | OptimizeSize = "/optimize", 21 | OptimizeSpeed = "/optimize", 22 | Symbols = "/debug", 23 | Unsafe = "/unsafe" 24 | } 25 | 26 | 27 | -- 28 | -- Return the default build action for a given file, based on the file extension. 29 | -- 30 | 31 | function premake.dotnet.getbuildaction(fcfg) 32 | local ext = path.getextension(fcfg.name):lower() 33 | if fcfg.buildaction == "Compile" or ext == ".cs" then 34 | return "Compile" 35 | elseif fcfg.buildaction == "Embed" or ext == ".resx" then 36 | return "EmbeddedResource" 37 | elseif fcfg.buildaction == "Copy" or ext == ".asax" or ext == ".aspx" then 38 | return "Content" 39 | else 40 | return "None" 41 | end 42 | end 43 | 44 | 45 | 46 | -- 47 | -- Returns the compiler filename (they all use the same arguments) 48 | -- 49 | 50 | function premake.dotnet.getcompilervar(cfg) 51 | if (_OPTIONS.dotnet == "msnet") then 52 | return "csc" 53 | elseif (_OPTIONS.dotnet == "mono") then 54 | return "mcs" 55 | else 56 | return "cscc" 57 | end 58 | end 59 | 60 | 61 | 62 | -- 63 | -- Returns a list of compiler flags, based on the supplied configuration. 64 | -- 65 | 66 | function premake.dotnet.getflags(cfg) 67 | local result = table.translate(cfg.flags, flags) 68 | return result 69 | end 70 | 71 | 72 | 73 | -- 74 | -- Translates the Premake kind into the CSC kind string. 75 | -- 76 | 77 | function premake.dotnet.getkind(cfg) 78 | if (cfg.kind == "ConsoleApp") then 79 | return "Exe" 80 | elseif (cfg.kind == "WindowedApp") then 81 | return "WinExe" 82 | elseif (cfg.kind == "SharedLib") then 83 | return "Library" 84 | end 85 | end 86 | -------------------------------------------------------------------------------- /src/tools/msc.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- msc.lua 3 | -- Interface for the MS C/C++ compiler. 4 | -- Copyright (c) 2009 Jason Perkins and the Premake project 5 | -- 6 | 7 | 8 | premake.msc = { } 9 | premake.msc.namestyle = "windows" 10 | -------------------------------------------------------------------------------- /src/tools/ow.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- ow.lua 3 | -- Provides Open Watcom-specific configuration strings. 4 | -- Copyright (c) 2008 Jason Perkins and the Premake project 5 | -- 6 | 7 | premake.ow = { } 8 | premake.ow.namestyle = "windows" 9 | 10 | 11 | -- 12 | -- Set default tools 13 | -- 14 | 15 | premake.ow.cc = "WCL386" 16 | premake.ow.cxx = "WCL386" 17 | premake.ow.ar = "ar" 18 | 19 | 20 | -- 21 | -- Translation of Premake flags into OpenWatcom flags 22 | -- 23 | 24 | local cflags = 25 | { 26 | PedanticWarnings = "-wx", 27 | ExtraWarnings = "-wx", 28 | FatalWarning = "-we", 29 | FloatFast = "-omn", 30 | FloatStrict = "-op", 31 | Optimize = "-ox", 32 | OptimizeSize = "-os", 33 | OptimizeSpeed = "-ot", 34 | Symbols = "-d2", 35 | } 36 | 37 | local cxxflags = 38 | { 39 | NoExceptions = "-xd", 40 | NoRTTI = "-xr", 41 | } 42 | 43 | 44 | 45 | -- 46 | -- No specific platform support yet 47 | -- 48 | 49 | premake.ow.platforms = 50 | { 51 | Native = { 52 | flags = "" 53 | }, 54 | } 55 | 56 | 57 | 58 | -- 59 | -- Returns a list of compiler flags, based on the supplied configuration. 60 | -- 61 | 62 | function premake.ow.getcppflags(cfg) 63 | return {} 64 | end 65 | 66 | function premake.ow.getcflags(cfg) 67 | local result = table.translate(cfg.flags, cflags) 68 | if (cfg.flags.Symbols) then 69 | table.insert(result, "-hw") -- Watcom debug format for Watcom debugger 70 | end 71 | return result 72 | end 73 | 74 | function premake.ow.getcxxflags(cfg) 75 | local result = table.translate(cfg.flags, cxxflags) 76 | return result 77 | end 78 | 79 | 80 | 81 | -- 82 | -- Returns a list of linker flags, based on the supplied configuration. 83 | -- 84 | 85 | function premake.ow.getldflags(cfg) 86 | local result = { } 87 | 88 | if (cfg.flags.Symbols) then 89 | table.insert(result, "op symf") 90 | end 91 | 92 | return result 93 | end 94 | 95 | 96 | -- 97 | -- Returns a list of project-relative paths to external library files. 98 | -- This function should examine the linker flags and return any that seem to be 99 | -- a real path to a library file (e.g. "path/to/a/library.a", but not "GL"). 100 | -- Useful for adding to targets to trigger a relink when an external static 101 | -- library gets updated. 102 | -- Not currently supported on this toolchain. 103 | -- 104 | function premake.ow.getlibfiles(cfg) 105 | local result = {} 106 | return result 107 | end 108 | 109 | -- 110 | -- Returns a list of linker flags for library search directories and 111 | -- library names. 112 | -- 113 | 114 | function premake.ow.getlinkflags(cfg) 115 | local result = { } 116 | return result 117 | end 118 | 119 | 120 | 121 | -- 122 | -- Decorate defines for the command line. 123 | -- 124 | 125 | function premake.ow.getdefines(defines) 126 | local result = { } 127 | for _,def in ipairs(defines) do 128 | table.insert(result, '-D' .. def) 129 | end 130 | return result 131 | end 132 | 133 | 134 | 135 | -- 136 | -- Decorate include file search paths for the command line. 137 | -- 138 | 139 | function premake.ow.getincludedirs(includedirs) 140 | local result = { } 141 | for _,dir in ipairs(includedirs) do 142 | table.insert(result, '-I "' .. dir .. '"') 143 | end 144 | return result 145 | end 146 | 147 | -------------------------------------------------------------------------------- /tests/actions/make/test_make_escaping.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- tests/actions/make/test_make_escaping.lua 3 | -- Validate the escaping of literal values in Makefiles. 4 | -- Copyright (c) 2010 Jason Perkins and the Premake project 5 | -- 6 | 7 | T.make_escaping = { } 8 | local suite = T.make_escaping 9 | 10 | 11 | function suite.Escapes_Spaces() 12 | test.isequal("Program\\ Files", _MAKE.esc("Program Files")) 13 | end 14 | 15 | function suite.Escapes_Backslashes() 16 | test.isequal("Program\\\\Files", _MAKE.esc("Program\\Files")) 17 | end 18 | 19 | function suite.Escapes_Parens() 20 | test.isequal("Debug\\(x86\\)", _MAKE.esc("Debug(x86)")) 21 | end 22 | 23 | function suite.DoesNotEscape_ShellReplacements() 24 | test.isequal("-L$(NVSDKCUDA_ROOT)/C/lib", _MAKE.esc("-L$(NVSDKCUDA_ROOT)/C/lib")) 25 | end 26 | 27 | function suite.CanEscape_ShellReplacementCapturesShortest() 28 | test.isequal("a\\(x\\)b$(ROOT)c\\(y\\)d", _MAKE.esc("a(x)b$(ROOT)c(y)d")) 29 | end 30 | 31 | -------------------------------------------------------------------------------- /tests/actions/make/test_make_linking.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- tests/actions/make/test_make_linking.lua 3 | -- Validate library references in makefiles. 4 | -- Copyright (c) 2010-2013 Jason Perkins and the Premake project 5 | -- 6 | 7 | T.gcc_linking = {} 8 | local suite = T.gcc_linking 9 | local cpp = premake.make.cpp 10 | 11 | -- 12 | -- Setup 13 | -- 14 | 15 | local sln, prj 16 | 17 | function suite.setup() 18 | _OS = "linux" 19 | sln, prj = test.createsolution() 20 | end 21 | 22 | local function prepare() 23 | premake.bake.buildconfigs() 24 | cfg = premake.getconfig(prj, "Debug") 25 | cpp.linker(cfg, premake.gcc) 26 | end 27 | 28 | 29 | -- 30 | -- Check linking to a shared library sibling project. In order to support 31 | -- custom target prefixes and extensions, use the full, relative path 32 | -- to the library. 33 | -- 34 | 35 | function suite.onSharedLibrarySibling() 36 | links { "MyProject2" } 37 | test.createproject(sln) 38 | kind "SharedLib" 39 | targetdir "libs" 40 | prepare() 41 | test.capture [[ 42 | ALL_LDFLAGS += $(LDFLAGS) -Llibs -s 43 | LDDEPS += libs/libMyProject2.so 44 | LIBS += $(LDDEPS) 45 | ]] 46 | end 47 | 48 | 49 | -- 50 | -- Check linking to a static library sibling project. As with shared 51 | -- libraries, it should list out the full relative path. 52 | -- 53 | 54 | function suite.onStaticLibrarySibling() 55 | links { "MyProject2" } 56 | test.createproject(sln) 57 | kind "StaticLib" 58 | targetdir "libs" 59 | prepare() 60 | test.capture [[ 61 | ALL_LDFLAGS += $(LDFLAGS) -Llibs -s 62 | LDDEPS += libs/libMyProject2.a 63 | LIBS += $(LDDEPS) 64 | ]] 65 | end 66 | 67 | 68 | -- 69 | -- If an executable is listed in the links, no linking should happen (a 70 | -- build dependency would have been created at the solution level) 71 | -- 72 | 73 | function suite.onConsoleAppSibling() 74 | links { "MyProject2" } 75 | test.createproject(sln) 76 | kind "ConsoleApp" 77 | targetdir "libs" 78 | prepare() 79 | test.capture [[ 80 | ALL_LDFLAGS += $(LDFLAGS) -s 81 | LDDEPS += 82 | LIBS += $(LDDEPS) 83 | ]] 84 | end 85 | 86 | 87 | -- 88 | -- Make sure that project locations are taken into account when building 89 | -- the path to the library. 90 | -- 91 | 92 | 93 | function suite.onProjectLocations() 94 | location "MyProject" 95 | links { "MyProject2" } 96 | 97 | test.createproject(sln) 98 | kind "SharedLib" 99 | location "MyProject2" 100 | targetdir "MyProject2" 101 | 102 | prepare() 103 | test.capture [[ 104 | ALL_LDFLAGS += $(LDFLAGS) -L../MyProject2 -s 105 | LDDEPS += ../MyProject2/libMyProject2.so 106 | LIBS += $(LDDEPS) 107 | ]] 108 | end 109 | 110 | 111 | -- 112 | -- When referencing an external library via a path, the directory 113 | -- should be added to the library search paths, and the library 114 | -- itself included via an -l flag. 115 | -- 116 | 117 | function suite.onExternalLibraryWithPath() 118 | location "MyProject" 119 | links { "libs/SomeLib" } 120 | prepare() 121 | test.capture [[ 122 | ALL_LDFLAGS += $(LDFLAGS) -L../libs -s 123 | LDDEPS += 124 | LIBS += $(LDDEPS) -lSomeLib 125 | ]] 126 | end 127 | -------------------------------------------------------------------------------- /tests/actions/make/test_make_pch.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- tests/actions/make/test_make_pch.lua 3 | -- Validate the setup for precompiled headers in makefiles. 4 | -- Copyright (c) 2010 Jason Perkins and the Premake project 5 | -- 6 | 7 | T.make_pch = { } 8 | local suite = T.make_pch 9 | local _ = premake.make.cpp 10 | 11 | 12 | -- 13 | -- Setup and teardown 14 | -- 15 | 16 | local sln, prj, cfg 17 | function suite.setup() 18 | sln, prj = test.createsolution() 19 | end 20 | 21 | local function prepare() 22 | premake.bake.buildconfigs() 23 | prj = premake.getconfig(prj) 24 | cfg = premake.getconfig(prj, "Debug") 25 | end 26 | 27 | 28 | -- 29 | -- Configuration block tests 30 | -- 31 | 32 | function suite.NoConfig_OnNoHeaderSet() 33 | prepare() 34 | _.pchconfig(cfg) 35 | test.capture [[]] 36 | end 37 | 38 | 39 | function suite.NoConfig_OnHeaderAndNoPCHFlag() 40 | pchheader "include/myproject.h" 41 | flags { NoPCH } 42 | prepare() 43 | _.pchconfig(cfg) 44 | test.capture [[]] 45 | end 46 | 47 | 48 | function suite.ConfigBlock_OnPchEnabled() 49 | pchheader "include/myproject.h" 50 | prepare() 51 | _.pchconfig(cfg) 52 | test.capture [[ 53 | PCH = include/myproject.h 54 | GCH = $(OBJDIR)/$(notdir $(PCH)).gch 55 | ]] 56 | end 57 | 58 | 59 | -- 60 | -- Build rule tests 61 | -- 62 | 63 | function suite.BuildRules_OnCpp() 64 | pchheader "include/myproject.h" 65 | prepare() 66 | _.pchrules(prj) 67 | test.capture [[ 68 | ifneq (,$(PCH)) 69 | $(GCH): $(PCH) 70 | @echo $(notdir $<) 71 | $(SILENT) $(CXX) -x c++-header $(ALL_CXXFLAGS) -MMD -MP $(DEFINES) $(INCLUDES) -o "$@" -MF "$(@:%.gch=%.d)" -c "$<" 72 | ]] 73 | end 74 | 75 | function suite.BuildRules_OnC() 76 | language "C" 77 | pchheader "include/myproject.h" 78 | prepare() 79 | _.pchrules(prj) 80 | test.capture [[ 81 | ifneq (,$(PCH)) 82 | $(GCH): $(PCH) 83 | @echo $(notdir $<) 84 | $(SILENT) $(CC) -x c-header $(ALL_CFLAGS) -MMD -MP $(DEFINES) $(INCLUDES) -o "$@" -MF "$(@:%.gch=%.d)" -c "$<" 85 | ]] 86 | end 87 | 88 | 89 | -- 90 | -- Ensure that PCH is included on all files that use it. 91 | -- 92 | 93 | function suite.includesPCH_onUse() 94 | pchheader "include/myproject.h" 95 | files { "main.cpp" } 96 | prepare() 97 | _.fileRules(prj) 98 | test.capture [[ 99 | $(OBJDIR)/main.o: main.cpp 100 | @echo $(notdir $<) 101 | $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF $(@:%.o=%.d) -c "$<" 102 | ]] 103 | end 104 | 105 | 106 | -- 107 | -- If the header is located on one of the include file 108 | -- search directories, it should get found automatically. 109 | -- 110 | 111 | function suite.findsPCH_onIncludeDirs() 112 | location "MyProject" 113 | pchheader "premake.h" 114 | includedirs { "../src/host" } 115 | prepare() 116 | _.pchconfig(cfg) 117 | test.capture [[ 118 | PCH = ../../src/host/premake.h 119 | ]] 120 | end 121 | -------------------------------------------------------------------------------- /tests/actions/make/test_makesettings.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- tests/actions/make/test_makesettings.lua 3 | -- Tests makesettings lists in generated makefiles. 4 | -- Copyright (c) 2011 Jason Perkins and the Premake project 5 | -- 6 | 7 | T.make_settings = { } 8 | local suite = T.make_settings 9 | local make = premake.make 10 | 11 | local sln, prj, cfg 12 | 13 | function suite.setup() 14 | _ACTION = "gmake" 15 | 16 | sln = solution("MySolution") 17 | configurations { "Debug", "Release" } 18 | makesettings { "SOLUTION_LEVEL_SETTINGS" } 19 | 20 | project("MyProject") 21 | makesettings { "PROJECT_LEVEL_SETTINGS" } 22 | 23 | configuration { "Debug" } 24 | makesettings { "DEBUG_LEVEL_SETTINGS" } 25 | 26 | configuration { "Release" } 27 | makesettings { "RELEASE_LEVEL_SETTINGS" } 28 | 29 | premake.bake.buildconfigs() 30 | prj = premake.solution.getproject(sln, 1) 31 | cfg = premake.getconfig(prj, "Debug") 32 | end 33 | 34 | 35 | function suite.writesProjectSettings() 36 | make.settings(prj, premake.gcc) 37 | test.capture [[ 38 | SOLUTION_LEVEL_SETTINGS 39 | PROJECT_LEVEL_SETTINGS 40 | 41 | ]] 42 | end 43 | 44 | function suite.writesConfigSettings() 45 | make.settings(cfg, premake.gcc) 46 | test.capture [[ 47 | DEBUG_LEVEL_SETTINGS 48 | 49 | ]] 50 | end 51 | 52 | -------------------------------------------------------------------------------- /tests/actions/make/test_wiidev.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- tests/actions/make/test_wiidev.lua 3 | -- Tests for Wii homebrew support in makefiles. 4 | -- Copyright (c) 2011 Jason Perkins and the Premake project 5 | -- 6 | 7 | T.make_wiidev = { } 8 | local suite = T.make_wiidev 9 | local make = premake.make 10 | local cpp = premake.make.cpp 11 | 12 | local sln, prj, cfg 13 | 14 | function suite.setup() 15 | _ACTION = "gmake" 16 | 17 | sln = solution("MySolution") 18 | configurations { "Debug", "Release" } 19 | platforms { "WiiDev" } 20 | 21 | prj = project("MyProject") 22 | 23 | premake.bake.buildconfigs() 24 | cfg = premake.getconfig(prj, "Debug", "WiiDev") 25 | end 26 | 27 | 28 | -- 29 | -- Make sure that the Wii-specific flags are passed to the tools. 30 | -- 31 | 32 | function suite.writesCorrectFlags() 33 | cpp.flags(cfg, premake.gcc) 34 | test.capture [[ 35 | ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP -I$(LIBOGC_INC) $(MACHDEP) -MP $(DEFINES) $(INCLUDES) 36 | ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH) 37 | ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS) 38 | ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) 39 | ]] 40 | end 41 | 42 | function suite.writesCorrectLinkFlags() 43 | cpp.linker(cfg, premake.gcc) 44 | test.capture [[ 45 | ALL_LDFLAGS += $(LDFLAGS) -s -L$(LIBOGC_LIB) $(MACHDEP) 46 | ]] 47 | end 48 | 49 | 50 | -- 51 | -- Make sure the dev kit include is written to each Wii build configuration. 52 | -- 53 | 54 | function suite.writesIncludeBlock() 55 | make.settings(cfg, premake.gcc) 56 | test.capture [[ 57 | ifeq ($(strip $(DEVKITPPC)),) 58 | $(error "DEVKITPPC environment variable is not set")' 59 | endif 60 | include $(DEVKITPPC)/wii_rules' 61 | ]] 62 | end 63 | -------------------------------------------------------------------------------- /tests/actions/vstudio/cs2002/test_files.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- tests/actions/vstudio/cs2002/test_files.lua 3 | -- Validate generation of block in Visual Studio 2002 .csproj 4 | -- Copyright (c) 2009-2012 Jason Perkins and the Premake project 5 | -- 6 | 7 | T.vstudio_cs2002_files = { } 8 | local suite = T.vstudio_cs2002_files 9 | local cs2002 = premake.vstudio.cs2002 10 | 11 | 12 | -- 13 | -- Setup 14 | -- 15 | 16 | local sln, prj 17 | 18 | function suite.setup() 19 | sln = test.createsolution() 20 | end 21 | 22 | local function prepare() 23 | premake.bake.buildconfigs() 24 | prj = premake.solution.getproject(sln, 1) 25 | sln.vstudio_configs = premake.vstudio.buildconfigs(sln) 26 | cs2002.Files(prj) 27 | end 28 | 29 | 30 | -- 31 | -- Test grouping and nesting 32 | -- 33 | 34 | function suite.SimpleSourceFile() 35 | files { "Hello.cs" } 36 | prepare() 37 | test.capture [[ 38 | 43 | ]] 44 | end 45 | 46 | function suite.NestedSourceFile() 47 | files { "Src/Hello.cs" } 48 | prepare() 49 | test.capture [[ 50 | 55 | ]] 56 | end 57 | 58 | 59 | -- 60 | -- The relative path to the file is correct for files that live outside 61 | -- the project's folder. 62 | -- 63 | 64 | function suite.filesUseRelativePath_onOutOfTreePath() 65 | files { "../Src/Hello.cs" } 66 | prepare() 67 | test.capture [[ 68 | 73 | ]] 74 | end 75 | 76 | 77 | 78 | -- 79 | -- Test file dependencies 80 | -- 81 | 82 | function suite.SimpleResourceDependency() 83 | files { "Resources.resx", "Resources.cs" } 84 | prepare() 85 | test.capture [[ 86 | 91 | 96 | ]] 97 | end 98 | 99 | 100 | -- 101 | -- Test build actions 102 | -- 103 | 104 | function suite.BuildAction_Compile() 105 | files { "Hello.png" } 106 | configuration "*.png" 107 | buildaction "Compile" 108 | prepare() 109 | test.capture [[ 110 | 114 | ]] 115 | end 116 | 117 | function suite.BuildAction_Copy() 118 | files { "Hello.png" } 119 | configuration "*.png" 120 | buildaction "Copy" 121 | prepare() 122 | test.capture [[ 123 | 127 | ]] 128 | end 129 | 130 | function suite.BuildAction_Embed() 131 | files { "Hello.png" } 132 | configuration "*.png" 133 | buildaction "Embed" 134 | prepare() 135 | test.capture [[ 136 | 140 | ]] 141 | end 142 | -------------------------------------------------------------------------------- /tests/actions/vstudio/cs2005/projectelement.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- tests/actions/vstudio/cs2005/projectelement.lua 3 | -- Validate generation of element in Visual Studio 2005+ .csproj 4 | -- Copyright (c) 2009-2011 Jason Perkins and the Premake project 5 | -- 6 | 7 | T.vstudio_cs2005_projectelement = { } 8 | local suite = T.vstudio_cs2005_projectelement 9 | local cs2005 = premake.vstudio.cs2005 10 | 11 | 12 | -- 13 | -- Setup 14 | -- 15 | 16 | local sln, prj 17 | 18 | function suite.setup() 19 | sln = test.createsolution() 20 | end 21 | 22 | local function prepare() 23 | premake.bake.buildconfigs() 24 | prj = premake.solution.getproject(sln, 1) 25 | cs2005.projectelement(prj) 26 | end 27 | 28 | 29 | -- 30 | -- Tests 31 | -- 32 | 33 | function suite.On2005() 34 | _ACTION = "vs2005" 35 | prepare() 36 | test.capture [[ 37 | 38 | ]] 39 | end 40 | 41 | function suite.On2008() 42 | _ACTION = "vs2008" 43 | prepare() 44 | test.capture [[ 45 | 46 | ]] 47 | end 48 | 49 | function suite.On2010() 50 | _ACTION = "vs2010" 51 | prepare() 52 | test.capture [[ 53 | 54 | 55 | ]] 56 | end 57 | 58 | function suite.On2012() 59 | _ACTION = "vs2012" 60 | prepare() 61 | test.capture [[ 62 | 63 | 64 | ]] 65 | end 66 | 67 | function suite.On2013() 68 | _ACTION = "vs2013" 69 | prepare() 70 | test.capture [[ 71 | 72 | 73 | ]] 74 | end 75 | -------------------------------------------------------------------------------- /tests/actions/vstudio/cs2005/propertygroup.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- tests/actions/vstudio/cs2005/propertygroup.lua 3 | -- Validate configuration elements in Visual Studio 2005+ .csproj 4 | -- Copyright (c) 2009-2011 Jason Perkins and the Premake project 5 | -- 6 | 7 | T.vstudio_cs2005_propertygroup = { } 8 | local suite = T.vstudio_cs2005_propertygroup 9 | local cs2005 = premake.vstudio.cs2005 10 | 11 | 12 | -- 13 | -- Setup 14 | -- 15 | 16 | local sln, prj, cfg 17 | 18 | function suite.setup() 19 | sln = test.createsolution() 20 | language "C#" 21 | end 22 | 23 | local function prepare() 24 | premake.bake.buildconfigs() 25 | prj = premake.solution.getproject(sln, 1) 26 | cfg = premake.getconfig(prj, "Debug") 27 | cs2005.propertygroup(cfg) 28 | end 29 | 30 | 31 | -- 32 | -- Version Tests 33 | -- 34 | 35 | function suite.OnVs2005() 36 | _ACTION = "vs2005" 37 | prepare() 38 | test.capture [[ 39 | 40 | ]] 41 | end 42 | 43 | 44 | function suite.OnVs2008() 45 | _ACTION = "vs2008" 46 | prepare() 47 | test.capture [[ 48 | 49 | ]] 50 | end 51 | 52 | 53 | function suite.OnVs2010() 54 | _ACTION = "vs2010" 55 | prepare() 56 | test.capture [[ 57 | 58 | ]] 59 | end 60 | -------------------------------------------------------------------------------- /tests/actions/vstudio/cs2005/test_files.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- tests/actions/vstudio/cs2005/test_files.lua 3 | -- Validate generation of block in Visual Studio 2005 .csproj 4 | -- Copyright (c) 2009-2012 Jason Perkins and the Premake project 5 | -- 6 | 7 | T.vstudio_cs2005_files = { } 8 | local suite = T.vstudio_cs2005_files 9 | local cs2005 = premake.vstudio.cs2005 10 | 11 | 12 | -- 13 | -- Setup 14 | -- 15 | 16 | local sln, prj 17 | 18 | function suite.setup() 19 | sln = test.createsolution() 20 | end 21 | 22 | local function prepare() 23 | premake.bake.buildconfigs() 24 | prj = premake.solution.getproject(sln, 1) 25 | sln.vstudio_configs = premake.vstudio.buildconfigs(sln) 26 | cs2005.files(prj) 27 | end 28 | 29 | 30 | -- 31 | -- Test grouping and nesting 32 | -- 33 | 34 | function suite.SimpleSourceFile() 35 | files { "Hello.cs" } 36 | prepare() 37 | test.capture [[ 38 | 39 | ]] 40 | end 41 | 42 | function suite.NestedSourceFile() 43 | files { "Src/Hello.cs" } 44 | prepare() 45 | test.capture [[ 46 | 47 | ]] 48 | end 49 | 50 | 51 | -- 52 | -- The relative path to the file is correct for files that live outside 53 | -- the project's folder. 54 | -- 55 | 56 | function suite.filesUseRelativePath_onOutOfTreePath() 57 | files { "../Src/Hello.cs" } 58 | prepare() 59 | test.capture [[ 60 | 61 | ]] 62 | end 63 | 64 | 65 | -- 66 | -- Test file dependencies 67 | -- 68 | 69 | function suite.SimpleResourceDependency() 70 | files { "Resources.resx", "Resources.Designer.cs" } 71 | prepare() 72 | test.capture [[ 73 | 74 | True 75 | Resources.resx 76 | 77 | 78 | Designer 79 | ResXFileCodeGenerator 80 | Resources.Designer.cs 81 | 82 | ]] 83 | end 84 | -------------------------------------------------------------------------------- /tests/actions/vstudio/sln2005/dependencies.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- tests/actions/vstudio/sln2005/dependencies.lua 3 | -- Validate generation of Visual Studio 2005+ solution project dependencies. 4 | -- Copyright (c) 2009-2011 Jason Perkins and the Premake project 5 | -- 6 | 7 | T.vstudio_sln2005_dependencies = { } 8 | local suite = T.vstudio_sln2005_dependencies 9 | local sln2005 = premake.vstudio.sln2005 10 | 11 | 12 | -- 13 | -- Setup 14 | -- 15 | 16 | local sln, prj1, prj2 17 | 18 | function suite.setup() 19 | _ACTION = "vs2005" 20 | sln, prj1 = test.createsolution() 21 | uuid "AE61726D-187C-E440-BD07-2556188A6565" 22 | prj2 = test.createproject(sln) 23 | uuid "2151E83B-997F-4A9D-955D-380157E88C31" 24 | links "MyProject" 25 | end 26 | 27 | local function prepare(language) 28 | prj1.language = language 29 | prj2.language = language 30 | premake.bake.buildconfigs() 31 | prj1 = premake.solution.getproject(sln, 1) 32 | prj2 = premake.solution.getproject(sln, 2) 33 | sln2005.projectdependencies(prj2) 34 | end 35 | 36 | 37 | -- 38 | -- Tests 39 | -- 40 | 41 | function suite.On2005_Cpp() 42 | prepare("C++") 43 | test.capture [[ 44 | ProjectSection(ProjectDependencies) = postProject 45 | {AE61726D-187C-E440-BD07-2556188A6565} = {AE61726D-187C-E440-BD07-2556188A6565} 46 | EndProjectSection 47 | ]] 48 | end 49 | 50 | 51 | function suite.On2005_Cs() 52 | prepare("C#") 53 | test.capture [[ 54 | ProjectSection(ProjectDependencies) = postProject 55 | {AE61726D-187C-E440-BD07-2556188A6565} = {AE61726D-187C-E440-BD07-2556188A6565} 56 | EndProjectSection 57 | ]] 58 | end 59 | -------------------------------------------------------------------------------- /tests/actions/vstudio/sln2005/header.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- tests/actions/vstudio/sln2005/header.lua 3 | -- Validate generation of Visual Studio 2005+ solution header. 4 | -- Copyright (c) 2009-2011 Jason Perkins and the Premake project 5 | -- 6 | 7 | T.vstudio_sln2005_header = { } 8 | local suite = T.vstudio_sln2005_header 9 | local sln2005 = premake.vstudio.sln2005 10 | 11 | 12 | -- 13 | -- Setup 14 | -- 15 | 16 | local sln, prj 17 | 18 | function suite.setup() 19 | sln = test.createsolution() 20 | end 21 | 22 | local function prepare() 23 | premake.bake.buildconfigs() 24 | sln2005.header() 25 | end 26 | 27 | 28 | -- 29 | -- Tests 30 | -- 31 | 32 | function suite.On2005() 33 | _ACTION = "vs2005" 34 | prepare() 35 | test.capture [[ 36 | Microsoft Visual Studio Solution File, Format Version 9.00 37 | # Visual Studio 2005 38 | ]] 39 | end 40 | 41 | 42 | function suite.On2008() 43 | _ACTION = "vs2008" 44 | prepare() 45 | test.capture [[ 46 | Microsoft Visual Studio Solution File, Format Version 10.00 47 | # Visual Studio 2008 48 | ]] 49 | end 50 | 51 | 52 | function suite.On2010() 53 | _ACTION = "vs2010" 54 | prepare() 55 | test.capture [[ 56 | Microsoft Visual Studio Solution File, Format Version 11.00 57 | # Visual Studio 2010 58 | ]] 59 | end 60 | 61 | 62 | function suite.On2012() 63 | _ACTION = "vs2012" 64 | prepare() 65 | test.capture [[ 66 | Microsoft Visual Studio Solution File, Format Version 12.00 67 | # Visual Studio 2012 68 | ]] 69 | end 70 | 71 | 72 | function suite.On2013() 73 | _ACTION = "vs2013" 74 | prepare() 75 | test.capture [[ 76 | Microsoft Visual Studio Solution File, Format Version 12.00 77 | # Visual Studio 2013 78 | ]] 79 | end 80 | -------------------------------------------------------------------------------- /tests/actions/vstudio/sln2005/layout.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- tests/actions/vstudio/sln2005/layout.lua 3 | -- Validate the overall layout of VS 2005-2010 solutions. 4 | -- Copyright (c) 2009-2011 Jason Perkins and the Premake project 5 | -- 6 | 7 | T.vstudio_sln2005_layout = { } 8 | local suite = T.vstudio_sln2005_layout 9 | local sln2005 = premake.vstudio.sln2005 10 | 11 | 12 | local sln 13 | 14 | function suite.setup() 15 | _ACTION = "vs2005" 16 | sln = test.createsolution() 17 | uuid "AE61726D-187C-E440-BD07-2556188A6565" 18 | end 19 | 20 | local function prepare() 21 | premake.bake.buildconfigs() 22 | sln.vstudio_configs = premake.vstudio.buildconfigs(sln) 23 | sln2005.generate(sln) 24 | end 25 | 26 | 27 | function suite.BasicLayout() 28 | prepare() 29 | test.capture ('\239\187\191' .. [[ 30 | 31 | Microsoft Visual Studio Solution File, Format Version 9.00 32 | # Visual Studio 2005 33 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MyProject", "MyProject.vcproj", "{AE61726D-187C-E440-BD07-2556188A6565}" 34 | EndProject 35 | Global 36 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 37 | Debug|Win32 = Debug|Win32 38 | Release|Win32 = Release|Win32 39 | EndGlobalSection 40 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 41 | {AE61726D-187C-E440-BD07-2556188A6565}.Debug|Win32.ActiveCfg = Debug|Win32 42 | {AE61726D-187C-E440-BD07-2556188A6565}.Debug|Win32.Build.0 = Debug|Win32 43 | {AE61726D-187C-E440-BD07-2556188A6565}.Release|Win32.ActiveCfg = Release|Win32 44 | {AE61726D-187C-E440-BD07-2556188A6565}.Release|Win32.Build.0 = Release|Win32 45 | EndGlobalSection 46 | GlobalSection(SolutionProperties) = preSolution 47 | HideSolutionNode = FALSE 48 | EndGlobalSection 49 | EndGlobal 50 | ]]) 51 | end 52 | -------------------------------------------------------------------------------- /tests/actions/vstudio/sln2005/projects.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- tests/actions/vstudio/sln2005/projects.lua 3 | -- Validate generation of Visual Studio 2005+ solution project entries. 4 | -- Copyright (c) 2009-2011 Jason Perkins and the Premake project 5 | -- 6 | 7 | T.vstudio_sln2005_projects = { } 8 | local suite = T.vstudio_sln2005_projects 9 | local sln2005 = premake.vstudio.sln2005 10 | 11 | 12 | -- 13 | -- Setup 14 | -- 15 | 16 | local sln, prj 17 | 18 | function suite.setup() 19 | _ACTION = "vs2005" 20 | sln = test.createsolution() 21 | uuid "AE61726D-187C-E440-BD07-2556188A6565" 22 | end 23 | 24 | local function prepare() 25 | premake.bake.buildconfigs() 26 | prj = premake.solution.getproject(sln, 1) 27 | sln2005.project(prj) 28 | end 29 | 30 | 31 | -- 32 | -- C/C++ project reference tests 33 | -- 34 | 35 | function suite.On2005_CppProject() 36 | _ACTION = "vs2005" 37 | prepare() 38 | test.capture [[ 39 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MyProject", "MyProject.vcproj", "{AE61726D-187C-E440-BD07-2556188A6565}" 40 | EndProject 41 | ]] 42 | end 43 | 44 | 45 | function suite.On2010_CppProject() 46 | _ACTION = "vs2010" 47 | prepare() 48 | test.capture [[ 49 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MyProject", "MyProject.vcxproj", "{AE61726D-187C-E440-BD07-2556188A6565}" 50 | EndProject 51 | ]] 52 | end 53 | 54 | 55 | -- 56 | -- C# project reference tests 57 | -- 58 | 59 | function suite.On2005_CsProject() 60 | _ACTION = "vs2005" 61 | language "C#" 62 | prepare() 63 | test.capture [[ 64 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyProject", "MyProject.csproj", "{AE61726D-187C-E440-BD07-2556188A6565}" 65 | EndProject 66 | ]] 67 | end 68 | -------------------------------------------------------------------------------- /tests/actions/vstudio/test_vs200x_vcproj_linker.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- tests/actions/vstudio/test_vs200x_vcproj_linker.lua 3 | -- Automated tests for Visual Studio 2002-2008 C/C++ linker block. 4 | -- Copyright (c) 2009-2011 Jason Perkins and the Premake project 5 | -- 6 | 7 | T.vs200x_vcproj_linker = { } 8 | local suite = T.vs200x_vcproj_linker 9 | local vc200x = premake.vstudio.vc200x 10 | 11 | 12 | -- 13 | -- Setup/Teardown 14 | -- 15 | 16 | local sln, prj 17 | function suite.setup() 18 | _ACTION = "vs2005" 19 | sln, prj = test.createsolution() 20 | end 21 | 22 | local function prepare() 23 | premake.bake.buildconfigs() 24 | end 25 | 26 | 27 | -- 28 | -- Test default linker blocks for each target kind 29 | -- (ConsoleApp, StaticLib, etc.) 30 | -- 31 | 32 | function suite.DefaultLinkerBlock_OnConsoleApp() 33 | kind "ConsoleApp" 34 | prepare() 35 | vc200x.VCLinkerTool(premake.getconfig(prj, "Debug")) 36 | test.capture [[ 37 | 47 | ]] 48 | end 49 | 50 | function suite.DefaultLinkerBlock_OnWindowedApp() 51 | kind "WindowedApp" 52 | prepare() 53 | vc200x.VCLinkerTool(premake.getconfig(prj, "Debug")) 54 | test.capture [[ 55 | 65 | ]] 66 | end 67 | 68 | function suite.DefaultLinkerBlock_OnSharedLib() 69 | kind "SharedLib" 70 | prepare() 71 | vc200x.VCLinkerTool(premake.getconfig(prj, "Debug")) 72 | test.capture [[ 73 | 83 | ]] 84 | end 85 | 86 | function suite.DefaultLinkerBlock_OnStaticLib() 87 | kind "StaticLib" 88 | prepare() 89 | vc200x.VCLinkerTool(premake.getconfig(prj, "Debug")) 90 | test.capture [[ 91 | 95 | ]] 96 | end 97 | 98 | 99 | -- 100 | -- linkoptions tests 101 | -- 102 | 103 | function suite.AdditionalOptions_OnStaticLib() 104 | kind "StaticLib" 105 | linkoptions { "/ltcg", "/lZ" } 106 | prepare() 107 | vc200x.VCLinkerTool(premake.getconfig(prj, "Debug")) 108 | test.capture [[ 109 | 114 | ]] 115 | end 116 | 117 | -------------------------------------------------------------------------------- /tests/actions/vstudio/vc200x/debugdir.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- tests/actions/vstudio/vc200x/debugdir.lua 3 | -- Validate handling of the working directory for debugging. 4 | -- Copyright (c) 2011 Jason Perkins and the Premake project 5 | -- 6 | 7 | T.vstudio_vs200x_debugdir = { } 8 | local suite = T.vstudio_vs200x_debugdir 9 | local vc200x = premake.vstudio.vc200x 10 | 11 | 12 | -- 13 | -- Setup 14 | -- 15 | 16 | local sln, prj 17 | 18 | function suite.setup() 19 | sln = test.createsolution() 20 | end 21 | 22 | local function prepare() 23 | premake.bake.buildconfigs() 24 | prj = premake.solution.getproject(sln, 1) 25 | sln.vstudio_configs = premake.vstudio.buildconfigs(sln) 26 | vc200x.debugdir(prj) 27 | end 28 | 29 | 30 | -- 31 | -- Tests 32 | -- 33 | 34 | function suite.EmptyBlock_OnNoDebugSettings() 35 | prepare() 36 | test.capture [[ 37 | 39 | ]] 40 | end 41 | 42 | function suite.WorkingDirectory_OnRelativePath() 43 | debugdir "bin/debug" 44 | prepare() 45 | test.capture [[ 46 | 49 | ]] 50 | end 51 | 52 | function suite.Arguments() 53 | debugargs { "arg1", "arg2" } 54 | prepare() 55 | test.capture [[ 56 | 59 | ]] 60 | end 61 | 62 | 63 | T.vc200x_env_args = { } 64 | local vs200x_env_args = T.vc200x_env_args 65 | 66 | function vs200x_env_args.environmentArgs_notSet_bufferDoesNotContainEnvironment() 67 | vc200x.environmentargs( {flags={}} ) 68 | test.string_does_not_contain(io.endcapture(),'Environment=') 69 | end 70 | function vs200x_env_args.environmentArgs_set_bufferContainsEnvironment() 71 | vc200x.environmentargs( {flags={},environmentargs={'key=value'}} ) 72 | test.string_contains(io.endcapture(),'Environment=') 73 | end 74 | 75 | function vs200x_env_args.environmentArgs_valueUsesQuotes_quotesMarksReplaced() 76 | vc200x.environmentargs( {flags={},environmentargs={'key="value"'}} ) 77 | test.string_contains(io.endcapture(),'Environment="key="value""') 78 | end 79 | 80 | function vs200x_env_args.environmentArgs_multipleArgs_seperatedUsingCorrectEscape() 81 | vc200x.environmentargs( {flags={},environmentargs={'key=value','foo=bar'}} ) 82 | test.string_contains(io.endcapture(),'Environment="key=value foo=bar"') 83 | end 84 | 85 | function vs200x_env_args.environmentArgs_withDontMergeFlag_EnvironmentArgsDontMergeEqualsFalse() 86 | vc200x.environmentargs( {flags={EnvironmentArgsDontMerge=1},environmentargs={'key=value'}} ) 87 | test.string_contains(io.endcapture(),'EnvironmentMerge="false"') 88 | end 89 | -------------------------------------------------------------------------------- /tests/actions/vstudio/vc200x/header.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- tests/actions/vstudio/vc200x/header.lua 3 | -- Validate generation of the project file header block. 4 | -- Copyright (c) 2011 Jason Perkins and the Premake project 5 | -- 6 | 7 | T.vstudio_vs200x_header = { } 8 | local suite = T.vstudio_vs200x_header 9 | local vc200x = premake.vstudio.vc200x 10 | 11 | 12 | -- 13 | -- Setup 14 | -- 15 | 16 | local sln, prj 17 | 18 | function suite.setup() 19 | sln = test.createsolution() 20 | end 21 | 22 | local function prepare() 23 | premake.bake.buildconfigs() 24 | prj = premake.solution.getproject(sln, 1) 25 | sln.vstudio_configs = premake.vstudio.buildconfigs(sln) 26 | vc200x.header('VisualStudioProject') 27 | end 28 | 29 | 30 | -- 31 | -- Tests 32 | -- 33 | 34 | function suite.On2008() 35 | _ACTION = 'vs2008' 36 | prepare() 37 | test.capture [[ 38 | 39 | 52 | 55 | 56 | 57 | ]] 58 | end 59 | -------------------------------------------------------------------------------- /tests/actions/vstudio/vc2010/test_config_props.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- tests/actions/vstudio/vc2010/test_config_props.lua 3 | -- Validate generation of the configuration property group. 4 | -- Copyright (c) 2011-2013 Jason Perkins and the Premake project 5 | -- 6 | 7 | T.vstudio_vs2010_config_props = { } 8 | local suite = T.vstudio_vs2010_config_props 9 | local vc2010 = premake.vstudio.vc2010 10 | local project = premake.project 11 | 12 | 13 | -- 14 | -- Setup 15 | -- 16 | 17 | local sln, prj 18 | 19 | function suite.setup() 20 | sln, prj = test.createsolution() 21 | end 22 | 23 | local function prepare(platform) 24 | premake.bake.buildconfigs() 25 | sln.vstudio_configs = premake.vstudio.buildconfigs(sln) 26 | local cfginfo = sln.vstudio_configs[1] 27 | local cfg = premake.getconfig(prj, cfginfo.src_buildcfg, cfginfo.src_platform) 28 | vc2010.configurationPropertyGroup(cfg, cfginfo) 29 | end 30 | 31 | 32 | -- 33 | -- Check the structure with the default project values. 34 | -- 35 | 36 | function suite.structureIsCorrect_onDefaultValues() 37 | prepare() 38 | test.capture [[ 39 | 40 | Application 41 | true 42 | MultiByte 43 | 44 | ]] 45 | end 46 | 47 | 48 | 49 | 50 | -- 51 | -- Visual Studio 2012 adds a platform toolset. 52 | -- 53 | 54 | function suite.structureIsCorrect_onDefaultValues() 55 | _ACTION = "vs2012" 56 | prepare() 57 | test.capture [[ 58 | 59 | Application 60 | true 61 | MultiByte 62 | v110 63 | 64 | ]] 65 | end 66 | 67 | function suite.structureIsCorrect_onDefaultValues_on2013() 68 | _ACTION = "vs2013" 69 | prepare() 70 | test.capture [[ 71 | 72 | Application 73 | true 74 | MultiByte 75 | v120 76 | 77 | ]] 78 | end 79 | -------------------------------------------------------------------------------- /tests/actions/vstudio/vc2010/test_files.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- tests/actions/vstudio/vc2010/test_files.lua 3 | -- Validate generation of files block in Visual Studio 2010 C/C++ projects. 4 | -- Copyright (c) 2011 Jason Perkins and the Premake project 5 | -- 6 | 7 | T.vstudio_vs2010_files = { } 8 | local suite = T.vstudio_vs2010_files 9 | local vc2010 = premake.vstudio.vc2010 10 | 11 | 12 | -- 13 | -- Setup 14 | -- 15 | 16 | local sln, prj 17 | 18 | function suite.setup() 19 | sln = test.createsolution() 20 | end 21 | 22 | local function prepare() 23 | premake.bake.buildconfigs() 24 | prj = premake.solution.getproject(sln, 1) 25 | sln.vstudio_configs = premake.vstudio.buildconfigs(sln) 26 | vc2010.files(prj) 27 | end 28 | 29 | 30 | -- 31 | -- Test file groups 32 | -- 33 | 34 | function suite.SimpleHeaderFile() 35 | files { "include/hello.h" } 36 | prepare() 37 | test.capture [[ 38 | 39 | 40 | 41 | ]] 42 | end 43 | 44 | 45 | function suite.SimpleSourceFile() 46 | files { "hello.c" } 47 | prepare() 48 | test.capture [[ 49 | 50 | 51 | 52 | 53 | ]] 54 | end 55 | 56 | 57 | function suite.SimpleObjectFile() 58 | files { "hello.obj" } 59 | prepare() 60 | test.capture [[ 61 | 62 | 63 | 64 | ]] 65 | end 66 | 67 | 68 | function suite.SimpleNoneFile() 69 | files { "docs/hello.txt" } 70 | prepare() 71 | test.capture [[ 72 | 73 | 74 | 75 | ]] 76 | end 77 | 78 | 79 | function suite.SimpleResourceFile() 80 | files { "resources/hello.rc" } 81 | prepare() 82 | test.capture [[ 83 | 84 | 85 | 86 | ]] 87 | end 88 | 89 | 90 | -- 91 | -- Test path handling 92 | -- 93 | 94 | function suite.MultipleFolderLevels() 95 | files { "src/greetings/hello.c" } 96 | prepare() 97 | test.capture [[ 98 | 99 | 100 | 101 | 102 | ]] 103 | end 104 | -------------------------------------------------------------------------------- /tests/actions/vstudio/vc2010/test_header.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- tests/actions/vstudio/vc2010/test_header.lua 3 | -- Validate generation of the project file header block. 4 | -- Copyright (c) 2011 Jason Perkins and the Premake project 5 | -- 6 | 7 | T.vstudio_vs2010_header = { } 8 | local suite = T.vstudio_vs2010_header 9 | local vc2010 = premake.vstudio.vc2010 10 | 11 | 12 | -- 13 | -- Setup 14 | -- 15 | 16 | local sln, prj 17 | 18 | function suite.setup() 19 | _ACTION = 'vs2010' 20 | sln = test.createsolution() 21 | premake.bake.buildconfigs() 22 | prj = premake.solution.getproject(sln, 1) 23 | sln.vstudio_configs = premake.vstudio.buildconfigs(sln) 24 | end 25 | 26 | 27 | -- 28 | -- Tests 29 | -- 30 | 31 | function suite.On2010_WithNoTarget() 32 | vc2010.header() 33 | test.capture [[ 34 | 35 | 36 | ]] 37 | end 38 | 39 | function suite.On2010_WithTarget() 40 | vc2010.header("Build") 41 | test.capture [[ 42 | 43 | 44 | ]] 45 | end 46 | -------------------------------------------------------------------------------- /tests/actions/vstudio/vc2010/test_links.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- tests/actions/vstudio/vc2010/test_links.lua 3 | -- Validate linking and project references in Visual Studio 2010 C/C++ projects. 4 | -- Copyright (c) 2011 Jason Perkins and the Premake project 5 | -- 6 | 7 | T.vstudio_vs2010_links = { } 8 | local suite = T.vstudio_vs2010_links 9 | local vc2010 = premake.vstudio.vc2010 10 | 11 | 12 | -- 13 | -- Setup 14 | -- 15 | 16 | local sln, prj, prj2 17 | 18 | function suite.setup() 19 | os_uuid = os.uuid 20 | os.uuid = function() return "00112233-4455-6677-8888-99AABBCCDDEE" end 21 | 22 | sln = test.createsolution() 23 | test.createproject(sln) 24 | end 25 | 26 | local function prepare() 27 | premake.bake.buildconfigs() 28 | prj = premake.solution.getproject(sln, 1) 29 | prj2 = premake.solution.getproject(sln, 2) 30 | sln.vstudio_configs = premake.vstudio.buildconfigs(sln) 31 | end 32 | 33 | 34 | -- 35 | -- If there are no sibling projects listed in links(), then the 36 | -- entire project references item group should be skipped. 37 | -- 38 | 39 | function suite.noProjectReferencesGroup_onNoSiblingReferences() 40 | prepare() 41 | vc2010.projectReferences(prj2) 42 | test.isemptycapture() 43 | end 44 | 45 | 46 | -- 47 | -- If a sibling project is listed in links(), an item group should 48 | -- be written with a reference to that sibling project. 49 | -- 50 | 51 | function suite.projectReferenceAdded_onSiblingProjectLink() 52 | links { "MyProject" } 53 | prepare() 54 | vc2010.projectReferences(prj2) 55 | test.capture [[ 56 | 57 | 58 | {00112233-4455-6677-8888-99AABBCCDDEE} 59 | 60 | 61 | ]] 62 | end 63 | 64 | 65 | -- 66 | -- If a sibling library is listed in links(), it should NOT appear in 67 | -- the additional dependencies element. Visual Studio will figure that 68 | -- out from the project reference item group. 69 | -- 70 | 71 | function suite.noDependencies_onOnlySiblingProjectLinks() 72 | links { "MyProject" } 73 | prepare() 74 | vc2010.additionalDependencies(prj2) 75 | test.isemptycapture() 76 | end 77 | 78 | 79 | -- 80 | -- If a mix of sibling and system links are listed, only the system 81 | -- libraries should appear in the additional dependencies element. 82 | -- 83 | 84 | function suite.onlySystemDependencies_OnSiblingProjectLink() 85 | links { "MyProject", "kernel32" } 86 | prepare() 87 | vc2010.additionalDependencies(prj2) 88 | test.capture [[ 89 | kernel32;%(AdditionalDependencies) 90 | ]] 91 | end 92 | 93 | 94 | -------------------------------------------------------------------------------- /tests/actions/vstudio/vc2010/test_pch.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- tests/actions/vstudio/vc2010/test_pch.lua 3 | -- Validate generation of files block in Visual Studio 2010 C/C++ projects. 4 | -- Copyright (c) 2011 Jason Perkins and the Premake project 5 | -- 6 | 7 | T.vstudio_vs2010_pch = { } 8 | local suite = T.vstudio_vs2010_pch 9 | local vc2010 = premake.vstudio.vc2010 10 | 11 | 12 | -- 13 | -- Setup 14 | -- 15 | 16 | local sln, prj 17 | 18 | function suite.setup() 19 | sln = test.createsolution() 20 | end 21 | 22 | local function prepare() 23 | premake.bake.buildconfigs() 24 | prj = premake.solution.getproject(sln, 1) 25 | sln.vstudio_configs = premake.vstudio.buildconfigs(sln) 26 | vc2010.files(prj) 27 | end 28 | 29 | 30 | -- 31 | -- Tests 32 | -- 33 | 34 | function suite.pch_OnProject() 35 | files { "afxwin.cpp" } 36 | pchheader "afxwin.h" 37 | pchsource "afxwin.cpp" 38 | prepare() 39 | test.capture [[ 40 | 41 | 42 | Create 43 | Create 44 | 45 | 46 | ]] 47 | end 48 | 49 | 50 | function suite.pch_OnSingleConfig() 51 | files { "afxwin.cpp" } 52 | configuration "Debug" 53 | pchheader "afxwin.h" 54 | pchsource "afxwin.cpp" 55 | prepare() 56 | test.capture [[ 57 | 58 | 59 | Create 60 | 61 | 62 | ]] 63 | end 64 | -------------------------------------------------------------------------------- /tests/actions/vstudio/vc2010/test_project_refs.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- tests/actions/vstudio/vc2010/test_project_refs.lua 3 | -- Validate project references in Visual Studio 2010 C/C++ projects. 4 | -- Copyright (c) 2011-2012 Jason Perkins and the Premake project 5 | -- 6 | 7 | T.vstudio_vs2010_project_refs = { } 8 | local suite = T.vstudio_vs2010_project_refs 9 | local vc2010 = premake.vstudio.vc2010 10 | 11 | 12 | -- 13 | -- Setup 14 | -- 15 | 16 | local sln, prj 17 | 18 | function suite.setup() 19 | _ACTION = "vs2010" 20 | sln = test.createsolution() 21 | uuid "00112233-4455-6677-8888-99AABBCCDDEE" 22 | test.createproject(sln) 23 | end 24 | 25 | local function prepare(platform) 26 | premake.bake.buildconfigs() 27 | prj = premake.solution.getproject(sln, 2) 28 | vc2010.projectReferences(prj) 29 | end 30 | 31 | 32 | -- 33 | -- If there are no sibling projects listed in links(), then the 34 | -- entire project references item group should be skipped. 35 | -- 36 | 37 | function suite.noProjectReferencesGroup_onNoSiblingReferences() 38 | prepare() 39 | test.isemptycapture() 40 | end 41 | 42 | -- 43 | -- If a sibling project is listed in links(), an item group should 44 | -- be written with a reference to that sibling project. 45 | -- 46 | 47 | function suite.projectReferenceAdded_onSiblingProjectLink() 48 | links { "MyProject" } 49 | prepare() 50 | test.capture [[ 51 | 52 | 53 | {00112233-4455-6677-8888-99AABBCCDDEE} 54 | 55 | 56 | ]] 57 | end 58 | 59 | -- 60 | -- Project references should always be specified relative to the 61 | -- project doing the referencing. 62 | -- 63 | 64 | function suite.referencesAreRelative_onDifferentProjectLocation() 65 | links { "MyProject" } 66 | location "build/MyProject2" 67 | project("MyProject") 68 | location "build/MyProject" 69 | prepare() 70 | test.capture [[ 71 | 72 | 73 | {00112233-4455-6677-8888-99AABBCCDDEE} 74 | 75 | 76 | ]] 77 | end 78 | 79 | -------------------------------------------------------------------------------- /tests/baking/test_merging.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- tests/baking/test_merging.lua 3 | -- Verifies different field types are merged properly during baking. 4 | -- Copyright (c) 2011 Jason Perkins and the Premake project 5 | -- 6 | 7 | T.baking_merging = { } 8 | local suite = T.baking_merging 9 | 10 | -- 11 | -- Setup code 12 | -- 13 | 14 | local sln, prj, cfg 15 | function suite.setup() 16 | sln = solution "MySolution" 17 | configurations { "Debug", "Release" } 18 | end 19 | 20 | local function prepare() 21 | premake.bake.buildconfigs() 22 | prj = premake.solution.getproject(sln, 1) 23 | end 24 | 25 | 26 | -- 27 | -- String value tests 28 | -- 29 | 30 | function suite.Strings_AreReplaced() 31 | kind "SharedLib" 32 | project "MyProject" 33 | kind "StaticLib" 34 | prepare() 35 | test.isequal("StaticLib", prj.kind) 36 | end 37 | 38 | function suite.Strings_KeepPreviousValue() 39 | kind "SharedLib" 40 | project "MyProject" 41 | prepare() 42 | test.isequal("SharedLib", prj.kind) 43 | end 44 | 45 | 46 | -- 47 | -- List tests 48 | -- 49 | 50 | function suite.Lists_KeepPreviousValue() 51 | project "MyProject" 52 | prepare() 53 | test.isequal("Debug:Release", table.concat(prj.configurations, ":")) 54 | end 55 | 56 | function suite.Lists_AreJoined() 57 | defines { "SOLUTION" } 58 | project "MyProject" 59 | defines { "PROJECT" } 60 | prepare() 61 | test.isequal("SOLUTION:PROJECT", table.concat(prj.defines, ":")) 62 | end 63 | 64 | function suite.Lists_RemoveDuplicates() 65 | defines { "SOLUTION", "DUPLICATE" } 66 | project "MyProject" 67 | defines { "PROJECT", "DUPLICATE" } 68 | prepare() 69 | test.isequal("SOLUTION:DUPLICATE:PROJECT", table.concat(prj.defines, ":")) 70 | end 71 | 72 | function suite.Lists_FlattensNestedTables() 73 | defines { "ROOT", { "NESTED" } } 74 | project "MyProject" 75 | prepare() 76 | test.isequal("ROOT:NESTED", table.concat(prj.defines, ":")) 77 | end 78 | 79 | 80 | -- 81 | -- Key/value tests 82 | -- 83 | 84 | function suite.KeyValue_AreMerged() 85 | vpaths { ["Solution"] = "*.sln" } 86 | project "MyProject" 87 | vpaths { ["Project"] = "*.prj" } 88 | prepare() 89 | test.isequal({"*.sln"}, prj.vpaths["Solution"]) 90 | test.isequal({"*.prj"}, prj.vpaths["Project"]) 91 | end 92 | 93 | function suite.KeyValue_MergesValues() 94 | vpaths { ["Solution"] = "*.sln", ["Project"] = "*.prj" } 95 | project "MyProject" 96 | vpaths { ["Project"] = "*.prjx" } 97 | prepare() 98 | test.isequal({"*.prj","*.prjx"}, prj.vpaths["Project"]) 99 | end 100 | -------------------------------------------------------------------------------- /tests/base/test_action.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- tests/base/test_action.lua 3 | -- Automated test suite for the action list. 4 | -- Copyright (c) 2009 Jason Perkins and the Premake project 5 | -- 6 | 7 | T.action = { } 8 | 9 | 10 | -- 11 | -- Setup/teardown 12 | -- 13 | 14 | local fake = { 15 | trigger = "fake", 16 | description = "Fake action used for testing", 17 | } 18 | 19 | function T.action.setup() 20 | premake.action.list["fake"] = fake 21 | solution "MySolution" 22 | configurations "Debug" 23 | project "MyProject" 24 | premake.bake.buildconfigs() 25 | end 26 | 27 | function T.action.teardown() 28 | premake.action.list["fake"] = nil 29 | end 30 | 31 | 32 | 33 | -- 34 | -- Tests for call() 35 | -- 36 | 37 | function T.action.CallCallsExecuteIfPresent() 38 | local called = false 39 | fake.execute = function () called = true end 40 | premake.action.call("fake") 41 | test.istrue(called) 42 | end 43 | 44 | function T.action.CallCallsOnSolutionIfPresent() 45 | local called = false 46 | fake.onsolution = function () called = true end 47 | premake.action.call("fake") 48 | test.istrue(called) 49 | end 50 | 51 | function T.action.CallCallsOnProjectIfPresent() 52 | local called = false 53 | fake.onproject = function () called = true end 54 | premake.action.call("fake") 55 | test.istrue(called) 56 | end 57 | 58 | function T.action.CallSkipsCallbacksIfNotPresent() 59 | test.success(premake.action.call, "fake") 60 | end 61 | 62 | 63 | -- 64 | -- Tests for set() 65 | -- 66 | 67 | function T.action.set_SetsActionOS() 68 | local oldos = _OS 69 | _OS = "linux" 70 | premake.action.set("vs2008") 71 | test.isequal(_OS, "windows") 72 | _OS = oldos 73 | end 74 | -------------------------------------------------------------------------------- /tests/base/test_config.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- tests/test_config.lua 3 | -- Automated test suite for the configuration handling functions. 4 | -- Copyright (c) 2010 Jason Perkins and the Premake project 5 | -- 6 | 7 | T.config = { } 8 | local suite = T.config 9 | 10 | 11 | -- 12 | -- Setup/Teardown 13 | -- 14 | 15 | function suite.setup() 16 | sln = test.createsolution() 17 | end 18 | 19 | local cfg 20 | local function prepare() 21 | premake.bake.buildconfigs() 22 | cfg = premake.solution.getproject(sln, 1) 23 | end 24 | 25 | 26 | -- 27 | -- Debug/Release build testing 28 | -- 29 | function suite.IsDebug_ReturnsFalse_EnglishSpellingOfOptimiseFlag() 30 | flags { "Optimise" } 31 | prepare() 32 | return test.isfalse(premake.config.isdebugbuild(cfg)) 33 | end 34 | 35 | function suite.IsDebug_ReturnsFalse_EnglishSpellingOfOptimiseSizeFlag() 36 | flags { "OptimiseSize" } 37 | prepare() 38 | return test.isfalse(premake.config.isdebugbuild(cfg)) 39 | end 40 | 41 | function suite.IsDebug_ReturnsFalse_EnglishSpellingOfOptimiseSpeedFlag() 42 | flags { "OptimiseSpeed" } 43 | prepare() 44 | return test.isfalse(premake.config.isdebugbuild(cfg)) 45 | end 46 | 47 | function suite.IsDebug_ReturnsFalse_OnOptimizeFlag() 48 | flags { "Optimize" } 49 | prepare() 50 | return test.isfalse(premake.config.isdebugbuild(cfg)) 51 | end 52 | 53 | function suite.IsDebug_ReturnsFalse_OnOptimizeSizeFlag() 54 | flags { "OptimizeSize" } 55 | prepare() 56 | return test.isfalse(premake.config.isdebugbuild(cfg)) 57 | end 58 | 59 | function suite.IsDebug_ReturnsFalse_OnOptimizeSpeedFlag() 60 | flags { "OptimizeSpeed" } 61 | prepare() 62 | return test.isfalse(premake.config.isdebugbuild(cfg)) 63 | end 64 | 65 | function suite.IsDebug_ReturnsFalse_OnNoSymbolsFlag() 66 | prepare() 67 | return test.isfalse(premake.config.isdebugbuild(cfg)) 68 | end 69 | 70 | function suite.IsDebug_ReturnsTrue_OnSymbolsFlag() 71 | flags { "Symbols" } 72 | prepare() 73 | return test.istrue(premake.config.isdebugbuild(cfg)) 74 | end 75 | 76 | function suite.shouldIncrementallyLink_staticLib_returnsFalse() 77 | kind "StaticLib" 78 | prepare() 79 | return test.isfalse(premake.config.isincrementallink(cfg)) 80 | end 81 | 82 | function suite.shouldIncrementallyLink_optimizeFlagSet_returnsFalse() 83 | flags { "Optimize" } 84 | prepare() 85 | return test.isfalse(premake.config.isincrementallink(cfg)) 86 | end 87 | 88 | function suite.shouldIncrementallyLink_NoIncrementalLinkFlag_returnsFalse() 89 | flags { "NoIncrementalLink" } 90 | prepare() 91 | return test.isfalse(premake.config.isincrementallink(cfg)) 92 | end 93 | 94 | function suite.shouldIncrementallyLink_notStaticLib_NoIncrementalLinkFlag_noOptimiseFlag_returnsTrue() 95 | prepare() 96 | return test.istrue(premake.config.isincrementallink(cfg)) 97 | end 98 | 99 | -------------------------------------------------------------------------------- /tests/base/test_location.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- tests/base/test_location.lua 3 | -- Automated tests for the location() function. 4 | -- Copyright (c) 2011 Jason Perkins and the Premake project 5 | -- 6 | 7 | T.base_location = { } 8 | local suite = T.base_location 9 | 10 | 11 | -- 12 | -- Setup/Teardown 13 | -- 14 | 15 | function suite.setup() 16 | sln = solution "MySolution" 17 | configurations { "Debug", "Release" } 18 | language "C" 19 | end 20 | 21 | local function prepare() 22 | premake.bake.buildconfigs() 23 | prj = premake.solution.getproject(sln, 1) 24 | end 25 | 26 | 27 | -- 28 | -- Test no location set 29 | -- 30 | 31 | function suite.solutionUsesCwd_OnNoLocationSet() 32 | project "MyProject" 33 | prepare() 34 | test.isequal(os.getcwd(), sln.location) 35 | end 36 | 37 | function suite.projectUsesCwd_OnNoLocationSet() 38 | project "MyProject" 39 | prepare() 40 | test.isequal(os.getcwd(), prj.location) 41 | end 42 | 43 | 44 | -- 45 | -- Test with location set on solution only 46 | -- 47 | 48 | function suite.solutionUsesLocation_OnSolutionOnly() 49 | location "build" 50 | project "MyProject" 51 | prepare() 52 | test.isequal(path.join(os.getcwd(), "build"), sln.location) 53 | end 54 | 55 | function suite.projectUsesLocation_OnSolutionOnly() 56 | location "build" 57 | project "MyProject" 58 | prepare() 59 | test.isequal(path.join(os.getcwd(), "build"), prj.location) 60 | end 61 | 62 | 63 | -- 64 | -- Test with location set on project only 65 | -- 66 | 67 | function suite.solutionUsesCwd_OnProjectOnly() 68 | project "MyProject" 69 | location "build" 70 | prepare() 71 | test.isequal(os.getcwd(), sln.location) 72 | end 73 | 74 | function suite.projectUsesLocation_OnProjectOnly() 75 | project "MyProject" 76 | location "build" 77 | prepare() 78 | test.isequal(path.join(os.getcwd(), "build"), prj.location) 79 | end 80 | 81 | 82 | -- 83 | -- Test with location set on both solution and project only 84 | -- 85 | 86 | function suite.solutionUsesCwd_OnProjectOnly() 87 | location "build/solution" 88 | project "MyProject" 89 | location "build/project" 90 | prepare() 91 | test.isequal(path.join(os.getcwd(), "build/solution"), sln.location) 92 | end 93 | 94 | function suite.projectUsesLocation_OnProjectOnly() 95 | location "build/solution" 96 | project "MyProject" 97 | location "build/project" 98 | prepare() 99 | test.isequal(path.join(os.getcwd(), "build/project"), prj.location) 100 | end 101 | -------------------------------------------------------------------------------- /tests/base/test_premake_command.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- tests/base/test_premake_command.lua 3 | -- Test the initialization of the _PREMAKE_COMMAND global. 4 | -- Copyright (c) 2012 Jason Perkins and the Premake project 5 | -- 6 | 7 | T.premake_command = { } 8 | local suite = T.premake_command 9 | 10 | 11 | function suite.valueIsSet() 12 | local filename = iif(os.is("windows"), "premake4.exe", "premake4") 13 | test.isequal(path.getabsolute("../bin/debug/" .. filename), _PREMAKE_COMMAND) 14 | end 15 | -------------------------------------------------------------------------------- /tests/base/test_table.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- tests/base/test_table.lua 3 | -- Automated test suite for the new table functions. 4 | -- Copyright (c) 2008-2010 Jason Perkins and the Premake project 5 | -- 6 | 7 | 8 | T.table = { } 9 | local suite = T.table 10 | 11 | 12 | -- 13 | -- table.contains() tests 14 | -- 15 | 16 | function suite.contains_OnContained() 17 | t = { "one", "two", "three" } 18 | test.istrue( table.contains(t, "two") ) 19 | end 20 | 21 | function suite.contains_OnNotContained() 22 | t = { "one", "two", "three" } 23 | test.isfalse( table.contains(t, "four") ) 24 | end 25 | 26 | 27 | -- 28 | -- table.flatten() tests 29 | -- 30 | 31 | function suite.flatten_OnMixedValues() 32 | t = { "a", { "b", "c" }, "d" } 33 | test.isequal({ "a", "b", "c", "d" }, table.flatten(t)) 34 | end 35 | 36 | 37 | -- 38 | -- table.implode() tests 39 | -- 40 | 41 | function suite.implode() 42 | t = { "one", "two", "three", "four" } 43 | test.isequal("[one], [two], [three], [four]", table.implode(t, "[", "]", ", ")) 44 | end 45 | 46 | 47 | -- 48 | -- table.isempty() tests 49 | -- 50 | 51 | function suite.isempty_ReturnsTrueOnEmpty() 52 | test.istrue(table.isempty({})) 53 | end 54 | 55 | function suite.isempty_ReturnsFalseOnNotEmpty() 56 | test.isfalse(table.isempty({ 1 })) 57 | end 58 | 59 | function suite.isempty_ReturnsFalseOnNotEmptyMap() 60 | test.isfalse(table.isempty({ name = 'premake' })) 61 | end 62 | 63 | function suite.isempty_ReturnsFalseOnNotEmptyMapWithFalseKey() 64 | test.isfalse(table.isempty({ [false] = 0 })) 65 | end 66 | -------------------------------------------------------------------------------- /tests/folder/ok.lua: -------------------------------------------------------------------------------- 1 | return "ok" 2 | -------------------------------------------------------------------------------- /tests/folder/ok.lua.2: -------------------------------------------------------------------------------- 1 | return "ok" 2 | -------------------------------------------------------------------------------- /tests/project/test_eachfile.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- tests/project/test_eachfile.lua 3 | -- Automated test suite for the file iteration function. 4 | -- Copyright (c) 2011 Jason Perkins and the Premake project 5 | -- 6 | 7 | T.project_eachfile = { } 8 | local suite = T.project_eachfile 9 | local project = premake.project 10 | 11 | 12 | -- 13 | -- Setup and teardown 14 | -- 15 | 16 | local sln, prj 17 | function suite.setup() 18 | sln = test.createsolution() 19 | end 20 | 21 | local function prepare() 22 | premake.bake.buildconfigs() 23 | prj = premake.solution.getproject(sln, 1) 24 | end 25 | 26 | 27 | -- 28 | -- Tests 29 | -- 30 | 31 | function suite.ReturnsAllFiles() 32 | files { "hello.h", "hello.c" } 33 | prepare() 34 | local iter = project.eachfile(prj) 35 | test.isequal("hello.h", iter().name) 36 | test.isequal("hello.c", iter().name) 37 | test.isnil(iter()) 38 | end 39 | 40 | 41 | function suite.ReturnedObjectIncludesVpath() 42 | files { "hello.h", "hello.c" } 43 | prepare() 44 | local iter = project.eachfile(prj) 45 | test.isequal("hello.h", iter().vpath) 46 | end 47 | -------------------------------------------------------------------------------- /tests/stress: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ../bin/debug/premake4 /scripts=../src /file=test_stress.lua vs2008 3 | -------------------------------------------------------------------------------- /tests/test: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd `dirname $0` && ../bin/debug/premake4 /scripts=../src $1 $2 $3 test 3 | -------------------------------------------------------------------------------- /tests/test.bat: -------------------------------------------------------------------------------- 1 | 2 | CALL ..\\bin\\debug\\premake4 /scripts=..\\src test 3 | ::CALL ..\\bin\\release\\premake4 /scripts=..\\src test 4 | -------------------------------------------------------------------------------- /tests/test_dofile.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- tests/test_dofile.lua 3 | -- Automated test suite for the extended dofile() functions. 4 | -- Copyright (c) 2008 Jason Perkins and the Premake project 5 | -- 6 | 7 | 8 | T.dofile = { } 9 | 10 | 11 | local os_getenv 12 | 13 | function T.dofile.setup() 14 | os_getenv = os.getenv 15 | end 16 | 17 | function T.dofile.teardown() 18 | os.getenv = os_getenv 19 | end 20 | 21 | 22 | -- 23 | -- dofile() tests 24 | -- 25 | 26 | function T.dofile.SearchesPath() 27 | os.getenv = function() return os.getcwd().."/folder" end 28 | result = dofile("ok.lua") 29 | test.isequal("ok", result) 30 | end 31 | 32 | function T.dofile.SearchesScriptsOption() 33 | _OPTIONS["scripts"] = os.getcwd().."/folder" 34 | result = dofile("ok.lua") 35 | test.isequal("ok", result) 36 | end 37 | -------------------------------------------------------------------------------- /tests/test_gmake_cs.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- tests/test_gmake_cs.lua 3 | -- Automated test suite for GNU Make C/C++ project generation. 4 | -- Copyright (c) 2009 Jason Perkins and the Premake project 5 | -- 6 | 7 | T.gmake_cs = { } 8 | 9 | -- 10 | -- Configure a solution for testing 11 | -- 12 | 13 | local sln, prj 14 | function T.gmake_cs.setup() 15 | _ACTION = "gmake" 16 | _OPTIONS.os = "linux" 17 | 18 | sln = solution "MySolution" 19 | configurations { "Debug", "Release" } 20 | platforms { "native" } 21 | 22 | prj = project "MyProject" 23 | language "C#" 24 | kind "ConsoleApp" 25 | end 26 | 27 | local function prepare() 28 | premake.bake.buildconfigs() 29 | end 30 | 31 | 32 | 33 | -- 34 | -- Test configuration blocks 35 | -- 36 | 37 | function T.gmake_cs.BasicCfgBlock() 38 | prepare() 39 | local cfg = premake.getconfig(prj, "Debug") 40 | premake.gmake_cs_config(cfg, premake.dotnet, {[cfg]={}}) 41 | test.capture [[ 42 | ifneq (,$(findstring debug,$(config))) 43 | TARGETDIR := . 44 | OBJDIR := obj/Debug 45 | DEPENDS := 46 | REFERENCES := 47 | FLAGS += 48 | define PREBUILDCMDS 49 | endef 50 | define PRELINKCMDS 51 | endef 52 | define POSTBUILDCMDS 53 | endef 54 | endif 55 | ]] 56 | end 57 | 58 | 59 | function T.gmake_cs.OnBuildOptions() 60 | buildoptions { "/define:SYMBOL" } 61 | prepare() 62 | local cfg = premake.getconfig(prj, "Debug") 63 | premake.gmake_cs_config(cfg, premake.dotnet, {[cfg]={}}) 64 | test.capture [[ 65 | ifneq (,$(findstring debug,$(config))) 66 | TARGETDIR := . 67 | OBJDIR := obj/Debug 68 | DEPENDS := 69 | REFERENCES := 70 | FLAGS += /define:SYMBOL 71 | define PREBUILDCMDS 72 | endef 73 | define PRELINKCMDS 74 | endef 75 | define POSTBUILDCMDS 76 | endef 77 | endif 78 | ]] 79 | end 80 | -------------------------------------------------------------------------------- /tests/test_keywords.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- tests/test_keywords.lua 3 | -- Automated test suite for configuration block keyword filtering. 4 | -- Copyright (c) 2008, 2009 Jason Perkins and the Premake project 5 | -- 6 | 7 | T.keywords = { } 8 | local suite = T.keywords 9 | 10 | -- 11 | -- Keyword escaping tests 12 | -- 13 | 14 | function suite.escapes_special_chars() 15 | test.isequal("%.%-", path.wildcards(".-")) 16 | end 17 | 18 | 19 | function suite.escapes_star() 20 | test.isequal("vs[^/]*", path.wildcards("vs*")) 21 | end 22 | 23 | 24 | function suite.escapes_star_star() 25 | test.isequal("Images/.*%.bmp", path.wildcards("Images/**.bmp")) 26 | end 27 | 28 | 29 | 30 | 31 | -- 32 | -- Keyword matching tests 33 | -- 34 | 35 | function T.keywords.matches_simple_strings() 36 | test.istrue(premake.iskeywordmatch("debug", { "debug", "windows", "vs2005" })) 37 | end 38 | 39 | 40 | function T.keywords.match_files_with_simple_strings() 41 | test.isfalse(premake.iskeywordmatch("release", { "debug", "windows", "vs2005" })) 42 | end 43 | 44 | 45 | function T.keywords.matches_with_patterns() 46 | test.istrue(premake.iskeywordmatch("vs20.*", { "debug", "windows", "vs2005" })) 47 | end 48 | 49 | 50 | function T.keywords.match_fails_with_not_term() 51 | test.isfalse(premake.iskeywordmatch("not windows", { "debug", "windows", "vs2005" })) 52 | end 53 | 54 | 55 | function T.keywords.match_ok_with_not_term() 56 | test.istrue(premake.iskeywordmatch("not linux", { "debug", "windows", "vs2005" })) 57 | end 58 | 59 | 60 | function T.keywords.match_ok_with_first_or() 61 | test.istrue(premake.iskeywordmatch("windows or linux", { "debug", "windows", "vs2005" })) 62 | end 63 | 64 | 65 | function T.keywords.match_ok_with_first_or() 66 | test.istrue(premake.iskeywordmatch("windows or linux", { "debug", "linux", "vs2005" })) 67 | end 68 | 69 | 70 | function T.keywords.match_ok_with_not_and_or() 71 | test.istrue(premake.iskeywordmatch("not macosx or linux", { "debug", "windows", "vs2005" })) 72 | end 73 | 74 | 75 | function T.keywords.match_fail_with_not_and_or() 76 | test.isfalse(premake.iskeywordmatch("not macosx or windows", { "debug", "windows", "vs2005" })) 77 | end 78 | 79 | 80 | function T.keywords.match_ok_required_term() 81 | test.istrue(premake.iskeywordsmatch({ "debug", "hello.c" }, { "debug", "windows", "vs2005", required="hello.c" })) 82 | end 83 | 84 | 85 | function T.keywords.match_fail_required_term() 86 | test.isfalse(premake.iskeywordsmatch({ "debug" }, { "debug", "windows", "vs2005", required="hello.c" })) 87 | end 88 | -------------------------------------------------------------------------------- /tests/test_platforms.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- tests/test_platforms.lua 3 | -- Automated test suite for platform handling functions. 4 | -- Copyright (c) 2009 Jason Perkins and the Premake project 5 | -- 6 | 7 | T.platforms = { } 8 | 9 | 10 | local testmap = { Native="Win32", x32="Win32", x64="x64" } 11 | 12 | local sln, r 13 | function T.platforms.setup() 14 | sln = solution "MySolution" 15 | configurations { "Debug", "Release" } 16 | end 17 | 18 | 19 | function T.platforms.filter_OnNoSolutionPlatforms() 20 | premake.bake.buildconfigs() 21 | r = premake.filterplatforms(sln, testmap) 22 | test.isequal("", table.concat(r, ":")) 23 | end 24 | 25 | function T.platforms.filter_OnNoSolutionPlatformsAndDefault() 26 | premake.bake.buildconfigs() 27 | r = premake.filterplatforms(sln, testmap, "x32") 28 | test.isequal("x32", table.concat(r, ":")) 29 | end 30 | 31 | function T.platforms.filter_OnIntersection() 32 | platforms { "x32", "x64", "Xbox360" } 33 | premake.bake.buildconfigs() 34 | r = premake.filterplatforms(sln, testmap, "x32") 35 | test.isequal("x32:x64", table.concat(r, ":")) 36 | end 37 | 38 | function T.platforms.filter_OnNoIntersection() 39 | platforms { "Universal", "Xbox360" } 40 | premake.bake.buildconfigs() 41 | r = premake.filterplatforms(sln, testmap) 42 | test.isequal("", table.concat(r, ":")) 43 | end 44 | 45 | function T.platforms.filter_OnNoIntersectionAndDefault() 46 | platforms { "Universal", "Xbox360" } 47 | premake.bake.buildconfigs() 48 | r = premake.filterplatforms(sln, testmap, "x32") 49 | test.isequal("x32", table.concat(r, ":")) 50 | end 51 | 52 | function T.platforms.filter_OnDuplicateKeys() 53 | platforms { "Native", "x32" } 54 | premake.bake.buildconfigs() 55 | r = premake.filterplatforms(sln, testmap, "x32") 56 | test.isequal("Native", table.concat(r, ":")) 57 | end 58 | 59 | -------------------------------------------------------------------------------- /tests/test_premake.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- tests/test_premake.lua 3 | -- Automated test suite for the Premake support functions. 4 | -- Copyright (c) 2008-2009 Jason Perkins and the Premake project 5 | -- 6 | 7 | 8 | T.premake = { } 9 | 10 | 11 | -- 12 | -- premake.checktools() tests 13 | -- 14 | 15 | function T.premake.checktools_SetsDefaultTools() 16 | _ACTION = "gmake" 17 | premake.checktools() 18 | test.isequal("gcc", _OPTIONS.cc) 19 | test.isequal("mono", _OPTIONS.dotnet) 20 | end 21 | 22 | 23 | function T.premake.checktools_Fails_OnToolMismatch() 24 | _ACTION = "gmake" 25 | _OPTIONS["cc"] = "xyz" 26 | ok, err = premake.checktools() 27 | test.isfalse( ok ) 28 | test.isequal("the GNU Make action does not support /cc=xyz (yet)", err) 29 | end 30 | 31 | 32 | 33 | -- 34 | -- generate() tests 35 | -- 36 | 37 | function T.premake.generate_OpensCorrectFile() 38 | prj = { name = "MyProject", location = "MyLocation" } 39 | premake.generate(prj, "%%.prj", function () end) 40 | test.openedfile("MyLocation/MyProject.prj") 41 | end 42 | 43 | function T.premake.generate_ClosesFile() 44 | prj = { name = "MyProject", location = "MyLocation" } 45 | premake.generate(prj, "%%.prj", function () end) 46 | test.closedfile(true) 47 | end 48 | -------------------------------------------------------------------------------- /tests/test_project.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- tests/test_project.lua 3 | -- Automated test suite for the project support functions. 4 | -- Copyright (c) 2008-2010 Jason Perkins and the Premake project 5 | -- 6 | 7 | local _project = premake.project 8 | 9 | T.project = { } 10 | 11 | local cfg, result 12 | function T.project.setup() 13 | _ACTION = "gmake" 14 | cfg = {} 15 | cfg.project = {} 16 | cfg.language = "C++" 17 | cfg.files = {} 18 | cfg.trimpaths = {} 19 | cfg.platform = "Native" 20 | result = "\n" 21 | end 22 | 23 | 24 | 25 | -- 26 | -- findproject() tests 27 | -- 28 | 29 | function T.project.findproject_IsCaseSensitive() 30 | local sln = test.createsolution() 31 | local prj = test.createproject(sln) 32 | premake.bake.buildconfigs() 33 | test.isnil(premake.findproject("myproject")) 34 | end 35 | 36 | 37 | -- 38 | -- getfilename() tests 39 | -- 40 | 41 | function T.project.getfilename_ReturnsRelativePath() 42 | local prj = { name = "project", location = "location" } 43 | local r = _project.getfilename(prj, path.join(os.getcwd(), "../filename")) 44 | test.isequal("../filename", r) 45 | end 46 | 47 | function T.project.getfilename_PerformsSubstitutions() 48 | local prj = { name = "project", location = "location" } 49 | local r = _project.getfilename(prj, "%%.prj") 50 | test.isequal("location/project.prj", r) 51 | end 52 | 53 | 54 | 55 | -- 56 | -- premake.getlinks() tests 57 | -- 58 | 59 | function T.project.getlinks_OnMscSystemLibs() 60 | _OPTIONS.cc = "msc" 61 | cfg.links = { "user32", "gdi32" } 62 | result = premake.getlinks(cfg, "all", "fullpath") 63 | test.isequal("user32.lib gdi32.lib", table.concat(result, " ")) 64 | end 65 | -------------------------------------------------------------------------------- /tests/test_stress.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- tests/tests_stress.lua 3 | -- Stress test for Premake. 4 | -- Copyright (c) 2009 Jason Perkins and the Premake project 5 | -- 6 | 7 | local numprojects = 100 8 | local numfiles = 100 9 | 10 | dofile("pepperfish_profiler.lua") 11 | profiler = newProfiler() 12 | function dumpresults(sorttotal) 13 | local outfile = io.open("build/profile.txt", "w+" ) 14 | profiler:report(outfile, sorttotal) 15 | outfile:close() 16 | end 17 | 18 | 19 | solution "MySolution" 20 | configurations { "Debug", "Release", "DebugDLL", "ReleaseDLL" } 21 | platforms { "Native", "x32", "x64" } 22 | location "build" 23 | 24 | configuration "Debug" 25 | defines { "_DEBUG" } 26 | flags { "Symbols" } 27 | 28 | configuration "Release" 29 | defines { "NDEBUG" } 30 | flags { "Optimize" } 31 | 32 | 33 | for pi = 1, numprojects do 34 | 35 | project ("Project" .. pi) 36 | location "build" 37 | kind "ConsoleApp" 38 | language "C++" 39 | 40 | for fi = 1, numfiles do 41 | files { "file" .. fi .. ".cpp" } 42 | end 43 | 44 | end 45 | -------------------------------------------------------------------------------- /tests/test_string.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- tests/test_string.lua 3 | -- Automated test suite for the new string functions. 4 | -- Copyright (c) 2008 Jason Perkins and the Premake project 5 | -- 6 | 7 | 8 | T.string = { } 9 | 10 | 11 | -- 12 | -- string.endswith() tests 13 | -- 14 | 15 | function T.string.endswith_ReturnsTrue_OnMatch() 16 | test.istrue(string.endswith("Abcdef", "def")) 17 | end 18 | 19 | function T.string.endswith_ReturnsFalse_OnMismatch() 20 | test.isfalse(string.endswith("Abcedf", "efg")) 21 | end 22 | 23 | function T.string.endswith_ReturnsFalse_OnLongerNeedle() 24 | test.isfalse(string.endswith("Abc", "Abcdef")) 25 | end 26 | 27 | function T.string.endswith_ReturnsFalse_OnNilHaystack() 28 | test.isfalse(string.endswith(nil, "ghi")) 29 | end 30 | 31 | function T.string.endswith_ReturnsFalse_OnNilNeedle() 32 | test.isfalse(string.endswith("Abc", nil)) 33 | end 34 | 35 | function T.string.endswith_ReturnsTrue_OnExactMatch() 36 | test.istrue(string.endswith("/", "/")) 37 | end 38 | 39 | 40 | 41 | -- 42 | -- string.explode() tests 43 | -- 44 | 45 | function T.string.explode_ReturnsParts_OnValidCall() 46 | test.isequal({"aaa","bbb","ccc"}, string.explode("aaa/bbb/ccc", "/", true)) 47 | end 48 | 49 | 50 | 51 | -- 52 | -- string.startswith() tests 53 | -- 54 | 55 | function T.string.startswith_OnMatch() 56 | test.istrue(string.startswith("Abcdef", "Abc")) 57 | end 58 | 59 | function T.string.startswith_OnMismatch() 60 | test.isfalse(string.startswith("Abcdef", "ghi")) 61 | end 62 | 63 | function T.string.startswith_OnLongerNeedle() 64 | test.isfalse(string.startswith("Abc", "Abcdef")) 65 | end 66 | 67 | function T.string.startswith_OnEmptyHaystack() 68 | test.isfalse(string.startswith("", "Abc")) 69 | end 70 | 71 | function T.string.startswith_OnEmptyNeedle() 72 | test.istrue(string.startswith("Abcdef", "")) 73 | end 74 | -------------------------------------------------------------------------------- /tests/tools/test_gcc.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- tests/test_gcc.lua 3 | -- Automated test suite for the GCC toolset interface. 4 | -- Copyright (c) 2009-2011 Jason Perkins and the Premake project 5 | -- 6 | 7 | T.gcc = { } 8 | local suite = T.gcc 9 | 10 | local cfg 11 | function suite.setup() 12 | cfg = { } 13 | cfg.basedir = "." 14 | cfg.location = "." 15 | cfg.language = "C++" 16 | cfg.project = { name = "MyProject" } 17 | cfg.flags = { } 18 | cfg.objectsdir = "obj" 19 | cfg.platform = "Native" 20 | cfg.links = { } 21 | cfg.libdirs = { } 22 | cfg.linktarget = { fullpath="libMyProject.a" } 23 | end 24 | 25 | 26 | -- 27 | -- CPPFLAGS tests 28 | -- 29 | 30 | function suite.cppflags_OnWindows() 31 | cfg.system = "windows" 32 | local r = premake.gcc.getcppflags(cfg) 33 | test.isequal("-MMD -MP", table.concat(r, " ")) 34 | end 35 | 36 | -- 37 | -- CFLAGS tests 38 | -- 39 | 40 | function suite.cflags_SharedLib_Windows() 41 | cfg.kind = "SharedLib" 42 | cfg.system = "windows" 43 | local r = premake.gcc.getcflags(cfg) 44 | test.isequal('', table.concat(r,"|")) 45 | end 46 | 47 | 48 | function suite.cflags_OnFpFast() 49 | cfg.flags = { "FloatFast" } 50 | local r = premake.gcc.getcflags(cfg) 51 | test.isequal('-ffast-math', table.concat(r,"|")) 52 | end 53 | 54 | 55 | function suite.cflags_OnFpStrict() 56 | cfg.flags = { "FloatStrict" } 57 | local r = premake.gcc.getcflags(cfg) 58 | test.isequal('-ffloat-store', table.concat(r,"|")) 59 | end 60 | 61 | 62 | -- 63 | -- LDFLAGS tests 64 | -- 65 | 66 | function suite.ldflags_SharedLib_Windows() 67 | cfg.kind = "SharedLib" 68 | cfg.system = "windows" 69 | local r = premake.gcc.getldflags(cfg) 70 | test.isequal('-s|-shared|-Wl,--out-implib="libMyProject.a"', table.concat(r,"|")) 71 | end 72 | 73 | 74 | function suite.linkflags_OnFrameworks() 75 | cfg.links = { "Cocoa.framework" } 76 | local r = premake.gcc.getlinkflags(cfg) 77 | test.isequal('-framework Cocoa', table.concat(r,"|")) 78 | end 79 | --------------------------------------------------------------------------------